Gentoo Archives: gentoo-commits

From: William Hubbs <williamh@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/openrc:master commit in: src/rc/
Date: Tue, 31 Jan 2012 23:00:11
Message-Id: 0fcc6251fcde9c722207afa6f953aea7e80d771b.WilliamH@gentoo
1 commit: 0fcc6251fcde9c722207afa6f953aea7e80d771b
2 Author: William Hubbs <williamh <AT> gentoo <DOT> org>
3 AuthorDate: Tue Jan 31 16:56:57 2012 +0000
4 Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
5 CommitDate: Tue Jan 31 22:33:05 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=0fcc6251
7
8 fstabinfo: add --remount option
9
10 This adds a --remount/-R option to fstabinfo. This new option works like
11 --mount, but it adds the necessary options to remount a file system
12 that is already mounted.
13
14 Reported-by: Piotr Karbowski <piotr.karbowski <AT> gmail.com>
15 X-Gentoo-Bug: 401573
16 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=401573
17
18 ---
19 src/rc/fstabinfo.c | 39 ++++++++++++++++++++++++++++++++-------
20 1 files changed, 32 insertions(+), 7 deletions(-)
21
22 diff --git a/src/rc/fstabinfo.c b/src/rc/fstabinfo.c
23 index 3cf0e02..91f2a56 100644
24 --- a/src/rc/fstabinfo.c
25 +++ b/src/rc/fstabinfo.c
26 @@ -93,9 +93,9 @@ getmntfile(const char *file)
27 extern const char *applet;
28
29 static int
30 -do_mount(struct ENT *ent)
31 +do_mount(struct ENT *ent, bool remount)
32 {
33 - char *argv[8];
34 + char *argv[10];
35 pid_t pid;
36 int status;
37
38 @@ -104,9 +104,24 @@ do_mount(struct ENT *ent)
39 argv[2] = ENT_OPTS(*ent);
40 argv[3] = UNCONST("-t");
41 argv[4] = ENT_TYPE(*ent);
42 - argv[5] = ENT_BLOCKDEVICE(*ent);
43 - argv[6] = ENT_FILE(*ent);
44 - argv[7] = NULL;
45 + if (!remount) {
46 + argv[5] = ENT_BLOCKDEVICE(*ent);
47 + argv[6] = ENT_FILE(*ent);
48 + argv[7] = NULL;
49 + } else {
50 +#ifdef __linux__
51 + argv[5] = UNCONST("-o");
52 + argv[6] = UNCONST("remount");
53 + argv[7] = ENT_BLOCKDEVICE(*ent);
54 + argv[8] = ENT_FILE(*ent);
55 + argv[9] = NULL;
56 +#else
57 + argv[5] = UNCONST("-u");
58 + argv[6] = ENT_BLOCKDEVICE(*ent);
59 + argv[7] = ENT_FILE(*ent);
60 + argv[8] = NULL;
61 +#endif
62 + }
63 switch (pid = vfork()) {
64 case -1:
65 eerrorx("%s: vfork: %s", applet, strerror(errno));
66 @@ -127,9 +142,10 @@ do_mount(struct ENT *ent)
67 }
68
69 #include "_usage.h"
70 -#define getoptstring "Mbmop:t:" getoptstring_COMMON
71 +#define getoptstring "MRbmop:t:" getoptstring_COMMON
72 static const struct option longopts[] = {
73 { "mount", 0, NULL, 'M' },
74 + { "remount", 0, NULL, 'R' },
75 { "blockdevice", 0, NULL, 'b' },
76 { "mountargs", 0, NULL, 'm' },
77 { "options", 0, NULL, 'o' },
78 @@ -139,6 +155,7 @@ static const struct option longopts[] = {
79 };
80 static const char * const longopts_help[] = {
81 "Mounts the filesytem from the mountpoint",
82 + "Remounts the filesystem based on the information in fstab",
83 "Extract the block device",
84 "Show arguments needed to mount the entry",
85 "Extract the options field",
86 @@ -154,6 +171,7 @@ static const char * const longopts_help[] = {
87 #define OUTPUT_PASSNO (1 << 4)
88 #define OUTPUT_BLOCKDEV (1 << 5)
89 #define OUTPUT_MOUNT (1 << 6)
90 +#define OUTPUT_REMOUNT (1 << 7)
91
92 int
93 fstabinfo(int argc, char **argv)
94 @@ -182,6 +200,9 @@ fstabinfo(int argc, char **argv)
95 case 'M':
96 output = OUTPUT_MOUNT;
97 break;
98 + case 'R':
99 + output = OUTPUT_REMOUNT;
100 + break;
101 case 'b':
102 output = OUTPUT_BLOCKDEV;
103 break;
104 @@ -287,7 +308,11 @@ fstabinfo(int argc, char **argv)
105 break;
106
107 case OUTPUT_MOUNT:
108 - result += do_mount(ent);
109 + result += do_mount(ent, false);
110 + break;
111 +
112 + case OUTPUT_REMOUNT:
113 + result += do_mount(ent, true);
114 break;
115
116 case OUTPUT_MOUNTARGS: