David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. |
Steven Whitehouse | 3a8a9a1 | 2006-05-18 15:09:15 -0400 | [diff] [blame] | 3 | * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 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 |
Steven Whitehouse | e9fc2aa | 2006-09-01 11:05:15 -0400 | [diff] [blame] | 7 | * of the GNU General Public License version 2. |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 10 | #include <linux/slab.h> |
| 11 | #include <linux/spinlock.h> |
| 12 | #include <linux/completion.h> |
| 13 | #include <linux/buffer_head.h> |
Steven Whitehouse | 5c676f6 | 2006-02-27 17:23:27 -0500 | [diff] [blame] | 14 | #include <linux/gfs2_ondisk.h> |
Josef Bacik | 476c006 | 2007-04-23 11:55:39 -0400 | [diff] [blame] | 15 | #include <linux/parser.h> |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 16 | |
| 17 | #include "gfs2.h" |
Steven Whitehouse | 5c676f6 | 2006-02-27 17:23:27 -0500 | [diff] [blame] | 18 | #include "incore.h" |
Steven Whitehouse | 6f04c1c | 2009-01-06 11:52:25 +0000 | [diff] [blame] | 19 | #include "super.h" |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 20 | #include "sys.h" |
Steven Whitehouse | 5c676f6 | 2006-02-27 17:23:27 -0500 | [diff] [blame] | 21 | #include "util.h" |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 22 | |
Josef Bacik | 476c006 | 2007-04-23 11:55:39 -0400 | [diff] [blame] | 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, |
Josef Bacik | 476c006 | 2007-04-23 11:55:39 -0400 | [diff] [blame] | 34 | Opt_acl, |
| 35 | Opt_noacl, |
| 36 | Opt_quota_off, |
| 37 | Opt_quota_account, |
| 38 | Opt_quota_on, |
Steven Whitehouse | b9a9694 | 2009-02-19 10:32:35 +0000 | [diff] [blame] | 39 | Opt_quota, |
| 40 | Opt_noquota, |
Josef Bacik | 476c006 | 2007-04-23 11:55:39 -0400 | [diff] [blame] | 41 | Opt_suiddir, |
| 42 | Opt_nosuiddir, |
| 43 | Opt_data_writeback, |
| 44 | Opt_data_ordered, |
Steven Whitehouse | 9b8df98 | 2008-08-08 13:45:13 +0100 | [diff] [blame] | 45 | Opt_meta, |
Steven Whitehouse | f15ab56 | 2009-02-09 09:25:01 +0000 | [diff] [blame] | 46 | Opt_discard, |
| 47 | Opt_nodiscard, |
Benjamin Marzinski | 9a5ad13 | 2007-08-17 20:22:07 -0500 | [diff] [blame] | 48 | Opt_err, |
Josef Bacik | 476c006 | 2007-04-23 11:55:39 -0400 | [diff] [blame] | 49 | }; |
| 50 | |
Steven Whitehouse | a447c09 | 2008-10-13 10:46:57 +0100 | [diff] [blame] | 51 | static const match_table_t tokens = { |
Josef Bacik | 476c006 | 2007-04-23 11:55:39 -0400 | [diff] [blame] | 52 | {Opt_lockproto, "lockproto=%s"}, |
| 53 | {Opt_locktable, "locktable=%s"}, |
| 54 | {Opt_hostdata, "hostdata=%s"}, |
| 55 | {Opt_spectator, "spectator"}, |
| 56 | {Opt_ignore_local_fs, "ignore_local_fs"}, |
| 57 | {Opt_localflocks, "localflocks"}, |
| 58 | {Opt_localcaching, "localcaching"}, |
| 59 | {Opt_debug, "debug"}, |
| 60 | {Opt_nodebug, "nodebug"}, |
| 61 | {Opt_upgrade, "upgrade"}, |
Josef Bacik | 476c006 | 2007-04-23 11:55:39 -0400 | [diff] [blame] | 62 | {Opt_acl, "acl"}, |
| 63 | {Opt_noacl, "noacl"}, |
| 64 | {Opt_quota_off, "quota=off"}, |
| 65 | {Opt_quota_account, "quota=account"}, |
| 66 | {Opt_quota_on, "quota=on"}, |
Steven Whitehouse | b9a9694 | 2009-02-19 10:32:35 +0000 | [diff] [blame] | 67 | {Opt_quota, "quota"}, |
| 68 | {Opt_noquota, "noquota"}, |
Josef Bacik | 476c006 | 2007-04-23 11:55:39 -0400 | [diff] [blame] | 69 | {Opt_suiddir, "suiddir"}, |
| 70 | {Opt_nosuiddir, "nosuiddir"}, |
| 71 | {Opt_data_writeback, "data=writeback"}, |
Benjamin Marzinski | 9a5ad13 | 2007-08-17 20:22:07 -0500 | [diff] [blame] | 72 | {Opt_data_ordered, "data=ordered"}, |
Steven Whitehouse | 9b8df98 | 2008-08-08 13:45:13 +0100 | [diff] [blame] | 73 | {Opt_meta, "meta"}, |
Steven Whitehouse | f15ab56 | 2009-02-09 09:25:01 +0000 | [diff] [blame] | 74 | {Opt_discard, "discard"}, |
| 75 | {Opt_nodiscard, "nodiscard"}, |
Benjamin Marzinski | 9a5ad13 | 2007-08-17 20:22:07 -0500 | [diff] [blame] | 76 | {Opt_err, NULL} |
Josef Bacik | 476c006 | 2007-04-23 11:55:39 -0400 | [diff] [blame] | 77 | }; |
| 78 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 79 | /** |
| 80 | * gfs2_mount_args - Parse mount options |
| 81 | * @sdp: |
| 82 | * @data: |
| 83 | * |
| 84 | * Return: errno |
| 85 | */ |
| 86 | |
Steven Whitehouse | 6f04c1c | 2009-01-06 11:52:25 +0000 | [diff] [blame] | 87 | int gfs2_mount_args(struct gfs2_sbd *sdp, struct gfs2_args *args, char *options) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 88 | { |
Steven Whitehouse | 6f04c1c | 2009-01-06 11:52:25 +0000 | [diff] [blame] | 89 | char *o; |
| 90 | int token; |
| 91 | substring_t tmp[MAX_OPT_ARGS]; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 92 | |
| 93 | /* Split the options into tokens with the "," character and |
| 94 | process them */ |
| 95 | |
Steven Whitehouse | 6f04c1c | 2009-01-06 11:52:25 +0000 | [diff] [blame] | 96 | while (1) { |
| 97 | o = strsep(&options, ","); |
| 98 | if (o == NULL) |
| 99 | break; |
| 100 | if (*o == '\0') |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 101 | continue; |
| 102 | |
Josef Bacik | 476c006 | 2007-04-23 11:55:39 -0400 | [diff] [blame] | 103 | token = match_token(o, tokens, tmp); |
| 104 | switch (token) { |
| 105 | case Opt_lockproto: |
Steven Whitehouse | 6f04c1c | 2009-01-06 11:52:25 +0000 | [diff] [blame] | 106 | match_strlcpy(args->ar_lockproto, &tmp[0], |
| 107 | GFS2_LOCKNAME_LEN); |
Josef Bacik | 476c006 | 2007-04-23 11:55:39 -0400 | [diff] [blame] | 108 | break; |
| 109 | case Opt_locktable: |
Steven Whitehouse | 6f04c1c | 2009-01-06 11:52:25 +0000 | [diff] [blame] | 110 | match_strlcpy(args->ar_locktable, &tmp[0], |
| 111 | GFS2_LOCKNAME_LEN); |
Josef Bacik | 476c006 | 2007-04-23 11:55:39 -0400 | [diff] [blame] | 112 | break; |
| 113 | case Opt_hostdata: |
Steven Whitehouse | 6f04c1c | 2009-01-06 11:52:25 +0000 | [diff] [blame] | 114 | match_strlcpy(args->ar_hostdata, &tmp[0], |
| 115 | GFS2_LOCKNAME_LEN); |
Josef Bacik | 476c006 | 2007-04-23 11:55:39 -0400 | [diff] [blame] | 116 | break; |
| 117 | case Opt_spectator: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 118 | args->ar_spectator = 1; |
Josef Bacik | 476c006 | 2007-04-23 11:55:39 -0400 | [diff] [blame] | 119 | break; |
| 120 | case Opt_ignore_local_fs: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 121 | args->ar_ignore_local_fs = 1; |
Josef Bacik | 476c006 | 2007-04-23 11:55:39 -0400 | [diff] [blame] | 122 | break; |
| 123 | case Opt_localflocks: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 124 | args->ar_localflocks = 1; |
Josef Bacik | 476c006 | 2007-04-23 11:55:39 -0400 | [diff] [blame] | 125 | break; |
| 126 | case Opt_localcaching: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 127 | args->ar_localcaching = 1; |
Josef Bacik | 476c006 | 2007-04-23 11:55:39 -0400 | [diff] [blame] | 128 | break; |
| 129 | case Opt_debug: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 130 | args->ar_debug = 1; |
Josef Bacik | 476c006 | 2007-04-23 11:55:39 -0400 | [diff] [blame] | 131 | break; |
| 132 | case Opt_nodebug: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 133 | args->ar_debug = 0; |
Josef Bacik | 476c006 | 2007-04-23 11:55:39 -0400 | [diff] [blame] | 134 | break; |
| 135 | case Opt_upgrade: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 136 | args->ar_upgrade = 1; |
Josef Bacik | 476c006 | 2007-04-23 11:55:39 -0400 | [diff] [blame] | 137 | break; |
Josef Bacik | 476c006 | 2007-04-23 11:55:39 -0400 | [diff] [blame] | 138 | case Opt_acl: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 139 | args->ar_posix_acl = 1; |
Josef Bacik | 476c006 | 2007-04-23 11:55:39 -0400 | [diff] [blame] | 140 | break; |
| 141 | case Opt_noacl: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 142 | args->ar_posix_acl = 0; |
Josef Bacik | 476c006 | 2007-04-23 11:55:39 -0400 | [diff] [blame] | 143 | break; |
| 144 | case Opt_quota_off: |
Steven Whitehouse | b9a9694 | 2009-02-19 10:32:35 +0000 | [diff] [blame] | 145 | case Opt_noquota: |
Josef Bacik | 476c006 | 2007-04-23 11:55:39 -0400 | [diff] [blame] | 146 | args->ar_quota = GFS2_QUOTA_OFF; |
| 147 | break; |
| 148 | case Opt_quota_account: |
| 149 | args->ar_quota = GFS2_QUOTA_ACCOUNT; |
| 150 | break; |
| 151 | case Opt_quota_on: |
Steven Whitehouse | b9a9694 | 2009-02-19 10:32:35 +0000 | [diff] [blame] | 152 | case Opt_quota: |
Josef Bacik | 476c006 | 2007-04-23 11:55:39 -0400 | [diff] [blame] | 153 | args->ar_quota = GFS2_QUOTA_ON; |
| 154 | break; |
| 155 | case Opt_suiddir: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 156 | args->ar_suiddir = 1; |
Josef Bacik | 476c006 | 2007-04-23 11:55:39 -0400 | [diff] [blame] | 157 | break; |
| 158 | case Opt_nosuiddir: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 159 | args->ar_suiddir = 0; |
Josef Bacik | 476c006 | 2007-04-23 11:55:39 -0400 | [diff] [blame] | 160 | break; |
| 161 | case Opt_data_writeback: |
| 162 | args->ar_data = GFS2_DATA_WRITEBACK; |
| 163 | break; |
| 164 | case Opt_data_ordered: |
| 165 | args->ar_data = GFS2_DATA_ORDERED; |
| 166 | break; |
Steven Whitehouse | 9b8df98 | 2008-08-08 13:45:13 +0100 | [diff] [blame] | 167 | case Opt_meta: |
Steven Whitehouse | 9b8df98 | 2008-08-08 13:45:13 +0100 | [diff] [blame] | 168 | args->ar_meta = 1; |
| 169 | break; |
Steven Whitehouse | f15ab56 | 2009-02-09 09:25:01 +0000 | [diff] [blame] | 170 | case Opt_discard: |
| 171 | args->ar_discard = 1; |
| 172 | break; |
| 173 | case Opt_nodiscard: |
| 174 | args->ar_discard = 0; |
| 175 | break; |
Benjamin Marzinski | 9a5ad13 | 2007-08-17 20:22:07 -0500 | [diff] [blame] | 176 | case Opt_err: |
Josef Bacik | 476c006 | 2007-04-23 11:55:39 -0400 | [diff] [blame] | 177 | default: |
Steven Whitehouse | 6f04c1c | 2009-01-06 11:52:25 +0000 | [diff] [blame] | 178 | fs_info(sdp, "invalid mount option: %s\n", o); |
| 179 | return -EINVAL; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 180 | } |
| 181 | } |
| 182 | |
Steven Whitehouse | 6f04c1c | 2009-01-06 11:52:25 +0000 | [diff] [blame] | 183 | return 0; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 184 | } |
| 185 | |