2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
3 * Copyright (C) 2004-2005 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 v.2.
10 #include <linux/sched.h>
11 #include <linux/slab.h>
12 #include <linux/spinlock.h>
13 #include <linux/completion.h>
14 #include <linux/buffer_head.h>
15 #include <asm/semaphore.h>
22 * gfs2_mount_args - Parse mount options
29 int gfs2_mount_args(struct gfs2_sbd *sdp, char *data_arg, int remount)
31 struct gfs2_args *args = &sdp->sd_args;
32 char *data = data_arg;
33 char *options, *o, *v;
37 /* If someone preloaded options, use those instead */
38 spin_lock(&gfs2_sys_margs_lock);
40 data = gfs2_sys_margs;
41 gfs2_sys_margs = NULL;
43 spin_unlock(&gfs2_sys_margs_lock);
45 /* Set some defaults */
46 args->ar_num_glockd = GFS2_GLOCKD_DEFAULT;
47 args->ar_quota = GFS2_QUOTA_DEFAULT;
48 args->ar_data = GFS2_DATA_DEFAULT;
51 /* Split the options into tokens with the "," character and
54 for (options = data; (o = strsep(&options, ",")); ) {
62 if (!strcmp(o, "lockproto")) {
65 if (remount && strcmp(v, args->ar_lockproto))
67 strncpy(args->ar_lockproto, v, GFS2_LOCKNAME_LEN);
68 args->ar_lockproto[GFS2_LOCKNAME_LEN - 1] = 0;
71 else if (!strcmp(o, "locktable")) {
74 if (remount && strcmp(v, args->ar_locktable))
76 strncpy(args->ar_locktable, v, GFS2_LOCKNAME_LEN);
77 args->ar_locktable[GFS2_LOCKNAME_LEN - 1] = 0;
80 else if (!strcmp(o, "hostdata")) {
83 if (remount && strcmp(v, args->ar_hostdata))
85 strncpy(args->ar_hostdata, v, GFS2_LOCKNAME_LEN);
86 args->ar_hostdata[GFS2_LOCKNAME_LEN - 1] = 0;
89 else if (!strcmp(o, "spectator")) {
90 if (remount && !args->ar_spectator)
92 args->ar_spectator = 1;
93 sdp->sd_vfs->s_flags |= MS_RDONLY;
96 else if (!strcmp(o, "ignore_local_fs")) {
97 if (remount && !args->ar_ignore_local_fs)
99 args->ar_ignore_local_fs = 1;
102 else if (!strcmp(o, "localflocks")) {
103 if (remount && !args->ar_localflocks)
105 args->ar_localflocks = 1;
108 else if (!strcmp(o, "localcaching")) {
109 if (remount && !args->ar_localcaching)
111 args->ar_localcaching = 1;
114 else if (!strcmp(o, "debug"))
117 else if (!strcmp(o, "nodebug"))
120 else if (!strcmp(o, "upgrade")) {
121 if (remount && !args->ar_upgrade)
123 args->ar_upgrade = 1;
126 else if (!strcmp(o, "num_glockd")) {
131 if (remount && x != args->ar_num_glockd)
133 if (!x || x > GFS2_GLOCKD_MAX) {
134 fs_info(sdp, "0 < num_glockd <= %u (not %u)\n",
139 args->ar_num_glockd = x;
142 else if (!strcmp(o, "acl")) {
143 args->ar_posix_acl = 1;
144 sdp->sd_vfs->s_flags |= MS_POSIXACL;
147 else if (!strcmp(o, "noacl")) {
148 args->ar_posix_acl = 0;
149 sdp->sd_vfs->s_flags &= ~MS_POSIXACL;
152 else if (!strcmp(o, "quota")) {
155 if (!strcmp(v, "off"))
156 args->ar_quota = GFS2_QUOTA_OFF;
157 else if (!strcmp(v, "account"))
158 args->ar_quota = GFS2_QUOTA_ACCOUNT;
159 else if (!strcmp(v, "on"))
160 args->ar_quota = GFS2_QUOTA_ON;
162 fs_info(sdp, "invalid value for quota\n");
168 else if (!strcmp(o, "suiddir"))
169 args->ar_suiddir = 1;
171 else if (!strcmp(o, "nosuiddir"))
172 args->ar_suiddir = 0;
174 else if (!strcmp(o, "data")) {
177 if (!strcmp(v, "writeback"))
178 args->ar_data = GFS2_DATA_WRITEBACK;
179 else if (!strcmp(v, "ordered"))
180 args->ar_data = GFS2_DATA_ORDERED;
182 fs_info(sdp, "invalid value for data\n");
189 fs_info(sdp, "unknown option: %s\n", o);
196 fs_info(sdp, "invalid mount option(s)\n");
198 if (data != data_arg)
204 fs_info(sdp, "need value for option %s\n", o);
208 fs_info(sdp, "can't remount with option %s\n", o);