Deleted Added
full compact
mount.c (36772) mount.c (37425)
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

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

35static const char copyright[] =
36"@(#) Copyright (c) 1980, 1989, 1993, 1994\n\
37 The Regents of the University of California. All rights reserved.\n";
38#endif /* not lint */
39
40#ifndef lint
41#if 0
42static char sccsid[] = "@(#)mount.c 8.25 (Berkeley) 5/8/95";
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

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

35static const char copyright[] =
36"@(#) Copyright (c) 1980, 1989, 1993, 1994\n\
37 The Regents of the University of California. All rights reserved.\n";
38#endif /* not lint */
39
40#ifndef lint
41#if 0
42static char sccsid[] = "@(#)mount.c 8.25 (Berkeley) 5/8/95";
43#else
44static const char rcsid[] =
45 "$Id: mount.c,v 1.26 1998/05/17 21:57:17 dt Exp $";
46#endif
43#endif
44static const char rcsid[] =
45 "$Id$";
47#endif /* not lint */
48
49#include <sys/param.h>
50#include <sys/mount.h>
51#include <sys/stat.h>
52#include <sys/wait.h>
53
54#include <err.h>

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

74int isremountable __P((const char *));
75void mangle __P((char *, int *, const char **));
76int mountfs __P((const char *, const char *, const char *,
77 int, const char *, const char *));
78void prmount __P((struct statfs *));
79void putfsent __P((const struct statfs *));
80void usage __P((void));
81
46#endif /* not lint */
47
48#include <sys/param.h>
49#include <sys/mount.h>
50#include <sys/stat.h>
51#include <sys/wait.h>
52
53#include <err.h>

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

