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.12p.orig/mount/fstab.c (-92 / +148 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> with help from Patrick McLean
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
	fd = open(mtab_path, O_RDWR | O_CREAT, 0644);
131
	if (fd >= 0) {
132
		close(fd);
133
		is_writable = 1;
134
	} else {
135
		is_writable = 0;
136
	}
137
	return is_writable;
75
}
138
}
76
139
77
/* Contents of mtab and fstab ---------------------------------*/
140
/* Contents of mtab and fstab ---------------------------------*/
Lines 154-174 Link Here
154
	got_mtab = 1;
217
	got_mtab = 1;
155
	mc->nxt = mc->prev = NULL;
218
	mc->nxt = mc->prev = NULL;
156
219
157
	fnam = MOUNTED;
220
	fnam = mtab_path;
158
	mfp = my_setmntent (fnam, "r");
221
	mfp = my_setmntent (fnam, "r");
159
	if (mfp == NULL || mfp->mntent_fp == NULL) {
222
	if (mfp == NULL || mfp->mntent_fp == NULL) {
160
		int errsv = errno;
223
		int errsv = errno;
161
		fnam = PROC_MOUNTS;
224
		fnam = PATH_PROC_MOUNTS;
162
		mfp = my_setmntent (fnam, "r");
225
		mfp = my_setmntent (fnam, "r");
163
		if (mfp == NULL || mfp->mntent_fp == NULL) {
226
		if (mfp == NULL || mfp->mntent_fp == NULL) {
164
			error(_("warning: can't open %s: %s"),
227
			error(_("warning: can't open %s: %s"),
165
			      MOUNTED, strerror (errsv));
228
			      mtab_path, strerror (errsv));
166
			return;
229
			return;
167
		}
230
		}
168
		if (verbose)
231
		if (verbose)
169
			printf (_("mount: could not open %s - "
232
			printf (_("mount: could not open %s - "
170
				  "using %s instead\n"),
233
				  "using %s instead\n"),
171
				MOUNTED, PROC_MOUNTS);
234
				mtab_path, PATH_PROC_MOUNTS);
172
	}
235
	}
173
	read_mntentchn(mfp, fnam, mc);
236
	read_mntentchn(mfp, fnam, mc);
174
}
237
}
Lines 396-404 Link Here
396
/* Flag for already existing lock file. */
459
/* Flag for already existing lock file. */
397
static int we_created_lockfile = 0;
460
static int we_created_lockfile = 0;
398
461
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.  */
462
/* Ensure that the lock is released if we are interrupted.  */
403
extern char *strsignal(int sig);	/* not always in <string.h> */
463
extern char *strsignal(int sig);	/* not always in <string.h> */
404
464
Lines 416-450 Link Here
416
void
476
void
417
unlock_mtab (void) {
477
unlock_mtab (void) {
418
	if (we_created_lockfile) {
478
	if (we_created_lockfile) {
419
		unlink (MOUNTED_LOCK);
479
		unlink (mtab_lock_path);
420
		we_created_lockfile = 0;
480
		we_created_lockfile = 0;
421
	}
481
	}
422
}
482
}
423
483
424
/* Create the lock file.
484
/*
425
   The lock file will be removed if we catch a signal or when we exit. */
485
 * Create the lock file
486
 *
487
 * The lock file will be removed if we catch a signal or when we exit
488
 */
426
/* The old code here used flock on a lock file /etc/mtab~ and deleted
489
/* 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
490
   this lock file afterwards. However, as rgooch remarks, that races:
428
   race: a second mount may be waiting on the lock and proceed as
491
   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
492
   soon as the lock file is deleted by the first mount; immediately
430
   afterwards a third mount comes, creates a new /etc/mtab~, applies
493
   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
494
   flock to that, and also proceed, so that the second and third mount
432
   now both are scribbling in /etc/mtab.
495
   now both scribble in /etc/mtab.
433
   The new code uses a link() instead of a creat(), where we proceed
496
   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
497
   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
498
   to delete the lock afterwards. Now the use of flock() is in principle
436
   superfluous, but avoids an arbitrary sleep(). */
499
   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
500
444
void
501
void
445
lock_mtab (void) {
502
lock_mtab (void) {
446
	int tries = 3;
503
	int tries = 3;
447
	char linktargetfile[MOUNTLOCK_LINKTARGET_LTH];
504
	/* Flag to indicate that signals have been set up. */
505
	static int signals_have_been_setup = 0;
448
506
449
	at_die = unlock_mtab;
507
	at_die = unlock_mtab;
450
508
Lines 467-496 Link Here
467
		signals_have_been_setup = 1;
525
		signals_have_been_setup = 1;
468
	}
526
	}
469
527
470
	sprintf(linktargetfile, MOUNTLOCK_LINKTARGET, getpid ());
471
472
	/* Repeat until it was us who made the link */
528
	/* Repeat until it was us who made the link */
