Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 98403 | Differences between
and this patch

Collapse All | Expand All

(-)util-linux-2.12q/mount/fstab.c (-92 / +150 lines)
Lines 1-7 Link Here
1
/* 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL>
1
/*
2
 * 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL>
2
 * - added Native Language Support
3
 * - added Native Language Support
3
 * Sun Mar 21 1999 - Arnaldo Carvalho de Melo <acme@conectiva.com.br>
4
 * 1999-03-21 Arnaldo Carvalho de Melo <acme@conectiva.com.br>
4
 * - fixed strerr(errno) in gettext calls
5
 * - fixed strerr(errno) in gettext calls
6
 * 2003-08-08 Thomas Hood <jdthood@yahoo.co.uk>
7
 * - Write through a symlink at /etc/mtab if it doesn't point into /proc/
5
 */
8
 */
6
9
7
#include <unistd.h>
10
#include <unistd.h>
Lines 11-77 Link Here
11
#include <sys/stat.h>
14
#include <sys/stat.h>
12
#include "mntent.h"
15
#include "mntent.h"
13
#include "fstab.h"
16
#include "fstab.h"
17
#include "realpath.h"
14
#include "sundries.h"
18
#include "sundries.h"
15
#include "xmalloc.h"
19
#include "xmalloc.h"
16
#include "mount_blkid.h"
20
#include "mount_blkid.h"
17
#include "paths.h"
21
#include "paths.h"
18
#include "nls.h"
22
#include "nls.h"
19
23
20
#define streq(s, t)	(strcmp ((s), (t)) == 0)
21
22
#define PROC_MOUNTS		"/proc/mounts"
23
24
25
/* Information about mtab. ------------------------------------*/
24
/* Information about mtab. ------------------------------------*/
26
static int have_mtab_info = 0;
25
/* A 64 bit number can be displayed in 20 decimal digits */
27
static int var_mtab_does_not_exist = 0;
26
#define LEN_LARGEST_PID 20
28
static int var_mtab_is_a_symlink = 0;
27
#define MTAB_PATH_MAX (PATH_MAX - (sizeof(MTAB_LOCK_SUFFIX) - 1) - LEN_LARGEST_PID)
28
static char mtab_path[MTAB_PATH_MAX];
29
static char mtab_lock_path[PATH_MAX];
30
static char mtab_lock_targ[PATH_MAX];
31
static char mtab_temp_path[PATH_MAX];
29
32
30
static void
33
/*
34
 * Set mtab_path to the real path of the mtab file
35
 * or to the null string if that path is inaccessible
36
 *
37
 * Run this early
38
 */
39
void
31
get_mtab_info(void) {
40
get_mtab_info(void) {
32
	struct stat mtab_stat;
41
	struct stat mtab_stat;
33
42
34
	if (!have_mtab_info) {
43
	if (lstat(MOUNTED, &mtab_stat)) {
35
		if (lstat(MOUNTED, &mtab_stat))
44
		/* Assume that the lstat error means that the file does not exist */
36
			var_mtab_does_not_exist = 1;
45
		/* (Maybe we should check errno here) */
37
		else if (S_ISLNK(mtab_stat.st_mode))
46
		strcpy(mtab_path, MOUNTED);
38
			var_mtab_is_a_symlink = 1;
47
	} else if (S_ISLNK(mtab_stat.st_mode)) {
39
		have_mtab_info = 1;
48
		/* Is a symlink */
49
		int len;
50
		char *r = myrealpath(MOUNTED, mtab_path, MTAB_PATH_MAX);
51
		mtab_path[MTAB_PATH_MAX - 1] = 0; /* Just to be sure */
52
		len = strlen(mtab_path);
53
		if (
54
			r == NULL
55
			|| len == 0
56
			|| len >= (MTAB_PATH_MAX - 1)
57
			|| streqn(mtab_path, PATH_PROC, sizeof(PATH_PROC) - 1)
58
		) {
59
			/* Real path invalid or inaccessible */
60
			mtab_path[0] = '\0';
61
			return;
62
		}
63
		/* mtab_path now contains mtab's real path */
64
	} else {
65
		/* Exists and is not a symlink */
66
		strcpy(mtab_path, MOUNTED);
40
	}
67
	}
68
69
	sprintf(mtab_lock_path, "%s%s", mtab_path, MTAB_LOCK_SUFFIX);
70
	sprintf(mtab_lock_targ, "%s%s%d", mtab_path, MTAB_LOCK_SUFFIX, getpid());
71
	sprintf(mtab_temp_path, "%s%s", mtab_path, MTAB_TEMP_SUFFIX);
72
73
	return;
41
}
74
}
42
75
43
int
76
/*
44
mtab_does_not_exist(void) {
77
 * Tell whether or not the mtab real path is accessible
45
	get_mtab_info();
78
 *
46
	return var_mtab_does_not_exist;
79
 * get_mtab_info() must have been run
80
 */
81
static int
82
mtab_is_accessible(void) {
83
	return (mtab_path[0] != '\0');
47
}
84
}
48
85
86
/*
87
 * Tell whether or not the mtab file currently exists
88
 *
89
 * Note that the answer here is independent of whether or
90
 * not the file is writable, so if you are planning to create
91
 * the mtab file then check mtab_is_writable() too.
92
 *
93
 * get_mtab_info() must have been run
94
 */
49
int
95
int
50
mtab_is_a_symlink(void) {
96
mtab_does_not_exist(void) {
51
	get_mtab_info();
97
	struct stat mtab_stat;
52
	return var_mtab_is_a_symlink;
98
99
	if (!mtab_is_accessible())
100
		return 1;
101
102
	if (lstat(mtab_path, &mtab_stat))
103
		return 1;
104
105
	return 0;
53
}
106
}
54
107
108
/*
109
 * Tell whether or not mtab is writable (whether or not it currently exists)
110
 *
111
 * This depends on whether or not the real path is accessible and,
112
 * if so, whether or not the file can be opened.  This function
113
 * has the side effect of creating the file if it is writable.
114
 *
115
 * get_mtab_info() must have been run
116
 */
55
int
117
int
56
mtab_is_writable() {
118
mtab_is_writable() {
57
	static int ret = -1;
119
	static int is_writable = -1;
120
	int fd;
121
122
	if (is_writable != -1)
123
		return is_writable;
58
124
59
	/* Should we write to /etc/mtab upon an update?
125
	if (!mtab_is_accessible()) {
60
	   Probably not if it is a symlink to /proc/mounts, since that
126
		is_writable = 0;
61
	   would create a file /proc/mounts in case the proc filesystem
127
		return is_writable;
62
	   is not mounted. */
63
	if (mtab_is_a_symlink())
64
		return 0;
65
66
	if (ret == -1) {
67
		int fd = open(MOUNTED, O_RDWR | O_CREAT, 0644);
68
		if (fd >= 0) {
69
			close(fd);
70
			ret = 1;
71
		} else
72
			ret = 0;
73
	}
128
	}
74
	return ret;
129
130
	lock_mtab();
131
	fd = open(mtab_path, O_RDWR | O_CREAT, 0644);
132
	if (fd >= 0) {
133
		close(fd);
134
		is_writable = 1;
135
	} else {
136
		is_writable = 0;
137
	}
138
	unlock_mtab();
139
	return is_writable;
75
}
140
}
76
141
77
/* Contents of mtab and fstab ---------------------------------*/
142
/* Contents of mtab and fstab ---------------------------------*/
Lines 154-174 Link Here
154
	got_mtab = 1;
