]> git.karo-electronics.de Git - mv-sheeva.git/blob - fs/gfs2/mount.c
GFS2: Merge lock_dlm module into GFS2
[mv-sheeva.git] / fs / gfs2 / mount.c
1 /*
2  * Copyright (C) Sistina Software, Inc.  1997-2003 All rights reserved.
3  * Copyright (C) 2004-2006 Red Hat, Inc.  All rights reserved.
4  *
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.
8  */
9
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/parser.h>
16
17 #include "gfs2.h"
18 #include "incore.h"
19 #include "super.h"
20 #include "sys.h"
21 #include "util.h"
22
23 enum {
24         Opt_lockproto,
25         Opt_locktable,
26         Opt_hostdata,
27         Opt_spectator,
28         Opt_ignore_local_fs,
29         Opt_localflocks,
30         Opt_localcaching,
31         Opt_debug,
32         Opt_nodebug,
33         Opt_upgrade,
34         Opt_acl,
35         Opt_noacl,
36         Opt_quota_off,
37         Opt_quota_account,
38         Opt_quota_on,
39         Opt_suiddir,
40         Opt_nosuiddir,
41         Opt_data_writeback,
42         Opt_data_ordered,
43         Opt_meta,
44         Opt_err,
45 };
46
47 static const match_table_t tokens = {
48         {Opt_lockproto, "lockproto=%s"},
49         {Opt_locktable, "locktable=%s"},
50         {Opt_hostdata, "hostdata=%s"},
51         {Opt_spectator, "spectator"},
52         {Opt_ignore_local_fs, "ignore_local_fs"},
53         {Opt_localflocks, "localflocks"},
54         {Opt_localcaching, "localcaching"},
55         {Opt_debug, "debug"},
56         {Opt_nodebug, "nodebug"},
57         {Opt_upgrade, "upgrade"},
58         {Opt_acl, "acl"},
59         {Opt_noacl, "noacl"},
60         {Opt_quota_off, "quota=off"},
61         {Opt_quota_account, "quota=account"},
62         {Opt_quota_on, "quota=on"},
63         {Opt_suiddir, "suiddir"},
64         {Opt_nosuiddir, "nosuiddir"},
65         {Opt_data_writeback, "data=writeback"},
66         {Opt_data_ordered, "data=ordered"},
67         {Opt_meta, "meta"},
68         {Opt_err, NULL}
69 };
70
71 /**
72  * gfs2_mount_args - Parse mount options
73  * @sdp:
74  * @data:
75  *
76  * Return: errno
77  */
78
79 int gfs2_mount_args(struct gfs2_sbd *sdp, struct gfs2_args *args, char *options)
80 {
81         char *o;
82         int token;
83         substring_t tmp[MAX_OPT_ARGS];
84
85         /* Split the options into tokens with the "," character and
86            process them */
87
88         while (1) {
89                 o = strsep(&options, ",");
90                 if (o == NULL)
91                         break;
92                 if (*o == '\0')
93                         continue;
94
95                 token = match_token(o, tokens, tmp);
96                 switch (token) {
97                 case Opt_lockproto:
98                         match_strlcpy(args->ar_lockproto, &tmp[0],
99                                       GFS2_LOCKNAME_LEN);
100                         break;
101                 case Opt_locktable:
102                         match_strlcpy(args->ar_locktable, &tmp[0],
103                                       GFS2_LOCKNAME_LEN);
104                         break;
105                 case Opt_hostdata:
106                         match_strlcpy(args->ar_hostdata, &tmp[0],
107                                       GFS2_LOCKNAME_LEN);
108                         break;
109                 case Opt_spectator:
110                         args->ar_spectator = 1;
111                         break;
112                 case Opt_ignore_local_fs:
113                         args->ar_ignore_local_fs = 1;
114                         break;
115                 case Opt_localflocks:
116                         args->ar_localflocks = 1;
117                         break;
118                 case Opt_localcaching:
119                         args->ar_localcaching = 1;
120                         break;
121                 case Opt_debug:
122                         args->ar_debug = 1;
123                         break;
124                 case Opt_nodebug:
125                         args->ar_debug = 0;
126                         break;
127                 case Opt_upgrade:
128                         args->ar_upgrade = 1;
129                         break;
130                 case Opt_acl:
131                         args->ar_posix_acl = 1;
132                         break;
133                 case Opt_noacl:
134                         args->ar_posix_acl = 0;
135                         break;
136                 case Opt_quota_off:
137                         args->ar_quota = GFS2_QUOTA_OFF;
138                         break;
139                 case Opt_quota_account:
140                         args->ar_quota = GFS2_QUOTA_ACCOUNT;
141                         break;
142                 case Opt_quota_on:
143                         args->ar_quota = GFS2_QUOTA_ON;
144                         break;
145                 case Opt_suiddir:
146                         args->ar_suiddir = 1;
147                         break;
148                 case Opt_nosuiddir:
149                         args->ar_suiddir = 0;
150                         break;
151                 case Opt_data_writeback:
152                         args->ar_data = GFS2_DATA_WRITEBACK;
153                         break;
154                 case Opt_data_ordered:
155                         args->ar_data = GFS2_DATA_ORDERED;
156                         break;
157                 case Opt_meta:
158                         args->ar_meta = 1;
159                         break;
160                 case Opt_err:
161                 default:
162                         fs_info(sdp, "invalid mount option: %s\n", o);
163                         return -EINVAL;
164                 }
165         }
166
167         return 0;
168 }
169