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 <linux/gfs2_ondisk.h>
16 #include <asm/semaphore.h>
19 #include "lm_interface.h"
26 * gfs2_mount_args - Parse mount options
33 int gfs2_mount_args(struct gfs2_sbd *sdp, char *data_arg, int remount)
35 struct gfs2_args *args = &sdp->sd_args;
36 char *data = data_arg;
37 char *options, *o, *v;
41 /* If someone preloaded options, use those instead */
42 spin_lock(&gfs2_sys_margs_lock);
44 data = gfs2_sys_margs;
45 gfs2_sys_margs = NULL;
47 spin_unlock(&gfs2_sys_margs_lock);
49 /* Set some defaults */
50 args->ar_num_glockd = GFS2_GLOCKD_DEFAULT;
51 args->ar_quota = GFS2_QUOTA_DEFAULT;
52 args->ar_data = GFS2_DATA_DEFAULT;
55 /* Split the options into tokens with the "," character and
58 for (options = data; (o = strsep(&options, ",")); ) {
66 if (!strcmp(o, "lockproto")) {
69 if (remount && strcmp(v, args->ar_lockproto))
71 strncpy(args->ar_lockproto, v, GFS2_LOCKNAME_LEN);
72 args->ar_lockproto[GFS2_LOCKNAME_LEN - 1] = 0;
75 else if (!strcmp(o, "locktable")) {
78 if (remount && strcmp(v, args->ar_locktable))
80 strncpy(args->ar_locktable, v, GFS2_LOCKNAME_LEN);
81 args->ar_locktable[GFS2_LOCKNAME_LEN - 1] = 0;
84 else if (!strcmp(o, "hostdata")) {
87 if (remount && strcmp(v, args->ar_hostdata))
89 strncpy(args->ar_hostdata, v, GFS2_LOCKNAME_LEN);
90 args->ar_hostdata[GFS2_LOCKNAME_LEN - 1] = 0;
93 else if (!strcmp(o, "spectator")) {
94 if (remount && !args->ar_spectator)
96 args->ar_spectator = 1;
97 sdp->sd_vfs->s_flags |= MS_RDONLY;
100 else if (!strcmp(o, "ignore_local_fs")) {
101 if (remount && !args->ar_ignore_local_fs)
103 args->ar_ignore_local_fs = 1;
106 else if (!strcmp(o, "localflocks")) {
107 if (remount && !args->ar_localflocks)
109 args->ar_localflocks = 1;
112 else if (!strcmp(o, "localcaching")) {
113 if (remount && !args->ar_localcaching)
115 args->ar_localcaching = 1;
118 else if (!strcmp(o, "debug"))
121 else if (!strcmp(o, "nodebug"))
124 else if (!strcmp(o, "upgrade")) {
125 if (remount && !args->ar_upgrade)
127 args->ar_upgrade = 1;
130 else if (!strcmp(o, "num_glockd")) {
135 if (remount && x != args->ar_num_glockd)
137 if (!x || x > GFS2_GLOCKD_MAX) {
138 fs_info(sdp, "0 < num_glockd <= %u (not %u)\n",
143 args->ar_num_glockd = x;
146 else if (!strcmp(o, "acl")) {
147 args->ar_posix_acl = 1;
148 sdp->sd_vfs->s_flags |= MS_POSIXACL;
151 else if (!strcmp(o, "noacl")) {
152 args->ar_posix_acl = 0;
153 sdp->sd_vfs->s_flags &= ~MS_POSIXACL;
156 else if (!strcmp(o, "quota")) {
159 if (!strcmp(v, "off"))
160 args->ar_quota = GFS2_QUOTA_OFF;
161 else if (!strcmp(v, "account"))
162 args->ar_quota = GFS2_QUOTA_ACCOUNT;
163 else if (!strcmp(v, "on"))
164 args->ar_quota = GFS2_QUOTA_ON;
166 fs_info(sdp, "invalid value for quota\n");
172 else if (!strcmp(o, "suiddir"))
173 args->ar_suiddir = 1;
175 else if (!strcmp(o, "nosuiddir"))
176 args->ar_suiddir = 0;
178 else if (!strcmp(o, "data")) {
181 if (!strcmp(v, "writeback"))
182 args->ar_data = GFS2_DATA_WRITEBACK;
183 else if (!strcmp(v, "ordered"))
184 args->ar_data = GFS2_DATA_ORDERED;
186 fs_info(sdp, "invalid value for data\n");
193 fs_info(sdp, "unknown option: %s\n", o);
200 fs_info(sdp, "invalid mount option(s)\n");
202 if (data != data_arg)
208 fs_info(sdp, "need value for option %s\n", o);
212 fs_info(sdp, "can't remount with option %s\n", o);