super.c (bc95f3669f5e6f63cf0b84fe4922c3c6dd4aa775) | super.c (80c72fe415698049a477314ac82790c1af0fa7e3) |
---|---|
1/* AFS superblock handling 2 * 3 * Copyright (c) 2002, 2007 Red Hat, Inc. All rights reserved. 4 * 5 * This software may be freely redistributed under the terms of the 6 * GNU General Public License. 7 * 8 * You should have received a copy of the GNU General Public License --- 6 unchanged lines hidden (view full) --- 15 */ 16 17#include <linux/kernel.h> 18#include <linux/module.h> 19#include <linux/init.h> 20#include <linux/slab.h> 21#include <linux/fs.h> 22#include <linux/pagemap.h> | 1/* AFS superblock handling 2 * 3 * Copyright (c) 2002, 2007 Red Hat, Inc. All rights reserved. 4 * 5 * This software may be freely redistributed under the terms of the 6 * GNU General Public License. 7 * 8 * You should have received a copy of the GNU General Public License --- 6 unchanged lines hidden (view full) --- 15 */ 16 17#include <linux/kernel.h> 18#include <linux/module.h> 19#include <linux/init.h> 20#include <linux/slab.h> 21#include <linux/fs.h> 22#include <linux/pagemap.h> |
23#include <linux/parser.h> |
|
23#include "internal.h" 24 25#define AFS_FS_MAGIC 0x6B414653 /* 'kAFS' */ 26 27static void afs_i_init_once(void *foo, struct kmem_cache *cachep, 28 unsigned long flags); 29 30static int afs_get_sb(struct file_system_type *fs_type, --- 6 unchanged lines hidden (view full) --- 37 38static void afs_destroy_inode(struct inode *inode); 39 40struct file_system_type afs_fs_type = { 41 .owner = THIS_MODULE, 42 .name = "afs", 43 .get_sb = afs_get_sb, 44 .kill_sb = kill_anon_super, | 24#include "internal.h" 25 26#define AFS_FS_MAGIC 0x6B414653 /* 'kAFS' */ 27 28static void afs_i_init_once(void *foo, struct kmem_cache *cachep, 29 unsigned long flags); 30 31static int afs_get_sb(struct file_system_type *fs_type, --- 6 unchanged lines hidden (view full) --- 38 39static void afs_destroy_inode(struct inode *inode); 40 41struct file_system_type afs_fs_type = { 42 .owner = THIS_MODULE, 43 .name = "afs", 44 .get_sb = afs_get_sb, 45 .kill_sb = kill_anon_super, |
45 .fs_flags = FS_BINARY_MOUNTDATA, | 46 .fs_flags = 0, |
46}; 47 48static const struct super_operations afs_super_ops = { 49 .statfs = simple_statfs, 50 .alloc_inode = afs_alloc_inode, 51 .drop_inode = generic_delete_inode, 52 .destroy_inode = afs_destroy_inode, 53 .clear_inode = afs_clear_inode, 54 .umount_begin = afs_umount_begin, 55 .put_super = afs_put_super, 56}; 57 58static struct kmem_cache *afs_inode_cachep; 59static atomic_t afs_count_active_inodes; 60 | 47}; 48 49static const struct super_operations afs_super_ops = { 50 .statfs = simple_statfs, 51 .alloc_inode = afs_alloc_inode, 52 .drop_inode = generic_delete_inode, 53 .destroy_inode = afs_destroy_inode, 54 .clear_inode = afs_clear_inode, 55 .umount_begin = afs_umount_begin, 56 .put_super = afs_put_super, 57}; 58 59static struct kmem_cache *afs_inode_cachep; 60static atomic_t afs_count_active_inodes; 61 |
62enum { 63 afs_no_opt, 64 afs_opt_cell, 65 afs_opt_rwpath, 66 afs_opt_vol, 67}; 68 69static const match_table_t afs_options_list = { 70 { afs_opt_cell, "cell=%s" }, 71 { afs_opt_rwpath, "rwpath" }, 72 { afs_opt_vol, "vol=%s" }, 73 { afs_no_opt, NULL }, 74}; 75 |
|
61/* 62 * initialise the filesystem 63 */ 64int __init afs_fs_init(void) 65{ 66 int ret; 67 68 _enter(""); --- 41 unchanged lines hidden (view full) --- 110 BUG(); 111 } 112 113 kmem_cache_destroy(afs_inode_cachep); 114 _leave(""); 115} 116 117/* | 76/* 77 * initialise the filesystem 78 */ 79int __init afs_fs_init(void) 80{ 81 int ret; 82 83 _enter(""); --- 41 unchanged lines hidden (view full) --- 125 BUG(); 126 } 127 128 kmem_cache_destroy(afs_inode_cachep); 129 _leave(""); 130} 131 132/* |
118 * check that an argument has a value 119 */ 120static int want_arg(char **_value, const char *option) 121{ 122 if (!_value || !*_value || !**_value) { 123 printk(KERN_NOTICE "kAFS: %s: argument missing\n", option); 124 return 0; 125 } 126 return 1; 127} 128 129/* 130 * check that there's no subsequent value 131 */ 132static int want_no_value(char *const *_value, const char *option) 133{ 134 if (*_value && **_value) { 135 printk(KERN_NOTICE "kAFS: %s: Invalid argument: %s\n", 136 option, *_value); 137 return 0; 138 } 139 return 1; 140} 141 142/* | |
143 * parse the mount options 144 * - this function has been shamelessly adapted from the ext3 fs which 145 * shamelessly adapted it from the msdos fs 146 */ 147static int afs_parse_options(struct afs_mount_params *params, 148 char *options, const char **devname) 149{ 150 struct afs_cell *cell; | 133 * parse the mount options 134 * - this function has been shamelessly adapted from the ext3 fs which 135 * shamelessly adapted it from the msdos fs 136 */ 137static int afs_parse_options(struct afs_mount_params *params, 138 char *options, const char **devname) 139{ 140 struct afs_cell *cell; |
151 char *key, *value; 152 int ret; | 141 substring_t args[MAX_OPT_ARGS]; 142 char *p; 143 int token; |
153 154 _enter("%s", options); 155 156 options[PAGE_SIZE - 1] = 0; 157 | 144 145 _enter("%s", options); 146 147 options[PAGE_SIZE - 1] = 0; 148 |
158 ret = 0; 159 while ((key = strsep(&options, ","))) { 160 value = strchr(key, '='); 161 if (value) 162 *value++ = 0; | 149 while ((p = strsep(&options, ","))) { 150 if (!*p) 151 continue; |
163 | 152 |
164 _debug("kAFS: KEY: %s, VAL:%s", key, value ?: "-"); 165 166 if (strcmp(key, "rwpath") == 0) { 167 if (!want_no_value(&value, "rwpath")) 168 return -EINVAL; 169 params->rwpath = 1; 170 } else if (strcmp(key, "vol") == 0) { 171 if (!want_arg(&value, "vol")) 172 return -EINVAL; 173 *devname = value; 174 } else if (strcmp(key, "cell") == 0) { 175 if (!want_arg(&value, "cell")) 176 return -EINVAL; 177 cell = afs_cell_lookup(value, strlen(value)); | 153 token = match_token(p, afs_options_list, args); 154 switch (token) { 155 case afs_opt_cell: 156 cell = afs_cell_lookup(args[0].from, 157 args[0].to - args[0].from); |
178 if (IS_ERR(cell)) 179 return PTR_ERR(cell); 180 afs_put_cell(params->cell); 181 params->cell = cell; | 158 if (IS_ERR(cell)) 159 return PTR_ERR(cell); 160 afs_put_cell(params->cell); 161 params->cell = cell; |
182 } else { 183 printk("kAFS: Unknown mount option: '%s'\n", key); 184 ret = -EINVAL; 185 goto error; | 162 break; 163 164 case afs_opt_rwpath: 165 params->rwpath = 1; 166 break; 167 168 case afs_opt_vol: 169 *devname = args[0].from; 170 break; 171 172 default: 173 printk(KERN_ERR "kAFS:" 174 " Unknown or invalid mount option: '%s'\n", p); 175 return -EINVAL; |
186 } 187 } 188 | 176 } 177 } 178 |
189 ret = 0; 190error: 191 _leave(" = %d", ret); 192 return ret; | 179 _leave(" = 0"); 180 return 0; |
193} 194 195/* 196 * parse a device name to get cell name, volume name, volume type and R/W 197 * selector 198 * - this can be one of the following: 199 * "%[cell:]volume[.]" R/W volume 200 * "#[cell:]volume[.]" R/O or R/W volume (rwpath=0), --- 155 unchanged lines hidden (view full) --- 356 sb->s_fs_info = NULL; 357 358 _leave(" = %d", ret); 359 return ret; 360} 361 362/* 363 * get an AFS superblock | 181} 182 183/* 184 * parse a device name to get cell name, volume name, volume type and R/W 185 * selector 186 * - this can be one of the following: 187 * "%[cell:]volume[.]" R/W volume 188 * "#[cell:]volume[.]" R/O or R/W volume (rwpath=0), --- 155 unchanged lines hidden (view full) --- 344 sb->s_fs_info = NULL; 345 346 _leave(" = %d", ret); 347 return ret; 348} 349 350/* 351 * get an AFS superblock |
364 * - TODO: don't use get_sb_nodev(), but rather call sget() directly | |
365 */ 366static int afs_get_sb(struct file_system_type *fs_type, 367 int flags, 368 const char *dev_name, 369 void *options, 370 struct vfsmount *mnt) 371{ 372 struct afs_mount_params params; --- 8 unchanged lines hidden (view full) --- 381 382 /* parse the options and device name */ 383 if (options) { 384 ret = afs_parse_options(¶ms, options, &dev_name); 385 if (ret < 0) 386 goto error; 387 } 388 | 352 */ 353static int afs_get_sb(struct file_system_type *fs_type, 354 int flags, 355 const char *dev_name, 356 void *options, 357 struct vfsmount *mnt) 358{ 359 struct afs_mount_params params; --- 8 unchanged lines hidden (view full) --- 368 369 /* parse the options and device name */ 370 if (options) { 371 ret = afs_parse_options(¶ms, options, &dev_name); 372 if (ret < 0) 373 goto error; 374 } 375 |
389 | |
390 ret = afs_parse_device_name(¶ms, dev_name); 391 if (ret < 0) 392 goto error; 393 394 /* try and do the mount securely */ 395 key = afs_request_key(params.cell); 396 if (IS_ERR(key)) { 397 _leave(" = %ld [key]", PTR_ERR(key)); --- 124 unchanged lines hidden --- | 376 ret = afs_parse_device_name(¶ms, dev_name); 377 if (ret < 0) 378 goto error; 379 380 /* try and do the mount securely */ 381 key = afs_request_key(params.cell); 382 if (IS_ERR(key)) { 383 _leave(" = %ld [key]", PTR_ERR(key)); --- 124 unchanged lines hidden --- |