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>
24 * gfs2_mount_args - Parse mount options
31 int gfs2_mount_args(struct gfs2_sbd
*sdp
, char *data_arg
, int remount
)
33 struct gfs2_args
*args
= &sdp
->sd_args
;
34 char *data
= data_arg
;
35 char *options
, *o
, *v
;
39 /* If someone preloaded options, use those instead */
40 spin_lock(&gfs2_sys_margs_lock
);
42 data
= gfs2_sys_margs
;
43 gfs2_sys_margs
= NULL
;
45 spin_unlock(&gfs2_sys_margs_lock
);
47 /* Set some defaults */
48 args
->ar_num_glockd
= GFS2_GLOCKD_DEFAULT
;
49 args
->ar_quota
= GFS2_QUOTA_DEFAULT
;
50 args
->ar_data
= GFS2_DATA_DEFAULT
;
53 /* Split the options into tokens with the "," character and
56 for (options
= data
; (o
= strsep(&options
, ",")); ) {
64 if (!strcmp(o
, "lockproto")) {
67 if (remount
&& strcmp(v
, args
->ar_lockproto
))
69 strncpy(args
->ar_lockproto
, v
, GFS2_LOCKNAME_LEN
);
70 args
->ar_lockproto
[GFS2_LOCKNAME_LEN
- 1] = 0;
73 else if (!strcmp(o
, "locktable")) {
76 if (remount
&& strcmp(v
, args
->ar_locktable
))
78 strncpy(args
->ar_locktable
, v
, GFS2_LOCKNAME_LEN
);
79 args
->ar_locktable
[GFS2_LOCKNAME_LEN
- 1] = 0;
82 else if (!strcmp(o
, "hostdata")) {
85 if (remount
&& strcmp(v
, args
->ar_hostdata
))
87 strncpy(args
->ar_hostdata
, v
, GFS2_LOCKNAME_LEN
);
88 args
->ar_hostdata
[GFS2_LOCKNAME_LEN
- 1] = 0;
91 else if (!strcmp(o
, "spectator")) {
92 if (remount
&& !args
->ar_spectator
)
94 args
->ar_spectator
= 1;
95 sdp
->sd_vfs
->s_flags
|= MS_RDONLY
;
98 else if (!strcmp(o
, "ignore_local_fs")) {
99 if (remount
&& !args
->ar_ignore_local_fs
)
101 args
->ar_ignore_local_fs
= 1;
104 else if (!strcmp(o
, "localflocks")) {
105 if (remount
&& !args
->ar_localflocks
)
107 args
->ar_localflocks
= 1;
110 else if (!strcmp(o
, "localcaching")) {
111 if (remount
&& !args
->ar_localcaching
)
113 args
->ar_localcaching
= 1;
116 else if (!strcmp(o
, "debug"))
119 else if (!strcmp(o
, "nodebug"))
122 else if (!strcmp(o
, "upgrade")) {
123 if (remount
&& !args
->ar_upgrade
)
125 args
->ar_upgrade
= 1;
128 else if (!strcmp(o
, "num_glockd")) {
133 if (remount
&& x
!= args
->ar_num_glockd
)
135 if (!x
|| x
> GFS2_GLOCKD_MAX
) {
136 fs_info(sdp
, "0 < num_glockd <= %u (not %u)\n",
141 args
->ar_num_glockd
= x
;
144 else if (!strcmp(o
, "acl")) {
145 args
->ar_posix_acl
= 1;
146 sdp
->sd_vfs
->s_flags
|= MS_POSIXACL
;
149 else if (!strcmp(o
, "noacl")) {
150 args
->ar_posix_acl
= 0;
151 sdp
->sd_vfs
->s_flags
&= ~MS_POSIXACL
;
154 else if (!strcmp(o
, "quota")) {
157 if (!strcmp(v
, "off"))
158 args
->ar_quota
= GFS2_QUOTA_OFF
;
159 else if (!strcmp(v
, "account"))
160 args
->ar_quota
= GFS2_QUOTA_ACCOUNT
;
161 else if (!strcmp(v
, "on"))
162 args
->ar_quota
= GFS2_QUOTA_ON
;
164 fs_info(sdp
, "invalid value for quota\n");
170 else if (!strcmp(o
, "suiddir"))
171 args
->ar_suiddir
= 1;
173 else if (!strcmp(o
, "nosuiddir"))
174 args
->ar_suiddir
= 0;
176 else if (!strcmp(o
, "data")) {
179 if (!strcmp(v
, "writeback"))
180 args
->ar_data
= GFS2_DATA_WRITEBACK
;
181 else if (!strcmp(v
, "ordered"))
182 args
->ar_data
= GFS2_DATA_ORDERED
;
184 fs_info(sdp
, "invalid value for data\n");
191 fs_info(sdp
, "unknown option: %s\n", o
);
198 fs_info(sdp
, "invalid mount option(s)\n");
200 if (data
!= data_arg
)
206 fs_info(sdp
, "need value for option %s\n", o
);
210 fs_info(sdp
, "can't remount with option %s\n", o
);