]> git.pld-linux.org Git - packages/util-linux.git/blob - mount-2.12pre-symlink_20030809.diff
- specified patches should be included, it will be reviewed later, NFY
[packages/util-linux.git] / mount-2.12pre-symlink_20030809.diff
1 --- util-linux-2.12pre/mount/sundries.h_ORIG    2002-11-01 02:00:50.000000000 +0100
2 +++ util-linux-2.12pre/mount/sundries.h 2003-08-09 14:31:41.000000000 +0200
3 @@ -17,7 +17,8 @@
4  extern int verbose;
5  extern int sloppy;
6  
7 -#define streq(s, t)    (strcmp ((s), (t)) == 0)
8 +#define streq(s, t)      (strcmp ((s), (t)) == 0)
9 +#define streqn(s, t, n)  (strncmp((s), (t), (n)) == 0)
10  
11  /* Functions in sundries.c that are used in mount.c and umount.c  */ 
12  void block_signals (int how);
13 --- util-linux-2.12pre/mount/fstab.h_ORIG       2000-12-03 00:13:47.000000000 +0100
14 +++ util-linux-2.12pre/mount/fstab.h    2003-08-09 13:52:48.000000000 +0200
15 @@ -1,17 +1,10 @@
16  #include <mntent.h>
17 -#define _PATH_FSTAB    "/etc/fstab"
18 -#ifdef _PATH_MOUNTED
19 -#define MOUNTED_LOCK   _PATH_MOUNTED "~"
20 -#define MOUNTED_TEMP   _PATH_MOUNTED ".tmp"
21 -#else
22 -#define MOUNTED_LOCK   "/etc/mtab~"
23 -#define MOUNTED_TEMP   "/etc/mtab.tmp"
24 -#endif
25 -#define LOCK_TIMEOUT   10
26 -
27 -int mtab_is_writable(void);
28 -int mtab_does_not_exist(void);
29 -int mtab_is_a_symlink(void);
30 +#define _PATH_FSTAB             "/etc/fstab"
31 +#define PATH_PROC               "/proc/"
32 +#define PATH_PROC_MOUNTS        PATH_PROC "mounts"
33 +#define MTAB_LOCK_SUFFIX        "~"
34 +#define MTAB_TEMP_SUFFIX        ".tmp"
35 +#define LOCK_TIMEOUT        10
36  
37  struct mntentchn {
38         struct mntentchn *nxt, *prev;
39 @@ -31,6 +24,10 @@
40  struct mntentchn *getfsvolspec (const char *label);
41  
42  #include <mntent.h>
43 +
44 +void get_mtab_info (void);
45 +int mtab_is_writable(void);
46 +int mtab_does_not_exist(void);
47  void lock_mtab (void);
48  void unlock_mtab (void);
49  void update_mtab (const char *special, struct mntent *with);
50 --- util-linux-2.12pre/mount/fstab.c_ORIG       2003-07-05 22:16:05.000000000 +0200
51 +++ util-linux-2.12pre/mount/fstab.c    2003-08-09 14:31:30.000000000 +0200
52 @@ -1,7 +1,10 @@
53 -/* 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL>
54 +/*
55 + * 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL>
56   * - added Native Language Support
57 - * Sun Mar 21 1999 - Arnaldo Carvalho de Melo <acme@conectiva.com.br>
58 + * 1999-03-21 Arnaldo Carvalho de Melo <acme@conectiva.com.br>
59   * - fixed strerr(errno) in gettext calls
60 + * 2003-08-08 Thomas Hood <jdthood@yahoo.co.uk>
61 + * - Write through a symlink at /etc/mtab if it doesn't point into /proc/
62   */
63  
64  #include <unistd.h>
65 @@ -11,65 +14,128 @@
66  #include <sys/stat.h>
67  #include "mntent.h"
68  #include "fstab.h"
69 +#include "realpath.h"
70  #include "sundries.h"          /* for xmalloc() etc */
71  #include "get_label_uuid.h"
72  #include "nls.h"
73  
74 -#define streq(s, t)    (strcmp ((s), (t)) == 0)
75 -
76 -#define PROC_MOUNTS            "/proc/mounts"
77 -
78 -
79  /* Information about mtab. ------------------------------------*/
80 -static int have_mtab_info = 0;
81 -static int var_mtab_does_not_exist = 0;
82 -static int var_mtab_is_a_symlink = 0;
83  
84 -static void
85 +/* A 64 bit number can be displayed in 20 decimal digits */
86 +#define LEN_LARGEST_PID 20
87 +#define MTAB_PATH_MAX (PATH_MAX - (sizeof(MTAB_LOCK_SUFFIX) - 1) - LEN_LARGEST_PID)
88 +static char mtab_path[MTAB_PATH_MAX];
89 +static char mtab_lock_path[PATH_MAX];
90 +static char mtab_lock_targ[PATH_MAX];
91 +static char mtab_temp_path[PATH_MAX];
92 +
93 +/*
94 + * Set mtab_path to the real path of the mtab file
95 + * or to the null string if that path is inaccessible
96 + *
97 + * Run this early
98 + */
99 +void
100  get_mtab_info(void) {
101         struct stat mtab_stat;
102  
103 -       if (!have_mtab_info) {
104 -               if (lstat(MOUNTED, &mtab_stat))
105 -                       var_mtab_does_not_exist = 1;
106 -               else if (S_ISLNK(mtab_stat.st_mode))
107 -                       var_mtab_is_a_symlink = 1;
108 -               have_mtab_info = 1;
109 +       if (lstat(MOUNTED, &mtab_stat)) {
110 +               /* Assume that the lstat error means that the file does not exist */
111 +               /* (Maybe we should check errno here) */
112 +               strcpy(mtab_path, MOUNTED);
113 +       } else if (S_ISLNK(mtab_stat.st_mode)) {
114 +               /* Is a symlink */
115 +               int len;
116 +               char *r = myrealpath(MOUNTED, mtab_path, MTAB_PATH_MAX);
117 +               mtab_path[MTAB_PATH_MAX - 1] = 0; /* Just to be sure */
118 +               len = strlen(mtab_path);
119 +               if (
120 +                       r == NULL
121 +                       || len == 0
122 +                       || len >= (MTAB_PATH_MAX - 1)
123 +                       || streqn(mtab_path, PATH_PROC, sizeof(PATH_PROC) - 1)
124 +               ) {
125 +                       /* Real path invalid or inaccessible */
126 +                       mtab_path[0] = '\0';
127 +                       return;
128 +               }
129 +               /* mtab_path now contains mtab's real path */
130 +       } else {
131 +               /* Exists and is not a symlink */
132 +               strcpy(mtab_path, MOUNTED);
133         }
134 +
135 +       sprintf(mtab_lock_path, "%s%s", mtab_path, MTAB_LOCK_SUFFIX);
136 +       sprintf(mtab_lock_targ, "%s%s%d", mtab_path, MTAB_LOCK_SUFFIX, getpid());
137 +       sprintf(mtab_temp_path, "%s%s", mtab_path, MTAB_TEMP_SUFFIX);
138 +
139 +       return;
140  }
141  
142 -int
143 -mtab_does_not_exist(void) {
144 -       get_mtab_info();
145 -       return var_mtab_does_not_exist;
146 +/*
147 + * Tell whether or not the mtab real path is accessible
148 + *
149 + * get_mtab_info() must have been run
150 + */
151 +static int
152 +mtab_is_accessible(void) {
153 +       return (mtab_path[0] != '\0');
154  }
155  
156 +/*
157 + * Tell whether or not the mtab file currently exists
158 + *
159 + * Note that the answer here is independent of whether or
160 + * not the file is writable, so if you are planning to create
161 + * the mtab file then check mtab_is_writable() too.
162 + *
163 + * get_mtab_info() must have been run
164 + */
165  int
166 -mtab_is_a_symlink(void) {
167 -       get_mtab_info();
168 -       return var_mtab_is_a_symlink;
169 +mtab_does_not_exist(void) {
170 +       struct stat mtab_stat;
171 +
172 +       if (!mtab_is_accessible())
173 +               return 1;
174 +
175 +       if (lstat(mtab_path, &mtab_stat))
176 +               return 1;
177 +
178 +       return 0;
179  }
180  
181 +/*
182 + * Tell whether or not mtab is writable (whether or not it currently exists)
183 + *
184 + * This depends on whether or not the real path is accessible and,
185 + * if so, whether or not the file can be opened.  This function
186 + * has the side effect of creating the file if it is writable.
187 + *
188 + * get_mtab_info() must have been run
189 + */
190  int
191  mtab_is_writable() {
192 -       static int ret = -1;
193 +       static int is_writable = -1;
194 +       int fd;
195  
196 -       /* Should we write to /etc/mtab upon an update?
197 -          Probably not if it is a symlink to /proc/mounts, since that
198 -          would create a file /proc/mounts in case the proc filesystem
199 -          is not mounted. */
200 -       if (mtab_is_a_symlink())
201 -               return 0;
202 -
203 -       if (ret == -1) {
204 -               int fd = open(MOUNTED, O_RDWR | O_CREAT, 0644);
205 -               if (fd >= 0) {
206 -                       close(fd);
207 -                       ret = 1;
208 -               } else
209 -                       ret = 0;
210 +       if (is_writable != -1)
211 +               return is_writable;
212 +
213 +       if (!mtab_is_accessible()) {
214 +               is_writable = 0;
215 +               return is_writable;
216         }
217 -       return ret;
218 +
219 +       lock_mtab();
220 +       fd = open(mtab_path, O_RDWR | O_CREAT, 0644);
221 +       if (fd >= 0) {
222 +               close(fd);
223 +               is_writable = 1;
224 +       } else {
225 +               is_writable = 0;
226 +       }
227 +       unlock_mtab();
228 +       return is_writable;
229  }
230  
231  /* Contents of mtab and fstab ---------------------------------*/
232 @@ -132,21 +198,21 @@
233         got_mtab = 1;
234         mc->nxt = mc->prev = NULL;
235  
236 -       fnam = MOUNTED;
237 +       fnam = mtab_path;
238         mfp = my_setmntent (fnam, "r");
239         if (mfp == NULL || mfp->mntent_fp == NULL) {
240                 int errsv = errno;
241 -               fnam = PROC_MOUNTS;
242 +               fnam = PATH_PROC_MOUNTS;
243                 mfp = my_setmntent (fnam, "r");
244                 if (mfp == NULL || mfp->mntent_fp == NULL) {
245                         error(_("warning: can't open %s: %s"),
246 -                             MOUNTED, strerror (errsv));
247 +                             mtab_path, strerror (errsv));
248                         return;
249                 }
250                 if (verbose)
251                         printf (_("mount: could not open %s - "
252                                   "using %s instead\n"),
253 -                               MOUNTED, PROC_MOUNTS);
254 +                               mtab_path, PATH_PROC_MOUNTS);
255         }
256         read_mntentchn(mfp, fnam, mc);
257  }
258 @@ -231,8 +297,8 @@
259         char devuuid[16];
260         char *devlabel;
261  
262 -       return !get_label_uuid(device, &devlabel, devuuid) &&
263 -               !strcmp(label, devlabel);
264 +       return !get_label_uuid(device, &devlabel, devuuid)
265 +               && streq(label, devlabel);
266  }
267  
268  static int
269 @@ -240,8 +306,8 @@
270         char devuuid[16];
271         char *devlabel;
272  
273 -       return !get_label_uuid(device, &devlabel, devuuid) &&
274 -               !memcmp(uuid, devuuid, sizeof(devuuid));
275 +       return !get_label_uuid(device, &devlabel, devuuid)
276 +               && !memcmp(uuid, devuuid, sizeof(devuuid));
277  }
278  
279  /* Find the entry (SPEC,FILE) in fstab */
280 @@ -338,9 +404,6 @@
281  /* Flag for already existing lock file. */
282  static int we_created_lockfile = 0;
283  
284 -/* Flag to indicate that signals have been set up. */
285 -static int signals_have_been_setup = 0;
286 -
287  /* Ensure that the lock is released if we are interrupted.  */
288  static void
289  handler (int sig) {
290 @@ -352,29 +415,28 @@
291       /* nothing, fcntl will fail anyway */
292  }
293  
294 -/* Create the lock file.
295 -   The lock file will be removed if we catch a signal or when we exit. */
296 +/*
297 + * Create the lock file
298 + *
299 + * The lock file will be removed if we catch a signal or when we exit
300 + */
301  /* The old code here used flock on a lock file /etc/mtab~ and deleted
302 -   this lock file afterwards. However, as rgooch remarks, that has a
303 -   race: a second mount may be waiting on the lock and proceed as
304 -   soon as the lock file is deleted by the first mount, and immediately
305 -   afterwards a third mount comes, creates a new /etc/mtab~, applies
306 -   flock to that, and also proceeds, so that the second and third mount
307 -   now both are scribbling in /etc/mtab.
308 +   this lock file afterwards. However, as rgooch remarks, that races:
309 +   a second mount may be waiting on the lock which will proceed as
310 +   soon as the lock file is deleted by the first mount; immediately
311 +   afterwards a third mount can come, create a new /etc/mtab~, apply
312 +   flock to that, and also proceed, so that the second and third mount
313 +   now both scribble in /etc/mtab.
314     The new code uses a link() instead of a creat(), where we proceed
315 -   only if it was us that created the lock, and hence we always have
316 +   only if it was we that created the lock, and hence we always have
317     to delete the lock afterwards. Now the use of flock() is in principle
318 -   superfluous, but avoids an arbitrary sleep(). */
319 -
320 -/* Where does the link point to? Obvious choices are mtab and mtab~~.
321 -   HJLu points out that the latter leads to races. Right now we use
322 -   mtab~.<pid> instead. */
323 -#define MOUNTLOCK_LINKTARGET   MOUNTED_LOCK "%d"
324 +   superfluous, but using it allows us to avoid an arbitrary sleep(). */
325  
326  void
327  lock_mtab (void) {
328         int tries = 3;
329 -       char *linktargetfile;
330 +       /* Flag to indicate that signals have been set up. */
331 +       static int signals_have_been_setup = 0;
332  
333         if (!signals_have_been_setup) {
334                 int sig = 0;
335 @@ -395,41 +457,36 @@
336                 signals_have_been_setup = 1;
337         }
338  
339 -       /* somewhat clumsy, but some ancient systems do not have snprintf() */
340 -       /* use 20 as upper bound for the length of %d output */
341 -       linktargetfile = xmalloc(strlen(MOUNTLOCK_LINKTARGET) + 20);
342 -       sprintf(linktargetfile, MOUNTLOCK_LINKTARGET, getpid ());
343 -
344         /* Repeat until it was us who made the link */
345         while (!we_created_lockfile) {
346                 struct flock flock;
347                 int errsv, fd, i, j;
348  
349 -               i = open (linktargetfile, O_WRONLY|O_CREAT, 0);
350 +               i = open (mtab_lock_targ, O_WRONLY|O_CREAT, 0);
351                 if (i < 0) {
352                         int errsv = errno;
353 -                       /* linktargetfile does not exist (as a file)
354 +                       /* mtab_lock_targ does not exist (as a file)
355                            and we cannot create it. Read-only filesystem?
356                            Too many files open in the system?
357                            Filesystem full? */
358                         die (EX_FILEIO, _("can't create lock file %s: %s "
359                              "(use -n flag to override)"),
360 -                            linktargetfile, strerror (errsv));
361 +                            mtab_lock_targ, strerror (errsv));
362                 }
363                 close(i);
364  
365 -               j = link(linktargetfile, MOUNTED_LOCK);
366 +               j = link(mtab_lock_targ, mtab_lock_path);
367                 errsv = errno;
368  
369 -               (void) unlink(linktargetfile);
370 +               (void) unlink(mtab_lock_targ);
371  
372                 if (j < 0 && errsv != EEXIST) {
373                         die (EX_FILEIO, _("can't link lock file %s: %s "
374                              "(use -n flag to override)"),
375 -                            MOUNTED_LOCK, strerror (errsv));
376 +                            mtab_lock_path, strerror (errsv));
377                 }
378  
379 -               fd = open (MOUNTED_LOCK, O_WRONLY);
380 +               fd = open (mtab_lock_path, O_WRONLY);
381  
382                 if (fd < 0) {
383                         int errsv = errno;
384 @@ -438,7 +495,7 @@
385                                 continue;
386                         die (EX_FILEIO, _("can't open lock file %s: %s "
387                              "(use -n flag to override)"),
388 -                            MOUNTED_LOCK, strerror (errsv));
389 +                            mtab_lock_path, strerror (errsv));
390                 }
391  
392                 flock.l_type = F_WRLCK;
393 @@ -452,7 +509,7 @@
394                                 if (verbose) {
395                                     int errsv = errno;
396                                     printf(_("Can't lock lock file %s: %s\n"),
397 -                                          MOUNTED_LOCK, strerror (errsv));
398 +                                          mtab_lock_path, strerror (errsv));
399                                 }
400                                 /* proceed anyway */
401                         }
402 @@ -465,17 +522,17 @@
403                         if (fcntl (fd, F_SETLKW, &flock) == -1) {
404                                 int errsv = errno;
405                                 die (EX_FILEIO, _("can't lock lock file %s: %s"),
406 -                                    MOUNTED_LOCK, (errno == EINTR) ?
407 +                                    mtab_lock_path, (errno == EINTR) ?
408                                      _("timed out") : strerror (errsv));
409                         }
410                         alarm(0);
411                         /* Limit the number of iterations - maybe there
412 -                          still is some old /etc/mtab~ */
413 +                          still is some old lock */
414                         if (tries++ > 3) {
415                                 if (tries > 5)
416                                         die (EX_FILEIO, _("Cannot create link %s\n"
417                                             "Perhaps there is a stale lock file?\n"),
418 -                                            MOUNTED_LOCK);
419 +                                            mtab_lock_path);
420                                 sleep(1);
421                         }
422                 }
423 @@ -488,7 +545,7 @@
424  void
425  unlock_mtab (void) {
426         if (we_created_lockfile) {
427 -               unlink (MOUNTED_LOCK);
428 +               unlink (mtab_lock_path);
429                 we_created_lockfile = 0;
430         }
431  }
432 @@ -506,16 +563,16 @@
433  void
434  update_mtab (const char *dir, struct mntent *instead) {
435         mntFILE *mfp, *mftmp;
436 -       const char *fnam = MOUNTED;
437 +       const char *fnam = mtab_path;
438         struct mntentchn mtabhead;      /* dummy */
439         struct mntentchn *mc, *mc0, absent;
440  
441 -       if (mtab_does_not_exist() || mtab_is_a_symlink())
442 +       if (mtab_does_not_exist())
443                 return;
444  
445         lock_mtab();
446  
447 -       /* having locked mtab, read it again */
448 +       /* Having got the lock, we read mtab again */
449         mc0 = mc = &mtabhead;
450         mc->nxt = mc->prev = NULL;
451  
452 @@ -555,11 +612,11 @@
453         }
454  
455         /* write chain to mtemp */
456 -       mftmp = my_setmntent (MOUNTED_TEMP, "w");
457 +       mftmp = my_setmntent (mtab_temp_path, "w");
458         if (mftmp == NULL || mftmp->mntent_fp == NULL) {
459                 int errsv = errno;
460                 error (_("cannot open %s (%s) - mtab not updated"),
461 -                      MOUNTED_TEMP, strerror (errsv));
462 +                      mtab_temp_path, strerror (errsv));
463                 goto leave;
464         }
465  
466 @@ -567,7 +624,7 @@
467                 if (my_addmntent(mftmp, &(mc->m)) == 1) {
468                         int errsv = errno;
469                         die (EX_FILEIO, _("error writing %s: %s"),
470 -                            MOUNTED_TEMP, strerror (errsv));
471 +                            mtab_temp_path, strerror (errsv));
472                 }
473         }
474  
475 @@ -575,25 +632,25 @@
476                     S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) < 0) {
477                 int errsv = errno;
478                 fprintf(stderr, _("error changing mode of %s: %s\n"),
479 -                       MOUNTED_TEMP, strerror (errsv));
480 +                       mtab_temp_path, strerror (errsv));
481         }
482         my_endmntent (mftmp);
483  
484         { /*
485            * If mount is setuid and some non-root user mounts sth,
486 -          * then mtab.tmp might get the group of this user. Copy uid/gid
487 -          * from the present mtab before renaming.
488 +          * then the temp file might get the group of this user.
489 +          * Copy uid/gid from the present mtab before renaming.
490            */
491             struct stat sbuf;
492 -           if (stat (MOUNTED, &sbuf) == 0)
493 -               chown (MOUNTED_TEMP, sbuf.st_uid, sbuf.st_gid);
494 +           if (stat (mtab_path, &sbuf) == 0)
495 +               chown (mtab_temp_path, sbuf.st_uid, sbuf.st_gid);
496         }
497  
498         /* rename mtemp to mtab */
499 -       if (rename (MOUNTED_TEMP, MOUNTED) < 0) {
500 +       if (rename (mtab_temp_path, mtab_path) < 0) {
501                 int errsv = errno;
502                 fprintf(stderr, _("can't rename %s to %s: %s\n"),
503 -                       MOUNTED_TEMP, MOUNTED, strerror(errsv));
504 +                       mtab_temp_path, mtab_path, strerror(errsv));
505         }
506  
507   leave:
508 --- util-linux-2.12pre/mount/mount.c_ORIG       2003-07-13 23:26:13.000000000 +0200
509 +++ util-linux-2.12pre/mount/mount.c    2003-08-09 00:22:21.000000000 +0200
510 @@ -39,6 +39,8 @@
511   * 2000-11-08 aeb: accept nonnumeric uid=, gid= options
512   * 2001-07-13 Michael K. Johnson <johnsonm@redhat.com>
513   * - implemented -a -O
514 + * 2003-08-08 Thomas Hood <jdthood@yahoo.co.uk>
515 + * - Write through a symlink at /etc/mtab if it doesn't point into /proc/
516   */
517  
518  #include <unistd.h>
519 @@ -396,7 +398,11 @@
520      return ret;
521  }
522  
523 -/* Create mtab with a root entry.  */
524 +/*
525 + * Create mtab with a root entry.
526 + *
527 + * Caller should check that mtab is writable first
528 + */
529  static void
530  create_mtab (void) {
531    struct mntentchn *fstab;
532 @@ -1433,6 +1439,9 @@
533         initproctitle(argc, argv);
534  #endif
535  
536 +       get_mtab_info();
537 +       /* Keep in mind that /etc/mtab may be a symlink */
538 +
539         while ((c = getopt_long (argc, argv, "afFhilL:no:O:p:rsU:vVwt:",
540                                  longopts, NULL)) != -1) {
541                 switch (c) {
542 @@ -1554,7 +1563,7 @@
543                         die (EX_USAGE, _("mount: only root can do that"));
544         }
545  
546 -       if (!nomtab && mtab_does_not_exist()) {
547 +       if (!nomtab && mtab_does_not_exist() && mtab_is_writable()) {
548                 if (verbose > 1)
549                         printf(_("mount: no %s found - creating it..\n"),
550                                MOUNTED);
551 --- util-linux-2.12pre/mount/umount.c_ORIG      2002-11-01 02:00:50.000000000 +0100
552 +++ util-linux-2.12pre/mount/umount.c   2003-08-09 00:47:17.000000000 +0200
553 @@ -27,6 +27,8 @@
554   * 010914: Jamie Strandboge - use tcp if that was used for mount
555   * 011005: hch - add lazy umount support
556   * 020105: aeb - permission test owner umount
557 + * 20030808: Thomas Hood <jdthood@yahoo.co.uk>
558 + * - Write through a symlink at /etc/mtab if it doesn't point into /proc/
559   */
560  
561  #include <stdio.h>
562 @@ -240,8 +242,11 @@
563    }
564  }
565  
566 -/* Umount a single device.  Return a status code, so don't exit
567 -   on a non-fatal error.  We lock/unlock around each umount.  */
568 +/*
569 + * Umount a single device
570 + *
571 + * Returns a status code; doesn't exit on a non-fatal error
572 + */
573  static int
574  umount_one (const char *spec, const char *node, const char *type,
575             const char *opts, struct mntentchn *mc) {
576 @@ -321,7 +326,8 @@
577                         remnt.mnt_type = remnt.mnt_fsname = NULL;
578                         remnt.mnt_dir = xstrdup(node);
579                         remnt.mnt_opts = "ro";
580 -                       update_mtab(node, &remnt);
581 +                       if (!nomtab && mtab_is_writable())
582 +                               update_mtab(node, &remnt);
583                         return 0;
584                 } else if (errno != EBUSY) {    /* hmm ... */
585                         perror("remount");
586 @@ -619,6 +625,8 @@
587  
588         umask(033);
589  
590 +       get_mtab_info();
591 +
592         while ((c = getopt_long (argc, argv, "adfhlnrt:O:vV",
593                                  longopts, NULL)) != -1)
594                 switch (c) {
595 --- util-linux-2.12pre/mount/mount.8_ORIG       2003-07-13 23:18:35.000000000 +0200
596 +++ util-linux-2.12pre/mount/mount.8    2003-08-09 08:55:43.000000000 +0200
597 @@ -38,8 +38,10 @@
598  .\" 010714, Michael K. Johnson <johnsonm@redhat.com> added -O
599  .\" 010725, Nikita Danilov <NikitaDanilov@Yahoo.COM>: reiserfs options
600  .\" 011124, Karl Eichwalder <ke@gnu.franken.de>: tmpfs options
601 +.\" 030808, Thomas Hood <jdthood@yahoo.co.uk>: symlinking /etc/mtab
602 +.\" 030809, Thomas Hood <jdthood@yahoo.co.uk>: use 'file system' consistently
603  .\"
604 -.TH MOUNT 8 "14 September 1997" "Linux 2.0" "Linux Programmer's Manual"
605 +.TH MOUNT 8 "8 August 2003" "Linux 2.0" "Linux Programmer's Manual"
606  .SH NAME
607  mount \- mount a file system
608  .SH SYNOPSIS
609 @@ -110,7 +112,7 @@
610  .RE
611  After this call the same contents is accessible in two places.
612  
613 -This call attaches only (part of) a single filesystem, not possible
614 +This call attaches only (part of) a single file system, not possible
615  submounts. The entire file hierarchy including submounts is attached
616  a second place using
617  .RS
618 @@ -167,7 +169,7 @@
619  keyword. Adding the
620  .B \-F
621  option will make mount fork, so that the
622 -filesystems are mounted simultaneously.
623 +file systems are mounted simultaneously.
624  .LP
625  (ii) When mounting a file system mentioned in
626  .IR fstab ,
627 @@ -198,7 +200,7 @@
628  .RE
629  For more details, see
630  .BR fstab (5).
631 -Only the user that mounted a filesystem can unmount it again.
632 +Only the user that mounted a file system can unmount it again.
633  If any user should be able to unmount, then use
634  .B users
635  instead of
636 @@ -227,23 +229,46 @@
637  
638  When the
639  .I proc
640 -filesystem is mounted (say at
641 +file system is mounted (usually at
642  .IR /proc ),
643  the files
644  .I /etc/mtab
645  and
646  .I /proc/mounts
647 -have very similar contents. The former has somewhat
648 +have very similar contents. The former contains somewhat
649  more information, such as the mount options used,
650 -but is not necessarily up-to-date (cf. the
651 +but is not necessarily completely accurate (cf. the
652  .B \-n
653 -option below). It is possible to replace
654 +and
655 +.B \-f
656 +options below). It is possible to replace
657  .I /etc/mtab
658  by a symbolic link to
659  .IR /proc/mounts ,
660 -but some information is lost that way, and in particular
661 -working with the loop device will be less convenient,
662 -and using the "user" option will fail.
663 +but some information is lost that way.  As a result,
664 +working with the loop device is less convenient
665 +and the "user" option does not work.
666 +
667 +You can also replace
668 +.I /etc/mtab
669 +by a symbolic link to
670 +another location such as
671 +.IR /var/run/mtab .
672 +This may be useful if your root file system is mounted read-only
673 +but you have another file system such as
674 +.I /var
675 +that is writable where you can store the mtab.
676 +Note that in this case you will have to mount
677 +.I /var
678 +first using the
679 +.B \-n
680 +option.  Once the target of the
681 +.I /etc/mtab
682 +symbolic link is writable you can run
683 +.B mount
684 +again with the
685 +.B \-f
686 +option to add the missing entry.
687  
688  .SH OPTIONS
689  The full set of options used by an invocation of
690 @@ -271,7 +296,7 @@
691  Verbose mode.
692  .TP
693  .B \-a
694 -Mount all filesystems (of the given types) mentioned in
695 +Mount all file systems (of the given types) mentioned in
696  .IR fstab .
697  .TP
698  .B \-F
699 @@ -317,7 +342,7 @@
700  .TP
701  .B \-s
702  Tolerate sloppy mount options rather than failing. This will ignore
703 -mount options not supported by a filesystem type. Not all filesystems
704 +mount options not supported by a file system type. Not all file systems
705  support this option. This option exists for support of the Linux
706  autofs\-based automounter.
707  .TP
708 @@ -396,7 +421,7 @@
709  .B mount
710  program has to do is issue a simple
711  .IR mount (2)
712 -system call, and no detailed knowledge of the filesystem type is required.
713 +system call, and no detailed knowledge of the file system type is required.
714  For a few types however (like nfs, smbfs, ncpfs) ad hoc code is
715  necessary. The nfs ad hoc code is built in, but smbfs and ncpfs
716  have a separate mount program. In order to make it possible to
717 @@ -416,7 +441,7 @@
718  .B \-t
719  option is given, or if the
720  .B auto
721 -type is specified, the superblock is probed for the filesystem type
722 +type is specified, the superblock is probed for the file system type
723  .RI ( adfs ,
724  .IR bfs ,
725  .IR cramfs ,
726 @@ -442,7 +467,7 @@
727  .IR /etc/filesystems ,
728  or, if that does not exist,
729  .IR /proc/filesystems .
730 -All of the filesystem types listed there will be tried,
731 +All of the file system types listed there will be tried,
732  except for those that are labeled "nodev" (e.g.,
733  .IR devpts ,
734  .I proc
735 @@ -462,7 +487,7 @@
736  can be useful to change the probe order (e.g., to try vfat before msdos)
737  or if you use a kernel module autoloader.
738  Warning: the probing uses a heuristic (the presence of appropriate `magic'),
739 -and could recognize the wrong filesystem type, possibly with catastrophic
740 +and could recognize the wrong file system type, possibly with catastrophic
741  consequences. If your data is valuable, don't ask
742  .B mount
743  to guess.
744 @@ -489,7 +514,7 @@
745  .B \-O
746  Used in conjunction with
747  .BR \-a ,
748 -to limit the set of filesystems to which the
749 +to limit the set of file systems to which the
750  .B \-a
751  is applied.  Like
752  .B \-t
753 @@ -520,7 +545,7 @@
754  .RS
755  .B "mount \-a \-t ext2 \-O _netdev"
756  .RE
757 -mounts all ext2 filesystems with the _netdev option, not all filesystems
758 +mounts all ext2 file systems with the _netdev option, not all file systems
759  that are either ext2 or have the _netdev option specified.
760  .RE
761  .TP
762 @@ -558,8 +583,8 @@
763  Permit execution of binaries.
764  .TP
765  .B _netdev
766 -The filesystem resides on a device that requires network access
767 -(used to prevent the system from attempting to mount these filesystems
768 +The file system resides on a device that requires network access
769 +(used to prevent the system from attempting to mount these file systems
770  until the network has been enabled on the system).
771  .TP
772  .B noatime
773 @@ -789,7 +814,7 @@
774  Define the behaviour when an error is encountered.
775  (Either ignore errors and just mark the file system erroneous and continue,
776  or remount the file system read-only, or panic and halt the system.)
777 -The default is set in the filesystem superblock, and can be
778 +The default is set in the file system superblock, and can be
779  changed using
780  .BR tune2fs (8).
781  .TP
782 @@ -815,18 +840,18 @@
783  .BI sb= n
784  Instead of block 1, use block
785  .I n
786 -as superblock. This could be useful when the filesystem has been damaged.
787 +as superblock. This could be useful when the file system has been damaged.
788  (Earlier, copies of the superblock would be made every 8192 blocks: in
789  block 1, 8193, 16385, ... (and one got hundreds or even thousands
790 -of copies on a big filesystem). Since version 1.08,
791 +of copies on a big file system). Since version 1.08,
792  .B mke2fs
793  has a \-s (sparse superblock) option to reduce the number of backup
794  superblocks, and since version 1.15 this is the default. Note
795 -that this may mean that ext2 filesystems created by a recent
796 +that this may mean that ext2 file systems created by a recent
797  .B mke2fs
798  cannot be mounted r/w under Linux 2.0.*.)
799  The block number here uses 1k units. Thus, if you want to use logical
800 -block 32768 on a filesystem with 4k blocks, use "sb=131072".
801 +block 32768 on a file system with 4k blocks, use "sb=131072".
802  .TP
803  .BR grpquota " / " noquota " / " quota " / " usrquota
804  These options are accepted but ignored.
805 @@ -880,12 +905,12 @@
806  .SH "Mount options for fat"
807  (Note:
808  .I fat
809 -is not a separate filesystem, but a common part of the
810 +is not a separate file system, but a common part of the
811  .IR msdos ,
812  .I umsdos
813  and
814  .I vfat
815 -filesystems.)
816 +file systems.)
817  .TP
818  .BR blocksize=512 " / " blocksize=1024 " / " blocksize=2048
819  Set blocksize (default 512).
820 @@ -934,7 +959,7 @@
821  .TP
822  .BI codepage= value
823  Sets the codepage for converting to shortname characters on FAT
824 -and VFAT filesystems. By default, codepage 437 is used.
825 +and VFAT file systems. By default, codepage 437 is used.
826  .TP
827  .BR conv=b[inary] " / " conv=t[ext] " / " conv=a[uto]
828  The
829 @@ -1035,10 +1060,10 @@
830  Do not abort mounting when certain consistency checks fail.
831  
832  .SH "Mount options for iso9660"
833 -ISO 9660 is a standard describing a filesystem structure to be used
834 -on CD-ROMs. (This filesystem type is also seen on some DVDs. See also the
835 +ISO 9660 is a standard describing a file system structure to be used
836 +on CD-ROMs. (This file system type is also seen on some DVDs. See also the
837  .I udf
838 -filesystem.)
839 +file system.)
840  
841  Normal
842  .I iso9660
843 @@ -1050,7 +1075,7 @@
844  Rock Ridge is an extension to iso9660 that provides all of these unix like
845  features.  Basically there are extensions to each directory record that
846  supply all of the additional information, and when Rock Ridge is in use,
847 -the filesystem is indistinguishable from a normal UNIX file system (except
848 +the file system is indistinguishable from a normal UNIX file system (except
849  that it is read-only, of course).
850  .TP
851  .B norock
852 @@ -1260,7 +1285,7 @@
853  hard links instead of being suppressed.
854  .TP
855  \fBuid=\fP\fIvalue\fP, \fBgid=\fP\fIvalue\fP and \fBumask=\fP\fIvalue\fP
856 -Set the file permission on the filesystem.
857 +Set the file permission on the file system.
858  The umask value is given in octal.
859  By default, the files are owned by root and not readable by somebody else.
860  
861 @@ -1270,12 +1295,12 @@
862  These options are recognized, but have no effect as far as I can see.
863  
864  .SH "Mount options for ramfs"
865 -Ramfs is a memory based filesystem. Mount it and you have it. Unmount it
866 +Ramfs is a memory based file system. Mount it and you have it. Unmount it
867  and it is gone. Present since Linux 2.3.99pre4.
868  There are no mount options.
869  
870  .SH "Mount options for reiserfs"
871 -Reiserfs is a journaling filesystem.
872 +Reiserfs is a journaling file system.
873  The reiserfs mount options are more fully described at
874  .IR http://www.namesys.com/mount-options.html .
875  .TP
876 @@ -1384,7 +1409,7 @@
877  for Ki, Mi, Gi (binary kilo, mega and giga) and can be changed on remount.
878  .TP
879  .BI size= nbytes
880 -Override default size of the filesystem.
881 +Override default size of the file system.
882  The size is given in bytes, and rounded down to entire pages.
883  The default is half of the memory.
884  .TP
885 @@ -1398,7 +1423,7 @@
886  Set initial permissions of the root directory.
887  
888  .SH "Mount options for udf"
889 -udf is the "Universal Disk Format" filesystem defined by the Optical
890 +udf is the "Universal Disk Format" file system defined by the Optical
891  Storage Technology Association, and is often used for DVD-ROM.
892  See also
893  .IR iso9660 .
894 @@ -1447,7 +1472,7 @@
895  Override the PartitionDesc location. (unused)
896  .TP
897  .B lastblock=
898 -Set the last block of the filesystem.
899 +Set the last block of the file system.
900  .TP
901  .B fileset=
902  Override the fileset block location. (unused)
903 @@ -1471,23 +1496,23 @@
904  (Don't forget to give the \-r option.)
905  .TP
906  .B 44bsd
907 -For filesystems created by a BSD-like system (NetBSD,FreeBSD,OpenBSD).
908 +For file systems created by a BSD-like system (NetBSD,FreeBSD,OpenBSD).
909  .TP
910  .B sun
911 -For filesystems created by SunOS or Solaris on Sparc.
912 +For file systems created by SunOS or Solaris on Sparc.
913  .TP
914  .B sunx86
915 -For filesystems created by Solaris on x86.
916 +For file systems created by Solaris on x86.
917  .TP
918  .B nextstep
919 -For filesystems created by NeXTStep (on NeXT station) (currently read only).
920 +For file systems created by NeXTStep (on NeXT station) (currently read only).
921  .TP
922  .B nextstep-cd
923  For NextStep CDROMs (block_size == 2048), read-only.
924  .TP
925  .B openstep
926 -For filesystems created by OpenStep (currently read only).
927 -The same filesystem type is also used by Mac OS X.
928 +For file systems created by OpenStep (currently read only).
929 +The same file system type is also used by Mac OS X.
930  .RE
931  
932  .TP
933 @@ -1525,7 +1550,7 @@
934  This lets you backup and restore filenames that are created with any
935  Unicode characters. Without this option, a '?' is used when no
936  translation is possible. The escape character is ':' because it is
937 -otherwise illegal on the vfat filesystem. The escape sequence
938 +otherwise illegal on the vfat file system. The escape sequence
939  that gets used, where u is the unicode character,
940  is: ':', (u & 0x3f), ((u>>6) & 0x3f), (u>>12).
941  .TP
942 @@ -1538,8 +1563,8 @@
943  .IR name~num.ext .
944  .TP
945  .B utf8
946 -UTF8 is the filesystem safe 8-bit encoding of Unicode that is used
947 -by the console. It can be be enabled for the filesystem with this option.
948 +UTF8 is the file system safe 8-bit encoding of Unicode that is used
949 +by the console. It can be be enabled for the file system with this option.
950  If `uni_xlate' gets set, UTF8 gets disabled.
951  .TP
952  .B shortname=[lower|win95|winnt|mixed]
953 @@ -1592,9 +1617,9 @@
954  .BI logbufs= value
955  Set the number of in-memory log buffers.
956  Valid numbers range from 2-8 inclusive.
957 -The default value is 8 buffers for filesystems with a blocksize of 64K,
958 -4 buffers for filesystems with a blocksize of 32K,
959 -3 buffers for filesystems with a blocksize of 16K,
960 +The default value is 8 buffers for file systems with a blocksize of 64K,
961 +4 buffers for file systems with a blocksize of 32K,
962 +3 buffers for file systems with a blocksize of 16K,
963  and 2 buffers for all other configurations.
964  Increasing the number of buffers may increase performance on
965  some workloads at the cost of the memory used for the
966 @@ -1608,7 +1633,7 @@
967  .TP
968  \fBlogdev=\fP\fIdevice\fP and \fBrtdev=\fP\fIdevice\fP
969  Use an external log (metadata journal) and/or real-time device.
970 -An XFS filesystem has up to three parts: a data section, a log section,
971 +An XFS file system has up to three parts: a data section, a log section,
972  and a real-time section.
973  The real-time section is optional, and the log section can be separate
974  from the data section or contained within it.
975 @@ -1622,8 +1647,8 @@
976  Access timestamps are not updated when a file is read.
977  .TP
978  .B norecovery
979 -The filesystem will be mounted without running log recovery.
980 -If the filesystem was not cleanly unmounted, it is likely to
981 +The file system will be mounted without running log recovery.
982 +If the file system was not cleanly unmounted, it is likely to
983  be inconsistent when mounted in
984  .B norecovery
985  mode.
986 @@ -1651,13 +1676,13 @@
987  volume.
988  .I value
989  must be specified in 512-byte block units.
990 -If this option is not specified and the filesystem was made on a stripe
991 +If this option is not specified and the file system was made on a stripe
992  volume or the stripe width or unit were specified for the RAID device at
993  mkfs time, then the mount system call will restore the value from the
994  superblock.
995 -For filesystems that are made directly on RAID devices, these options can be
996 +For file systems that are made directly on RAID devices, these options can be
997  used to override the information in the superblock if the underlying disk
998 -layout changes after the filesystem has been created.
999 +layout changes after the file system has been created.
1000  The
1001  .B swidth
1002  option is required if the
This page took 0.106156 seconds and 3 git commands to generate.