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#endif |
44static const char rcsid[] = 45 "$Id$"; |
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 |
81/* Map from mount options to printable formats. */ |
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) |
157 errx(1, "only one -t option may be specified"); |
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, |
224 "unknown special file or file system %s", |
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) |
236 errx(1, "%s: unknown special file or file system", |
237 *argv); 238 if (BADTYPE(fs->fs_type)) |
239 errx(1, "%s has unknown file system type", |
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)) { |
357 warnx("%s: not a directory", mntpath); |
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 |
388 * optimization mode. We don't pass the default "-o rw" |
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; /* ", " */ |
429 if ((cp = malloc(len)) == NULL) 430 errx(1, "malloc failed"); |
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) |
529 errx(1, "malloc failed"); |
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 |
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"); |
574 exit(1); 575} 576 577void 578putfsent(ent) 579 const struct statfs *ent; 580{ 581 struct fstab *fst; --- 37 unchanged lines hidden --- |