static int do_mount(struct ENT *ent) { char *argv[8]; pid_t pid; int status; argv[0] = UNCONST("mount"); argv[1] = UNCONST("-o"); argv[2] = ENT_OPTS(*ent); argv[3] = UNCONST("-t"); argv[4] = ENT_TYPE(*ent); argv[5] = ENT_BLOCKDEVICE(*ent); argv[6] = ENT_FILE(*ent); argv[7] = NULL; switch (pid = vfork()) { case -1: eerrorx("%s: vfork: %s", applet, strerror(errno)); /* NOTREACHED */ case 0: execvp(argv[0], argv); eerror("%s: execv: %s", applet, strerror(errno)); _exit(EXIT_FAILURE); /* NOTREACHED */ default: waitpid(pid, &status, 0); if (WIFEXITED(status)) return WEXITSTATUS(status); else return -1; /* NOTREACHED */ } }
int fstabinfo(int argc, char **argv) { struct ENT *ent; int result = EXIT_SUCCESS; char *token; int i, p; int opt; int output = OUTPUT_FILE; RC_STRINGLIST *files = rc_stringlist_new(); RC_STRING *file, *file_np; bool filtered = false; #ifdef HAVE_GETMNTENT FILE *fp; #endif /* Ensure that we are only quiet when explicitly told to be */ unsetenv("EINFO_QUIET"); while ((opt = getopt_long(argc, argv, getoptstring, longopts, (int *) 0)) != -1) { switch (opt) { case 'M': output = OUTPUT_MOUNT; break; case 'R': output = OUTPUT_REMOUNT; break; case 'b': output = OUTPUT_BLOCKDEV; break; case 'o': output = OUTPUT_OPTIONS; break; case 'm': output = OUTPUT_MOUNTARGS; break; case 'p': switch (optarg[0]) { case '=': case '<': case '>': if (sscanf(optarg + 1, "%d", &i) != 1) eerrorx("%s: invalid passno %s", argv[0], optarg + 1); filtered = true; opt = optarg[0]; START_ENT; while ((ent = GET_ENT)) { if (strcmp(ENT_FILE(ent), "none") == 0) continue; p = ENT_PASS(ent); if ((opt == '=' && i == p) || (opt == '<' && i > p && p != 0) || (opt == '>' && i < p && p != 0)) rc_stringlist_add(files, ENT_FILE(ent)); } END_ENT; break; default: rc_stringlist_add(files, optarg); output = OUTPUT_PASSNO; break; } break; case 't': filtered = true; while ((token = strsep(&optarg, ","))) { START_ENT; while ((ent = GET_ENT)) if (strcmp(token, ENT_TYPE(ent)) == 0) rc_stringlist_add(files, ENT_FILE(ent)); END_ENT; } break; case_RC_COMMON_GETOPT } } if (optind < argc) { if (TAILQ_FIRST(files)) { TAILQ_FOREACH_SAFE(file, files, entries, file_np) { for (i = optind; i < argc; i++) if (strcmp(argv[i], file->value) == 0) break; if (i >= argc) rc_stringlist_delete(files, file->value); } } else { while (optind < argc) rc_stringlist_add(files, argv[optind++]); } } else if (!filtered) {