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 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 4. Neither the name of the University nor the names of its contributors 14 * may be used to endorse or promote products derived from this software 15 * without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30 #ifndef lint 31 static const char copyright[] = 32 "@(#) Copyright (c) 1980, 1989, 1993, 1994\n\ 33 The Regents of the University of California. All rights reserved.\n"; 34 #endif /* not lint */ 35 36 #ifndef lint 37 #if 0 38 static char sccsid[] = "@(#)mount.c 8.25 (Berkeley) 5/8/95"; 39 #endif 40 static const char rcsid[] = 41 "$FreeBSD$"; 42 #endif /* not lint */ 43 44 #include <sys/param.h> 45 #include <sys/mount.h> 46 #include <sys/stat.h> 47 #include <sys/wait.h> 48 49 #include <ctype.h> 50 #include <err.h> 51 #include <errno.h> 52 #include <fstab.h> 53 #include <paths.h> 54 #include <pwd.h> 55 #include <signal.h> 56 #include <stdint.h> 57 #include <stdio.h> 58 #include <stdlib.h> 59 #include <string.h> 60 #include <unistd.h> 61 62 #include "extern.h" 63 #include "mntopts.h" 64 #include "pathnames.h" 65 66 /* `meta' options */ 67 #define MOUNT_META_OPTION_FSTAB "fstab" 68 #define MOUNT_META_OPTION_CURRENT "current" 69 70 int debug, fstab_style, verbose; 71 72 char *catopt(char *, const char *); 73 struct statfs *getmntpt(const char *); 74 int hasopt(const char *, const char *); 75 int ismounted(struct fstab *, struct statfs *, int); 76 int isremountable(const char *); 77 void mangle(char *, int *, const char **); 78 char *update_options(char *, char *, int); 79 int mountfs(const char *, const char *, const char *, 80 int, const char *, const char *); 81 void remopt(char *, const char *); 82 void prmount(struct statfs *); 83 void putfsent(const struct statfs *); 84 void usage(void); 85 char *flags2opts(int); 86 87 /* Map from mount options to printable formats. */ 88 static struct opt { 89 int o_opt; 90 const char *o_name; 91 } optnames[] = { 92 { MNT_ASYNC, "asynchronous" }, 93 { MNT_EXPORTED, "NFS exported" }, 94 { MNT_LOCAL, "local" }, 95 { MNT_NOATIME, "noatime" }, 96 { MNT_NODEV, "nodev" }, 97 { MNT_NOEXEC, "noexec" }, 98 { MNT_NOSUID, "nosuid" }, 99 { MNT_NOSYMFOLLOW, "nosymfollow" }, 100 { MNT_QUOTA, "with quotas" }, 101 { MNT_RDONLY, "read-only" }, 102 { MNT_SYNCHRONOUS, "synchronous" }, 103 { MNT_UNION, "union" }, 104 { MNT_NOCLUSTERR, "noclusterr" }, 105 { MNT_NOCLUSTERW, "noclusterw" }, 106 { MNT_SUIDDIR, "suiddir" }, 107 { MNT_SOFTDEP, "soft-updates" }, 108 { MNT_MULTILABEL, "multilabel" }, 109 { MNT_ACLS, "acls" }, 110 { 0, NULL } 111 }; 112 113 /* 114 * List of VFS types that can be remounted without becoming mounted on top 115 * of each other. 116 * XXX Is this list correct? 117 */ 118 static const char * 119 remountable_fs_names[] = { 120 "ufs", "ffs", "ext2fs", 121 0 122 }; 123 124 int 125 main(argc, argv) 126 int argc; 127 char * const argv[]; 128 { 129 const char *mntfromname, **vfslist, *vfstype; 130 struct fstab *fs; 131 struct statfs *mntbuf; 132 FILE *mountdfp; 133 pid_t pid; 134 int all, ch, i, init_flags, mntsize, rval, have_fstab; 135 char *cp, *ep, *options; 136 137 all = init_flags = 0; 138 options = NULL; 139 vfslist = NULL; 140 vfstype = "ufs"; 141 while ((ch = getopt(argc, argv, "adF:fo:prwt:uv")) != -1) 142 switch (ch) { 143 case 'a': 144 all = 1; 145 break; 146 case 'd': 147 debug = 1; 148 break; 149 case 'F': 150 setfstab(optarg); 151 break; 152 case 'f': 153 init_flags |= MNT_FORCE; 154 break; 155 case 'o': 156 if (*optarg) 157 options = catopt(options, optarg); 158 break; 159 case 'p': 160 fstab_style = 1; 161 verbose = 1; 162 break; 163 case 'r': 164 options = catopt(options, "ro"); 165 break; 166 case 't': 167 if (vfslist != NULL) 168 errx(1, "only one -t option may be specified"); 169 vfslist = makevfslist(optarg); 170 vfstype = optarg; 171 break; 172 case 'u': 173 init_flags |= MNT_UPDATE; 174 break; 175 case 'v': 176 verbose = 1; 177 break; 178 case 'w': 179 options = catopt(options, "noro"); 180 break; 181 case '?': 182 default: 183 usage(); 184 /* NOTREACHED */ 185 } 186 argc -= optind; 187 argv += optind; 188 189 #define BADTYPE(type) \ 190 (strcmp(type, FSTAB_RO) && \ 191 strcmp(type, FSTAB_RW) && strcmp(type, FSTAB_RQ)) 192 193 rval = 0; 194 switch (argc) { 195 case 0: 196 if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0) 197 err(1, "getmntinfo"); 198 if (all) { 199 while ((fs = getfsent()) != NULL) { 200 if (BADTYPE(fs->fs_type)) 201 continue; 202 if (checkvfsname(fs->fs_vfstype, vfslist)) 203 continue; 204 if (hasopt(fs->fs_mntops, "noauto")) 205 continue; 206 if (!(init_flags & MNT_UPDATE) && 207 ismounted(fs, mntbuf, mntsize)) 208 continue; 209 options = update_options(options, fs->fs_mntops, 210 mntbuf->f_flags); 211 if (mountfs(fs->fs_vfstype, fs->fs_spec, 212 fs->fs_file, init_flags, options, 213 fs->fs_mntops)) 214 rval = 1; 215 } 216 } else if (fstab_style) { 217 for (i = 0; i < mntsize; i++) { 218 if (checkvfsname(mntbuf[i].f_fstypename, vfslist)) 219 continue; 220 putfsent(&mntbuf[i]); 221 } 222 } else { 223 for (i = 0; i < mntsize; i++) { 224 if (checkvfsname(mntbuf[i].f_fstypename, 225 vfslist)) 226 continue; 227 prmount(&mntbuf[i]); 228 } 229 } 230 exit(rval); 231 case 1: 232 if (vfslist != NULL) 233 usage(); 234 235 rmslashes(*argv, *argv); 236 if (init_flags & MNT_UPDATE) { 237 mntfromname = NULL; 238 have_fstab = 0; 239 if ((mntbuf = getmntpt(*argv)) == NULL) 240 errx(1, "not currently mounted %s", *argv); 241 /* 242 * Only get the mntflags from fstab if both mntpoint 243 * and mntspec are identical. Also handle the special 244 * case where just '/' is mounted and 'spec' is not 245 * identical with the one from fstab ('/dev' is missing 246 * in the spec-string at boot-time). 247 */ 248 if ((fs = getfsfile(mntbuf->f_mntonname)) != NULL) { 249 if (strcmp(fs->fs_spec, 250 mntbuf->f_mntfromname) == 0 && 251 strcmp(fs->fs_file, 252 mntbuf->f_mntonname) == 0) { 253 have_fstab = 1; 254 mntfromname = mntbuf->f_mntfromname; 255 } else if (argv[0][0] == '/' && 256 argv[0][1] == '\0') { 257 fs = getfsfile("/"); 258 have_fstab = 1; 259 mntfromname = fs->fs_spec; 260 } 261 } 262 if (have_fstab) { 263 options = update_options(options, fs->fs_mntops, 264 mntbuf->f_flags); 265 } else { 266 mntfromname = mntbuf->f_mntfromname; 267 options = update_options(options, NULL, 268 mntbuf->f_flags); 269 } 270 rval = mountfs(mntbuf->f_fstypename, mntfromname, 271 mntbuf->f_mntonname, init_flags, options, 0); 272 break; 273 } 274 if ((fs = getfsfile(*argv)) == NULL && 275 (fs = getfsspec(*argv)) == NULL) 276 errx(1, "%s: unknown special file or file system", 277 *argv); 278 if (BADTYPE(fs->fs_type)) 279 errx(1, "%s has unknown file system type", 280 *argv); 281 rval = mountfs(fs->fs_vfstype, fs->fs_spec, fs->fs_file, 282 init_flags, options, fs->fs_mntops); 283 break; 284 case 2: 285 /* 286 * If -t flag has not been specified, the path cannot be 287 * found, spec contains either a ':' or a '@', then assume 288 * that an NFS file system is being specified ala Sun. 289 * Check if the hostname contains only allowed characters 290 * to reduce false positives. IPv6 addresses containing 291 * ':' will be correctly parsed only if the separator is '@'. 292 * The definition of a valid hostname is taken from RFC 1034. 293 */ 294 if (vfslist == NULL && ((ep = strchr(argv[0], '@')) != NULL || 295 (ep = strchr(argv[0], ':')) != NULL)) { 296 if (*ep == '@') { 297 cp = ep + 1; 298 ep = cp + strlen(cp); 299 } else 300 cp = argv[0]; 301 while (cp != ep) { 302 if (!isdigit(*cp) && !isalpha(*cp) && 303 *cp != '.' && *cp != '-' && *cp != ':') 304 break; 305 cp++; 306 } 307 if (cp == ep) 308 vfstype = "nfs"; 309 } 310 rval = mountfs(vfstype, 311 argv[0], argv[1], init_flags, options, NULL); 312 break; 313 default: 314 usage(); 315 /* NOTREACHED */ 316 } 317 318 /* 319 * If the mount was successfully, and done by root, tell mountd the 320 * good news. Pid checks are probably unnecessary, but don't hurt. 321 */ 322 if (rval == 0 && getuid() == 0 && 323 (mountdfp = fopen(_PATH_MOUNTDPID, "r")) != NULL) { 324 if (fscanf(mountdfp, "%d", &pid) == 1 && 325 pid > 0 && kill(pid, SIGHUP) == -1 && errno != ESRCH) 326 err(1, "signal mountd"); 327 (void)fclose(mountdfp); 328 } 329 330 exit(rval); 331 } 332 333 int 334 ismounted(fs, mntbuf, mntsize) 335 struct fstab *fs; 336 struct statfs *mntbuf; 337 int mntsize; 338 { 339 int i; 340 341 if (fs->fs_file[0] == '/' && fs->fs_file[1] == '\0') 342 /* the root file system can always be remounted */ 343 return (0); 344 345 for (i = mntsize - 1; i >= 0; --i) 346 if (strcmp(fs->fs_file, mntbuf[i].f_mntonname) == 0 && 347 (!isremountable(fs->fs_vfstype) || 348 strcmp(fs->fs_spec, mntbuf[i].f_mntfromname) == 0)) 349 return (1); 350 return (0); 351 } 352 353 int 354 isremountable(vfsname) 355 const char *vfsname; 356 { 357 const char **cp; 358 359 for (cp = remountable_fs_names; *cp; cp++) 360 if (strcmp(*cp, vfsname) == 0) 361 return (1); 362 return (0); 363 } 364 365 int 366 hasopt(mntopts, option) 367 const char *mntopts, *option; 368 { 369 int negative, found; 370 char *opt, *optbuf; 371 372 if (option[0] == 'n' && option[1] == 'o') { 373 negative = 1; 374 option += 2; 375 } else 376 negative = 0; 377 optbuf = strdup(mntopts); 378 found = 0; 379 for (opt = optbuf; (opt = strtok(opt, ",")) != NULL; opt = NULL) { 380 if (opt[0] == 'n' && opt[1] == 'o') { 381 if (!strcasecmp(opt + 2, option)) 382 found = negative; 383 } else if (!strcasecmp(opt, option)) 384 found = !negative; 385 } 386 free(optbuf); 387 return (found); 388 } 389 390 int 391 mountfs(vfstype, spec, name, flags, options, mntopts) 392 const char *vfstype, *spec, *name, *options, *mntopts; 393 int flags; 394 { 395 const char *argv[100]; 396 struct statfs sf; 397 pid_t pid; 398 int argc, i, status; 399 char *optbuf, execname[PATH_MAX], mntpath[PATH_MAX]; 400 401 #if __GNUC__ 402 (void)&optbuf; 403 (void)&name; 404 #endif 405 406 /* resolve the mountpoint with realpath(3) */ 407 (void)checkpath(name, mntpath); 408 name = mntpath; 409 410 if (mntopts == NULL) 411 mntopts = ""; 412 if (options == NULL) { 413 if (*mntopts == '\0') { 414 options = "rw"; 415 } else { 416 options = mntopts; 417 mntopts = ""; 418 } 419 } 420 optbuf = catopt(strdup(mntopts), options); 421 422 if (strcmp(name, "/") == 0) 423 flags |= MNT_UPDATE; 424 if (flags & MNT_FORCE) 425 optbuf = catopt(optbuf, "force"); 426 if (flags & MNT_RDONLY) 427 optbuf = catopt(optbuf, "ro"); 428 /* 429 * XXX 430 * The mount_mfs (newfs) command uses -o to select the 431 * optimization mode. We don't pass the default "-o rw" 432 * for that reason. 433 */ 434 if (flags & MNT_UPDATE) 435 optbuf = catopt(optbuf, "update"); 436 437 /* Compatibility glue. */ 438 if (strcmp(vfstype, "msdos") == 0) 439 vfstype = "msdosfs"; 440 441 argc = 0; 442 argv[argc++] = vfstype; 443 mangle(optbuf, &argc, argv); 444 argv[argc++] = spec; 445 argv[argc++] = name; 446 argv[argc] = NULL; 447 448 if (debug) { 449 (void)printf("exec: mount_%s", vfstype); 450 for (i = 1; i < argc; i++) 451 (void)printf(" %s", argv[i]); 452 (void)printf("\n"); 453 return (0); 454 } 455 456 switch (pid = fork()) { 457 case -1: /* Error. */ 458 warn("fork"); 459 free(optbuf); 460 return (1); 461 case 0: /* Child. */ 462 if (strcmp(vfstype, "ufs") == 0) 463 exit(mount_ufs(argc, (char * const *) argv)); 464 465 /* Go find an executable. */ 466 (void)snprintf(execname, sizeof(execname), "mount_%s", vfstype); 467 execvP(execname, _PATH_SYSPATH, (char * const *)argv); 468 if (errno == ENOENT) { 469 warn("exec mount_%s not found in %s", vfstype, 470 _PATH_SYSPATH); 471 } 472 exit(1); 473 /* NOTREACHED */ 474 default: /* Parent. */ 475 free(optbuf); 476 477 if (waitpid(pid, &status, 0) < 0) { 478 warn("waitpid"); 479 return (1); 480 } 481 482 if (WIFEXITED(status)) { 483 if (WEXITSTATUS(status) != 0) 484 return (WEXITSTATUS(status)); 485 } else if (WIFSIGNALED(status)) { 486 warnx("%s: %s", name, sys_siglist[WTERMSIG(status)]); 487 return (1); 488 } 489 490 if (verbose) { 491 if (statfs(name, &sf) < 0) { 492 warn("statfs %s", name); 493 return (1); 494 } 495 if (fstab_style) 496 putfsent(&sf); 497 else 498 prmount(&sf); 499 } 500 break; 501 } 502 503 return (0); 504 } 505 506 void 507 prmount(sfp) 508 struct statfs *sfp; 509 { 510 int flags, i; 511 struct opt *o; 512 struct passwd *pw; 513 514 (void)printf("%s on %s (%s", sfp->f_mntfromname, sfp->f_mntonname, 515 sfp->f_fstypename); 516 517 flags = sfp->f_flags & MNT_VISFLAGMASK; 518 for (o = optnames; flags && o->o_opt; o++) 519 if (flags & o->o_opt) { 520 (void)printf(", %s", o->o_name); 521 flags &= ~o->o_opt; 522 } 523 /* 524 * Inform when file system is mounted by an unprivileged user 525 * or privileged non-root user. 526 */ 527 if ((flags & MNT_USER) != 0 || sfp->f_owner != 0) { 528 (void)printf(", mounted by "); 529 if ((pw = getpwuid(sfp->f_owner)) != NULL) 530 (void)printf("%s", pw->pw_name); 531 else 532 (void)printf("%d", sfp->f_owner); 533 } 534 if (verbose) { 535 if (sfp->f_syncwrites != 0 || sfp->f_asyncwrites != 0) 536 (void)printf(", writes: sync %ju async %ju", 537 (uintmax_t)sfp->f_syncwrites, 538 (uintmax_t)sfp->f_asyncwrites); 539 if (sfp->f_syncreads != 0 || sfp->f_asyncreads != 0) 540 (void)printf(", reads: sync %ju async %ju", 541 (uintmax_t)sfp->f_syncreads, 542 (uintmax_t)sfp->f_asyncreads); 543 if (sfp->f_fsid.val[0] != 0 || sfp->f_fsid.val[1] != 0) { 544 printf(", fsid "); 545 for (i = 0; i < sizeof(sfp->f_fsid); i++) 546 printf("%02x", ((u_char *)&sfp->f_fsid)[i]); 547 } 548 } 549 (void)printf(")\n"); 550 } 551 552 struct statfs * 553 getmntpt(name) 554 const char *name; 555 { 556 struct statfs *mntbuf; 557 int i, mntsize; 558 559 mntsize = getmntinfo(&mntbuf, MNT_NOWAIT); 560 for (i = mntsize - 1; i >= 0; i--) { 561 if (strcmp(mntbuf[i].f_mntfromname, name) == 0 || 562 strcmp(mntbuf[i].f_mntonname, name) == 0) 563 return (&mntbuf[i]); 564 } 565 return (NULL); 566 } 567 568 char * 569 catopt(s0, s1) 570 char *s0; 571 const char *s1; 572 { 573 size_t i; 574 char *cp; 575 576 if (s1 == NULL || *s1 == '\0') 577 return s0; 578 579 if (s0 && *s0) { 580 i = strlen(s0) + strlen(s1) + 1 + 1; 581 if ((cp = malloc(i)) == NULL) 582 errx(1, "malloc failed"); 583 (void)snprintf(cp, i, "%s,%s", s0, s1); 584 } else 585 cp = strdup(s1); 586 587 if (s0) 588 free(s0); 589 return (cp); 590 } 591 592 void 593 mangle(options, argcp, argv) 594 char *options; 595 int *argcp; 596 const char **argv; 597 { 598 char *p, *s; 599 int argc; 600 601 argc = *argcp; 602 for (s = options; (p = strsep(&s, ",")) != NULL;) 603 if (*p != '\0') { 604 if (*p == '-') { 605 argv[argc++] = p; 606 p = strchr(p, '='); 607 if (p != NULL) { 608 *p = '\0'; 609 argv[argc++] = p+1; 610 } 611 } else if (strcmp(p, "rw") != 0) { 612 argv[argc++] = "-o"; 613 argv[argc++] = p; 614 } 615 } 616 617 *argcp = argc; 618 } 619 620 621 char * 622 update_options(opts, fstab, curflags) 623 char *opts; 624 char *fstab; 625 int curflags; 626 { 627 char *o, *p; 628 char *cur; 629 char *expopt, *newopt, *tmpopt; 630 631 if (opts == NULL) 632 return strdup(""); 633 634 /* remove meta options from list */ 635 remopt(fstab, MOUNT_META_OPTION_FSTAB); 636 remopt(fstab, MOUNT_META_OPTION_CURRENT); 637 cur = flags2opts(curflags); 638 639 /* 640 * Expand all meta-options passed to us first. 641 */ 642 expopt = NULL; 643 for (p = opts; (o = strsep(&p, ",")) != NULL;) { 644 if (strcmp(MOUNT_META_OPTION_FSTAB, o) == 0) 645 expopt = catopt(expopt, fstab); 646 else if (strcmp(MOUNT_META_OPTION_CURRENT, o) == 0) 647 expopt = catopt(expopt, cur); 648 else 649 expopt = catopt(expopt, o); 650 } 651 free(cur); 652 free(opts); 653 654 /* 655 * Remove previous contradictory arguments. Given option "foo" we 656 * remove all the "nofoo" options. Given "nofoo" we remove "nonofoo" 657 * and "foo" - so we can deal with possible options like "notice". 658 */ 659 newopt = NULL; 660 for (p = expopt; (o = strsep(&p, ",")) != NULL;) { 661 if ((tmpopt = malloc( strlen(o) + 2 + 1 )) == NULL) 662 errx(1, "malloc failed"); 663 664 strcpy(tmpopt, "no"); 665 strcat(tmpopt, o); 666 remopt(newopt, tmpopt); 667 free(tmpopt); 668 669 if (strncmp("no", o, 2) == 0) 670 remopt(newopt, o+2); 671 672 newopt = catopt(newopt, o); 673 } 674 free(expopt); 675 676 return newopt; 677 } 678 679 void 680 remopt(string, opt) 681 char *string; 682 const char *opt; 683 { 684 char *o, *p, *r; 685 686 if (string == NULL || *string == '\0' || opt == NULL || *opt == '\0') 687 return; 688 689 r = string; 690 691 for (p = string; (o = strsep(&p, ",")) != NULL;) { 692 if (strcmp(opt, o) != 0) { 693 if (*r == ',' && *o != '\0') 694 r++; 695 while ((*r++ = *o++) != '\0') 696 ; 697 *--r = ','; 698 } 699 } 700 *r = '\0'; 701 } 702 703 void 704 usage() 705 { 706 707 (void)fprintf(stderr, "%s\n%s\n%s\n", 708 "usage: mount [-dfpruvw] [-o options] [-t ufs | external_type] special node", 709 " mount [-adfpruvw] [ -F fstab] [-o options] [-t ufs | external_type]", 710 " mount [-dfpruvw] special | node"); 711 exit(1); 712 } 713 714 void 715 putfsent(ent) 716 const struct statfs *ent; 717 { 718 struct fstab *fst; 719 char *opts; 720 721 opts = flags2opts(ent->f_flags); 722 printf("%s\t%s\t%s %s", ent->f_mntfromname, ent->f_mntonname, 723 ent->f_fstypename, opts); 724 free(opts); 725 726 if ((fst = getfsspec(ent->f_mntfromname))) 727 printf("\t%u %u\n", fst->fs_freq, fst->fs_passno); 728 else if ((fst = getfsfile(ent->f_mntonname))) 729 printf("\t%u %u\n", fst->fs_freq, fst->fs_passno); 730 else if (strcmp(ent->f_fstypename, "ufs") == 0) { 731 if (strcmp(ent->f_mntonname, "/") == 0) 732 printf("\t1 1\n"); 733 else 734 printf("\t2 2\n"); 735 } else 736 printf("\t0 0\n"); 737 } 738 739 740 char * 741 flags2opts(flags) 742 int flags; 743 { 744 char *res; 745 746 res = NULL; 747 748 res = catopt(res, (flags & MNT_RDONLY) ? "ro" : "rw"); 749 750 if (flags & MNT_SYNCHRONOUS) res = catopt(res, "sync"); 751 if (flags & MNT_NOEXEC) res = catopt(res, "noexec"); 752 if (flags & MNT_NOSUID) res = catopt(res, "nosuid"); 753 if (flags & MNT_NODEV) res = catopt(res, "nodev"); 754 if (flags & MNT_UNION) res = catopt(res, "union"); 755 if (flags & MNT_ASYNC) res = catopt(res, "async"); 756 if (flags & MNT_NOATIME) res = catopt(res, "noatime"); 757 if (flags & MNT_NOCLUSTERR) res = catopt(res, "noclusterr"); 758 if (flags & MNT_NOCLUSTERW) res = catopt(res, "noclusterw"); 759 if (flags & MNT_NOSYMFOLLOW) res = catopt(res, "nosymfollow"); 760 if (flags & MNT_SUIDDIR) res = catopt(res, "suiddir"); 761 if (flags & MNT_MULTILABEL) res = catopt(res, "multilabel"); 762 if (flags & MNT_ACLS) res = catopt(res, "acls"); 763 764 return res; 765 } 766