473
	while (!we_created_lockfile) {
529
	while (!we_created_lockfile) {
474
		struct flock flock;
530
		struct flock flock;
475
		int errsv, fd, i, j;
531
		int errsv, fd, i, j;
476
532
477
		i = open (linktargetfile, O_WRONLY|O_CREAT, 0);
533
		i = open (mtab_lock_targ, O_WRONLY|O_CREAT, 0);
478
		if (i < 0) {
534
		if (i < 0) {
479
			int errsv = errno;
535
			int errsv = errno;
480
			/* linktargetfile does not exist (as a file)
536
			/* mtab_lock_targ does not exist (as a file)
481
			   and we cannot create it. Read-only filesystem?
537
			   and we cannot create it. Read-only filesystem?
482
			   Too many files open in the system?
538
			   Too many files open in the system?
483
			   Filesystem full? */
539
			   Filesystem full? */
484
			die (EX_FILEIO, _("can't create lock file %s: %s "
540
			die (EX_FILEIO, _("can't create lock file %s: %s "
485
			     "(use -n flag to override)"),
541
			     "(use -n flag to override)"),
486
			     linktargetfile, strerror (errsv));
542
			     mtab_lock_targ, strerror (errsv));
487
		}
543
		}
488
		close(i);
544
		close(i);
489
545
490
		j = link(linktargetfile, MOUNTED_LOCK);
546
		j = link(mtab_lock_targ, mtab_lock_path);
491
		errsv = errno;
547
		errsv = errno;
492
548
493
		(void) unlink(linktargetfile);
549
		(void) unlink(mtab_lock_targ);
494
550
495
		if (j == 0)
551
		if (j == 0)
496
			we_created_lockfile = 1;
552
			we_created_lockfile = 1;
Lines 498-507 Link Here
498
		if (j < 0 && errsv != EEXIST) {
554
		if (j < 0 && errsv != EEXIST) {
499
			die (EX_FILEIO, _("can't link lock file %s: %s "
555
			die (EX_FILEIO, _("can't link lock file %s: %s "
500
			     "(use -n flag to override)"),
556
			     "(use -n flag to override)"),
501
			     MOUNTED_LOCK, strerror (errsv));
557
			     mtab_lock_path, strerror (errsv));
502
		}
558
		}
503
559
504
		fd = open (MOUNTED_LOCK, O_WRONLY);
560
		fd = open (mtab_lock_path, O_WRONLY);
505
561
506
		if (fd < 0) {
562
		if (fd < 0) {
507
			int errsv = errno;
563
			int errsv = errno;
Lines 510-516 Link Here
510
				continue;
566
				continue;
511
			die (EX_FILEIO, _("can't open lock file %s: %s "
567
			die (EX_FILEIO, _("can't open lock file %s: %s "
512
			     "(use -n flag to override)"),
568
			     "(use -n flag to override)"),
513
			     MOUNTED_LOCK, strerror (errsv));
569
			     mtab_lock_path, strerror (errsv));
514
		}
570
		}
515
571
516
		flock.l_type = F_WRLCK;
572
		flock.l_type = F_WRLCK;
Lines 524-530 Link Here
524
				if (verbose) {
580
				if (verbose) {
525
				    int errsv = errno;
581
				    int errsv = errno;
526
				    printf(_("Can't lock lock file %s: %s\n"),
582
				    printf(_("Can't lock lock file %s: %s\n"),
527
					   MOUNTED_LOCK, strerror (errsv));
583
					   mtab_lock_path, strerror (errsv));
528
				}
584
				}
529
				/* proceed anyway */
585
				/* proceed anyway */
530
			}
586
			}
Lines 536-552 Link Here
536
			if (fcntl (fd, F_SETLKW, &flock) == -1) {
592
			if (fcntl (fd, F_SETLKW, &flock) == -1) {
537
				int errsv = errno;
593
				int errsv = errno;
538
				die (EX_FILEIO, _("can't lock lock file %s: %s"),
594
				die (EX_FILEIO, _("can't lock lock file %s: %s"),
539
				     MOUNTED_LOCK, (errno == EINTR) ?
595
				     mtab_lock_path, (errno == EINTR) ?
540
				     _("timed out") : strerror (errsv));
596
				     _("timed out") : strerror (errsv));
541
			}
597
			}
542
			alarm(0);
598
			alarm(0);
543
			/* Limit the number of iterations - maybe there
599
			/* Limit the number of iterations - maybe there
544
			   still is some old /etc/mtab~ */
600
			   still is some old lock */
545
			if (tries++ > 3) {
601
			if (tries++ > 3) {
546
				if (tries > 5)
602
				if (tries > 5)
547
					die (EX_FILEIO, _("Cannot create link %s\n"
603
					die (EX_FILEIO, _("Cannot create link %s\n"
548
					    "Perhaps there is a stale lock file?\n"),
604
					    "Perhaps there is a stale lock file?\n"),
549
					     MOUNTED_LOCK);
605
					     mtab_lock_path);
550
				sleep(1);
606
				sleep(1);
551
			}
607
			}
552
		}
608
		}
Lines 568-583 Link Here
568
void
624
void
569
update_mtab (const char *dir, struct my_mntent *instead) {
625
update_mtab (const char *dir, struct my_mntent *instead) {
570
	mntFILE *mfp, *mftmp;
626
	mntFILE *mfp, *mftmp;
571
	const char *fnam = MOUNTED;
627
	const char *fnam = mtab_path;
572
	struct mntentchn mtabhead;	/* dummy */
628
	struct mntentchn mtabhead;	/* dummy */
573
	struct mntentchn *mc, *mc0, *absent = NULL;
629
	struct mntentchn *mc, *mc0, *absent = NULL;
574
630
575
	if (mtab_does_not_exist() || mtab_is_a_symlink())
631
	if (mtab_does_not_exist())
576
		return;
632
		return;
577
633
578
	lock_mtab();
634
	lock_mtab();
579
635
580
	/* having locked mtab, read it again */
636
	/* Having got the lock, we read mtab again */
581
	mc0 = mc = &mtabhead;
637
	mc0 = mc = &mtabhead;
582
	mc->nxt = mc->prev = NULL;
638
	mc->nxt = mc->prev = NULL;
583
639
Lines 619-629 Link Here
619
	}
675
	}
620
676
621
	/* write chain to mtemp */
677
	/* write chain to mtemp */
622
	mftmp = my_setmntent (MOUNTED_TEMP, "w");
678
	mftmp = my_setmntent (mtab_temp_path, "w");
623
	if (mftmp == NULL || mftmp->mntent_fp == NULL) {
679
	if (mftmp == NULL || mftmp->mntent_fp == NULL) {
624
		int errsv = errno;
680
		int errsv = errno;
625
		error (_("cannot open %s (%s) - mtab not updated"),
681
		error (_("cannot open %s (%s) - mtab not updated"),
626
		       MOUNTED_TEMP, strerror (errsv));
682
		       mtab_temp_path, strerror (errsv));
627
		goto leave;
683
		goto leave;
628
	}
684
	}
629
685
Lines 631-637 Link Here
631
		if (my_addmntent(mftmp, &(mc->m)) == 1) {
687
		if (my_addmntent(mftmp, &(mc->m)) == 1) {
632
			int errsv = errno;
688
			int errsv = errno;
633
			die (EX_FILEIO, _("error writing %s: %s"),
689
			die (EX_FILEIO, _("error writing %s: %s"),
634
			     MOUNTED_TEMP, strerror (errsv));
690
			     mtab_temp_path, strerror (errsv));
635
		}
691
		}
636
	}
692
	}
637
693
Lines 641-665 Link Here
641
		    S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) < 0) {
697
		    S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) < 0) {
642
		int errsv = errno;
698
		int errsv = errno;
643
		fprintf(stderr, _("error changing mode of %s: %s\n"),
699
		fprintf(stderr, _("error changing mode of %s: %s\n"),
644
			MOUNTED_TEMP, strerror (errsv));
700
			mtab_temp_path, strerror (errsv));
645
	}
701
	}
646
	my_endmntent (mftmp);
702
	my_endmntent (mftmp);
647
703
648
	{ /*
704
	{ /*
649
	   * If mount is setuid and some non-root user mounts sth,
705
	   * 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
706
	   * then the temp file might get the group of this user.
651
	   * from the present mtab before renaming.
707
	   * Copy uid/gid from the present mtab before renaming.
652
	   */
708
	   */
653
	    struct stat sbuf;
709
	    struct stat sbuf;
654
	    if (stat (MOUNTED, &sbuf) == 0)
710
	    if (stat (mtab_path, &sbuf) == 0)
655
		chown (MOUNTED_TEMP, sbuf.st_uid, sbuf.st_gid);
711
		chown (mtab_temp_path, sbuf.st_uid, sbuf.st_gid);
656
	}
712
	}
657
713
658
	/* rename mtemp to mtab */
714
	/* rename mtemp to mtab */
659
	if (rename (MOUNTED_TEMP, MOUNTED) < 0) {
715
	if (rename (mtab_temp_path, mtab_path) < 0) {
660
		int errsv = errno;
716
		int errsv = errno;
661
		fprintf(stderr, _("can't rename %s to %s: %s\n"),
717
		fprintf(stderr, _("can't rename %s to %s: %s\n"),
662
			MOUNTED_TEMP, MOUNTED, strerror(errsv));
718
			mtab_temp_path, mtab_path, strerror(errsv));
663
	}
719
	}
664
720
665
 leave:
721
 leave:
(-)util-linux-2.12p.orig/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.12p.orig/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.12p.orig/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.12p.orig/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.12p.orig/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