mount.c (6e34b4796ddb57be97f31b96bc0df416e816a399) mount.c (e24dc56a221a481029e370679686566f0f1cbf7b)
1/*-
2 * Copyright (c) 1980, 1989, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 107 unchanged lines hidden (view full) ---

116 */
117static const char *
118remountable_fs_names[] = {
119 "ufs", "ffs", "ext2fs",
120 0
121};
122
123int
1/*-
2 * Copyright (c) 1980, 1989, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 107 unchanged lines hidden (view full) ---

116 */
117static const char *
118remountable_fs_names[] = {
119 "ufs", "ffs", "ext2fs",
120 0
121};
122
123int
124main(argc, argv)
125 int argc;
126 char * const argv[];
124main(int argc, char *argv[])
127{
128 const char *mntfromname, **vfslist, *vfstype;
129 struct fstab *fs;
130 struct statfs *mntbuf;
131 FILE *mountdfp;
132 pid_t pid;
133 int all, ch, i, init_flags, mntsize, rval, have_fstab;
134 char *cp, *ep, *options;

--- 190 unchanged lines hidden (view full) ---

325 err(1, "signal mountd");
326 (void)fclose(mountdfp);
327 }
328
329 exit(rval);
330}
331
332int
125{
126 const char *mntfromname, **vfslist, *vfstype;
127 struct fstab *fs;
128 struct statfs *mntbuf;
129 FILE *mountdfp;
130 pid_t pid;
131 int all, ch, i, init_flags, mntsize, rval, have_fstab;
132 char *cp, *ep, *options;

--- 190 unchanged lines hidden (view full) ---

323 err(1, "signal mountd");
324 (void)fclose(mountdfp);
325 }
326
327 exit(rval);
328}
329
330int
333ismounted(fs, mntbuf, mntsize)
334 struct fstab *fs;
335 struct statfs *mntbuf;
336 int mntsize;
331ismounted(struct fstab *fs, struct statfs *mntbuf, int mntsize)
337{
338 int i;
339
340 if (fs->fs_file[0] == '/' && fs->fs_file[1] == '\0')
341 /* the root file system can always be remounted */
342 return (0);
343
344 for (i = mntsize - 1; i >= 0; --i)
345 if (strcmp(fs->fs_file, mntbuf[i].f_mntonname) == 0 &&
346 (!isremountable(fs->fs_vfstype) ||
347 strcmp(fs->fs_spec, mntbuf[i].f_mntfromname) == 0))
348 return (1);
349 return (0);
350}
351
352int
332{
333 int i;
334
335 if (fs->fs_file[0] == '/' && fs->fs_file[1] == '\0')
336 /* the root file system can always be remounted */
337 return (0);
338
339 for (i = mntsize - 1; i >= 0; --i)
340 if (strcmp(fs->fs_file, mntbuf[i].f_mntonname) == 0 &&
341 (!isremountable(fs->fs_vfstype) ||
342 strcmp(fs->fs_spec, mntbuf[i].f_mntfromname) == 0))
343 return (1);
344 return (0);
345}
346
347int
353isremountable(vfsname)
354 const char *vfsname;
348isremountable(const char *vfsname)
355{
356 const char **cp;
357
358 for (cp = remountable_fs_names; *cp; cp++)
359 if (strcmp(*cp, vfsname) == 0)
360 return (1);
361 return (0);
362}
363
364int
349{
350 const char **cp;
351
352 for (cp = remountable_fs_names; *cp; cp++)
353 if (strcmp(*cp, vfsname) == 0)
354 return (1);
355 return (0);
356}
357
358int
365hasopt(mntopts, option)
366 const char *mntopts, *option;
359hasopt(const char *mntopts, const char *option)
367{
368 int negative, found;
369 char *opt, *optbuf;
370
371 if (option[0] == 'n' && option[1] == 'o') {
372 negative = 1;
373 option += 2;
374 } else

--- 7 unchanged lines hidden (view full) ---

382 } else if (!strcasecmp(opt, option))
383 found = !negative;
384 }
385 free(optbuf);
386 return (found);
387}
388
389int
360{
361 int negative, found;
362 char *opt, *optbuf;
363
364 if (option[0] == 'n' && option[1] == 'o') {
365 negative = 1;
366 option += 2;
367 } else

--- 7 unchanged lines hidden (view full) ---

375 } else if (!strcasecmp(opt, option))
376 found = !negative;
377 }
378 free(optbuf);
379 return (found);
380}
381
382int
390mountfs(vfstype, spec, name, flags, options, mntopts)
391 const char *vfstype, *spec, *name, *options, *mntopts;
392 int flags;
383mountfs(const char *vfstype, const char *spec, const char *name, int flags,
384 const char *options, const char *mntopts)
393{
394 const char *argv[100];
395 struct statfs sf;
396 pid_t pid;
397 int argc, i, status;
398 char *optbuf, execname[PATH_MAX], mntpath[PATH_MAX];
399
400#if __GNUC__

--- 99 unchanged lines hidden (view full) ---

500 }
501 break;
502 }
503
504 return (0);
505}
506
507void
385{
386 const char *argv[100];
387 struct statfs sf;
388 pid_t pid;
389 int argc, i, status;
390 char *optbuf, execname[PATH_MAX], mntpath[PATH_MAX];
391
392#if __GNUC__

--- 99 unchanged lines hidden (view full) ---

492 }
493 break;
494 }
495
496 return (0);
497}
498
499void
508prmount(sfp)
509 struct statfs *sfp;
500prmount(struct statfs *sfp)
510{
511 int flags, i;
512 struct opt *o;
513 struct passwd *pw;
514
515 (void)printf("%s on %s (%s", sfp->f_mntfromname, sfp->f_mntonname,
516 sfp->f_fstypename);
517

--- 28 unchanged lines hidden (view full) ---

546 for (i = 0; i < sizeof(sfp->f_fsid); i++)
547 printf("%02x", ((u_char *)&sfp->f_fsid)[i]);
548 }
549 }
550 (void)printf(")\n");
551}
552
553struct statfs *
501{
502 int flags, i;
503 struct opt *o;
504 struct passwd *pw;
505
506 (void)printf("%s on %s (%s", sfp->f_mntfromname, sfp->f_mntonname,
507 sfp->f_fstypename);
508

--- 28 unchanged lines hidden (view full) ---

537 for (i = 0; i < sizeof(sfp->f_fsid); i++)
538 printf("%02x", ((u_char *)&sfp->f_fsid)[i]);
539 }
540 }
541 (void)printf(")\n");
542}
543
544struct statfs *
554getmntpt(name)
555 const char *name;
545getmntpt(const char *name)
556{
557 struct statfs *mntbuf;
558 int i, mntsize;
559
560 mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
561 for (i = mntsize - 1; i >= 0; i--) {
562 if (strcmp(mntbuf[i].f_mntfromname, name) == 0 ||
563 strcmp(mntbuf[i].f_mntonname, name) == 0)
564 return (&mntbuf[i]);
565 }
566 return (NULL);
567}
568
569char *
546{
547 struct statfs *mntbuf;
548 int i, mntsize;
549
550 mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
551 for (i = mntsize - 1; i >= 0; i--) {
552 if (strcmp(mntbuf[i].f_mntfromname, name) == 0 ||
553 strcmp(mntbuf[i].f_mntonname, name) == 0)
554 return (&mntbuf[i]);
555 }
556 return (NULL);
557}
558
559char *
570catopt(s0, s1)
571 char *s0;
572 const char *s1;
560catopt(char *s0, const char *s1)
573{
574 size_t i;
575 char *cp;
576
577 if (s1 == NULL || *s1 == '\0')
578 return s0;
579
580 if (s0 && *s0) {

--- 185 unchanged lines hidden ---
561{
562 size_t i;
563 char *cp;
564
565 if (s1 == NULL || *s1 == '\0')
566 return s0;
567
568 if (s0 && *s0) {

--- 185 unchanged lines hidden ---