static struct option long_options[] = {
{"root", 1, NULL, 'r'},
{"help", 0, NULL, 'h'},
- {"squash", 0, NULL, 'q'},
{"version", 0, NULL, 'v'},
{"devtable", 1, NULL, 'D'},
{NULL, 0, NULL, 0}
"Options:\n"
" -r, -d, --root=DIR Build filesystem from directory DIR (default: cwd)\n"
" -D, --devtable=FILE Use the named FILE as a device table file\n"
- " -q, --squash Squash permissions and owners making all files be owned by root\n"
" -h, --help Display this help text\n"
" -v, --version Display version information\n\n";
FILE *passwd_file = NULL;
FILE *group_file = NULL;
FILE *devtable = NULL;
+ DIR *dir = NULL;
umask (0);
+ if (argc==1) {
+ fprintf(stderr, helptext);
+ exit(1);
+ }
+
while ((opt = getopt_long(argc, argv, "D:d:r:qhv",
long_options, &c)) >= 0) {
switch (opt) {
if (rootdir != default_rootdir) {
error_msg_and_die("root directory specified more than once");
}
+ if ((dir = opendir(optarg)) == NULL) {
+ perror_msg_and_die(optarg);
+ } else {
+ closedir(dir);
+ }
rootdir = xstrdup(optarg);
break;
}
}
+ if (argv[optind] != NULL) {
+ fprintf(stderr, helptext);
+ exit(1);
+ }
+
// Get name-id mapping
sprintf(passwd_path, "%s/etc/passwd", rootdir);
sprintf(group_path, "%s/etc/group", rootdir);