summaryrefslogtreecommitdiffstats
path: root/sbin/mount_ifs/mount.c
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/mount_ifs/mount.c')
-rw-r--r--sbin/mount_ifs/mount.c185
1 files changed, 6 insertions, 179 deletions
diff --git a/sbin/mount_ifs/mount.c b/sbin/mount_ifs/mount.c
index 3177776..521be4a 100644
--- a/sbin/mount_ifs/mount.c
+++ b/sbin/mount_ifs/mount.c
@@ -134,179 +134,8 @@ main(argc, argv)
int all, ch, i, init_flags, mntsize, rval, have_fstab;
char *options;
- all = init_flags = 0;
- options = NULL;
- vfslist = NULL;
- vfstype = "ufs";
- while ((ch = getopt(argc, argv, "adfo:prwt:uv")) != -1)
- switch (ch) {
- case 'a':
- all = 1;
- break;
- case 'd':
- debug = 1;
- break;
- case 'f':
- init_flags |= MNT_FORCE;
- break;
- case 'o':
- if (*optarg)
- options = catopt(options, optarg);
- break;
- case 'p':
- fstab_style = 1;
- verbose = 1;
- break;
- case 'r':
- init_flags |= MNT_RDONLY;
- break;
- case 't':
- if (vfslist != NULL)
- errx(1, "only one -t option may be specified");
- vfslist = makevfslist(optarg);
- vfstype = optarg;
- break;
- case 'u':
- init_flags |= MNT_UPDATE;
- break;
- case 'v':
- verbose = 1;
- break;
- case 'w':
- init_flags &= ~MNT_RDONLY;
- break;
- case '?':
- default:
- usage();
- /* NOTREACHED */
- }
- argc -= optind;
- argv += optind;
-
-#define BADTYPE(type) \
- (strcmp(type, FSTAB_RO) && \
- strcmp(type, FSTAB_RW) && strcmp(type, FSTAB_RQ))
-
- rval = 0;
- switch (argc) {
- case 0:
- if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0)
- err(1, "getmntinfo");
- if (all) {
- while ((fs = getfsent()) != NULL) {
- if (BADTYPE(fs->fs_type))
- continue;
- if (checkvfsname(fs->fs_vfstype, vfslist))
- continue;
- if (hasopt(fs->fs_mntops, "noauto"))
- continue;
- if (!(init_flags & MNT_UPDATE) &&
- ismounted(fs, mntbuf, mntsize))
- continue;
- if (mountfs(fs->fs_vfstype, fs->fs_spec,
- fs->fs_file, init_flags, options,
- fs->fs_mntops))
- rval = 1;
- }
- } else if (fstab_style) {
- for (i = 0; i < mntsize; i++) {
- if (checkvfsname(mntbuf[i].f_fstypename, vfslist))
- continue;
- putfsent(&mntbuf[i]);
- }
- } else {
- for (i = 0; i < mntsize; i++) {
- if (checkvfsname(mntbuf[i].f_fstypename,
- vfslist))
- continue;
- prmount(&mntbuf[i]);
- }
- }
- exit(rval);
- case 1:
- if (vfslist != NULL)
- usage();
-
- if (init_flags & MNT_UPDATE) {
- mntfromname = NULL;
- have_fstab = 0;
- if ((mntbuf = getmntpt(*argv)) == NULL)
- errx(1, "not currently mounted %s", *argv);
- /*
- * Only get the mntflags from fstab if both mntpoint
- * and mntspec are identical. Also handle the special
- * case where just '/' is mounted and 'spec' is not
- * identical with the one from fstab ('/dev' is missing
- * in the spec-string at boot-time).
- */
- if ((fs = getfsfile(mntbuf->f_mntonname)) != NULL) {
- if (strcmp(fs->fs_spec,
- mntbuf->f_mntfromname) == 0 &&
- strcmp(fs->fs_file,
- mntbuf->f_mntonname) == 0) {
- have_fstab = 1;
- mntfromname = mntbuf->f_mntfromname;
- } else if (argv[0][0] == '/' &&
- argv[0][1] == '\0') {
- fs = getfsfile("/");
- have_fstab = 1;
- mntfromname = fs->fs_spec;
- }
- }
- if (have_fstab) {
- options = update_options(options, fs->fs_mntops,
- mntbuf->f_flags);
- } else {
- mntfromname = mntbuf->f_mntfromname;
- options = update_options(options, NULL,
- mntbuf->f_flags);
- }
- rval = mountfs(mntbuf->f_fstypename, mntfromname,
- mntbuf->f_mntonname, init_flags, options, 0);
- break;
- }
- rmslashes(*argv, *argv);
- if ((fs = getfsfile(*argv)) == NULL &&
- (fs = getfsspec(*argv)) == NULL)
- errx(1, "%s: unknown special file or file system",
- *argv);
- if (BADTYPE(fs->fs_type))
- errx(1, "%s has unknown file system type",
- *argv);
- rval = mountfs(fs->fs_vfstype, fs->fs_spec, fs->fs_file,
- init_flags, options, fs->fs_mntops);
- break;
- case 2:
- /*
- * If -t flag has not been specified, the path cannot be
- * found, spec contains either a ':' or a '@', and the
- * spec is not a file with those characters, then assume
- * that an NFS filesystem is being specified ala Sun.
- */
- if (vfslist == NULL && strpbrk(argv[0], ":@") != NULL &&
- access(argv[0], 0) == -1)
- vfstype = "nfs";
- rval = mountfs(vfstype,
- argv[0], argv[1], init_flags, options, NULL);
- break;
- default:
- usage();
- /* NOTREACHED */
- }
-
- /*
- * If the mount was successfully, and done by root, tell mountd the
- * good news. Pid checks are probably unnecessary, but don't hurt.
- */
- if (rval == 0 && getuid() == 0 &&
- (mountdfp = fopen(_PATH_MOUNTDPID, "r")) != NULL) {
- if (fscanf(mountdfp, "%d", &pid) == 1 &&
- pid > 0 && kill(pid, SIGHUP) == -1 && errno != ESRCH)
- err(1, "signal mountd");
- (void)fclose(mountdfp);
- }
-
- exit(rval);
+ mount_ifs(argc, argv);
+ /* NOTREACHED */
}
int
@@ -440,8 +269,8 @@ mountfs(vfstype, spec, name, flags, options, mntopts)
free(optbuf);
return (1);
case 0: /* Child. */
- if (strcmp(vfstype, "ufs") == 0)
- exit(mount_ufs(argc, (char * const *) argv));
+ if (strcmp(vfstype, "ifs") == 0)
+ exit(mount_ifs(argc, (char * const *) argv));
/* Go find an executable. */
for (edir = edirs; *edir; edir++) {
@@ -688,10 +517,8 @@ void
usage()
{
- (void)fprintf(stderr, "%s\n%s\n%s\n",
-"usage: mount [-dfpruvw] [-o options] [-t ufs | external_type] special node",
-" mount [-adfpruvw] [-t ufs | external_type]",
-" mount [-dfpruvw] special | node");
+ (void)fprintf(stderr, "%s\n",
+"usage: mount [-dfpruvw] [-o options] special node");
exit(1);
}
OpenPOWER on IntegriCloud