219
	got_mtab = 1;
155
	mc->nxt = mc->prev = NULL;
220
	mc->nxt = mc->prev = NULL;
156
221
157
	fnam = MOUNTED;
222
	fnam = mtab_path;
158
	mfp = my_setmntent (fnam, "r");
223
	mfp = my_setmntent (fnam, "r");
159
	if (mfp == NULL || mfp->mntent_fp == NULL) {
224
	if (mfp == NULL || mfp->mntent_fp == NULL) {
160
		int errsv = errno;
225
		int errsv = errno;
161
		fnam = PROC_MOUNTS;
226
		fnam = PATH_PROC_MOUNTS;
162
		mfp = my_setmntent (fnam, "r");
227
		mfp = my_setmntent (fnam, "r");
163
		if (mfp == NULL || mfp->mntent_fp == NULL) {
228
		if (mfp == NULL || mfp->mntent_fp == NULL) {
164
			error(_("warning: can't open %s: %s"),
229
			error(_("warning: can't open %s: %s"),
165
			      MOUNTED, strerror (errsv));
230
			      mtab_path, strerror (errsv));
166
			return;
231
			return;
167
		}
232
		}
168
		if (verbose)
233
		if (verbose)
169
			printf (_("mount: could not open %s - "
234
			printf (_("mount: could not open %s - "
170
				  "using %s instead\n"),
235
				  "using %s instead\n"),
171
				MOUNTED, PROC_MOUNTS);
236
				mtab_path, PATH_PROC_MOUNTS);
172
	}
237
	}
173
	read_mntentchn(mfp, fnam, mc);
238
	read_mntentchn(mfp, fnam, mc);
174
}
239
}
Lines 396-404 Link Here
396
/* Flag for already existing lock file. */
461
/* Flag for already existing lock file. */
397
static int we_created_lockfile = 0;
462
static int we_created_lockfile = 0;
398
463
399
/* Flag to indicate that signals have been set up. */
400
static int signals_have_been_setup = 0;
401
402
/* Ensure that the lock is released if we are interrupted.  */
464
/* Ensure that the lock is released if we are interrupted.  */
403
extern char *strsignal(int sig);	/* not always in <string.h> */
465
extern char *strsignal(int sig);	/* not always in <string.h> */
404
466
Lines 416-450 Link Here
416
void
478
void
417
unlock_mtab (void) {
479
unlock_mtab (void) {
418
	if (we_created_lockfile) {
480
	if (we_created_lockfile) {
419
		unlink (MOUNTED_LOCK);
481
		unlink (mtab_lock_path);
420
		we_created_lockfile = 0;
482
		we_created_lockfile = 0;
421
	}
483
	}
422
}
484
}
423
485
424
/* Create the lock file.
486
/*
425
   The lock file will be removed if we catch a signal or when we exit. */
487
 * Create the lock file
488
 *
489
 * The lock file will be removed if we catch a signal or when we exit
490
 */
426
/* The old code here used flock on a lock file /etc/mtab~ and deleted
491
/* The old code here used flock on a lock file /etc/mtab~ and deleted
427
   this lock file afterwards. However, as rgooch remarks, that has a
492
   this lock file afterwards. However, as rgooch remarks, that races:
428
   race: a second mount may be waiting on the lock and proceed as
493
   a second mount may be waiting on the lock which will proceed as
429
   soon as the lock file is deleted by the first mount, and immediately
494
   soon as the lock file is deleted by the first mount; immediately
430
   afterwards a third mount comes, creates a new /etc/mtab~, applies
495
   afterwards a third mount can come, create a new /etc/mtab~, apply
431
   flock to that, and also proceeds, so that the second and third mount
496
   flock to that, and also proceed, so that the second and third mount
432
   now both are scribbling in /etc/mtab.
497
   now both scribble in /etc/mtab.
433
   The new code uses a link() instead of a creat(), where we proceed
498
   The new code uses a link() instead of a creat(), where we proceed
434
   only if it was us that created the lock, and hence we always have
499
   only if it was we that created the lock, and hence we always have
435
   to delete the lock afterwards. Now the use of flock() is in principle
500
   to delete the lock afterwards. Now the use of flock() is in principle
436
   superfluous, but avoids an arbitrary sleep(). */
501
   superfluous, but using it allows us to avoid an arbitrary sleep(). */
437
438
/* Where does the link point to? Obvious choices are mtab and mtab~~.
439
   HJLu points out that the latter leads to races. Right now we use
440
   mtab~.<pid> instead. Use 20 as upper bound for the length of %d. */
441
#define MOUNTLOCK_LINKTARGET		MOUNTED_LOCK "%d"
442
#define MOUNTLOCK_LINKTARGET_LTH	(sizeof(MOUNTED_LOCK)+20)
443
502
444
void
503
void
445
lock_mtab (void) {
504
lock_mtab (void) {
446
	int tries = 3;
505
	int tries = 3;
447
	char linktargetfile[MOUNTLOCK_LINKTARGET_LTH];
506
	/* Flag to indicate that signals have been set up. */
507
	static int signals_have_been_setup = 0;
448
508
449
	at_die = unlock_mtab;
509
	at_die = unlock_mtab;
450
510
Lines 467-496 Link Here
467
		signals_have_been_setup = 1;
527
		signals_have_been_setup = 1;
468
	}
528
	}
469
529
470
	sprintf(linktargetfile, MOUNTLOCK_LINKTARGET, getpid ());
471
472
	/* Repeat until it was us who made the link */
530
	/* Repeat until it was us who made the link */
