4
* Decode mount options.
10
#include "mount_opts.h"
12
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
14
static const struct mount_opts options[] = {
15
/* name mask set noset */
16
{ "async", MS_SYNCHRONOUS, 0, MS_SYNCHRONOUS },
17
{ "atime", MS_NOATIME, 0, MS_NOATIME },
18
{ "bind", MS_TYPE, MS_BIND, 0, },
19
{ "dev", MS_NODEV, 0, MS_NODEV },
20
{ "diratime", MS_NODIRATIME, 0, MS_NODIRATIME },
21
{ "dirsync", MS_DIRSYNC, MS_DIRSYNC, 0 },
22
{ "exec", MS_NOEXEC, 0, MS_NOEXEC },
23
{ "move", MS_TYPE, MS_MOVE, 0 },
24
{ "recurse", MS_REC, MS_REC, 0 },
25
{ "remount", MS_TYPE, MS_REMOUNT, 0 },
26
{ "ro", MS_RDONLY, MS_RDONLY, 0 },
27
{ "rw", MS_RDONLY, 0, MS_RDONLY },
28
{ "suid", MS_NOSUID, 0, MS_NOSUID },
29
{ "sync", MS_SYNCHRONOUS, MS_SYNCHRONOUS, 0 },
30
{ "verbose", MS_VERBOSE, MS_VERBOSE, 0 },
33
static void add_extra_option(struct extra_opts *extra, char *s)
36
int newlen = extra->used_size + len;
39
len++; /* +1 for ',' */
41
if (newlen >= extra->alloc_size) {
44
new = realloc(extra->str, newlen + 1); /* +1 for NUL */
49
extra->end = extra->str + extra->used_size;
50
extra->alloc_size = newlen;
53
if (extra->used_size) {
57
strcpy(extra->end, s);
58
extra->used_size += len;
63
parse_mount_options(char *arg, unsigned long rwflag, struct extra_opts *extra)
67
while ((s = strsep(&arg, ",")) != NULL) {
70
int res, no = s[0] == 'n' && s[1] == 'o';
75
for (i = 0, res = 1; i < ARRAY_SIZE(options); i++) {
76
res = strcmp(s, options[i].str);
79
rwflag &= ~options[i].rwmask;
81
rwflag |= options[i].rwnoset;
83
rwflag |= options[i].rwset;
90
add_extra_option(extra, opt);