fstabinfo: add --remount option
This adds a --remount/-R option to fstabinfo. This new option works like --mount, but it adds the necessary options to remount a file system that is already mounted. Reported-by: Piotr Karbowski <piotr.karbowski@gmail.com> X-Gentoo-Bug: 401573 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=401573
This commit is contained in:
parent
7da8394a8e
commit
0fcc6251fc
@ -93,9 +93,9 @@ getmntfile(const char *file)
|
|||||||
extern const char *applet;
|
extern const char *applet;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
do_mount(struct ENT *ent)
|
do_mount(struct ENT *ent, bool remount)
|
||||||
{
|
{
|
||||||
char *argv[8];
|
char *argv[10];
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
@ -104,9 +104,24 @@ do_mount(struct ENT *ent)
|
|||||||
argv[2] = ENT_OPTS(*ent);
|
argv[2] = ENT_OPTS(*ent);
|
||||||
argv[3] = UNCONST("-t");
|
argv[3] = UNCONST("-t");
|
||||||
argv[4] = ENT_TYPE(*ent);
|
argv[4] = ENT_TYPE(*ent);
|
||||||
argv[5] = ENT_BLOCKDEVICE(*ent);
|
if (!remount) {
|
||||||
argv[6] = ENT_FILE(*ent);
|
argv[5] = ENT_BLOCKDEVICE(*ent);
|
||||||
argv[7] = NULL;
|
argv[6] = ENT_FILE(*ent);
|
||||||
|
argv[7] = NULL;
|
||||||
|
} else {
|
||||||
|
#ifdef __linux__
|
||||||
|
argv[5] = UNCONST("-o");
|
||||||
|
argv[6] = UNCONST("remount");
|
||||||
|
argv[7] = ENT_BLOCKDEVICE(*ent);
|
||||||
|
argv[8] = ENT_FILE(*ent);
|
||||||
|
argv[9] = NULL;
|
||||||
|
#else
|
||||||
|
argv[5] = UNCONST("-u");
|
||||||
|
argv[6] = ENT_BLOCKDEVICE(*ent);
|
||||||
|
argv[7] = ENT_FILE(*ent);
|
||||||
|
argv[8] = NULL;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
switch (pid = vfork()) {
|
switch (pid = vfork()) {
|
||||||
case -1:
|
case -1:
|
||||||
eerrorx("%s: vfork: %s", applet, strerror(errno));
|
eerrorx("%s: vfork: %s", applet, strerror(errno));
|
||||||
@ -127,9 +142,10 @@ do_mount(struct ENT *ent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#include "_usage.h"
|
#include "_usage.h"
|
||||||
#define getoptstring "Mbmop:t:" getoptstring_COMMON
|
#define getoptstring "MRbmop:t:" getoptstring_COMMON
|
||||||
static const struct option longopts[] = {
|
static const struct option longopts[] = {
|
||||||
{ "mount", 0, NULL, 'M' },
|
{ "mount", 0, NULL, 'M' },
|
||||||
|
{ "remount", 0, NULL, 'R' },
|
||||||
{ "blockdevice", 0, NULL, 'b' },
|
{ "blockdevice", 0, NULL, 'b' },
|
||||||
{ "mountargs", 0, NULL, 'm' },
|
{ "mountargs", 0, NULL, 'm' },
|
||||||
{ "options", 0, NULL, 'o' },
|
{ "options", 0, NULL, 'o' },
|
||||||
@ -139,6 +155,7 @@ static const struct option longopts[] = {
|
|||||||
};
|
};
|
||||||
static const char * const longopts_help[] = {
|
static const char * const longopts_help[] = {
|
||||||
"Mounts the filesytem from the mountpoint",
|
"Mounts the filesytem from the mountpoint",
|
||||||
|
"Remounts the filesystem based on the information in fstab",
|
||||||
"Extract the block device",
|
"Extract the block device",
|
||||||
"Show arguments needed to mount the entry",
|
"Show arguments needed to mount the entry",
|
||||||
"Extract the options field",
|
"Extract the options field",
|
||||||
@ -154,6 +171,7 @@ static const char * const longopts_help[] = {
|
|||||||
#define OUTPUT_PASSNO (1 << 4)
|
#define OUTPUT_PASSNO (1 << 4)
|
||||||
#define OUTPUT_BLOCKDEV (1 << 5)
|
#define OUTPUT_BLOCKDEV (1 << 5)
|
||||||
#define OUTPUT_MOUNT (1 << 6)
|
#define OUTPUT_MOUNT (1 << 6)
|
||||||
|
#define OUTPUT_REMOUNT (1 << 7)
|
||||||
|
|
||||||
int
|
int
|
||||||
fstabinfo(int argc, char **argv)
|
fstabinfo(int argc, char **argv)
|
||||||
@ -182,6 +200,9 @@ fstabinfo(int argc, char **argv)
|
|||||||
case 'M':
|
case 'M':
|
||||||
output = OUTPUT_MOUNT;
|
output = OUTPUT_MOUNT;
|
||||||
break;
|
break;
|
||||||
|
case 'R':
|
||||||
|
output = OUTPUT_REMOUNT;
|
||||||
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
output = OUTPUT_BLOCKDEV;
|
output = OUTPUT_BLOCKDEV;
|
||||||
break;
|
break;
|
||||||
@ -287,7 +308,11 @@ fstabinfo(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case OUTPUT_MOUNT:
|
case OUTPUT_MOUNT:
|
||||||
result += do_mount(ent);
|
result += do_mount(ent, false);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OUTPUT_REMOUNT:
|
||||||
|
result += do_mount(ent, true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OUTPUT_MOUNTARGS:
|
case OUTPUT_MOUNTARGS:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user