473
	while (!we_created_lockfile) {
531
	while (!we_created_lockfile) {
474
		struct flock flock;
532
		struct flock flock;
475
		int errsv, fd, i, j;
533
		int errsv, fd, i, j;
476
534
477
		i = open (linktargetfile, O_WRONLY|O_CREAT, 0);
535
		i = open (mtab_lock_targ, O_WRONLY|O_CREAT, 0);
478
		if (i < 0) {
536
		if (i < 0) {
479
			int errsv = errno;
537
			int errsv = errno;
480
			/* linktargetfile does not exist (as a file)
538
			/* mtab_lock_targ does not exist (as a file)
481
			   and we cannot create it. Read-only filesystem?
539
			   and we cannot create it. Read-only filesystem?
482
			   Too many files open in the system?
540
			   Too many files open in the system?
483
			   Filesystem full? */
541
			   Filesystem full? */
484
			die (EX_FILEIO, _("can't create lock file %s: %s "
542
			die (EX_FILEIO, _("can't create lock file %s: %s "
485
			     "(use -n flag to override)"),
543
			     "(use -n flag to override)"),
486
			     linktargetfile, strerror (errsv));
544
			     mtab_lock_targ, strerror (errsv));
487
		}
545
		}
488
		close(i);
546
		close(i);
489
547
490
		j = link(linktargetfile, MOUNTED_LOCK);
548
		j = link(mtab_lock_targ, mtab_lock_path);
491
		errsv = errno;
549
		errsv = errno;
492
550
493
		(void) unlink(linktargetfile);
551
		(void) unlink(mtab_lock_targ);
494
552
495
		if (j == 0)
553
		if (j == 0)
496
			we_created_lockfile = 1;
554
			we_created_lockfile = 1;
Lines 498-507 Link Here
498
		if (j < 0 && errsv != EEXIST) {
556
		if (j < 0 && errsv != EEXIST) {
499
			die (EX_FILEIO, _("can't link lock file %s: %s "
557
			die (EX_FILEIO, _("can't link lock file %s: %s "
500
			     "(use -n flag to override)"),
558
			     "(use -n flag to override)"),
501
			     MOUNTED_LOCK, strerror (errsv));
559
			     mtab_lock_path, strerror (errsv));
502
		}
560
		}
503
561
504
		fd = open (MOUNTED_LOCK, O_WRONLY);
562
		fd = open (mtab_lock_path, O_WRONLY);
505
563
506
		if (fd < 0) {
564
		if (fd < 0) {
507
			int errsv = errno;
565
			int errsv = errno;
Lines 510-516 Link Here
510
				continue;
568
				continue;
511
			die (EX_FILEIO, _("can't open lock file %s: %s "
569
			die (EX_FILEIO, _("can't open lock file %s: %s "
512
			     "(use -n flag to override)"),
570
			     "(use -n flag to override)"),
513
			     MOUNTED_LOCK, strerror (errsv));
571
			     mtab_lock_path, strerror (errsv));
514
		}
572
		}
515
573
516
		flock.l_type = F_WRLCK;
574
		flock.l_type = F_WRLCK;
Lines 524-530 Link Here
524
				if (verbose) {
582
				if (verbose) {
525
				    int errsv = errno;
583
				    int errsv = errno;
526
				    printf(_("Can't lock lock file %s: %s\n"),
584
				    printf(_("Can't lock lock file %s: %s\n"),
527
					   MOUNTED_LOCK, strerror (errsv));
585
					   mtab_lock_path, strerror (errsv));
528
				}
586
				}
529
				/* proceed anyway */
587
				/* proceed anyway */
530
			}
588
			}
Lines 536-552 Link Here
536
			if (fcntl (fd, F_SETLKW, &flock) == -1) {
594
			if (fcntl (fd, F_SETLKW, &flock) == -1) {
537
				int errsv = errno;
595
				int errsv = errno;
538
				die (EX_FILEIO, _("can't lock lock file %s: %s"),
596
				die (EX_FILEIO, _("can't lock lock file %s: %s"),
539
				     MOUNTED_LOCK, (errno == EINTR) ?
597
				     mtab_lock_path, (errno == EINTR) ?
540
				     _("timed out") : strerror (errsv));
598
				     _("timed out") : strerror (errsv));
541
			}
599
			}
542
			alarm(0);
600
			alarm(0);
543
			/* Limit the number of iterations - maybe there
601
			/* Limit the number of iterations - maybe there
544
			   still is some old /etc/mtab~ */
602
			   still is some old lock */
545
			if (tries++ > 3) {
603
			if (tries++ > 3) {
546
				if (tries > 5)
604
				if (tries > 5)
547
					die (EX_FILEIO, _("Cannot create link %s\n"
605
					die (EX_FILEIO, _("Cannot create link %s\n"
548
					    "Perhaps there is a stale lock file?\n"),
606
					    "Perhaps there is a stale lock file?\n"),
549
					     MOUNTED_LOCK);
607
					     mtab_lock_path);
550
				sleep(1);
608
				sleep(1);
551
			}
609
			}
552
		}
610
		}
Lines 568-583 Link Here
568
void
626
void
569
update_mtab (const char *dir, struct my_mntent *instead) {
627
update_mtab (const char *dir, struct my_mntent *instead) {
570
	mntFILE *mfp, *mftmp;
628
	mntFILE *mfp, *mftmp;
571
	const char *fnam = MOUNTED;
629
	const char *fnam = mtab_path;
572
	struct mntentchn mtabhead;	/* dummy */
630
	struct mntentchn mtabhead;	/* dummy */
573
	struct mntentchn *mc, *mc0, *absent = NULL;
631
	struct mntentchn *mc, *mc0, *absent = NULL;
574
632
575
	if (mtab_does_not_exist() || mtab_is_a_symlink())
633
	if (mtab_does_not_exist())
576
		return;
634
		return;
577
635
578
	lock_mtab();
636
	lock_mtab();
579
637
580
	/* having locked mtab, read it again */
638
	/* Having got the lock, we read mtab again */
581
	mc0 = mc = &mtabhead;
639
	mc0 = mc = &mtabhead;
582
	mc->nxt = mc->prev = NULL;
640
	mc->nxt = mc->prev = NULL;
583
641
Lines 619-629 Link Here
619
	}
677
	}
620
678
621
	/* write chain to mtemp */
679
	/* write chain to mtemp */
622
	mftmp = my_setmntent (MOUNTED_TEMP, "w");
680
	mftmp = my_setmntent (mtab_temp_path, "w");
623
	if (mftmp == NULL || mftmp->mntent_fp == NULL) {
681
	if (mftmp == NULL || mftmp->mntent_fp == NULL) {
624
		int errsv = errno;
682
		int errsv = errno;
625
		error (_("cannot open %s (%s) - mtab not updated"),
683
		error (_("cannot open %s (%s) - mtab not updated"),
626
		       MOUNTED_TEMP, strerror (errsv));
684
		       mtab_temp_path, strerror (errsv));
627
		goto leave;
685
		goto leave;
628
	}
686
	}
629
687
Lines 631-637 Link Here
631
		if (my_addmntent(mftmp, &(mc->m)) == 1) {
689
		if (my_addmntent(mftmp, &(mc->m)) == 1) {
632
			int errsv = errno;
690
			int errsv = errno;
633
			die (EX_FILEIO, _("error writing %s: %s"),
691
			die (EX_FILEIO, _("error writing %s: %s"),
634
			     MOUNTED_TEMP, strerror (errsv));
692
			     mtab_temp_path, strerror (errsv));
635
		}
693
		}
636
	}
694
	}
637
695
Lines 641-665 Link Here
641
		    S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) < 0) {
699
		    S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) < 0) {
642
		int errsv = errno;
700
		int errsv = errno;
643
		fprintf(stderr, _("error changing mode of %s: %s\n"),
701
		fprintf(stderr, _("error changing mode of %s: %s\n"),
644
			MOUNTED_TEMP, strerror (errsv));
702
			mtab_temp_path, strerror (errsv));
645
	}
703
	}
646
	my_endmntent (mftmp);
704
	my_endmntent (mftmp);
647
705
648
	{ /*
706
	{ /*
649
	   * If mount is setuid and some non-root user mounts sth,
707
	   * If mount is setuid and some non-root user mounts sth,
650
	   * then mtab.tmp might get the group of this user. Copy uid/gid
708
	   * then the temp file might get the group of this user.
651
	   * from the present mtab before renaming.
709
	   * Copy uid/gid from the present mtab before renaming.
652
	   */
710
	   */
653
	    struct stat sbuf;
711
	    struct stat sbuf;
654
	    if (stat (MOUNTED, &sbuf) == 0)
712
	    if (stat (mtab_path, &sbuf) == 0)
655
		chown (MOUNTED_TEMP, sbuf.st_uid, sbuf.st_gid);
713
		chown (mtab_temp_path, sbuf.st_uid, sbuf.st_gid);
656
	}
714
	}
657
715
658
	/* rename mtemp to mtab */
716
	/* rename mtemp to mtab */
659
	if (rename (MOUNTED_TEMP, MOUNTED) < 0) {
717
	if (rename (mtab_temp_path, mtab_path) < 0) {
660
		int errsv = errno;
718
		int errsv = errno;
661
		fprintf(stderr, _("can't rename %s to %s: %s\n"),
719
		fprintf(stderr, _("can't rename %s to %s: %s\n"),
662
			MOUNTED_TEMP, MOUNTED, strerror(errsv));
720
			mtab_temp_path, mtab_path, strerror(errsv));
663
	}
721
	}
664
722
665
 leave:
723
 leave:
(-)util-linux-2.12q/mount/fstab.h (-1 / +5 lines)
Lines 22-27 Link Here
22
struct mntentchn *getfsuuidspec (const char *uuid);
22
struct mntentchn *getfsuuidspec (const char *uuid);
23
struct mntentchn *getfsvolspec (const char *label);
23
struct mntentchn *getfsvolspec (const char *label);
24
24
25
void get_mtab_info (void);
26
int mtab_is_writable(void);
27
int mtab_does_not_exist(void);
28
int is_mounted_once(const char *name);
25
void lock_mtab (void);
29
void lock_mtab (void);
26
void unlock_mtab (void);
30
void unlock_mtab (void);
27
void update_mtab (const char *special, struct my_mntent *with);
31
void update_mtab (const char *dir, struct my_mntent *instead);
(-)util-linux-2.12q/mount/mount.8 (-64 / +89 lines)
Lines 38-43 Link Here
38
.\" 010714, Michael K. Johnson <johnsonm@redhat.com> added -O
38
.\" 010714, Michael K. Johnson <johnsonm@redhat.com> added -O
39
.\" 010725, Nikita Danilov <NikitaDanilov@Yahoo.COM>: reiserfs options
39
.\" 010725, Nikita Danilov <NikitaDanilov@Yahoo.COM>: reiserfs options
40
.\" 011124, Karl Eichwalder <ke@gnu.franken.de>: tmpfs options
40
.\" 011124, Karl Eichwalder <ke@gnu.franken.de>: tmpfs options
41
.\" 030808, Thomas Hood <jdthood@yahoo.co.uk>: symlinking /etc/mtab
42
.\" 030809, Thomas Hood <jdthood@yahoo.co.uk>: use 'file system' consistently
41
.\"
43
.\"
42
.TH MOUNT 8 "2004-12-16" "Linux 2.6" "Linux Programmer's Manual"
44
.TH MOUNT 8 "2004-12-16" "Linux 2.6" "Linux Programmer's Manual"
43
.SH NAME
45
.SH NAME
Lines 111-117 Link Here
111
After this call the same contents is accessible in two places.
113
After this call the same contents is accessible in two places.
112
One can also remount a single file (on a single file).
114
One can also remount a single file (on a single file).
113
115
114
This call attaches only (part of) a single filesystem, not possible
116
This call attaches only (part of) a single file system, not possible
115
submounts. The entire file hierarchy including submounts is attached
117
submounts. The entire file hierarchy including submounts is attached
116
a second place using
118
a second place using
117
.RS
119
.RS
Lines 120-126 Link Here
120
.RE
122
.RE
121
.\" available since Linux 2.4.11.
123
.\" available since Linux 2.4.11.
122
124
123
Note that the filesystem mount options will remain the same as those
125
Note that the file system mount options will remain the same as those
124
on the original mount point, and cannot be changed by passing the -o
126
on the original mount point, and cannot be changed by passing the -o
125
option along with --bind/--rbind.
127
option along with --bind/--rbind.
126
128
Lines 172-178 Link Here
172
keyword. Adding the
174
keyword. Adding the
173
.B \-F
175
.B \-F
174
option will make mount fork, so that the
176
option will make mount fork, so that the
175
filesystems are mounted simultaneously.
177
file systems are mounted simultaneously.
176
.LP
178
.LP
177
(ii) When mounting a file system mentioned in
179
(ii) When mounting a file system mentioned in
178
.IR fstab ,
180
.IR fstab ,
Lines 203-209 Link Here
203
.RE
205
.RE
204
For more details, see
206
For more details, see
205
.BR fstab (5).
207
.BR fstab (5).
206
Only the user that mounted a filesystem can unmount it again.
208
Only the user that mounted a file system can unmount it again.
207
If any user should be able to unmount, then use
209
If any user should be able to unmount, then use
208
.B users
210
.B users
209
instead of
211
instead of
Lines 236-260 Link Here
236
238
237
When the
239
When the
238
.I proc
240
.I proc
239
filesystem is mounted (say at
241
file system is mounted (say at
240
.IR /proc ),
242
.IR /proc ),
241
the files
243
the files
242
.I /etc/mtab
244
.I /etc/mtab
243
and
245
and
244
.I /proc/mounts
246
.I /proc/mounts
245
have very similar contents. The former has somewhat
247
have very similar contents. The former contains somewhat
246
more information, such as the mount options used,
248
more information, such as the mount options used,
247
but is not necessarily up-to-date (cf. the
249
but is not necessarily completely accurate (cf. the
248
.B \-n
250
.B \-n
249
option below). It is possible to replace
251
and
252
.B \-f
253
options below). It is possible to replace
250
.I /etc/mtab
254
.I /etc/mtab
251
by a symbolic link to
255
by a symbolic link to
252
.IR /proc/mounts ,
256
.IR /proc/mounts ,
253
and especially when you have very large numbers of mounts
257
and especially when you have very large numbers of mounts
254
things will be much faster with that symlink,
258
things will be much faster with that symlink,
255
but some information is lost that way, and in particular
259
but some information is lost that way.  As a result,
256
working with the loop device will be less convenient,
260
working with the loop device is less convenient
257
and using the "user" option will fail.
261
and the "user" option does not work.
262
263
You can also replace
264
.I /etc/mtab
265
by a symbolic link to
266
another location such as
267
.IR /var/run/mtab .
268
This may be useful if your root file system is mounted read-only
269
but you have another file system such as
270
.I /var
271
that is writable where you can store the mtab.
272
Note that in this case you will have to mount
273
.I /var
274
first using the
275
.B \-n
276
option.  Once the target of the
277
.I /etc/mtab
278
symbolic link is writable you can run
279
.B mount
280
again with the
281
.B \-f
282
option to add the missing entry.
258
283
259
.SH OPTIONS
284
.SH OPTIONS
260
The full set of options used by an invocation of
285
The full set of options used by an invocation of
Lines 282-288 Link Here
282
Verbose mode.
307
Verbose mode.
283
.TP
308
.TP
284
.B \-a
309
.B \-a
285
Mount all filesystems (of the given types) mentioned in
310
Mount all file systems (of the given types) mentioned in
286
.IR fstab .
311
.IR fstab .
287
.TP
312
.TP
288
.B \-F
313
.B \-F
Lines 336-342 Link Here
336
.TP
361
.TP
337
.B \-s
362
.B \-s
338
Tolerate sloppy mount options rather than failing. This will ignore
363
Tolerate sloppy mount options rather than failing. This will ignore
339
mount options not supported by a filesystem type. Not all filesystems
364
mount options not supported by a file system type. Not all file systems
340
support this option. This option exists for support of the Linux
365
support this option. This option exists for support of the Linux
341
autofs\-based automounter.
366
autofs\-based automounter.
342
.TP
367
.TP
Lines 419-425 Link Here
419
.B mount
444
.B mount
420
program has to do is issue a simple
445
program has to do is issue a simple
421
.IR mount (2)
446
.IR mount (2)
422
system call, and no detailed knowledge of the filesystem type is required.
447
system call, and no detailed knowledge of the file system type is required.
423
For a few types however (like nfs, smbfs, ncpfs) ad hoc code is
448
For a few types however (like nfs, smbfs, ncpfs) ad hoc code is
424
necessary. The nfs ad hoc code is built in, but smbfs and ncpfs
449
necessary. The nfs ad hoc code is built in, but smbfs and ncpfs
425
have a separate mount program. In order to make it possible to
450
have a separate mount program. In order to make it possible to
Lines 445-451 Link Here
445
.IR /etc/filesystems ,
470
.IR /etc/filesystems ,
446
or, if that does not exist,
471
or, if that does not exist,
447
.IR /proc/filesystems .
472
.IR /proc/filesystems .
448
All of the filesystem types listed there will be tried,
473
All of the file system types listed there will be tried,
449
except for those that are labeled "nodev" (e.g.,
474
except for those that are labeled "nodev" (e.g.,
450
.IR devpts ,
475
.IR devpts ,
451
.I proc
476
.I proc
Lines 465-471 Link Here
465
can be useful to change the probe order (e.g., to try vfat before msdos
490
can be useful to change the probe order (e.g., to try vfat before msdos
466
or ext3 before ext2) or if you use a kernel module autoloader.
491
or ext3 before ext2) or if you use a kernel module autoloader.
467
Warning: the probing uses a heuristic (the presence of appropriate `magic'),
492
Warning: the probing uses a heuristic (the presence of appropriate `magic'),
468
and could recognize the wrong filesystem type, possibly with catastrophic
493
and could recognize the wrong file system type, possibly with catastrophic
469
consequences. If your data is valuable, don't ask
494
consequences. If your data is valuable, don't ask
470
.B mount
495
.B mount
471
to guess.
496
to guess.
Lines 492-498 Link Here
492
.B \-O
517
.B \-O
493
Used in conjunction with
518
Used in conjunction with
494
.BR \-a ,
519
.BR \-a ,
495
to limit the set of filesystems to which the
520
to limit the set of file systems to which the
496
.B \-a
521
.B \-a
497
is applied.  Like
522
is applied.  Like
498
.B \-t
523
.B \-t
Lines 523-529 Link Here
523
.RS
548
.RS
524
.B "mount \-a \-t ext2 \-O _netdev"
549
.B "mount \-a \-t ext2 \-O _netdev"
525
.RE
550
.RE
526
mounts all ext2 filesystems with the _netdev option, not all filesystems
551
mounts all ext2 file systems with the _netdev option, not all file systems
527
that are either ext2 or have the _netdev option specified.
552
that are either ext2 or have the _netdev option specified.
528
.RE
553
.RE
529
.TP
554
.TP
Lines 569-580 Link Here
569
.BR group,dev,suid ).
594
.BR group,dev,suid ).
570
.TP
595
.TP
571
.B mand
596
.B mand
572
Allow mandatory locks on this filesystem. See
597
Allow mandatory locks on this file system. See
573
.BR fcntl (2).
598
.BR fcntl (2).
574
.TP
599
.TP
575
.B _netdev
600
.B _netdev
576
The filesystem resides on a device that requires network access
601
The file system resides on a device that requires network access
577
(used to prevent the system from attempting to mount these filesystems
602
(used to prevent the system from attempting to mount these file systems
578
until the network has been enabled on the system).
603
until the network has been enabled on the system).
579
.TP
604
.TP
580
.B noatime
605
.B noatime
Lines 596-602 Link Here
596
/lib/ld*.so /mnt/binary. This trick fails since Linux 2.4.25 / 2.6.0.)
621
/lib/ld*.so /mnt/binary. This trick fails since Linux 2.4.25 / 2.6.0.)
597
.TP
622
.TP
598
.B nomand
623
.B nomand
599
Do not allow mandatory locks on this filesystem.
624
Do not allow mandatory locks on this file system.
600
.TP
625
.TP
601
.B nosuid
626
.B nosuid
602
Do not allow set-user-identifier or set-group-identifier bits to take
627
Do not allow set-user-identifier or set-group-identifier bits to take
Lines 772-778 Link Here
772
.\" Due to a kernel bug, it may be mounted with random mount options
797
.\" Due to a kernel bug, it may be mounted with random mount options
773
.\" (fixed in Linux 2.0.4).
798
.\" (fixed in Linux 2.0.4).
774
Since Linux 2.5.46, for most mount options the default
799
Since Linux 2.5.46, for most mount options the default
775
is determined by the filesystem superblock. Set them with
800
is determined by the file system superblock. Set them with
776
.BR tune2fs (8).
801
.BR tune2fs (8).
777
.TP
802
.TP
778
.BR acl " / " noacl
803
.BR acl " / " noacl
Lines 817-823 Link Here
817
.\" Since 2.3.99-pre3 but before 2.6.0-test7 every string check=foo
842
.\" Since 2.3.99-pre3 but before 2.6.0-test7 every string check=foo
818
.\" was equivalent to just check. Since 2.6.0-test7 only check is accepted.
843
.\" was equivalent to just check. Since 2.6.0-test7 only check is accepted.
819
.BR check
844
.BR check
820
Check filesystem (block and inode bitmaps) at mount time.
845
Check file system (block and inode bitmaps) at mount time.
821
.\" requires CONFIG_EXT2_CHECK
846
.\" requires CONFIG_EXT2_CHECK
822
.TP
847
.TP
823
.BR check=none " / " nocheck
848
.BR check=none " / " nocheck
Lines 833-839 Link Here
833
Define the behaviour when an error is encountered.
858
Define the behaviour when an error is encountered.
834
(Either ignore errors and just mark the file system erroneous and continue,
859
(Either ignore errors and just mark the file system erroneous and continue,
835
or remount the file system read-only, or panic and halt the system.)
860
or remount the file system read-only, or panic and halt the system.)
836
The default is set in the filesystem superblock, and can be
861
The default is set in the file system superblock, and can be
837
changed using
862
changed using
838
.BR tune2fs (8).
863
.BR tune2fs (8).
839
.TP
864
.TP
Lines 872-889 Link Here
872
.BI sb= n
897
.BI sb= n
873
Instead of block 1, use block
898
Instead of block 1, use block
874
.I n
899
.I n
875
as superblock. This could be useful when the filesystem has been damaged.
900
as superblock. This could be useful when the file system has been damaged.
876
(Earlier, copies of the superblock would be made every 8192 blocks: in
901
(Earlier, copies of the superblock would be made every 8192 blocks: in
877
block 1, 8193, 16385, ... (and one got thousands of copies on
902
block 1, 8193, 16385, ... (and one got thousands of copies on
878
a big filesystem). Since version 1.08,
903
a big file system). Since version 1.08,
879
.B mke2fs
904
.B mke2fs
880
has a \-s (sparse superblock) option to reduce the number of backup
905
has a \-s (sparse superblock) option to reduce the number of backup
881
superblocks, and since version 1.15 this is the default. Note
906
superblocks, and since version 1.15 this is the default. Note
882
that this may mean that ext2 filesystems created by a recent
907
that this may mean that ext2 file systems created by a recent
883
.B mke2fs
908
.B mke2fs
884
cannot be mounted r/w under Linux 2.0.*.)
909
cannot be mounted r/w under Linux 2.0.*.)
885
The block number here uses 1k units. Thus, if you want to use logical
910
The block number here uses 1k units. Thus, if you want to use logical
886
block 32768 on a filesystem with 4k blocks, use "sb=131072".
911
block 32768 on a file system with 4k blocks, use "sb=131072".
887
.TP
912
.TP
888
.BR user_xattr " / " nouser_xattr
913
.BR user_xattr " / " nouser_xattr
889
Support "user." extended attributes (or not).
914
Support "user." extended attributes (or not).
Lines 943-954 Link Here
943
.SH "Mount options for fat"
968
.SH "Mount options for fat"
944
(Note:
969
(Note:
945
.I fat
970
.I fat
946
is not a separate filesystem, but a common part of the
971
is not a separate file system, but a common part of the
947
.IR msdos ,
972
.IR msdos ,
948
.I umsdos
973
.I umsdos
949
and
974
and
950
.I vfat
975
.I vfat
951
filesystems.)
976
file systems.)
952
.TP
977
.TP
953
.BR blocksize=512 " / " blocksize=1024 " / " blocksize=2048
978
.BR blocksize=512 " / " blocksize=1024 " / " blocksize=2048
954
Set blocksize (default 512).
979
Set blocksize (default 512).
Lines 999-1005 Link Here
999
.TP
1024
.TP
1000
.BI codepage= value
1025
.BI codepage= value
1001
Sets the codepage for converting to shortname characters on FAT
1026
Sets the codepage for converting to shortname characters on FAT
1002
and VFAT filesystems. By default, codepage 437 is used.
1027
and VFAT file systems. By default, codepage 437 is used.
1003
.TP
1028
.TP
1004
.BR conv=b[inary] " / " conv=t[ext] " / " conv=a[uto]
1029
.BR conv=b[inary] " / " conv=t[ext] " / " conv=a[uto]
1005
The
1030
The
Lines 1127-1136 Link Here
1127
Do not abort mounting when certain consistency checks fail.
1152
Do not abort mounting when certain consistency checks fail.
1128
1153
1129
.SH "Mount options for iso9660"
1154
.SH "Mount options for iso9660"
1130
ISO 9660 is a standard describing a filesystem structure to be used
1155
ISO 9660 is a standard describing a file system structure to be used
1131
on CD-ROMs. (This filesystem type is also seen on some DVDs. See also the
1156
on CD-ROMs. (This file system type is also seen on some DVDs. See also the
1132
.I udf
1157
.I udf
1133
filesystem.)
1158
file system.)
1134
1159
1135
Normal
1160
Normal
1136
.I iso9660
1161
.I iso9660
Lines 1142-1148 Link Here
1142
Rock Ridge is an extension to iso9660 that provides all of these unix like
1167
Rock Ridge is an extension to iso9660 that provides all of these unix like
1143
features.  Basically there are extensions to each directory record that
1168
features.  Basically there are extensions to each directory record that
1144
supply all of the additional information, and when Rock Ridge is in use,
1169
supply all of the additional information, and when Rock Ridge is in use,
1145
the filesystem is indistinguishable from a normal UNIX file system (except
1170
the file system is indistinguishable from a normal UNIX file system (except
1146
that it is read-only, of course).
1171
that it is read-only, of course).
1147
.TP
1172
.TP
1148
.B norock
1173
.B norock
Lines 1393-1399 Link Here
1393
hard links instead of being suppressed.
1418
hard links instead of being suppressed.
1394
.TP
1419
.TP
1395
\fBuid=\fP\fIvalue\fP, \fBgid=\fP\fIvalue\fP and \fBumask=\fP\fIvalue\fP
1420
\fBuid=\fP\fIvalue\fP, \fBgid=\fP\fIvalue\fP and \fBumask=\fP\fIvalue\fP
1396
Set the file permission on the filesystem.
1421
Set the file permission on the file system.
1397
The umask value is given in octal.
1422
The umask value is given in octal.
1398
By default, the files are owned by root and not readable by somebody else.
1423
By default, the files are owned by root and not readable by somebody else.
1399
1424
Lines 1403-1414 Link Here
1403
These options are recognized, but have no effect as far as I can see.
1428
These options are recognized, but have no effect as far as I can see.
1404
1429
1405
.SH "Mount options for ramfs"
1430
.SH "Mount options for ramfs"
1406
Ramfs is a memory based filesystem. Mount it and you have it. Unmount it
1431
Ramfs is a memory based file system. Mount it and you have it. Unmount it
1407
and it is gone. Present since Linux 2.3.99pre4.
1432
and it is gone. Present since Linux 2.3.99pre4.
1408
There are no mount options.
1433
There are no mount options.
1409
1434
1410
.SH "Mount options for reiserfs"
1435
.SH "Mount options for reiserfs"
1411
Reiserfs is a journaling filesystem.
1436
Reiserfs is a journaling file system.
1412
The reiserfs mount options are more fully described at
1437
The reiserfs mount options are more fully described at
1413
.IR http://www.namesys.com/mount-options.html .
1438
.IR http://www.namesys.com/mount-options.html .
1414
.TP
1439
.TP
Lines 1517-1523 Link Here
1517
for Ki, Mi, Gi (binary kilo, mega and giga) and can be changed on remount.
1542
for Ki, Mi, Gi (binary kilo, mega and giga) and can be changed on remount.
1518
.TP
1543
.TP
1519
.BI size= nbytes
1544
.BI size= nbytes
1520
Override default maximum size of the filesystem.
1545
Override default maximum size of the file system.
1521
The size is given in bytes, and rounded down to entire pages.
1546
The size is given in bytes, and rounded down to entire pages.
1522
The default is half of the memory.
1547
The default is half of the memory.
1523
.TP
1548
.TP
Lines 1531-1537 Link Here
1531
Set initial permissions of the root directory.
1556
Set initial permissions of the root directory.
1532
1557
1533
.SH "Mount options for udf"
1558
.SH "Mount options for udf"
1534
udf is the "Universal Disk Format" filesystem defined by the Optical
1559
udf is the "Universal Disk Format" file system defined by the Optical
1535
Storage Technology Association, and is often used for DVD-ROM.
1560
Storage Technology Association, and is often used for DVD-ROM.
1536
See also
1561
See also
1537
.IR iso9660 .
1562
.IR iso9660 .
Lines 1580-1586 Link Here
1580
Override the PartitionDesc location. (unused)
1605
Override the PartitionDesc location. (unused)
1581
.TP
1606
.TP
1582
.B lastblock=
1607
.B lastblock=
1583
Set the last block of the filesystem.
1608
Set the last block of the file system.
1584
.TP
1609
.TP
1585
.B fileset=
1610
.B fileset=
1586
Override the fileset block location. (unused)
1611
Override the fileset block location. (unused)
Lines 1604-1629 Link Here
1604
(Don't forget to give the \-r option.)
1629
(Don't forget to give the \-r option.)
1605
.TP
1630
.TP
1606
.B 44bsd
1631
.B 44bsd
1607
For filesystems created by a BSD-like system (NetBSD,FreeBSD,OpenBSD).
1632
For file systems created by a BSD-like system (NetBSD,FreeBSD,OpenBSD).
1608
.TP
1633
.TP
1609
.B sun
1634
.B sun
1610
For filesystems created by SunOS or Solaris on Sparc.
1635
For file systems created by SunOS or Solaris on Sparc.
1611
.TP
1636
.TP
1612
.B sunx86
1637
.B sunx86
1613
For filesystems created by Solaris on x86.
1638
For file systems created by Solaris on x86.
1614
.TP
1639
.TP
1615
.B hp
1640
.B hp
1616
For filesystems created by HP-UX, read-only.
1641
For file systems created by HP-UX, read-only.
1617
.TP
1642
.TP
1618
.B nextstep
1643
.B nextstep
1619
For filesystems created by NeXTStep (on NeXT station) (currently read only).
1644
For file systems created by NeXTStep (on NeXT station) (currently read only).
1620
.TP
1645
.TP
1621
.B nextstep-cd
1646
.B nextstep-cd
1622
For NextStep CDROMs (block_size == 2048), read-only.
1647
For NextStep CDROMs (block_size == 2048), read-only.
1623
.TP
1648
.TP
1624
.B openstep
1649
.B openstep
1625
For filesystems created by OpenStep (currently read only).
1650
For file systems created by OpenStep (currently read only).
1626
The same filesystem type is also used by Mac OS X.
1651
The same file system type is also used by Mac OS X.
1627
.RE
1652
.RE
1628
1653
1629
.TP
1654
.TP
Lines 1661-1667 Link Here
1661
This lets you backup and restore filenames that are created with any
1686
This lets you backup and restore filenames that are created with any
1662
Unicode characters. Without this option, a '?' is used when no
1687
Unicode characters. Without this option, a '?' is used when no
1663
translation is possible. The escape character is ':' because it is
1688
translation is possible. The escape character is ':' because it is
1664
otherwise illegal on the vfat filesystem. The escape sequence
1689
otherwise illegal on the vfat file system. The escape sequence
1665
that gets used, where u is the unicode character,
1690
that gets used, where u is the unicode character,
1666
is: ':', (u & 0x3f), ((u>>6) & 0x3f), (u>>12).
1691
is: ':', (u & 0x3f), ((u>>6) & 0x3f), (u>>12).
1667
.TP
1692
.TP
Lines 1674-1681 Link Here
1674
.IR name~num.ext .
1699
.IR name~num.ext .
1675
.TP
1700
.TP
1676
.B utf8
1701
.B utf8
1677
UTF8 is the filesystem safe 8-bit encoding of Unicode that is used
1702
UTF8 is the file system safe 8-bit encoding of Unicode that is used
1678
by the console. It can be be enabled for the filesystem with this option.
1703
by the console. It can be be enabled for the file system with this option.
1679
If `uni_xlate' gets set, UTF8 gets disabled.
1704
If `uni_xlate' gets set, UTF8 gets disabled.
1680
.TP
1705
.TP
1681
.B shortname=[lower|win95|winnt|mixed]
1706
.B shortname=[lower|win95|winnt|mixed]
Lines 1743-1751 Link Here
1743
.BI logbufs= value
1768
.BI logbufs= value
1744
Set the number of in-memory log buffers.
1769
Set the number of in-memory log buffers.
1745
Valid numbers range from 2-8 inclusive.
1770
Valid numbers range from 2-8 inclusive.
1746
The default value is 8 buffers for filesystems with a blocksize of 64K,
1771
The default value is 8 buffers for file systems with a blocksize of 64K,
1747
4 buffers for filesystems with a blocksize of 32K,
1772
4 buffers for file systems with a blocksize of 32K,
1748
3 buffers for filesystems with a blocksize of 16K,
1773
3 buffers for file systems with a blocksize of 16K,
1749
and 2 buffers for all other configurations.
1774
and 2 buffers for all other configurations.
1750
Increasing the number of buffers may increase performance on
1775
Increasing the number of buffers may increase performance on
1751
some workloads at the cost of the memory used for the
1776
some workloads at the cost of the memory used for the
Lines 1759-1765 Link Here
1759
.TP
1784
.TP
1760
\fBlogdev=\fP\fIdevice\fP and \fBrtdev=\fP\fIdevice\fP
1785
\fBlogdev=\fP\fIdevice\fP and \fBrtdev=\fP\fIdevice\fP
1761
Use an external log (metadata journal) and/or real-time device.
1786
Use an external log (metadata journal) and/or real-time device.
1762
An XFS filesystem has up to three parts: a data section, a log section,
1787
An XFS file system has up to three parts: a data section, a log section,
1763
and a real-time section.
1788
and a real-time section.
1764
The real-time section is optional, and the log section can be separate
1789
The real-time section is optional, and the log section can be separate
1765
from the data section or contained within it.
1790
from the data section or contained within it.
Lines 1773-1780 Link Here
1773
Access timestamps are not updated when a file is read.
1798
Access timestamps are not updated when a file is read.
1774
.TP
1799
.TP
1775
.B norecovery
1800
.B norecovery
1776
The filesystem will be mounted without running log recovery.
1801
The file system will be mounted without running log recovery.
1777
If the filesystem was not cleanly unmounted, it is likely to
1802
If the file system was not cleanly unmounted, it is likely to
1778
be inconsistent when mounted in
1803
be inconsistent when mounted in
1779
.B norecovery
1804
.B norecovery
1780
mode.
1805
mode.
Lines 1784-1790 Link Here
1784
must be mounted read-only or the mount will fail.
1809
must be mounted read-only or the mount will fail.
1785
.TP
1810
.TP
1786
.B nouuid
1811
.B nouuid
1787
Ignore the filesystem uuid. This avoids errors for duplicate uuids.
1812
Ignore the file system uuid. This avoids errors for duplicate uuids.
1788
.TP
1813
.TP
1789
.B osyncisdsync
1814
.B osyncisdsync
1790
Make writes to files opened with the O_SYNC flag set behave
1815
Make writes to files opened with the O_SYNC flag set behave
Lines 1805-1817 Link Here
1805
volume.
1830
volume.
1806
.I value
1831
.I value
1807
must be specified in 512-byte block units.
1832
must be specified in 512-byte block units.
1808
If this option is not specified and the filesystem was made on a stripe
1833
If this option is not specified and the file system was made on a stripe
1809
volume or the stripe width or unit were specified for the RAID device at
1834
volume or the stripe width or unit were specified for the RAID device at
1810
mkfs time, then the mount system call will restore the value from the
1835
mkfs time, then the mount system call will restore the value from the
1811
superblock.
1836
superblock.
1812
For filesystems that are made directly on RAID devices, these options can be
1837
For file systems that are made directly on RAID devices, these options can be
1813
used to override the information in the superblock if the underlying disk
1838
used to override the information in the superblock if the underlying disk
1814
layout changes after the filesystem has been created.
1839
layout changes after the file system has been created.
1815
The
1840
The
1816
.B swidth
1841
.B swidth
1817
option is required if the
1842
option is required if the
Lines 1846-1852 Link Here
1846
that are really options to
1871
that are really options to
1847
.BR \%losetup (8).
1872
.BR \%losetup (8).
1848
(These options can be used in addition to those specific
1873
(These options can be used in addition to those specific
1849
to the filesystem type.)
1874
to the file system type.)
1850
1875
1851
If no explicit loop device is mentioned
1876
If no explicit loop device is mentioned
1852
(but just an option `\fB\-o loop\fP' is given), then
1877
(but just an option `\fB\-o loop\fP' is given), then
Lines 1911-1917 Link Here
1911
temporary file
1936
temporary file
1912
.TP
1937
.TP
1913
.I /etc/filesystems
1938
.I /etc/filesystems
1914
a list of filesystem types to try
1939
a list of file system types to try
1915
1940
1916
.SH "SEE ALSO"
1941
.SH "SEE ALSO"
1917
.BR mount (2),
1942
.BR mount (2),
(-)util-linux-2.12q/mount/mount.c (-2 / +9 lines)
Lines 391-397 Link Here
391
	return ret;
391
	return ret;
392
}
392
}
393
393
394
/* Create mtab with a root entry.  */
394
/*
395
 * Create mtab with a root entry.
396
 *
397
 * Caller should check that mtab is writable first
398
 */
395
static void
399
static void
396
create_mtab (void) {
400
create_mtab (void) {
397
	struct mntentchn *fstab;
401
	struct mntentchn *fstab;
Lines 1491-1496 Link Here
1491
	initproctitle(argc, argv);
1495
	initproctitle(argc, argv);
1492
#endif
1496
#endif
1493
1497
1498
	get_mtab_info();
1499
	/* Keep in mind that /etc/mtab may be a symlink */
1500
1494
	while ((c = getopt_long (argc, argv, "afFhilL:no:O:p:rsU:vVwt:",
1501
	while ((c = getopt_long (argc, argv, "afFhilL:no:O:p:rsU:vVwt:",
1495
				 longopts, NULL)) != -1) {
1502
				 longopts, NULL)) != -1) {
1496
		switch (c) {
1503
		switch (c) {
Lines 1615-1621 Link Here
1615
			die (EX_USAGE, _("mount: only root can do that"));
1622
			die (EX_USAGE, _("mount: only root can do that"));
1616
	}
1623
	}
1617
1624
1618
	if (!nomtab && mtab_does_not_exist()) {
1625
	if (!nomtab && mtab_does_not_exist() && mtab_is_writable()) {
1619
		if (verbose > 1)
1626
		if (verbose > 1)
1620
			printf(_("mount: no %s found - creating it..\n"),
1627
			printf(_("mount: no %s found - creating it..\n"),
1621
			       MOUNTED);
1628
			       MOUNTED);
(-)util-linux-2.12q/mount/paths.h (-6 / +10 lines)
Lines 1-10 Link Here
1
#include <mntent.h>
1
#include <mntent.h>
2
#define _PATH_FSTAB	"/etc/fstab"
2
#define _PATH_FSTAB		"/etc/fstab"
3
#define PATH_PROC		"/proc/"
4
#define PATH_PROC_MOUNTS	PATH_PROC "mounts"
5
#define MTAB_LOCK_SUFFIX	"~"
6
#define MTAB_TEMP_SUFFIX	".tmp"
3
#ifdef _PATH_MOUNTED
7
#ifdef _PATH_MOUNTED
4
#define MOUNTED_LOCK	_PATH_MOUNTED "~"
8
#define MOUNTED_LOCK		_PATH_MOUNTED "~"
5
#define MOUNTED_TEMP	_PATH_MOUNTED ".tmp"
9
#define MOUNTED_TEMP		_PATH_MOUNTED ".tmp"
6
#else
10
#else
7
#define MOUNTED_LOCK	"/etc/mtab~"
11
#define MOUNTED_LOCK		"/etc/mtab~"
8
#define MOUNTED_TEMP	"/etc/mtab.tmp"
12
#define MOUNTED_TEMP		"/etc/mtab.tmp"
9
#endif
13
#endif
10
#define LOCK_TIMEOUT	10
14
#define LOCK_TIMEOUT		10
(-)util-linux-2.12q/mount/sundries.h (-1 / +2 lines)
Lines 17-23 Link Here
17
extern int verbose;
17
extern int verbose;
18
extern int sloppy;
18
extern int sloppy;
19
19
20
#define streq(s, t)	(strcmp ((s), (t)) == 0)
20
#define streq(s, t)      (strcmp ((s), (t)) == 0)
21
#define streqn(s, t, n)  (strncmp((s), (t), (n)) == 0)
21
22
22
/* Functions in sundries.c that are used in mount.c and umount.c  */ 
23
/* Functions in sundries.c that are used in mount.c and umount.c  */ 
23
void block_signals (int how);
24
void block_signals (int how);
(-)util-linux-2.12q/mount/umount.c (-3 / +9 lines)
Lines 264-271 Link Here
264
  }
264
  }
265
}
265
}
266
266
267
/* Umount a single device.  Return a status code, so don't exit
267
/*
268
   on a non-fatal error.  We lock/unlock around each umount.  */
268
 * Umount a single device
269
 *
270
 * Returns a status code; doesn't exit on a non-fatal error
271
 */
269
static int
272
static int
270
umount_one (const char *spec, const char *node, const char *type,
273
umount_one (const char *spec, const char *node, const char *type,
271
	    const char *opts, struct mntentchn *mc) {
274
	    const char *opts, struct mntentchn *mc) {
Lines 355-361 Link Here
355
			remnt.mnt_type = remnt.mnt_fsname = NULL;
358
			remnt.mnt_type = remnt.mnt_fsname = NULL;
356
			remnt.mnt_dir = xstrdup(node);
359
			remnt.mnt_dir = xstrdup(node);
357
			remnt.mnt_opts = xstrdup("ro");
360
			remnt.mnt_opts = xstrdup("ro");
358
			update_mtab(node, &remnt);
361
			if (!nomtab && mtab_is_writable())
362
				update_mtab(node, &remnt);
359
			return 0;
363
			return 0;
360
		} else if (errno != EBUSY) { 	/* hmm ... */
364
		} else if (errno != EBUSY) { 	/* hmm ... */
361
			perror("remount");
365
			perror("remount");
Lines 665-670 Link Here
665
669
666
	umask(022);
670
	umask(022);
667
671
672
	get_mtab_info();
673
668
	while ((c = getopt_long (argc, argv, "adfhlnrit:O:vV",
674
	while ((c = getopt_long (argc, argv, "adfhlnrit:O:vV",
669
				 longopts, NULL)) != -1)
675
				 longopts, NULL)) != -1)
670
		switch (c) {
676
		switch (c) {

Return to bug 98403