73int isremountable __P((const char *));
74void mangle __P((char *, int *, const char **));
75int mountfs __P((const char *, const char *, const char *,
76 int, const char *, const char *));
77void prmount __P((struct statfs *));
78void putfsent __P((const struct statfs *));
79void usage __P((void));
80
82/* Map from mount otions to printable formats. */
81/* Map from mount options to printable formats. */
83static struct opt {
84 int o_opt;
85 const char *o_name;
86} optnames[] = {
87 { MNT_ASYNC, "asynchronous" },
88 { MNT_EXPORTED, "NFS exported" },
89 { MNT_LOCAL, "local" },
90 { MNT_NOATIME, "noatime" },

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

150 fstab_style = 1;
151 verbose = 1;
152 break;
153 case 'r':
154 init_flags |= MNT_RDONLY;
155 break;
156 case 't':
157 if (vfslist != NULL)
82static struct opt {
83 int o_opt;
84 const char *o_name;
85} optnames[] = {
86 { MNT_ASYNC, "asynchronous" },
87 { MNT_EXPORTED, "NFS exported" },
88 { MNT_LOCAL, "local" },
89 { MNT_NOATIME, "noatime" },

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

149 fstab_style = 1;
150 verbose = 1;
151 break;
152 case 'r':
153 init_flags |= MNT_RDONLY;
154 break;
155 case 't':
156 if (vfslist != NULL)
158 errx(1, "only one -t option may be specified.");
157 errx(1, "only one -t option may be specified");
159 vfslist = makevfslist(optarg);
160 vfstype = optarg;
161 break;
162 case 'u':
163 init_flags |= MNT_UPDATE;
164 break;
165 case 'v':
166 verbose = 1;

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

217 exit(rval);
218 case 1:
219 if (vfslist != NULL)
220 usage();
221
222 if (init_flags & MNT_UPDATE) {
223 if ((mntbuf = getmntpt(*argv)) == NULL)
224 errx(1,
158 vfslist = makevfslist(optarg);
159 vfstype = optarg;
160 break;
161 case 'u':
162 init_flags |= MNT_UPDATE;
163 break;
164 case 'v':
165 verbose = 1;

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

216 exit(rval);
217 case 1:
218 if (vfslist != NULL)
219 usage();
220
221 if (init_flags & MNT_UPDATE) {
222 if ((mntbuf = getmntpt(*argv)) == NULL)
223 errx(1,
225 "unknown special file or file system %s.",
224 "unknown special file or file system %s",
226 *argv);
227 if ((fs = getfsfile(mntbuf->f_mntonname)) != NULL)
228 mntfromname = fs->fs_spec;
229 else
230 mntfromname = mntbuf->f_mntfromname;
231 rval = mountfs(mntbuf->f_fstypename, mntfromname,
232 mntbuf->f_mntonname, init_flags, options, 0);
233 break;
234 }
235 if ((fs = getfsfile(*argv)) == NULL &&
236 (fs = getfsspec(*argv)) == NULL)
225 *argv);
226 if ((fs = getfsfile(mntbuf->f_mntonname)) != NULL)
227 mntfromname = fs->fs_spec;
228 else
229 mntfromname = mntbuf->f_mntfromname;
230 rval = mountfs(mntbuf->f_fstypename, mntfromname,
231 mntbuf->f_mntonname, init_flags, options, 0);
232 break;
233 }
234 if ((fs = getfsfile(*argv)) == NULL &&
235 (fs = getfsspec(*argv)) == NULL)
237 errx(1, "%s: unknown special file or file system.",
236 errx(1, "%s: unknown special file or file system",
238 *argv);
239 if (BADTYPE(fs->fs_type))
237 *argv);
238 if (BADTYPE(fs->fs_type))
240 errx(1, "%s has unknown file system type.",
239 errx(1, "%s has unknown file system type",
241 *argv);
242 rval = mountfs(fs->fs_vfstype, fs->fs_spec, fs->fs_file,
243 init_flags, options, fs->fs_mntops);
244 break;
245 case 2:
246 /*
247 * If -t flag has not been specified, and spec contains either
248 * a ':' or a '@' then assume that an NFS filesystem is being

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

350
351#if __GNUC__
352 (void)&optbuf;
353 (void)&name;
354#endif
355
356 if (realpath(name, mntpath) != NULL && stat(mntpath, &sb) == 0) {
357 if (!S_ISDIR(sb.st_mode)) {
240 *argv);
241 rval = mountfs(fs->fs_vfstype, fs->fs_spec, fs->fs_file,
242 init_flags, options, fs->fs_mntops);
243 break;
244 case 2:
245 /*
246 * If -t flag has not been specified, and spec contains either
247 * a ':' or a '@' then assume that an NFS filesystem is being

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

349
350#if __GNUC__
351 (void)&optbuf;
352 (void)&name;
353#endif
354
355 if (realpath(name, mntpath) != NULL && stat(mntpath, &sb) == 0) {
356 if (!S_ISDIR(sb.st_mode)) {
358 warnx("%s: Not a directory", mntpath);
357 warnx("%s: not a directory", mntpath);
359 return (1);
360 }
361 } else {
362 warn("%s", mntpath);
363 return (1);
364 }
365
366 name = mntpath;

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

381 flags |= MNT_UPDATE;
382 if (flags & MNT_FORCE)
383 optbuf = catopt(optbuf, "force");
384 if (flags & MNT_RDONLY)
385 optbuf = catopt(optbuf, "ro");
386 /*
387 * XXX
388 * The mount_mfs (newfs) command uses -o to select the
358 return (1);
359 }
360 } else {
361 warn("%s", mntpath);
362 return (1);
363 }
364
365 name = mntpath;

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

380 flags |= MNT_UPDATE;
381 if (flags & MNT_FORCE)
382 optbuf = catopt(optbuf, "force");
383 if (flags & MNT_RDONLY)
384 optbuf = catopt(optbuf, "ro");
385 /*
386 * XXX
387 * The mount_mfs (newfs) command uses -o to select the
389 * optimisation mode. We don't pass the default "-o rw"
388 * optimization mode. We don't pass the default "-o rw"
390 * for that reason.
391 */
392 if (flags & MNT_UPDATE)
393 optbuf = catopt(optbuf, "update");
394
395 argc = 0;
396 argv[argc++] = vfstype;
397 mangle(optbuf, &argc, argv);

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

422 sizeof(execname), "%s/mount_%s", *edir, vfstype);
423 execv(execname, (char * const *)argv);
424 }
425 if (errno == ENOENT) {
426 int len = 0;
427 char *cp;
428 for (edir = edirs; *edir; edir++)
429 len += strlen(*edir) + 2; /* ", " */
389 * for that reason.
390 */
391 if (flags & MNT_UPDATE)
392 optbuf = catopt(optbuf, "update");
393
394 argc = 0;
395 argv[argc++] = vfstype;
396 mangle(optbuf, &argc, argv);

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

421 sizeof(execname), "%s/mount_%s", *edir, vfstype);
422 execv(execname, (char * const *)argv);
423 }
424 if (errno == ENOENT) {
425 int len = 0;
426 char *cp;
427 for (edir = edirs; *edir; edir++)
428 len += strlen(*edir) + 2; /* ", " */
430 if ((cp = malloc(len)) == NULL) {
431 warn(NULL);
432 exit(1);
433 }
429 if ((cp = malloc(len)) == NULL)
430 errx(1, "malloc failed");
434 cp[0] = '\0';
435 for (edir = edirs; *edir; edir++) {
436 strcat(cp, *edir);
437 if (edir[1] != NULL)
438 strcat(cp, ", ");
439 }
440 warn("exec mount_%s not found in %s", vfstype, cp);
441 }

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

