2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
3 * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
5 * This copyrighted material is made available to anyone wishing to use,
6 * modify, copy, or redistribute it subject to the terms and conditions
7 * of the GNU General Public License version 2.
10 #include <linux/slab.h>
11 #include <linux/spinlock.h>
12 #include <linux/completion.h>
13 #include <linux/buffer_head.h>
14 #include <linux/gfs2_ondisk.h>
15 #include <linux/lm_interface.h>
16 #include <linux/parser.h>
48 static const match_table_t tokens = {
49 {Opt_lockproto, "lockproto=%s"},
50 {Opt_locktable, "locktable=%s"},
51 {Opt_hostdata, "hostdata=%s"},
52 {Opt_spectator, "spectator"},
53 {Opt_ignore_local_fs, "ignore_local_fs"},
54 {Opt_localflocks, "localflocks"},
55 {Opt_localcaching, "localcaching"},
57 {Opt_nodebug, "nodebug"},
58 {Opt_upgrade, "upgrade"},
61 {Opt_quota_off, "quota=off"},
62 {Opt_quota_account, "quota=account"},
63 {Opt_quota_on, "quota=on"},
64 {Opt_suiddir, "suiddir"},
65 {Opt_nosuiddir, "nosuiddir"},
66 {Opt_data_writeback, "data=writeback"},
67 {Opt_data_ordered, "data=ordered"},
73 * gfs2_mount_args - Parse mount options
80 int gfs2_mount_args(struct gfs2_sbd *sdp, char *data_arg, int remount)
82 struct gfs2_args *args = &sdp->sd_args;
83 char *data = data_arg;
84 char *options, *o, *v;
88 /* Set some defaults */
89 args->ar_quota = GFS2_QUOTA_DEFAULT;
90 args->ar_data = GFS2_DATA_DEFAULT;
93 /* Split the options into tokens with the "," character and
96 for (options = data; (o = strsep(&options, ",")); ) {
98 substring_t tmp[MAX_OPT_ARGS];
103 token = match_token(o, tokens, tmp);
106 v = match_strdup(&tmp[0]);
108 fs_info(sdp, "no memory for lockproto\n");
113 if (remount && strcmp(v, args->ar_lockproto)) {
118 strncpy(args->ar_lockproto, v, GFS2_LOCKNAME_LEN);
119 args->ar_lockproto[GFS2_LOCKNAME_LEN - 1] = 0;
123 v = match_strdup(&tmp[0]);
125 fs_info(sdp, "no memory for locktable\n");
130 if (remount && strcmp(v, args->ar_locktable)) {
135 strncpy(args->ar_locktable, v, GFS2_LOCKNAME_LEN);
136 args->ar_locktable[GFS2_LOCKNAME_LEN - 1] = 0;
140 v = match_strdup(&tmp[0]);
142 fs_info(sdp, "no memory for hostdata\n");
147 if (remount && strcmp(v, args->ar_hostdata)) {
152 strncpy(args->ar_hostdata, v, GFS2_LOCKNAME_LEN);
153 args->ar_hostdata[GFS2_LOCKNAME_LEN - 1] = 0;
157 if (remount && !args->ar_spectator)
159 args->ar_spectator = 1;
160 sdp->sd_vfs->s_flags |= MS_RDONLY;
162 case Opt_ignore_local_fs:
163 if (remount && !args->ar_ignore_local_fs)
165 args->ar_ignore_local_fs = 1;
167 case Opt_localflocks:
168 if (remount && !args->ar_localflocks)
170 args->ar_localflocks = 1;
172 case Opt_localcaching:
173 if (remount && !args->ar_localcaching)
175 args->ar_localcaching = 1;
184 if (remount && !args->ar_upgrade)
186 args->ar_upgrade = 1;
189 args->ar_posix_acl = 1;
190 sdp->sd_vfs->s_flags |= MS_POSIXACL;
193 args->ar_posix_acl = 0;
194 sdp->sd_vfs->s_flags &= ~MS_POSIXACL;
197 args->ar_quota = GFS2_QUOTA_OFF;
199 case Opt_quota_account:
200 args->ar_quota = GFS2_QUOTA_ACCOUNT;
203 args->ar_quota = GFS2_QUOTA_ON;
206 args->ar_suiddir = 1;
209 args->ar_suiddir = 0;
211 case Opt_data_writeback:
212 args->ar_data = GFS2_DATA_WRITEBACK;
214 case Opt_data_ordered:
215 args->ar_data = GFS2_DATA_ORDERED;
218 if (remount && args->ar_meta != 1)
224 fs_info(sdp, "unknown option: %s\n", o);
232 fs_info(sdp, "invalid mount option(s)\n");
234 if (data != data_arg)
240 fs_info(sdp, "can't remount with option %s\n", o);