blob: 3524ae81189bbd3d7c3b6294b54f5fa8ccd490a2 [file] [log] [blame]
David Teiglandb3b94fa2006-01-16 16:50:04 +00001/*
2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
Steven Whitehouse3a8a9a12006-05-18 15:09:15 -04003 * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
David Teiglandb3b94fa2006-01-16 16:50:04 +00004 *
5 * This copyrighted material is made available to anyone wishing to use,
6 * modify, copy, or redistribute it subject to the terms and conditions
Steven Whitehousee9fc2aa2006-09-01 11:05:15 -04007 * of the GNU General Public License version 2.
David Teiglandb3b94fa2006-01-16 16:50:04 +00008 */
9
David Teiglandb3b94fa2006-01-16 16:50:04 +000010#include <linux/slab.h>
11#include <linux/spinlock.h>
12#include <linux/completion.h>
13#include <linux/buffer_head.h>
Steven Whitehouse5c676f62006-02-27 17:23:27 -050014#include <linux/gfs2_ondisk.h>
Fabio Massimo Di Nitto7d308592006-09-19 07:56:29 +020015#include <linux/lm_interface.h>
Josef Bacik476c0062007-04-23 11:55:39 -040016#include <linux/parser.h>
David Teiglandb3b94fa2006-01-16 16:50:04 +000017
18#include "gfs2.h"
Steven Whitehouse5c676f62006-02-27 17:23:27 -050019#include "incore.h"
Steven Whitehouse6f04c1c2009-01-06 11:52:25 +000020#include "super.h"
David Teiglandb3b94fa2006-01-16 16:50:04 +000021#include "sys.h"
Steven Whitehouse5c676f62006-02-27 17:23:27 -050022#include "util.h"
David Teiglandb3b94fa2006-01-16 16:50:04 +000023
Josef Bacik476c0062007-04-23 11:55:39 -040024enum {
25 Opt_lockproto,
26 Opt_locktable,
27 Opt_hostdata,
28 Opt_spectator,
29 Opt_ignore_local_fs,
30 Opt_localflocks,
31 Opt_localcaching,
32 Opt_debug,
33 Opt_nodebug,
34 Opt_upgrade,
Josef Bacik476c0062007-04-23 11:55:39 -040035 Opt_acl,
36 Opt_noacl,
37 Opt_quota_off,
38 Opt_quota_account,
39 Opt_quota_on,
40 Opt_suiddir,
41 Opt_nosuiddir,
42 Opt_data_writeback,
43 Opt_data_ordered,
Steven Whitehouse9b8df982008-08-08 13:45:13 +010044 Opt_meta,
Benjamin Marzinski9a5ad132007-08-17 20:22:07 -050045 Opt_err,
Josef Bacik476c0062007-04-23 11:55:39 -040046};
47
Steven Whitehousea447c092008-10-13 10:46:57 +010048static const match_table_t tokens = {
Josef Bacik476c0062007-04-23 11:55:39 -040049 {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"},
56 {Opt_debug, "debug"},
57 {Opt_nodebug, "nodebug"},
58 {Opt_upgrade, "upgrade"},
Josef Bacik476c0062007-04-23 11:55:39 -040059 {Opt_acl, "acl"},
60 {Opt_noacl, "noacl"},
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"},
Benjamin Marzinski9a5ad132007-08-17 20:22:07 -050067 {Opt_data_ordered, "data=ordered"},
Steven Whitehouse9b8df982008-08-08 13:45:13 +010068 {Opt_meta, "meta"},
Benjamin Marzinski9a5ad132007-08-17 20:22:07 -050069 {Opt_err, NULL}
Josef Bacik476c0062007-04-23 11:55:39 -040070};
71
David Teiglandb3b94fa2006-01-16 16:50:04 +000072/**
73 * gfs2_mount_args - Parse mount options
74 * @sdp:
75 * @data:
76 *
77 * Return: errno
78 */
79
Steven Whitehouse6f04c1c2009-01-06 11:52:25 +000080int gfs2_mount_args(struct gfs2_sbd *sdp, struct gfs2_args *args, char *options)
David Teiglandb3b94fa2006-01-16 16:50:04 +000081{
Steven Whitehouse6f04c1c2009-01-06 11:52:25 +000082 char *o;
83 int token;
84 substring_t tmp[MAX_OPT_ARGS];
David Teiglandb3b94fa2006-01-16 16:50:04 +000085
86 /* Split the options into tokens with the "," character and
87 process them */
88
Steven Whitehouse6f04c1c2009-01-06 11:52:25 +000089 while (1) {
90 o = strsep(&options, ",");
91 if (o == NULL)
92 break;
93 if (*o == '\0')
David Teiglandb3b94fa2006-01-16 16:50:04 +000094 continue;
95
Josef Bacik476c0062007-04-23 11:55:39 -040096 token = match_token(o, tokens, tmp);
97 switch (token) {
98 case Opt_lockproto:
Steven Whitehouse6f04c1c2009-01-06 11:52:25 +000099 match_strlcpy(args->ar_lockproto, &tmp[0],
100 GFS2_LOCKNAME_LEN);
Josef Bacik476c0062007-04-23 11:55:39 -0400101 break;
102 case Opt_locktable:
Steven Whitehouse6f04c1c2009-01-06 11:52:25 +0000103 match_strlcpy(args->ar_locktable, &tmp[0],
104 GFS2_LOCKNAME_LEN);
Josef Bacik476c0062007-04-23 11:55:39 -0400105 break;
106 case Opt_hostdata:
Steven Whitehouse6f04c1c2009-01-06 11:52:25 +0000107 match_strlcpy(args->ar_hostdata, &tmp[0],
108 GFS2_LOCKNAME_LEN);
Josef Bacik476c0062007-04-23 11:55:39 -0400109 break;
110 case Opt_spectator:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000111 args->ar_spectator = 1;
Josef Bacik476c0062007-04-23 11:55:39 -0400112 break;
113 case Opt_ignore_local_fs:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000114 args->ar_ignore_local_fs = 1;
Josef Bacik476c0062007-04-23 11:55:39 -0400115 break;
116 case Opt_localflocks:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000117 args->ar_localflocks = 1;
Josef Bacik476c0062007-04-23 11:55:39 -0400118 break;
119 case Opt_localcaching:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000120 args->ar_localcaching = 1;
Josef Bacik476c0062007-04-23 11:55:39 -0400121 break;
122 case Opt_debug:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000123 args->ar_debug = 1;
Josef Bacik476c0062007-04-23 11:55:39 -0400124 break;
125 case Opt_nodebug:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000126 args->ar_debug = 0;
Josef Bacik476c0062007-04-23 11:55:39 -0400127 break;
128 case Opt_upgrade:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000129 args->ar_upgrade = 1;
Josef Bacik476c0062007-04-23 11:55:39 -0400130 break;
Josef Bacik476c0062007-04-23 11:55:39 -0400131 case Opt_acl:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000132 args->ar_posix_acl = 1;
Josef Bacik476c0062007-04-23 11:55:39 -0400133 break;
134 case Opt_noacl:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000135 args->ar_posix_acl = 0;
Josef Bacik476c0062007-04-23 11:55:39 -0400136 break;
137 case Opt_quota_off:
138 args->ar_quota = GFS2_QUOTA_OFF;
139 break;
140 case Opt_quota_account:
141 args->ar_quota = GFS2_QUOTA_ACCOUNT;
142 break;
143 case Opt_quota_on:
144 args->ar_quota = GFS2_QUOTA_ON;
145 break;
146 case Opt_suiddir:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000147 args->ar_suiddir = 1;
Josef Bacik476c0062007-04-23 11:55:39 -0400148 break;
149 case Opt_nosuiddir:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000150 args->ar_suiddir = 0;
Josef Bacik476c0062007-04-23 11:55:39 -0400151 break;
152 case Opt_data_writeback:
153 args->ar_data = GFS2_DATA_WRITEBACK;
154 break;
155 case Opt_data_ordered:
156 args->ar_data = GFS2_DATA_ORDERED;
157 break;
Steven Whitehouse9b8df982008-08-08 13:45:13 +0100158 case Opt_meta:
Steven Whitehouse9b8df982008-08-08 13:45:13 +0100159 args->ar_meta = 1;
160 break;
Benjamin Marzinski9a5ad132007-08-17 20:22:07 -0500161 case Opt_err:
Josef Bacik476c0062007-04-23 11:55:39 -0400162 default:
Steven Whitehouse6f04c1c2009-01-06 11:52:25 +0000163 fs_info(sdp, "invalid mount option: %s\n", o);
164 return -EINVAL;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000165 }
166 }
167
Steven Whitehouse6f04c1c2009-01-06 11:52:25 +0000168 return 0;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000169}
170