524 const char *s1;
525{
526 size_t i;
527 char *cp;
528
529 if (s0 && *s0) {
530 i = strlen(s0) + strlen(s1) + 1 + 1;
531 if ((cp = malloc(i)) == NULL)
431 cp[0] = '\0';
432 for (edir = edirs; *edir; edir++) {
433 strcat(cp, *edir);
434 if (edir[1] != NULL)
435 strcat(cp, ", ");
436 }
437 warn("exec mount_%s not found in %s", vfstype, cp);
438 }

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

521 const char *s1;
522{
523 size_t i;
524 char *cp;
525
526 if (s0 && *s0) {
527 i = strlen(s0) + strlen(s1) + 1 + 1;
528 if ((cp = malloc(i)) == NULL)
532 err(1, NULL);
529 errx(1, "malloc failed");
533 (void)snprintf(cp, i, "%s,%s", s0, s1);
534 } else
535 cp = strdup(s1);
536
537 if (s0)
538 free(s0);
539 return (cp);
540}

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

565
566 *argcp = argc;
567}
568
569void
570usage()
571{
572
530 (void)snprintf(cp, i, "%s,%s", s0, s1);
531 } else
532 cp = strdup(s1);
533
534 if (s0)
535 free(s0);
536 return (cp);
537}

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

562
563 *argcp = argc;
564}
565
566void
567usage()
568{
569
573 (void)fprintf(stderr,
574 "usage: mount %s %s\n mount %s\n mount %s\n",
575 "[-dfpruvw] [-o options] [-t ufs | external_type]",
576 "special node",
577 "[-adfpruvw] [-t ufs | external_type]",
578 "[-dfpruvw] special | node");
570 (void)fprintf(stderr, "%s\n%s\n%s\n",
571"usage: mount [-dfpruvw] [-o options] [-t ufs | external_type] special node",
572" mount [-adfpruvw] [-t ufs | external_type]",
573" mount [-dfpruvw] special | node");
579 exit(1);
580}
581
582void
583putfsent(ent)
584 const struct statfs *ent;
585{
586 struct fstab *fst;

--- 37 unchanged lines hidden ---
574 exit(1);
575}
576
577void
578putfsent(ent)
579 const struct statfs *ent;
580{
581 struct fstab *fst;

--- 37 unchanged lines hidden ---