Since commit ab2d32f ("Replace create/destroy by a script"), configure_rootfs and many of its descendents are unused; remove them.
Signed-off-by: Nathan Lynch <n...@pobox.com> --- src/lxc/conf.c | 182 -------------------------------------------------------- 1 files changed, 0 insertions(+), 182 deletions(-) diff --git a/src/lxc/conf.c b/src/lxc/conf.c index a0c7a7c..9a9b4e5 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -177,188 +177,6 @@ static struct caps_opt caps_opt[] = { { "mac_admin", CAP_MAC_ADMIN }, }; - -static int configure_find_fstype_cb(char* buffer, void *data) -{ - struct cbarg { - const char *rootfs; - const char *testdir; - char *fstype; - int mntopt; - } *cbarg = data; - - char *fstype; - - /* we don't try 'nodev' entries */ - if (strstr(buffer, "nodev")) - return 0; - - fstype = buffer; - fstype += lxc_char_left_gc(fstype, strlen(fstype)); - fstype[lxc_char_right_gc(fstype, strlen(fstype))] = '\0'; - - if (mount(cbarg->rootfs, cbarg->testdir, fstype, cbarg->mntopt, NULL)) - return 0; - - /* found ! */ - umount(cbarg->testdir); - strcpy(cbarg->fstype, fstype); - - return 1; -} - -/* find the filesystem type with brute force */ -static int configure_find_fstype(const char *rootfs, char *fstype, int mntopt) -{ - int i, found; - - struct cbarg { - const char *rootfs; - const char *testdir; - char *fstype; - int mntopt; - } cbarg = { - .rootfs = rootfs, - .fstype = fstype, - .mntopt = mntopt, - }; - - /* first we check with /etc/filesystems, in case the modules - * are auto-loaded and fall back to the supported kernel fs - */ - char *fsfile[] = { - "/etc/filesystems", - "/proc/filesystems", - }; - - cbarg.testdir = tempnam("/tmp", "lxc-"); - if (!cbarg.testdir) { - SYSERROR("failed to build a temp name"); - return -1; - } - - if (mkdir(cbarg.testdir, 0755)) { - SYSERROR("failed to create temporary directory"); - return -1; - } - - for (i = 0; i < sizeof(fsfile)/sizeof(fsfile[0]); i++) { - - found = lxc_file_for_each_line(fsfile[i], - configure_find_fstype_cb, - &cbarg); - - if (found < 0) { - SYSERROR("failed to read '%s'", fsfile[i]); - goto out; - } - - if (found) - break; - } - - if (!found) { - ERROR("failed to determine fs type for '%s'", rootfs); - goto out; - } - -out: - rmdir(cbarg.testdir); - return found - 1; -} - -static int configure_rootfs_dir_cb(const char *rootfs, const char *absrootfs, - FILE *f) -{ - return fprintf(f, "%s %s none rbind 0 0\n", absrootfs, rootfs); -} - -static int configure_rootfs_blk_cb(const char *rootfs, const char *absrootfs, - FILE *f) -{ - char fstype[MAXPATHLEN]; - - if (configure_find_fstype(absrootfs, fstype, 0)) { - ERROR("failed to configure mount for block device '%s'", - absrootfs); - return -1; - } - - return fprintf(f, "%s %s %s defaults 0 0\n", absrootfs, rootfs, fstype); -} - -static int configure_rootfs(const char *name, const char *rootfs) -{ - char path[MAXPATHLEN]; - char absrootfs[MAXPATHLEN]; - char fstab[MAXPATHLEN]; - struct stat s; - FILE *f; - int i, ret; - - typedef int (*rootfs_cb)(const char *, const char *, FILE *); - - struct rootfs_type { - int type; - rootfs_cb cb; - } rtfs_type[] = { - { __S_IFDIR, configure_rootfs_dir_cb }, - { __S_IFBLK, configure_rootfs_blk_cb }, - }; - - if (!realpath(rootfs, absrootfs)) { - SYSERROR("failed to get real path for '%s'", rootfs); - return -1; - } - - snprintf(path, MAXPATHLEN, LXCPATH "/%s/rootfs", name); - - if (mkdir(path, 0755)) { - SYSERROR("failed to create the '%s' directory", path); - return -1; - } - - if (access(absrootfs, F_OK)) { - SYSERROR("'%s' is not accessible", absrootfs); - return -1; - } - - if (stat(absrootfs, &s)) { - SYSERROR("failed to stat '%s'", absrootfs); - return -1; - } - - for (i = 0; i < sizeof(rtfs_type)/sizeof(rtfs_type[0]); i++) { - - if (!__S_ISTYPE(s.st_mode, rtfs_type[i].type)) - continue; - - snprintf(fstab, MAXPATHLEN, LXCPATH "/%s/fstab", name); - - f = fopen(fstab, "a+"); - if (!f) { - SYSERROR("failed to open fstab file"); - return -1; - } - - ret = rtfs_type[i].cb(path, absrootfs, f); - - fclose(f); - - if (ret < 0) { - ERROR("failed to add rootfs mount in fstab"); - return -1; - } - - snprintf(path, MAXPATHLEN, LXCPATH "/%s/rootfs/rootfs", name); - - return symlink(absrootfs, path); - } - - ERROR("unsupported rootfs type for '%s'", absrootfs); - return -1; -} - static int setup_utsname(struct utsname *utsname) { if (!utsname) -- 1.6.6.1 ------------------------------------------------------------------------------ _______________________________________________ Lxc-devel mailing list Lxc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-devel