diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-07-28 15:14:43 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-07-28 15:14:43 -0400 |
commit | 414f746d232d41ed6ae8632c4495ae795373c44b (patch) | |
tree | 167f9bc8f139c6e82e6732b38c7a938b8a9d31cd /fs | |
parent | 5a7a201c51c324876d00a54e7208af6af12d1ca4 (diff) | |
parent | c9272c4f9fbe2087beb3392f526dc5b19efaa56b (diff) |
Merge branch 'linus' into cpus4096
Diffstat (limited to 'fs')
152 files changed, 3147 insertions, 1791 deletions
diff --git a/fs/Kconfig b/fs/Kconfig index 97e3bdedb1e6..d3873583360b 100644 --- a/fs/Kconfig +++ b/fs/Kconfig | |||
@@ -1383,6 +1383,19 @@ config MINIX_FS | |||
1383 | partition (the one containing the directory /) cannot be compiled as | 1383 | partition (the one containing the directory /) cannot be compiled as |
1384 | a module. | 1384 | a module. |
1385 | 1385 | ||
1386 | config OMFS_FS | ||
1387 | tristate "SonicBlue Optimized MPEG File System support" | ||
1388 | depends on BLOCK | ||
1389 | select CRC_ITU_T | ||
1390 | help | ||
1391 | This is the proprietary file system used by the Rio Karma music | ||
1392 | player and ReplayTV DVR. Despite the name, this filesystem is not | ||
1393 | more efficient than a standard FS for MPEG files, in fact likely | ||
1394 | the opposite is true. Say Y if you have either of these devices | ||
1395 | and wish to mount its disk. | ||
1396 | |||
1397 | To compile this file system support as a module, choose M here: the | ||
1398 | module will be called omfs. If unsure, say N. | ||
1386 | 1399 | ||
1387 | config HPFS_FS | 1400 | config HPFS_FS |
1388 | tristate "OS/2 HPFS file system support" | 1401 | tristate "OS/2 HPFS file system support" |
diff --git a/fs/Makefile b/fs/Makefile index 3b2178b4bb66..a1482a5eff15 100644 --- a/fs/Makefile +++ b/fs/Makefile | |||
@@ -111,6 +111,7 @@ obj-$(CONFIG_ADFS_FS) += adfs/ | |||
111 | obj-$(CONFIG_FUSE_FS) += fuse/ | 111 | obj-$(CONFIG_FUSE_FS) += fuse/ |
112 | obj-$(CONFIG_UDF_FS) += udf/ | 112 | obj-$(CONFIG_UDF_FS) += udf/ |
113 | obj-$(CONFIG_SUN_OPENPROMFS) += openpromfs/ | 113 | obj-$(CONFIG_SUN_OPENPROMFS) += openpromfs/ |
114 | obj-$(CONFIG_OMFS_FS) += omfs/ | ||
114 | obj-$(CONFIG_JFS_FS) += jfs/ | 115 | obj-$(CONFIG_JFS_FS) += jfs/ |
115 | obj-$(CONFIG_XFS_FS) += xfs/ | 116 | obj-$(CONFIG_XFS_FS) += xfs/ |
116 | obj-$(CONFIG_9P_FS) += 9p/ | 117 | obj-$(CONFIG_9P_FS) += 9p/ |
diff --git a/fs/adfs/super.c b/fs/adfs/super.c index 9e421eeb672b..26f3b43726bb 100644 --- a/fs/adfs/super.c +++ b/fs/adfs/super.c | |||
@@ -249,7 +249,7 @@ static void adfs_destroy_inode(struct inode *inode) | |||
249 | kmem_cache_free(adfs_inode_cachep, ADFS_I(inode)); | 249 | kmem_cache_free(adfs_inode_cachep, ADFS_I(inode)); |
250 | } | 250 | } |
251 | 251 | ||
252 | static void init_once(struct kmem_cache *cachep, void *foo) | 252 | static void init_once(void *foo) |
253 | { | 253 | { |
254 | struct adfs_inode_info *ei = (struct adfs_inode_info *) foo; | 254 | struct adfs_inode_info *ei = (struct adfs_inode_info *) foo; |
255 | 255 | ||
diff --git a/fs/affs/affs.h b/fs/affs/affs.h index 223b1917093e..e9ec915f7553 100644 --- a/fs/affs/affs.h +++ b/fs/affs/affs.h | |||
@@ -2,6 +2,7 @@ | |||
2 | #include <linux/fs.h> | 2 | #include <linux/fs.h> |
3 | #include <linux/buffer_head.h> | 3 | #include <linux/buffer_head.h> |
4 | #include <linux/amigaffs.h> | 4 | #include <linux/amigaffs.h> |
5 | #include <linux/mutex.h> | ||
5 | 6 | ||
6 | /* AmigaOS allows file names with up to 30 characters length. | 7 | /* AmigaOS allows file names with up to 30 characters length. |
7 | * Names longer than that will be silently truncated. If you | 8 | * Names longer than that will be silently truncated. If you |
@@ -98,7 +99,7 @@ struct affs_sb_info { | |||
98 | gid_t s_gid; /* gid to override */ | 99 | gid_t s_gid; /* gid to override */ |
99 | umode_t s_mode; /* mode to override */ | 100 | umode_t s_mode; /* mode to override */ |
100 | struct buffer_head *s_root_bh; /* Cached root block. */ | 101 | struct buffer_head *s_root_bh; /* Cached root block. */ |
101 | struct semaphore s_bmlock; /* Protects bitmap access. */ | 102 | struct mutex s_bmlock; /* Protects bitmap access. */ |
102 | struct affs_bm_info *s_bitmap; /* Bitmap infos. */ | 103 | struct affs_bm_info *s_bitmap; /* Bitmap infos. */ |
103 | u32 s_bmap_count; /* # of bitmap blocks. */ | 104 | u32 s_bmap_count; /* # of bitmap blocks. */ |
104 | u32 s_bmap_bits; /* # of bits in one bitmap blocks */ | 105 | u32 s_bmap_bits; /* # of bits in one bitmap blocks */ |
diff --git a/fs/affs/bitmap.c b/fs/affs/bitmap.c index c4a5ad09ddf2..dc5ef14bdc1c 100644 --- a/fs/affs/bitmap.c +++ b/fs/affs/bitmap.c | |||
@@ -45,14 +45,14 @@ affs_count_free_blocks(struct super_block *sb) | |||
45 | if (sb->s_flags & MS_RDONLY) | 45 | if (sb->s_flags & MS_RDONLY) |
46 | return 0; | 46 | return 0; |
47 | 47 | ||
48 | down(&AFFS_SB(sb)->s_bmlock); | 48 | mutex_lock(&AFFS_SB(sb)->s_bmlock); |
49 | 49 | ||
50 | bm = AFFS_SB(sb)->s_bitmap; | 50 | bm = AFFS_SB(sb)->s_bitmap; |
51 | free = 0; | 51 | free = 0; |
52 | for (i = AFFS_SB(sb)->s_bmap_count; i > 0; bm++, i--) | 52 | for (i = AFFS_SB(sb)->s_bmap_count; i > 0; bm++, i--) |
53 | free += bm->bm_free; | 53 | free += bm->bm_free; |
54 | 54 | ||
55 | up(&AFFS_SB(sb)->s_bmlock); | 55 | mutex_unlock(&AFFS_SB(sb)->s_bmlock); |
56 | 56 | ||
57 | return free; | 57 | return free; |
58 | } | 58 | } |
@@ -76,7 +76,7 @@ affs_free_block(struct super_block *sb, u32 block) | |||
76 | bit = blk % sbi->s_bmap_bits; | 76 | bit = blk % sbi->s_bmap_bits; |
77 | bm = &sbi->s_bitmap[bmap]; | 77 | bm = &sbi->s_bitmap[bmap]; |
78 | 78 | ||
79 | down(&sbi->s_bmlock); | 79 | mutex_lock(&sbi->s_bmlock); |
80 | 80 | ||
81 | bh = sbi->s_bmap_bh; | 81 | bh = sbi->s_bmap_bh; |
82 | if (sbi->s_last_bmap != bmap) { | 82 | if (sbi->s_last_bmap != bmap) { |
@@ -105,19 +105,19 @@ affs_free_block(struct super_block *sb, u32 block) | |||
105 | sb->s_dirt = 1; | 105 | sb->s_dirt = 1; |
106 | bm->bm_free++; | 106 | bm->bm_free++; |
107 | 107 | ||
108 | up(&sbi->s_bmlock); | 108 | mutex_unlock(&sbi->s_bmlock); |
109 | return; | 109 | return; |
110 | 110 | ||
111 | err_free: | 111 | err_free: |
112 | affs_warning(sb,"affs_free_block","Trying to free block %u which is already free", block); | 112 | affs_warning(sb,"affs_free_block","Trying to free block %u which is already free", block); |
113 | up(&sbi->s_bmlock); | 113 | mutex_unlock(&sbi->s_bmlock); |
114 | return; | 114 | return; |
115 | 115 | ||
116 | err_bh_read: | 116 | err_bh_read: |
117 | affs_error(sb,"affs_free_block","Cannot read bitmap block %u", bm->bm_key); | 117 | affs_error(sb,"affs_free_block","Cannot read bitmap block %u", bm->bm_key); |
118 | sbi->s_bmap_bh = NULL; | 118 | sbi->s_bmap_bh = NULL; |
119 | sbi->s_last_bmap = ~0; | 119 | sbi->s_last_bmap = ~0; |
120 | up(&sbi->s_bmlock); | 120 | mutex_unlock(&sbi->s_bmlock); |
121 | return; | 121 | return; |
122 | 122 | ||
123 | err_range: | 123 | err_range: |
@@ -168,7 +168,7 @@ affs_alloc_block(struct inode *inode, u32 goal) | |||
168 | bmap = blk / sbi->s_bmap_bits; | 168 | bmap = blk / sbi->s_bmap_bits; |
169 | bm = &sbi->s_bitmap[bmap]; | 169 | bm = &sbi->s_bitmap[bmap]; |
170 | 170 | ||
171 | down(&sbi->s_bmlock); | 171 | mutex_lock(&sbi->s_bmlock); |
172 | 172 | ||
173 | if (bm->bm_free) | 173 | if (bm->bm_free) |
174 | goto find_bmap_bit; | 174 | goto find_bmap_bit; |
@@ -249,7 +249,7 @@ find_bit: | |||
249 | mark_buffer_dirty(bh); | 249 | mark_buffer_dirty(bh); |
250 | sb->s_dirt = 1; | 250 | sb->s_dirt = 1; |
251 | 251 | ||
252 | up(&sbi->s_bmlock); | 252 | mutex_unlock(&sbi->s_bmlock); |
253 | 253 | ||
254 | pr_debug("%d\n", blk); | 254 | pr_debug("%d\n", blk); |
255 | return blk; | 255 | return blk; |
@@ -259,7 +259,7 @@ err_bh_read: | |||
259 | sbi->s_bmap_bh = NULL; | 259 | sbi->s_bmap_bh = NULL; |
260 | sbi->s_last_bmap = ~0; | 260 | sbi->s_last_bmap = ~0; |
261 | err_full: | 261 | err_full: |
262 | up(&sbi->s_bmlock); | 262 | mutex_unlock(&sbi->s_bmlock); |
263 | pr_debug("failed\n"); | 263 | pr_debug("failed\n"); |
264 | return 0; | 264 | return 0; |
265 | } | 265 | } |
diff --git a/fs/affs/file.c b/fs/affs/file.c index 6eac7bdeec94..1377b1240b6e 100644 --- a/fs/affs/file.c +++ b/fs/affs/file.c | |||
@@ -46,8 +46,6 @@ const struct inode_operations affs_file_inode_operations = { | |||
46 | static int | 46 | static int |
47 | affs_file_open(struct inode *inode, struct file *filp) | 47 | affs_file_open(struct inode *inode, struct file *filp) |
48 | { | 48 | { |
49 | if (atomic_read(&filp->f_count) != 1) | ||
50 | return 0; | ||
51 | pr_debug("AFFS: open(%lu,%d)\n", | 49 | pr_debug("AFFS: open(%lu,%d)\n", |
52 | inode->i_ino, atomic_read(&AFFS_I(inode)->i_opencnt)); | 50 | inode->i_ino, atomic_read(&AFFS_I(inode)->i_opencnt)); |
53 | atomic_inc(&AFFS_I(inode)->i_opencnt); | 51 | atomic_inc(&AFFS_I(inode)->i_opencnt); |
@@ -57,8 +55,6 @@ affs_file_open(struct inode *inode, struct file *filp) | |||
57 | static int | 55 | static int |
58 | affs_file_release(struct inode *inode, struct file *filp) | 56 | affs_file_release(struct inode *inode, struct file *filp) |
59 | { | 57 | { |
60 | if (atomic_read(&filp->f_count) != 0) | ||
61 | return 0; | ||
62 | pr_debug("AFFS: release(%lu, %d)\n", | 58 | pr_debug("AFFS: release(%lu, %d)\n", |
63 | inode->i_ino, atomic_read(&AFFS_I(inode)->i_opencnt)); | 59 | inode->i_ino, atomic_read(&AFFS_I(inode)->i_opencnt)); |
64 | 60 | ||
diff --git a/fs/affs/super.c b/fs/affs/super.c index d214837d5e42..3a89094f93d0 100644 --- a/fs/affs/super.c +++ b/fs/affs/super.c | |||
@@ -90,7 +90,7 @@ static void affs_destroy_inode(struct inode *inode) | |||
90 | kmem_cache_free(affs_inode_cachep, AFFS_I(inode)); | 90 | kmem_cache_free(affs_inode_cachep, AFFS_I(inode)); |
91 | } | 91 | } |
92 | 92 | ||
93 | static void init_once(struct kmem_cache *cachep, void *foo) | 93 | static void init_once(void *foo) |
94 | { | 94 | { |
95 | struct affs_inode_info *ei = (struct affs_inode_info *) foo; | 95 | struct affs_inode_info *ei = (struct affs_inode_info *) foo; |
96 | 96 | ||
@@ -290,7 +290,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent) | |||
290 | if (!sbi) | 290 | if (!sbi) |
291 | return -ENOMEM; | 291 | return -ENOMEM; |
292 | sb->s_fs_info = sbi; | 292 | sb->s_fs_info = sbi; |
293 | init_MUTEX(&sbi->s_bmlock); | 293 | mutex_init(&sbi->s_bmlock); |
294 | 294 | ||
295 | if (!parse_options(data,&uid,&gid,&i,&reserved,&root_block, | 295 | if (!parse_options(data,&uid,&gid,&i,&reserved,&root_block, |
296 | &blocksize,&sbi->s_prefix, | 296 | &blocksize,&sbi->s_prefix, |
diff --git a/fs/afs/internal.h b/fs/afs/internal.h index 7102824ba847..3cb6920ff30b 100644 --- a/fs/afs/internal.h +++ b/fs/afs/internal.h | |||
@@ -469,8 +469,6 @@ extern bool afs_cm_incoming_call(struct afs_call *); | |||
469 | extern const struct inode_operations afs_dir_inode_operations; | 469 | extern const struct inode_operations afs_dir_inode_operations; |
470 | extern const struct file_operations afs_dir_file_operations; | 470 | extern const struct file_operations afs_dir_file_operations; |
471 | 471 | ||
472 | extern int afs_permission(struct inode *, int, struct nameidata *); | ||
473 | |||
474 | /* | 472 | /* |
475 | * file.c | 473 | * file.c |
476 | */ | 474 | */ |
@@ -605,7 +603,7 @@ extern void afs_clear_permits(struct afs_vnode *); | |||
605 | extern void afs_cache_permit(struct afs_vnode *, struct key *, long); | 603 | extern void afs_cache_permit(struct afs_vnode *, struct key *, long); |
606 | extern void afs_zap_permits(struct rcu_head *); | 604 | extern void afs_zap_permits(struct rcu_head *); |
607 | extern struct key *afs_request_key(struct afs_cell *); | 605 | extern struct key *afs_request_key(struct afs_cell *); |
608 | extern int afs_permission(struct inode *, int, struct nameidata *); | 606 | extern int afs_permission(struct inode *, int); |
609 | 607 | ||
610 | /* | 608 | /* |
611 | * server.c | 609 | * server.c |
diff --git a/fs/afs/security.c b/fs/afs/security.c index 3bcbeceba1bb..3ef504370034 100644 --- a/fs/afs/security.c +++ b/fs/afs/security.c | |||
@@ -284,7 +284,7 @@ static int afs_check_permit(struct afs_vnode *vnode, struct key *key, | |||
284 | * - AFS ACLs are attached to directories only, and a file is controlled by its | 284 | * - AFS ACLs are attached to directories only, and a file is controlled by its |
285 | * parent directory's ACL | 285 | * parent directory's ACL |
286 | */ | 286 | */ |
287 | int afs_permission(struct inode *inode, int mask, struct nameidata *nd) | 287 | int afs_permission(struct inode *inode, int mask) |
288 | { | 288 | { |
289 | struct afs_vnode *vnode = AFS_FS_I(inode); | 289 | struct afs_vnode *vnode = AFS_FS_I(inode); |
290 | afs_access_t uninitialized_var(access); | 290 | afs_access_t uninitialized_var(access); |
diff --git a/fs/afs/super.c b/fs/afs/super.c index 7e3faeef6818..250d8c4d66e4 100644 --- a/fs/afs/super.c +++ b/fs/afs/super.c | |||
@@ -27,7 +27,7 @@ | |||
27 | 27 | ||
28 | #define AFS_FS_MAGIC 0x6B414653 /* 'kAFS' */ | 28 | #define AFS_FS_MAGIC 0x6B414653 /* 'kAFS' */ |
29 | 29 | ||
30 | static void afs_i_init_once(struct kmem_cache *cachep, void *foo); | 30 | static void afs_i_init_once(void *foo); |
31 | static int afs_get_sb(struct file_system_type *fs_type, | 31 | static int afs_get_sb(struct file_system_type *fs_type, |
32 | int flags, const char *dev_name, | 32 | int flags, const char *dev_name, |
33 | void *data, struct vfsmount *mnt); | 33 | void *data, struct vfsmount *mnt); |
@@ -449,7 +449,7 @@ static void afs_put_super(struct super_block *sb) | |||
449 | /* | 449 | /* |
450 | * initialise an inode cache slab element prior to any use | 450 | * initialise an inode cache slab element prior to any use |
451 | */ | 451 | */ |
452 | static void afs_i_init_once(struct kmem_cache *cachep, void *_vnode) | 452 | static void afs_i_init_once(void *_vnode) |
453 | { | 453 | { |
454 | struct afs_vnode *vnode = _vnode; | 454 | struct afs_vnode *vnode = _vnode; |
455 | 455 | ||
@@ -512,8 +512,8 @@ static void aio_fput_routine(struct work_struct *data) | |||
512 | */ | 512 | */ |
513 | static int __aio_put_req(struct kioctx *ctx, struct kiocb *req) | 513 | static int __aio_put_req(struct kioctx *ctx, struct kiocb *req) |
514 | { | 514 | { |
515 | dprintk(KERN_DEBUG "aio_put(%p): f_count=%d\n", | 515 | dprintk(KERN_DEBUG "aio_put(%p): f_count=%ld\n", |
516 | req, atomic_read(&req->ki_filp->f_count)); | 516 | req, atomic_long_read(&req->ki_filp->f_count)); |
517 | 517 | ||
518 | assert_spin_locked(&ctx->ctx_lock); | 518 | assert_spin_locked(&ctx->ctx_lock); |
519 | 519 | ||
@@ -528,7 +528,7 @@ static int __aio_put_req(struct kioctx *ctx, struct kiocb *req) | |||
528 | /* Must be done under the lock to serialise against cancellation. | 528 | /* Must be done under the lock to serialise against cancellation. |
529 | * Call this aio_fput as it duplicates fput via the fput_work. | 529 | * Call this aio_fput as it duplicates fput via the fput_work. |
530 | */ | 530 | */ |
531 | if (unlikely(atomic_dec_and_test(&req->ki_filp->f_count))) { | 531 | if (unlikely(atomic_long_dec_and_test(&req->ki_filp->f_count))) { |
532 | get_ioctx(ctx); | 532 | get_ioctx(ctx); |
533 | spin_lock(&fput_lock); | 533 | spin_lock(&fput_lock); |
534 | list_add(&req->ki_list, &fput_head); | 534 | list_add(&req->ki_list, &fput_head); |
@@ -51,7 +51,7 @@ int inode_change_ok(struct inode *inode, struct iattr *attr) | |||
51 | } | 51 | } |
52 | 52 | ||
53 | /* Check for setting the inode time. */ | 53 | /* Check for setting the inode time. */ |
54 | if (ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET)) { | 54 | if (ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET | ATTR_TIMES_SET)) { |
55 | if (!is_owner_or_cap(inode)) | 55 | if (!is_owner_or_cap(inode)) |
56 | goto error; | 56 | goto error; |
57 | } | 57 | } |
@@ -108,6 +108,11 @@ int notify_change(struct dentry * dentry, struct iattr * attr) | |||
108 | struct timespec now; | 108 | struct timespec now; |
109 | unsigned int ia_valid = attr->ia_valid; | 109 | unsigned int ia_valid = attr->ia_valid; |
110 | 110 | ||
111 | if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) { | ||
112 | if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) | ||
113 | return -EPERM; | ||
114 | } | ||
115 | |||
111 | now = current_fs_time(inode->i_sb); | 116 | now = current_fs_time(inode->i_sb); |
112 | 117 | ||
113 | attr->ia_ctime = now; | 118 | attr->ia_ctime = now; |
diff --git a/fs/bad_inode.c b/fs/bad_inode.c index f1c2ea8342f5..5f1538c03b1b 100644 --- a/fs/bad_inode.c +++ b/fs/bad_inode.c | |||
@@ -243,8 +243,7 @@ static int bad_inode_readlink(struct dentry *dentry, char __user *buffer, | |||
243 | return -EIO; | 243 | return -EIO; |
244 | } | 244 | } |
245 | 245 | ||
246 | static int bad_inode_permission(struct inode *inode, int mask, | 246 | static int bad_inode_permission(struct inode *inode, int mask) |
247 | struct nameidata *nd) | ||
248 | { | 247 | { |
249 | return -EIO; | 248 | return -EIO; |
250 | } | 249 | } |
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c index e8717de3bab3..02c6e62b72f8 100644 --- a/fs/befs/linuxvfs.c +++ b/fs/befs/linuxvfs.c | |||
@@ -289,7 +289,7 @@ befs_destroy_inode(struct inode *inode) | |||
289 | kmem_cache_free(befs_inode_cachep, BEFS_I(inode)); | 289 | kmem_cache_free(befs_inode_cachep, BEFS_I(inode)); |
290 | } | 290 | } |
291 | 291 | ||
292 | static void init_once(struct kmem_cache *cachep, void *foo) | 292 | static void init_once(void *foo) |
293 | { | 293 | { |
294 | struct befs_inode_info *bi = (struct befs_inode_info *) foo; | 294 | struct befs_inode_info *bi = (struct befs_inode_info *) foo; |
295 | 295 | ||
diff --git a/fs/bfs/bfs.h b/fs/bfs/bfs.h index 70f5d3a8eede..7109e451abf7 100644 --- a/fs/bfs/bfs.h +++ b/fs/bfs/bfs.h | |||
@@ -16,8 +16,9 @@ struct bfs_sb_info { | |||
16 | unsigned long si_freei; | 16 | unsigned long si_freei; |
17 | unsigned long si_lf_eblk; | 17 | unsigned long si_lf_eblk; |
18 | unsigned long si_lasti; | 18 | unsigned long si_lasti; |
19 | unsigned long * si_imap; | 19 | unsigned long *si_imap; |
20 | struct buffer_head * si_sbh; /* buffer header w/superblock */ | 20 | struct buffer_head *si_sbh; /* buffer header w/superblock */ |
21 | struct mutex bfs_lock; | ||
21 | }; | 22 | }; |
22 | 23 | ||
23 | /* | 24 | /* |
diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c index 034950cb3cbe..87ee5ccee348 100644 --- a/fs/bfs/dir.c +++ b/fs/bfs/dir.c | |||
@@ -32,16 +32,17 @@ static int bfs_readdir(struct file *f, void *dirent, filldir_t filldir) | |||
32 | struct inode *dir = f->f_path.dentry->d_inode; | 32 | struct inode *dir = f->f_path.dentry->d_inode; |
33 | struct buffer_head *bh; | 33 | struct buffer_head *bh; |
34 | struct bfs_dirent *de; | 34 | struct bfs_dirent *de; |
35 | struct bfs_sb_info *info = BFS_SB(dir->i_sb); | ||
35 | unsigned int offset; | 36 | unsigned int offset; |
36 | int block; | 37 | int block; |
37 | 38 | ||
38 | lock_kernel(); | 39 | mutex_lock(&info->bfs_lock); |
39 | 40 | ||
40 | if (f->f_pos & (BFS_DIRENT_SIZE - 1)) { | 41 | if (f->f_pos & (BFS_DIRENT_SIZE - 1)) { |
41 | printf("Bad f_pos=%08lx for %s:%08lx\n", | 42 | printf("Bad f_pos=%08lx for %s:%08lx\n", |
42 | (unsigned long)f->f_pos, | 43 | (unsigned long)f->f_pos, |
43 | dir->i_sb->s_id, dir->i_ino); | 44 | dir->i_sb->s_id, dir->i_ino); |
44 | unlock_kernel(); | 45 | mutex_unlock(&info->bfs_lock); |
45 | return -EBADF; | 46 | return -EBADF; |
46 | } | 47 | } |
47 | 48 | ||
@@ -61,7 +62,7 @@ static int bfs_readdir(struct file *f, void *dirent, filldir_t filldir) | |||
61 | le16_to_cpu(de->ino), | 62 | le16_to_cpu(de->ino), |
62 | DT_UNKNOWN) < 0) { | 63 | DT_UNKNOWN) < 0) { |
63 | brelse(bh); | 64 | brelse(bh); |
64 | unlock_kernel(); | 65 | mutex_unlock(&info->bfs_lock); |
65 | return 0; | 66 | return 0; |
66 | } | 67 | } |
67 | } | 68 | } |
@@ -71,7 +72,7 @@ static int bfs_readdir(struct file *f, void *dirent, filldir_t filldir) | |||
71 | brelse(bh); | 72 | brelse(bh); |
72 | } | 73 | } |
73 | 74 | ||
74 | unlock_kernel(); | 75 | mutex_unlock(&info->bfs_lock); |
75 | return 0; | 76 | return 0; |
76 | } | 77 | } |
77 | 78 | ||
@@ -95,10 +96,10 @@ static int bfs_create(struct inode *dir, struct dentry *dentry, int mode, | |||
95 | inode = new_inode(s); | 96 | inode = new_inode(s); |
96 | if (!inode) | 97 | if (!inode) |
97 | return -ENOSPC; | 98 | return -ENOSPC; |
98 | lock_kernel(); | 99 | mutex_lock(&info->bfs_lock); |
99 | ino = find_first_zero_bit(info->si_imap, info->si_lasti); | 100 | ino = find_first_zero_bit(info->si_imap, info->si_lasti); |
100 | if (ino > info->si_lasti) { | 101 | if (ino > info->si_lasti) { |
101 | unlock_kernel(); | 102 | mutex_unlock(&info->bfs_lock); |
102 | iput(inode); | 103 | iput(inode); |
103 | return -ENOSPC; | 104 | return -ENOSPC; |
104 | } | 105 | } |
@@ -125,10 +126,10 @@ static int bfs_create(struct inode *dir, struct dentry *dentry, int mode, | |||
125 | if (err) { | 126 | if (err) { |
126 | inode_dec_link_count(inode); | 127 | inode_dec_link_count(inode); |
127 | iput(inode); | 128 | iput(inode); |
128 | unlock_kernel(); | 129 | mutex_unlock(&info->bfs_lock); |
129 | return err; | 130 | return err; |
130 | } | 131 | } |
131 | unlock_kernel(); | 132 | mutex_unlock(&info->bfs_lock); |
132 | d_instantiate(dentry, inode); | 133 | d_instantiate(dentry, inode); |
133 | return 0; | 134 | return 0; |
134 | } | 135 | } |
@@ -139,22 +140,23 @@ static struct dentry *bfs_lookup(struct inode *dir, struct dentry *dentry, | |||
139 | struct inode *inode = NULL; | 140 | struct inode *inode = NULL; |
140 | struct buffer_head *bh; | 141 | struct buffer_head *bh; |
141 | struct bfs_dirent *de; | 142 | struct bfs_dirent *de; |
143 | struct bfs_sb_info *info = BFS_SB(dir->i_sb); | ||
142 | 144 | ||
143 | if (dentry->d_name.len > BFS_NAMELEN) | 145 | if (dentry->d_name.len > BFS_NAMELEN) |
144 | return ERR_PTR(-ENAMETOOLONG); | 146 | return ERR_PTR(-ENAMETOOLONG); |
145 | 147 | ||
146 | lock_kernel(); | 148 | mutex_lock(&info->bfs_lock); |
147 | bh = bfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len, &de); | 149 | bh = bfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len, &de); |
148 | if (bh) { | 150 | if (bh) { |
149 | unsigned long ino = (unsigned long)le16_to_cpu(de->ino); | 151 | unsigned long ino = (unsigned long)le16_to_cpu(de->ino); |
150 | brelse(bh); | 152 | brelse(bh); |
151 | inode = bfs_iget(dir->i_sb, ino); | 153 | inode = bfs_iget(dir->i_sb, ino); |
152 | if (IS_ERR(inode)) { | 154 | if (IS_ERR(inode)) { |
153 | unlock_kernel(); | 155 | mutex_unlock(&info->bfs_lock); |
154 | return ERR_CAST(inode); | 156 | return ERR_CAST(inode); |
155 | } | 157 | } |
156 | } | 158 | } |
157 | unlock_kernel(); | 159 | mutex_unlock(&info->bfs_lock); |
158 | d_add(dentry, inode); | 160 | d_add(dentry, inode); |
159 | return NULL; | 161 | return NULL; |
160 | } | 162 | } |
@@ -163,13 +165,14 @@ static int bfs_link(struct dentry *old, struct inode *dir, | |||
163 | struct dentry *new) | 165 | struct dentry *new) |
164 | { | 166 | { |
165 | struct inode *inode = old->d_inode; | 167 | struct inode *inode = old->d_inode; |
168 | struct bfs_sb_info *info = BFS_SB(inode->i_sb); | ||
166 | int err; | 169 | int err; |
167 | 170 | ||
168 | lock_kernel(); | 171 | mutex_lock(&info->bfs_lock); |
169 | err = bfs_add_entry(dir, new->d_name.name, new->d_name.len, | 172 | err = bfs_add_entry(dir, new->d_name.name, new->d_name.len, |
170 | inode->i_ino); | 173 | inode->i_ino); |
171 | if (err) { | 174 | if (err) { |
172 | unlock_kernel(); | 175 | mutex_unlock(&info->bfs_lock); |
173 | return err; | 176 | return err; |
174 | } | 177 | } |
175 | inc_nlink(inode); | 178 | inc_nlink(inode); |
@@ -177,19 +180,19 @@ static int bfs_link(struct dentry *old, struct inode *dir, | |||
177 | mark_inode_dirty(inode); | 180 | mark_inode_dirty(inode); |
178 | atomic_inc(&inode->i_count); | 181 | atomic_inc(&inode->i_count); |
179 | d_instantiate(new, inode); | 182 | d_instantiate(new, inode); |
180 | unlock_kernel(); | 183 | mutex_unlock(&info->bfs_lock); |
181 | return 0; | 184 | return 0; |
182 | } | 185 | } |
183 | 186 | ||
184 | static int bfs_unlink(struct inode *dir, struct dentry *dentry) | 187 | static int bfs_unlink(struct inode *dir, struct dentry *dentry) |
185 | { | 188 | { |
186 | int error = -ENOENT; | 189 | int error = -ENOENT; |
187 | struct inode *inode; | 190 | struct inode *inode = dentry->d_inode; |
188 | struct buffer_head *bh; | 191 | struct buffer_head *bh; |
189 | struct bfs_dirent *de; | 192 | struct bfs_dirent *de; |
193 | struct bfs_sb_info *info = BFS_SB(inode->i_sb); | ||
190 | 194 | ||
191 | inode = dentry->d_inode; | 195 | mutex_lock(&info->bfs_lock); |
192 | lock_kernel(); | ||
193 | bh = bfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len, &de); | 196 | bh = bfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len, &de); |
194 | if (!bh || (le16_to_cpu(de->ino) != inode->i_ino)) | 197 | if (!bh || (le16_to_cpu(de->ino) != inode->i_ino)) |
195 | goto out_brelse; | 198 | goto out_brelse; |
@@ -210,7 +213,7 @@ static int bfs_unlink(struct inode *dir, struct dentry *dentry) | |||
210 | 213 | ||
211 | out_brelse: | 214 | out_brelse: |
212 | brelse(bh); | 215 | brelse(bh); |
213 | unlock_kernel(); | 216 | mutex_unlock(&info->bfs_lock); |
214 | return error; | 217 | return error; |
215 | } | 218 | } |
216 | 219 | ||
@@ -220,6 +223,7 @@ static int bfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
220 | struct inode *old_inode, *new_inode; | 223 | struct inode *old_inode, *new_inode; |
221 | struct buffer_head *old_bh, *new_bh; | 224 | struct buffer_head *old_bh, *new_bh; |
222 | struct bfs_dirent *old_de, *new_de; | 225 | struct bfs_dirent *old_de, *new_de; |
226 | struct bfs_sb_info *info; | ||
223 | int error = -ENOENT; | 227 | int error = -ENOENT; |
224 | 228 | ||
225 | old_bh = new_bh = NULL; | 229 | old_bh = new_bh = NULL; |
@@ -227,7 +231,9 @@ static int bfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
227 | if (S_ISDIR(old_inode->i_mode)) | 231 | if (S_ISDIR(old_inode->i_mode)) |
228 | return -EINVAL; | 232 | return -EINVAL; |
229 | 233 | ||
230 | lock_kernel(); | 234 | info = BFS_SB(old_inode->i_sb); |
235 | |||
236 | mutex_lock(&info->bfs_lock); | ||
231 | old_bh = bfs_find_entry(old_dir, | 237 | old_bh = bfs_find_entry(old_dir, |
232 | old_dentry->d_name.name, | 238 | old_dentry->d_name.name, |
233 | old_dentry->d_name.len, &old_de); | 239 | old_dentry->d_name.len, &old_de); |
@@ -264,7 +270,7 @@ static int bfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
264 | error = 0; | 270 | error = 0; |
265 | 271 | ||
266 | end_rename: | 272 | end_rename: |
267 | unlock_kernel(); | 273 | mutex_unlock(&info->bfs_lock); |
268 | brelse(old_bh); | 274 | brelse(old_bh); |
269 | brelse(new_bh); | 275 | brelse(new_bh); |
270 | return error; | 276 | return error; |
diff --git a/fs/bfs/file.c b/fs/bfs/file.c index b11e63e8fbcd..6a021265f018 100644 --- a/fs/bfs/file.c +++ b/fs/bfs/file.c | |||
@@ -99,7 +99,7 @@ static int bfs_get_block(struct inode *inode, sector_t block, | |||
99 | return -ENOSPC; | 99 | return -ENOSPC; |
100 | 100 | ||
101 | /* The rest has to be protected against itself. */ | 101 | /* The rest has to be protected against itself. */ |
102 | lock_kernel(); | 102 | mutex_lock(&info->bfs_lock); |
103 | 103 | ||
104 | /* | 104 | /* |
105 | * If the last data block for this file is the last allocated | 105 | * If the last data block for this file is the last allocated |
@@ -151,7 +151,7 @@ static int bfs_get_block(struct inode *inode, sector_t block, | |||
151 | mark_buffer_dirty(sbh); | 151 | mark_buffer_dirty(sbh); |
152 | map_bh(bh_result, sb, phys); | 152 | map_bh(bh_result, sb, phys); |
153 | out: | 153 | out: |
154 | unlock_kernel(); | 154 | mutex_unlock(&info->bfs_lock); |
155 | return err; | 155 | return err; |
156 | } | 156 | } |
157 | 157 | ||
diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c index 8db623838b50..0ed57b5ee012 100644 --- a/fs/bfs/inode.c +++ b/fs/bfs/inode.c | |||
@@ -104,6 +104,7 @@ static int bfs_write_inode(struct inode *inode, int unused) | |||
104 | struct bfs_inode *di; | 104 | struct bfs_inode *di; |
105 | struct buffer_head *bh; | 105 | struct buffer_head *bh; |
106 | int block, off; | 106 | int block, off; |
107 | struct bfs_sb_info *info = BFS_SB(inode->i_sb); | ||
107 | 108 | ||
108 | dprintf("ino=%08x\n", ino); | 109 | dprintf("ino=%08x\n", ino); |
109 | 110 | ||
@@ -112,13 +113,13 @@ static int bfs_write_inode(struct inode *inode, int unused) | |||
112 | return -EIO; | 113 | return -EIO; |
113 | } | 114 | } |
114 | 115 | ||
115 | lock_kernel(); | 116 | mutex_lock(&info->bfs_lock); |
116 | block = (ino - BFS_ROOT_INO) / BFS_INODES_PER_BLOCK + 1; | 117 | block = (ino - BFS_ROOT_INO) / BFS_INODES_PER_BLOCK + 1; |
117 | bh = sb_bread(inode->i_sb, block); | 118 | bh = sb_bread(inode->i_sb, block); |
118 | if (!bh) { | 119 | if (!bh) { |
119 | printf("Unable to read inode %s:%08x\n", | 120 | printf("Unable to read inode %s:%08x\n", |
120 | inode->i_sb->s_id, ino); | 121 | inode->i_sb->s_id, ino); |
121 | unlock_kernel(); | 122 | mutex_unlock(&info->bfs_lock); |
122 | return -EIO; | 123 | return -EIO; |
123 | } | 124 | } |
124 | 125 | ||
@@ -145,7 +146,7 @@ static int bfs_write_inode(struct inode *inode, int unused) | |||
145 | 146 | ||
146 | mark_buffer_dirty(bh); | 147 | mark_buffer_dirty(bh); |
147 | brelse(bh); | 148 | brelse(bh); |
148 | unlock_kernel(); | 149 | mutex_unlock(&info->bfs_lock); |
149 | return 0; | 150 | return 0; |
150 | } | 151 | } |
151 | 152 | ||
@@ -170,7 +171,7 @@ static void bfs_delete_inode(struct inode *inode) | |||
170 | 171 | ||
171 | inode->i_size = 0; | 172 | inode->i_size = 0; |
172 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC; | 173 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC; |
173 | lock_kernel(); | 174 | mutex_lock(&info->bfs_lock); |
174 | mark_inode_dirty(inode); | 175 | mark_inode_dirty(inode); |
175 | 176 | ||
176 | block = (ino - BFS_ROOT_INO) / BFS_INODES_PER_BLOCK + 1; | 177 | block = (ino - BFS_ROOT_INO) / BFS_INODES_PER_BLOCK + 1; |
@@ -178,7 +179,7 @@ static void bfs_delete_inode(struct inode *inode) | |||
178 | if (!bh) { | 179 | if (!bh) { |
179 | printf("Unable to read inode %s:%08lx\n", | 180 | printf("Unable to read inode %s:%08lx\n", |
180 | inode->i_sb->s_id, ino); | 181 | inode->i_sb->s_id, ino); |
181 | unlock_kernel(); | 182 | mutex_unlock(&info->bfs_lock); |
182 | return; | 183 | return; |
183 | } | 184 | } |
184 | off = (ino - BFS_ROOT_INO) % BFS_INODES_PER_BLOCK; | 185 | off = (ino - BFS_ROOT_INO) % BFS_INODES_PER_BLOCK; |
@@ -204,14 +205,16 @@ static void bfs_delete_inode(struct inode *inode) | |||
204 | info->si_lf_eblk = bi->i_sblock - 1; | 205 | info->si_lf_eblk = bi->i_sblock - 1; |
205 | mark_buffer_dirty(info->si_sbh); | 206 | mark_buffer_dirty(info->si_sbh); |
206 | } | 207 | } |
207 | unlock_kernel(); | 208 | mutex_unlock(&info->bfs_lock); |
208 | clear_inode(inode); | 209 | clear_inode(inode); |
209 | } | 210 | } |
210 | 211 | ||
211 | static void bfs_put_super(struct super_block *s) | 212 | static void bfs_put_super(struct super_block *s) |
212 | { | 213 | { |
213 | struct bfs_sb_info *info = BFS_SB(s); | 214 | struct bfs_sb_info *info = BFS_SB(s); |
215 | |||
214 | brelse(info->si_sbh); | 216 | brelse(info->si_sbh); |
217 | mutex_destroy(&info->bfs_lock); | ||
215 | kfree(info->si_imap); | 218 | kfree(info->si_imap); |
216 | kfree(info); | 219 | kfree(info); |
217 | s->s_fs_info = NULL; | 220 | s->s_fs_info = NULL; |
@@ -236,11 +239,13 @@ static int bfs_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
236 | 239 | ||
237 | static void bfs_write_super(struct super_block *s) | 240 | static void bfs_write_super(struct super_block *s) |
238 | { | 241 | { |
239 | lock_kernel(); | 242 | struct bfs_sb_info *info = BFS_SB(s); |
243 | |||
244 | mutex_lock(&info->bfs_lock); | ||
240 | if (!(s->s_flags & MS_RDONLY)) | 245 | if (!(s->s_flags & MS_RDONLY)) |
241 | mark_buffer_dirty(BFS_SB(s)->si_sbh); | 246 | mark_buffer_dirty(info->si_sbh); |
242 | s->s_dirt = 0; | 247 | s->s_dirt = 0; |
243 | unlock_kernel(); | 248 | mutex_unlock(&info->bfs_lock); |
244 | } | 249 | } |
245 | 250 | ||
246 | static struct kmem_cache *bfs_inode_cachep; | 251 | static struct kmem_cache *bfs_inode_cachep; |
@@ -259,7 +264,7 @@ static void bfs_destroy_inode(struct inode *inode) | |||
259 | kmem_cache_free(bfs_inode_cachep, BFS_I(inode)); | 264 | kmem_cache_free(bfs_inode_cachep, BFS_I(inode)); |
260 | } | 265 | } |
261 | 266 | ||
262 | static void init_once(struct kmem_cache *cachep, void *foo) | 267 | static void init_once(void *foo) |
263 | { | 268 | { |
264 | struct bfs_inode_info *bi = foo; | 269 | struct bfs_inode_info *bi = foo; |
265 | 270 | ||
@@ -380,7 +385,7 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent) | |||
380 | struct bfs_inode *di; | 385 | struct bfs_inode *di; |
381 | int block = (i - BFS_ROOT_INO) / BFS_INODES_PER_BLOCK + 1; | 386 | int block = (i - BFS_ROOT_INO) / BFS_INODES_PER_BLOCK + 1; |
382 | int off = (i - BFS_ROOT_INO) % BFS_INODES_PER_BLOCK; | 387 | int off = (i - BFS_ROOT_INO) % BFS_INODES_PER_BLOCK; |
383 | unsigned long sblock, eblock; | 388 | unsigned long eblock; |
384 | 389 | ||
385 | if (!off) { | 390 | if (!off) { |
386 | brelse(bh); | 391 | brelse(bh); |
@@ -399,7 +404,6 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent) | |||
399 | set_bit(i, info->si_imap); | 404 | set_bit(i, info->si_imap); |
400 | info->si_freeb -= BFS_FILEBLOCKS(di); | 405 | info->si_freeb -= BFS_FILEBLOCKS(di); |
401 | 406 | ||
402 | sblock = le32_to_cpu(di->i_sblock); | ||
403 | eblock = le32_to_cpu(di->i_eblock); | 407 | eblock = le32_to_cpu(di->i_eblock); |
404 | if (eblock > info->si_lf_eblk) | 408 | if (eblock > info->si_lf_eblk) |
405 | info->si_lf_eblk = eblock; | 409 | info->si_lf_eblk = eblock; |
@@ -410,6 +414,7 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent) | |||
410 | s->s_dirt = 1; | 414 | s->s_dirt = 1; |
411 | } | 415 | } |
412 | dump_imap("read_super", s); | 416 | dump_imap("read_super", s); |
417 | mutex_init(&info->bfs_lock); | ||
413 | return 0; | 418 | return 0; |
414 | 419 | ||
415 | out: | 420 | out: |
diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c index ba4cddb92f1d..204cfd1d7676 100644 --- a/fs/binfmt_aout.c +++ b/fs/binfmt_aout.c | |||
@@ -444,12 +444,6 @@ beyond_if: | |||
444 | regs->gp = ex.a_gpvalue; | 444 | regs->gp = ex.a_gpvalue; |
445 | #endif | 445 | #endif |
446 | start_thread(regs, ex.a_entry, current->mm->start_stack); | 446 | start_thread(regs, ex.a_entry, current->mm->start_stack); |
447 | if (unlikely(current->ptrace & PT_PTRACED)) { | ||
448 | if (current->ptrace & PT_TRACE_EXEC) | ||
449 | ptrace_notify ((PTRACE_EVENT_EXEC << 8) | SIGTRAP); | ||
450 | else | ||
451 | send_sig(SIGTRAP, current, 0); | ||
452 | } | ||
453 | return 0; | 447 | return 0; |
454 | } | 448 | } |
455 | 449 | ||
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 3b6ff854d983..655ed8d30a86 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c | |||
@@ -1003,12 +1003,6 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs) | |||
1003 | #endif | 1003 | #endif |
1004 | 1004 | ||
1005 | start_thread(regs, elf_entry, bprm->p); | 1005 | start_thread(regs, elf_entry, bprm->p); |
1006 | if (unlikely(current->ptrace & PT_PTRACED)) { | ||
1007 | if (current->ptrace & PT_TRACE_EXEC) | ||
1008 | ptrace_notify ((PTRACE_EVENT_EXEC << 8) | SIGTRAP); | ||
1009 | else | ||
1010 | send_sig(SIGTRAP, current, 0); | ||
1011 | } | ||
1012 | retval = 0; | 1006 | retval = 0; |
1013 | out: | 1007 | out: |
1014 | kfree(loc); | 1008 | kfree(loc); |
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c index 1b59b1edf26d..fdeadab2f18b 100644 --- a/fs/binfmt_elf_fdpic.c +++ b/fs/binfmt_elf_fdpic.c | |||
@@ -433,13 +433,6 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm, | |||
433 | entryaddr = interp_params.entry_addr ?: exec_params.entry_addr; | 433 | entryaddr = interp_params.entry_addr ?: exec_params.entry_addr; |
434 | start_thread(regs, entryaddr, current->mm->start_stack); | 434 | start_thread(regs, entryaddr, current->mm->start_stack); |
435 | 435 | ||
436 | if (unlikely(current->ptrace & PT_PTRACED)) { | ||
437 | if (current->ptrace & PT_TRACE_EXEC) | ||
438 | ptrace_notify((PTRACE_EVENT_EXEC << 8) | SIGTRAP); | ||
439 | else | ||
440 | send_sig(SIGTRAP, current, 0); | ||
441 | } | ||
442 | |||
443 | retval = 0; | 436 | retval = 0; |
444 | 437 | ||
445 | error: | 438 | error: |
diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c index 2cb1acda3a82..56372ecf1690 100644 --- a/fs/binfmt_flat.c +++ b/fs/binfmt_flat.c | |||
@@ -920,9 +920,6 @@ static int load_flat_binary(struct linux_binprm * bprm, struct pt_regs * regs) | |||
920 | 920 | ||
921 | start_thread(regs, start_addr, current->mm->start_stack); | 921 | start_thread(regs, start_addr, current->mm->start_stack); |
922 | 922 | ||
923 | if (current->ptrace & PT_PTRACED) | ||
924 | send_sig(SIGTRAP, current, 0); | ||
925 | |||
926 | return 0; | 923 | return 0; |
927 | } | 924 | } |
928 | 925 | ||
diff --git a/fs/binfmt_som.c b/fs/binfmt_som.c index fdc36bfd6a7b..68be580ba289 100644 --- a/fs/binfmt_som.c +++ b/fs/binfmt_som.c | |||
@@ -274,8 +274,6 @@ load_som_binary(struct linux_binprm * bprm, struct pt_regs * regs) | |||
274 | map_hpux_gateway_page(current,current->mm); | 274 | map_hpux_gateway_page(current,current->mm); |
275 | 275 | ||
276 | start_thread_som(regs, som_entry, bprm->p); | 276 | start_thread_som(regs, som_entry, bprm->p); |
277 | if (current->ptrace & PT_PTRACED) | ||
278 | send_sig(SIGTRAP, current, 0); | ||
279 | return 0; | 277 | return 0; |
280 | 278 | ||
281 | /* error cleanup */ | 279 | /* error cleanup */ |
@@ -721,12 +721,8 @@ static struct bio *__bio_map_user_iov(struct request_queue *q, | |||
721 | const int local_nr_pages = end - start; | 721 | const int local_nr_pages = end - start; |
722 | const int page_limit = cur_page + local_nr_pages; | 722 | const int page_limit = cur_page + local_nr_pages; |
723 | 723 | ||
724 | down_read(¤t->mm->mmap_sem); | 724 | ret = get_user_pages_fast(uaddr, local_nr_pages, |
725 | ret = get_user_pages(current, current->mm, uaddr, | 725 | write_to_vm, &pages[cur_page]); |
726 | local_nr_pages, | ||
727 | write_to_vm, 0, &pages[cur_page], NULL); | ||
728 | up_read(¤t->mm->mmap_sem); | ||
729 | |||
730 | if (ret < local_nr_pages) { | 726 | if (ret < local_nr_pages) { |
731 | ret = -EFAULT; | 727 | ret = -EFAULT; |
732 | goto out_unmap; | 728 | goto out_unmap; |
diff --git a/fs/block_dev.c b/fs/block_dev.c index 10d8a0aa871a..dcf37cada369 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c | |||
@@ -271,7 +271,7 @@ static void bdev_destroy_inode(struct inode *inode) | |||
271 | kmem_cache_free(bdev_cachep, bdi); | 271 | kmem_cache_free(bdev_cachep, bdi); |
272 | } | 272 | } |
273 | 273 | ||
274 | static void init_once(struct kmem_cache * cachep, void *foo) | 274 | static void init_once(void *foo) |
275 | { | 275 | { |
276 | struct bdev_inode *ei = (struct bdev_inode *) foo; | 276 | struct bdev_inode *ei = (struct bdev_inode *) foo; |
277 | struct block_device *bdev = &ei->bdev; | 277 | struct block_device *bdev = &ei->bdev; |
diff --git a/fs/buffer.c b/fs/buffer.c index d48caee12e2a..f95805019639 100644 --- a/fs/buffer.c +++ b/fs/buffer.c | |||
@@ -706,7 +706,7 @@ static int __set_page_dirty(struct page *page, | |||
706 | if (TestSetPageDirty(page)) | 706 | if (TestSetPageDirty(page)) |
707 | return 0; | 707 | return 0; |
708 | 708 | ||
709 | write_lock_irq(&mapping->tree_lock); | 709 | spin_lock_irq(&mapping->tree_lock); |
710 | if (page->mapping) { /* Race with truncate? */ | 710 | if (page->mapping) { /* Race with truncate? */ |
711 | WARN_ON_ONCE(warn && !PageUptodate(page)); | 711 | WARN_ON_ONCE(warn && !PageUptodate(page)); |
712 | 712 | ||
@@ -719,7 +719,7 @@ static int __set_page_dirty(struct page *page, | |||
719 | radix_tree_tag_set(&mapping->page_tree, | 719 | radix_tree_tag_set(&mapping->page_tree, |
720 | page_index(page), PAGECACHE_TAG_DIRTY); | 720 | page_index(page), PAGECACHE_TAG_DIRTY); |
721 | } | 721 | } |
722 | write_unlock_irq(&mapping->tree_lock); | 722 | spin_unlock_irq(&mapping->tree_lock); |
723 | __mark_inode_dirty(mapping->host, I_DIRTY_PAGES); | 723 | __mark_inode_dirty(mapping->host, I_DIRTY_PAGES); |
724 | 724 | ||
725 | return 1; | 725 | return 1; |
@@ -1214,8 +1214,7 @@ void __brelse(struct buffer_head * buf) | |||
1214 | put_bh(buf); | 1214 | put_bh(buf); |
1215 | return; | 1215 | return; |
1216 | } | 1216 | } |
1217 | printk(KERN_ERR "VFS: brelse: Trying to free free buffer\n"); | 1217 | WARN(1, KERN_ERR "VFS: brelse: Trying to free free buffer\n"); |
1218 | WARN_ON(1); | ||
1219 | } | 1218 | } |
1220 | 1219 | ||
1221 | /* | 1220 | /* |
@@ -3272,7 +3271,7 @@ int bh_submit_read(struct buffer_head *bh) | |||
3272 | EXPORT_SYMBOL(bh_submit_read); | 3271 | EXPORT_SYMBOL(bh_submit_read); |
3273 | 3272 | ||
3274 | static void | 3273 | static void |
3275 | init_buffer_head(struct kmem_cache *cachep, void *data) | 3274 | init_buffer_head(void *data) |
3276 | { | 3275 | { |
3277 | struct buffer_head *bh = data; | 3276 | struct buffer_head *bh = data; |
3278 | 3277 | ||
diff --git a/fs/cifs/asn1.c b/fs/cifs/asn1.c index f58e41d3ba48..6bb440b257b0 100644 --- a/fs/cifs/asn1.c +++ b/fs/cifs/asn1.c | |||
@@ -400,7 +400,7 @@ asn1_oid_decode(struct asn1_ctx *ctx, | |||
400 | size = eoc - ctx->pointer + 1; | 400 | size = eoc - ctx->pointer + 1; |
401 | 401 | ||
402 | /* first subid actually encodes first two subids */ | 402 | /* first subid actually encodes first two subids */ |
403 | if (size < 2 || size > ULONG_MAX/sizeof(unsigned long)) | 403 | if (size < 2 || size > UINT_MAX/sizeof(unsigned long)) |
404 | return 0; | 404 | return 0; |
405 | 405 | ||
406 | *oid = kmalloc(size * sizeof(unsigned long), GFP_ATOMIC); | 406 | *oid = kmalloc(size * sizeof(unsigned long), GFP_ATOMIC); |
@@ -494,7 +494,7 @@ decode_negTokenInit(unsigned char *security_blob, int length, | |||
494 | /* remember to free obj->oid */ | 494 | /* remember to free obj->oid */ |
495 | rc = asn1_header_decode(&ctx, &end, &cls, &con, &tag); | 495 | rc = asn1_header_decode(&ctx, &end, &cls, &con, &tag); |
496 | if (rc) { | 496 | if (rc) { |
497 | if ((tag == ASN1_OJI) && (cls == ASN1_PRI)) { | 497 | if ((tag == ASN1_OJI) && (con == ASN1_PRI)) { |
498 | rc = asn1_oid_decode(&ctx, end, &oid, &oidlen); | 498 | rc = asn1_oid_decode(&ctx, end, &oid, &oidlen); |
499 | if (rc) { | 499 | if (rc) { |
500 | rc = compare_oid(oid, oidlen, | 500 | rc = compare_oid(oid, oidlen, |
diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c index cc950f69e51e..688a2d42153f 100644 --- a/fs/cifs/cifs_debug.c +++ b/fs/cifs/cifs_debug.c | |||
@@ -107,9 +107,7 @@ void cifs_dump_mids(struct TCP_Server_Info *server) | |||
107 | #endif /* CONFIG_CIFS_DEBUG2 */ | 107 | #endif /* CONFIG_CIFS_DEBUG2 */ |
108 | 108 | ||
109 | #ifdef CONFIG_PROC_FS | 109 | #ifdef CONFIG_PROC_FS |
110 | static int | 110 | static int cifs_debug_data_proc_show(struct seq_file *m, void *v) |
111 | cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset, | ||
112 | int count, int *eof, void *data) | ||
113 | { | 111 | { |
114 | struct list_head *tmp; | 112 | struct list_head *tmp; |
115 | struct list_head *tmp1; | 113 | struct list_head *tmp1; |
@@ -117,23 +115,13 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset, | |||
117 | struct cifsSesInfo *ses; | 115 | struct cifsSesInfo *ses; |
118 | struct cifsTconInfo *tcon; | 116 | struct cifsTconInfo *tcon; |
119 | int i; | 117 | int i; |
120 | int length = 0; | ||
121 | char *original_buf = buf; | ||
122 | 118 | ||
123 | *beginBuffer = buf + offset; | 119 | seq_puts(m, |
124 | |||
125 | length = | ||
126 | sprintf(buf, | ||
127 | "Display Internal CIFS Data Structures for Debugging\n" | 120 | "Display Internal CIFS Data Structures for Debugging\n" |
128 | "---------------------------------------------------\n"); | 121 | "---------------------------------------------------\n"); |
129 | buf += length; | 122 | seq_printf(m, "CIFS Version %s\n", CIFS_VERSION); |
130 | length = sprintf(buf, "CIFS Version %s\n", CIFS_VERSION); | 123 | seq_printf(m, "Active VFS Requests: %d\n", GlobalTotalActiveXid); |
131 | buf += length; | 124 | seq_printf(m, "Servers:"); |
132 | length = sprintf(buf, | ||
133 | "Active VFS Requests: %d\n", GlobalTotalActiveXid); | ||
134 | buf += length; | ||
135 | length = sprintf(buf, "Servers:"); | ||
136 | buf += length; | ||
137 | 125 | ||
138 | i = 0; | 126 | i = 0; |
139 | read_lock(&GlobalSMBSeslock); | 127 | read_lock(&GlobalSMBSeslock); |
@@ -142,11 +130,10 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset, | |||
142 | ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); | 130 | ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); |
143 | if ((ses->serverDomain == NULL) || (ses->serverOS == NULL) || | 131 | if ((ses->serverDomain == NULL) || (ses->serverOS == NULL) || |
144 | (ses->serverNOS == NULL)) { | 132 | (ses->serverNOS == NULL)) { |
145 | buf += sprintf(buf, "\nentry for %s not fully " | 133 | seq_printf(m, "\nentry for %s not fully " |
146 | "displayed\n\t", ses->serverName); | 134 | "displayed\n\t", ses->serverName); |
147 | } else { | 135 | } else { |
148 | length = | 136 | seq_printf(m, |
149 | sprintf(buf, | ||
150 | "\n%d) Name: %s Domain: %s Mounts: %d OS:" | 137 | "\n%d) Name: %s Domain: %s Mounts: %d OS:" |
151 | " %s \n\tNOS: %s\tCapability: 0x%x\n\tSMB" | 138 | " %s \n\tNOS: %s\tCapability: 0x%x\n\tSMB" |
152 | " session status: %d\t", | 139 | " session status: %d\t", |
@@ -154,10 +141,9 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset, | |||
154 | atomic_read(&ses->inUse), | 141 | atomic_read(&ses->inUse), |
155 | ses->serverOS, ses->serverNOS, | 142 | ses->serverOS, ses->serverNOS, |
156 | ses->capabilities, ses->status); | 143 | ses->capabilities, ses->status); |
157 | buf += length; | ||
158 | } | 144 | } |
159 | if (ses->server) { | 145 | if (ses->server) { |
160 | buf += sprintf(buf, "TCP status: %d\n\tLocal Users To " | 146 | seq_printf(m, "TCP status: %d\n\tLocal Users To " |
161 | "Server: %d SecMode: 0x%x Req On Wire: %d", | 147 | "Server: %d SecMode: 0x%x Req On Wire: %d", |
162 | ses->server->tcpStatus, | 148 | ses->server->tcpStatus, |
163 | atomic_read(&ses->server->socketUseCount), | 149 | atomic_read(&ses->server->socketUseCount), |
@@ -165,13 +151,12 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset, | |||
165 | atomic_read(&ses->server->inFlight)); | 151 | atomic_read(&ses->server->inFlight)); |
166 | 152 | ||
167 | #ifdef CONFIG_CIFS_STATS2 | 153 | #ifdef CONFIG_CIFS_STATS2 |
168 | buf += sprintf(buf, " In Send: %d In MaxReq Wait: %d", | 154 | seq_printf(m, " In Send: %d In MaxReq Wait: %d", |
169 | atomic_read(&ses->server->inSend), | 155 | atomic_read(&ses->server->inSend), |
170 | atomic_read(&ses->server->num_waiters)); | 156 | atomic_read(&ses->server->num_waiters)); |
171 | #endif | 157 | #endif |
172 | 158 | ||
173 | length = sprintf(buf, "\nMIDs:\n"); | 159 | seq_puts(m, "\nMIDs:\n"); |
174 | buf += length; | ||
175 | 160 | ||
176 | spin_lock(&GlobalMid_Lock); | 161 | spin_lock(&GlobalMid_Lock); |
177 | list_for_each(tmp1, &ses->server->pending_mid_q) { | 162 | list_for_each(tmp1, &ses->server->pending_mid_q) { |
@@ -179,7 +164,7 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset, | |||
179 | mid_q_entry, | 164 | mid_q_entry, |
180 | qhead); | 165 | qhead); |
181 | if (mid_entry) { | 166 | if (mid_entry) { |
182 | length = sprintf(buf, | 167 | seq_printf(m, |
183 | "State: %d com: %d pid:" | 168 | "State: %d com: %d pid:" |
184 | " %d tsk: %p mid %d\n", | 169 | " %d tsk: %p mid %d\n", |
185 | mid_entry->midState, | 170 | mid_entry->midState, |
@@ -187,7 +172,6 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset, | |||
187 | mid_entry->pid, | 172 | mid_entry->pid, |
188 | mid_entry->tsk, | 173 | mid_entry->tsk, |
189 | mid_entry->mid); | 174 | mid_entry->mid); |
190 | buf += length; | ||
191 | } | 175 | } |
192 | } | 176 | } |
193 | spin_unlock(&GlobalMid_Lock); | 177 | spin_unlock(&GlobalMid_Lock); |
@@ -195,11 +179,9 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset, | |||
195 | 179 | ||
196 | } | 180 | } |
197 | read_unlock(&GlobalSMBSeslock); | 181 | read_unlock(&GlobalSMBSeslock); |
198 | sprintf(buf, "\n"); | 182 | seq_putc(m, '\n'); |
199 | buf++; | ||
200 | 183 | ||
201 | length = sprintf(buf, "Shares:"); | 184 | seq_puts(m, "Shares:"); |
202 | buf += length; | ||
203 | 185 | ||
204 | i = 0; | 186 | i = 0; |
205 | read_lock(&GlobalSMBSeslock); | 187 | read_lock(&GlobalSMBSeslock); |
@@ -208,62 +190,52 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset, | |||
208 | i++; | 190 | i++; |
209 | tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); | 191 | tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); |
210 | dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType); | 192 | dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType); |
211 | length = sprintf(buf, "\n%d) %s Uses: %d ", i, | 193 | seq_printf(m, "\n%d) %s Uses: %d ", i, |
212 | tcon->treeName, atomic_read(&tcon->useCount)); | 194 | tcon->treeName, atomic_read(&tcon->useCount)); |
213 | buf += length; | ||
214 | if (tcon->nativeFileSystem) { | 195 | if (tcon->nativeFileSystem) { |
215 | length = sprintf(buf, "Type: %s ", | 196 | seq_printf(m, "Type: %s ", |
216 | tcon->nativeFileSystem); | 197 | tcon->nativeFileSystem); |
217 | buf += length; | ||
218 | } | 198 | } |
219 | length = sprintf(buf, "DevInfo: 0x%x Attributes: 0x%x" | 199 | seq_printf(m, "DevInfo: 0x%x Attributes: 0x%x" |
220 | "\nPathComponentMax: %d Status: %d", | 200 | "\nPathComponentMax: %d Status: %d", |
221 | le32_to_cpu(tcon->fsDevInfo.DeviceCharacteristics), | 201 | le32_to_cpu(tcon->fsDevInfo.DeviceCharacteristics), |
222 | le32_to_cpu(tcon->fsAttrInfo.Attributes), | 202 | le32_to_cpu(tcon->fsAttrInfo.Attributes), |
223 | le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength), | 203 | le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength), |
224 | tcon->tidStatus); | 204 | tcon->tidStatus); |
225 | buf += length; | ||
226 | if (dev_type == FILE_DEVICE_DISK) | 205 | if (dev_type == FILE_DEVICE_DISK) |
227 | length = sprintf(buf, " type: DISK "); | 206 | seq_puts(m, " type: DISK "); |
228 | else if (dev_type == FILE_DEVICE_CD_ROM) | 207 | else if (dev_type == FILE_DEVICE_CD_ROM) |
229 | length = sprintf(buf, " type: CDROM "); | 208 | seq_puts(m, " type: CDROM "); |
230 | else | 209 | else |
231 | length = | 210 | seq_printf(m, " type: %d ", dev_type); |
232 | sprintf(buf, " type: %d ", dev_type); | 211 | |
233 | buf += length; | 212 | if (tcon->tidStatus == CifsNeedReconnect) |
234 | if (tcon->tidStatus == CifsNeedReconnect) { | 213 | seq_puts(m, "\tDISCONNECTED "); |
235 | buf += sprintf(buf, "\tDISCONNECTED "); | ||
236 | length += 14; | ||
237 | } | ||
238 | } | 214 | } |
239 | read_unlock(&GlobalSMBSeslock); | 215 | read_unlock(&GlobalSMBSeslock); |
240 | 216 | ||
241 | length = sprintf(buf, "\n"); | 217 | seq_putc(m, '\n'); |
242 | buf += length; | ||
243 | 218 | ||
244 | /* BB add code to dump additional info such as TCP session info now */ | 219 | /* BB add code to dump additional info such as TCP session info now */ |
245 | /* Now calculate total size of returned data */ | 220 | return 0; |
246 | length = buf - original_buf; | 221 | } |
247 | |||
248 | if (offset + count >= length) | ||
249 | *eof = 1; | ||
250 | if (length < offset) { | ||
251 | *eof = 1; | ||
252 | return 0; | ||
253 | } else { | ||
254 | length = length - offset; | ||
255 | } | ||
256 | if (length > count) | ||
257 | length = count; | ||
258 | 222 | ||
259 | return length; | 223 | static int cifs_debug_data_proc_open(struct inode *inode, struct file *file) |
224 | { | ||
225 | return single_open(file, cifs_debug_data_proc_show, NULL); | ||
260 | } | 226 | } |
261 | 227 | ||
262 | #ifdef CONFIG_CIFS_STATS | 228 | static const struct file_operations cifs_debug_data_proc_fops = { |
229 | .owner = THIS_MODULE, | ||
230 | .open = cifs_debug_data_proc_open, | ||
231 | .read = seq_read, | ||
232 | .llseek = seq_lseek, | ||
233 | .release = single_release, | ||
234 | }; | ||
263 | 235 | ||
264 | static int | 236 | #ifdef CONFIG_CIFS_STATS |
265 | cifs_stats_write(struct file *file, const char __user *buffer, | 237 | static ssize_t cifs_stats_proc_write(struct file *file, |
266 | unsigned long count, void *data) | 238 | const char __user *buffer, size_t count, loff_t *ppos) |
267 | { | 239 | { |
268 | char c; | 240 | char c; |
269 | int rc; | 241 | int rc; |
@@ -307,236 +279,132 @@ cifs_stats_write(struct file *file, const char __user *buffer, | |||
307 | return count; | 279 | return count; |
308 | } | 280 | } |
309 | 281 | ||
310 | static int | 282 | static int cifs_stats_proc_show(struct seq_file *m, void *v) |
311 | cifs_stats_read(char *buf, char **beginBuffer, off_t offset, | ||
312 | int count, int *eof, void *data) | ||
313 | { | 283 | { |
314 | int item_length, i, length; | 284 | int i; |
315 | struct list_head *tmp; | 285 | struct list_head *tmp; |
316 | struct cifsTconInfo *tcon; | 286 | struct cifsTconInfo *tcon; |
317 | 287 | ||
318 | *beginBuffer = buf + offset; | 288 | seq_printf(m, |
319 | |||
320 | length = sprintf(buf, | ||
321 | "Resources in use\nCIFS Session: %d\n", | 289 | "Resources in use\nCIFS Session: %d\n", |
322 | sesInfoAllocCount.counter); | 290 | sesInfoAllocCount.counter); |
323 | buf += length; | 291 | seq_printf(m, "Share (unique mount targets): %d\n", |
324 | item_length = | ||
325 | sprintf(buf, "Share (unique mount targets): %d\n", | ||
326 | tconInfoAllocCount.counter); | 292 | tconInfoAllocCount.counter); |
327 | length += item_length; | 293 | seq_printf(m, "SMB Request/Response Buffer: %d Pool size: %d\n", |
328 | buf += item_length; | ||
329 | item_length = | ||
330 | sprintf(buf, "SMB Request/Response Buffer: %d Pool size: %d\n", | ||
331 | bufAllocCount.counter, | 294 | bufAllocCount.counter, |
332 | cifs_min_rcv + tcpSesAllocCount.counter); | 295 | cifs_min_rcv + tcpSesAllocCount.counter); |
333 | length += item_length; | 296 | seq_printf(m, "SMB Small Req/Resp Buffer: %d Pool size: %d\n", |
334 | buf += item_length; | ||
335 | item_length = | ||
336 | sprintf(buf, "SMB Small Req/Resp Buffer: %d Pool size: %d\n", | ||
337 | smBufAllocCount.counter, cifs_min_small); | 297 | smBufAllocCount.counter, cifs_min_small); |
338 | length += item_length; | ||
339 | buf += item_length; | ||
340 | #ifdef CONFIG_CIFS_STATS2 | 298 | #ifdef CONFIG_CIFS_STATS2 |
341 | item_length = sprintf(buf, "Total Large %d Small %d Allocations\n", | 299 | seq_printf(m, "Total Large %d Small %d Allocations\n", |
342 | atomic_read(&totBufAllocCount), | 300 | atomic_read(&totBufAllocCount), |
343 | atomic_read(&totSmBufAllocCount)); | 301 | atomic_read(&totSmBufAllocCount)); |
344 | length += item_length; | ||
345 | buf += item_length; | ||
346 | #endif /* CONFIG_CIFS_STATS2 */ | 302 | #endif /* CONFIG_CIFS_STATS2 */ |
347 | 303 | ||
348 | item_length = | 304 | seq_printf(m, "Operations (MIDs): %d\n", midCount.counter); |
349 | sprintf(buf, "Operations (MIDs): %d\n", | 305 | seq_printf(m, |
350 | midCount.counter); | ||
351 | length += item_length; | ||
352 | buf += item_length; | ||
353 | item_length = sprintf(buf, | ||
354 | "\n%d session %d share reconnects\n", | 306 | "\n%d session %d share reconnects\n", |
355 | tcpSesReconnectCount.counter, tconInfoReconnectCount.counter); | 307 | tcpSesReconnectCount.counter, tconInfoReconnectCount.counter); |
356 | length += item_length; | ||
357 | buf += item_length; | ||
358 | 308 | ||
359 | item_length = sprintf(buf, | 309 | seq_printf(m, |
360 | "Total vfs operations: %d maximum at one time: %d\n", | 310 | "Total vfs operations: %d maximum at one time: %d\n", |
361 | GlobalCurrentXid, GlobalMaxActiveXid); | 311 | GlobalCurrentXid, GlobalMaxActiveXid); |
362 | length += item_length; | ||
363 | buf += item_length; | ||
364 | 312 | ||
365 | i = 0; | 313 | i = 0; |
366 | read_lock(&GlobalSMBSeslock); | 314 | read_lock(&GlobalSMBSeslock); |
367 | list_for_each(tmp, &GlobalTreeConnectionList) { | 315 | list_for_each(tmp, &GlobalTreeConnectionList) { |
368 | i++; | 316 | i++; |
369 | tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); | 317 | tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); |
370 | item_length = sprintf(buf, "\n%d) %s", i, tcon->treeName); | 318 | seq_printf(m, "\n%d) %s", i, tcon->treeName); |
371 | buf += item_length; | 319 | if (tcon->tidStatus == CifsNeedReconnect) |
372 | length += item_length; | 320 | seq_puts(m, "\tDISCONNECTED "); |
373 | if (tcon->tidStatus == CifsNeedReconnect) { | 321 | seq_printf(m, "\nSMBs: %d Oplock Breaks: %d", |
374 | buf += sprintf(buf, "\tDISCONNECTED "); | ||
375 | length += 14; | ||
376 | } | ||
377 | item_length = sprintf(buf, "\nSMBs: %d Oplock Breaks: %d", | ||
378 | atomic_read(&tcon->num_smbs_sent), | 322 | atomic_read(&tcon->num_smbs_sent), |
379 | atomic_read(&tcon->num_oplock_brks)); | 323 | atomic_read(&tcon->num_oplock_brks)); |
380 | buf += item_length; | 324 | seq_printf(m, "\nReads: %d Bytes: %lld", |
381 | length += item_length; | ||
382 | item_length = sprintf(buf, "\nReads: %d Bytes: %lld", | ||
383 | atomic_read(&tcon->num_reads), | 325 | atomic_read(&tcon->num_reads), |
384 | (long long)(tcon->bytes_read)); | 326 | (long long)(tcon->bytes_read)); |
385 | buf += item_length; | 327 | seq_printf(m, "\nWrites: %d Bytes: %lld", |
386 | length += item_length; | ||
387 | item_length = sprintf(buf, "\nWrites: %d Bytes: %lld", | ||
388 | atomic_read(&tcon->num_writes), | 328 | atomic_read(&tcon->num_writes), |
389 | (long long)(tcon->bytes_written)); | 329 | (long long)(tcon->bytes_written)); |
390 | buf += item_length; | 330 | seq_printf(m, |
391 | length += item_length; | ||
392 | item_length = sprintf(buf, | ||
393 | "\nLocks: %d HardLinks: %d Symlinks: %d", | 331 | "\nLocks: %d HardLinks: %d Symlinks: %d", |
394 | atomic_read(&tcon->num_locks), | 332 | atomic_read(&tcon->num_locks), |
395 | atomic_read(&tcon->num_hardlinks), | 333 | atomic_read(&tcon->num_hardlinks), |
396 | atomic_read(&tcon->num_symlinks)); | 334 | atomic_read(&tcon->num_symlinks)); |
397 | buf += item_length; | ||
398 | length += item_length; | ||
399 | 335 | ||
400 | item_length = sprintf(buf, "\nOpens: %d Closes: %d Deletes: %d", | 336 | seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d", |
401 | atomic_read(&tcon->num_opens), | 337 | atomic_read(&tcon->num_opens), |
402 | atomic_read(&tcon->num_closes), | 338 | atomic_read(&tcon->num_closes), |
403 | atomic_read(&tcon->num_deletes)); | 339 | atomic_read(&tcon->num_deletes)); |
404 | buf += item_length; | 340 | seq_printf(m, "\nMkdirs: %d Rmdirs: %d", |
405 | length += item_length; | ||
406 | item_length = sprintf(buf, "\nMkdirs: %d Rmdirs: %d", | ||
407 | atomic_read(&tcon->num_mkdirs), | 341 | atomic_read(&tcon->num_mkdirs), |
408 | atomic_read(&tcon->num_rmdirs)); | 342 | atomic_read(&tcon->num_rmdirs)); |
409 | buf += item_length; | 343 | seq_printf(m, "\nRenames: %d T2 Renames %d", |
410 | length += item_length; | ||
411 | item_length = sprintf(buf, "\nRenames: %d T2 Renames %d", | ||
412 | atomic_read(&tcon->num_renames), | 344 | atomic_read(&tcon->num_renames), |
413 | atomic_read(&tcon->num_t2renames)); | 345 | atomic_read(&tcon->num_t2renames)); |
414 | buf += item_length; | 346 | seq_printf(m, "\nFindFirst: %d FNext %d FClose %d", |
415 | length += item_length; | ||
416 | item_length = sprintf(buf, "\nFindFirst: %d FNext %d FClose %d", | ||
417 | atomic_read(&tcon->num_ffirst), | 347 | atomic_read(&tcon->num_ffirst), |
418 | atomic_read(&tcon->num_fnext), | 348 | atomic_read(&tcon->num_fnext), |
419 | atomic_read(&tcon->num_fclose)); | 349 | atomic_read(&tcon->num_fclose)); |
420 | buf += item_length; | ||
421 | length += item_length; | ||
422 | } | 350 | } |
423 | read_unlock(&GlobalSMBSeslock); | 351 | read_unlock(&GlobalSMBSeslock); |
424 | 352 | ||
425 | buf += sprintf(buf, "\n"); | 353 | seq_putc(m, '\n'); |
426 | length++; | 354 | return 0; |
427 | 355 | } | |
428 | if (offset + count >= length) | ||
429 | *eof = 1; | ||
430 | if (length < offset) { | ||
431 | *eof = 1; | ||
432 | return 0; | ||
433 | } else { | ||
434 | length = length - offset; | ||
435 | } | ||
436 | if (length > count) | ||
437 | length = count; | ||
438 | 356 | ||
439 | return length; | 357 | static int cifs_stats_proc_open(struct inode *inode, struct file *file) |
358 | { | ||
359 | return single_open(file, cifs_stats_proc_show, NULL); | ||
440 | } | 360 | } |
361 | |||
362 | static const struct file_operations cifs_stats_proc_fops = { | ||
363 | .owner = THIS_MODULE, | ||
364 | .open = cifs_stats_proc_open, | ||
365 | .read = seq_read, | ||
366 | .llseek = seq_lseek, | ||
367 | .release = single_release, | ||
368 | .write = cifs_stats_proc_write, | ||
369 | }; | ||
441 | #endif /* STATS */ | 370 | #endif /* STATS */ |
442 | 371 | ||
443 | static struct proc_dir_entry *proc_fs_cifs; | 372 | static struct proc_dir_entry *proc_fs_cifs; |
444 | read_proc_t cifs_txanchor_read; | 373 | static const struct file_operations cifsFYI_proc_fops; |
445 | static read_proc_t cifsFYI_read; | 374 | static const struct file_operations cifs_oplock_proc_fops; |
446 | static write_proc_t cifsFYI_write; | 375 | static const struct file_operations cifs_lookup_cache_proc_fops; |
447 | static read_proc_t oplockEnabled_read; | 376 | static const struct file_operations traceSMB_proc_fops; |
448 | static write_proc_t oplockEnabled_write; | 377 | static const struct file_operations cifs_multiuser_mount_proc_fops; |
449 | static read_proc_t lookupFlag_read; | 378 | static const struct file_operations cifs_security_flags_proc_fops; |
450 | static write_proc_t lookupFlag_write; | 379 | static const struct file_operations cifs_experimental_proc_fops; |
451 | static read_proc_t traceSMB_read; | 380 | static const struct file_operations cifs_linux_ext_proc_fops; |
452 | static write_proc_t traceSMB_write; | ||
453 | static read_proc_t multiuser_mount_read; | ||
454 | static write_proc_t multiuser_mount_write; | ||
455 | static read_proc_t security_flags_read; | ||
456 | static write_proc_t security_flags_write; | ||
457 | /* static read_proc_t ntlmv2_enabled_read; | ||
458 | static write_proc_t ntlmv2_enabled_write; | ||
459 | static read_proc_t packet_signing_enabled_read; | ||
460 | static write_proc_t packet_signing_enabled_write;*/ | ||
461 | static read_proc_t experimEnabled_read; | ||
462 | static write_proc_t experimEnabled_write; | ||
463 | static read_proc_t linuxExtensionsEnabled_read; | ||
464 | static write_proc_t linuxExtensionsEnabled_write; | ||
465 | 381 | ||
466 | void | 382 | void |
467 | cifs_proc_init(void) | 383 | cifs_proc_init(void) |
468 | { | 384 | { |
469 | struct proc_dir_entry *pde; | ||
470 | |||
471 | proc_fs_cifs = proc_mkdir("fs/cifs", NULL); | 385 | proc_fs_cifs = proc_mkdir("fs/cifs", NULL); |
472 | if (proc_fs_cifs == NULL) | 386 | if (proc_fs_cifs == NULL) |
473 | return; | 387 | return; |
474 | 388 | ||
475 | proc_fs_cifs->owner = THIS_MODULE; | 389 | proc_fs_cifs->owner = THIS_MODULE; |
476 | create_proc_read_entry("DebugData", 0, proc_fs_cifs, | 390 | proc_create("DebugData", 0, proc_fs_cifs, &cifs_debug_data_proc_fops); |
477 | cifs_debug_data_read, NULL); | ||
478 | 391 | ||
479 | #ifdef CONFIG_CIFS_STATS | 392 | #ifdef CONFIG_CIFS_STATS |
480 | pde = create_proc_read_entry("Stats", 0, proc_fs_cifs, | 393 | proc_create("Stats", 0, proc_fs_cifs, &cifs_stats_proc_fops); |
481 | cifs_stats_read, NULL); | ||
482 | if (pde) | ||
483 | pde->write_proc = cifs_stats_write; | ||
484 | #endif /* STATS */ | 394 | #endif /* STATS */ |
485 | pde = create_proc_read_entry("cifsFYI", 0, proc_fs_cifs, | 395 | proc_create("cifsFYI", 0, proc_fs_cifs, &cifsFYI_proc_fops); |
486 | cifsFYI_read, NULL); | 396 | proc_create("traceSMB", 0, proc_fs_cifs, &traceSMB_proc_fops); |
487 | if (pde) | 397 | proc_create("OplockEnabled", 0, proc_fs_cifs, &cifs_oplock_proc_fops); |
488 | pde->write_proc = cifsFYI_write; | 398 | proc_create("Experimental", 0, proc_fs_cifs, |
489 | 399 | &cifs_experimental_proc_fops); | |
490 | pde = | 400 | proc_create("LinuxExtensionsEnabled", 0, proc_fs_cifs, |
491 | create_proc_read_entry("traceSMB", 0, proc_fs_cifs, | 401 | &cifs_linux_ext_proc_fops); |
492 | traceSMB_read, NULL); | 402 | proc_create("MultiuserMount", 0, proc_fs_cifs, |
493 | if (pde) | 403 | &cifs_multiuser_mount_proc_fops); |
494 | pde->write_proc = traceSMB_write; | 404 | proc_create("SecurityFlags", 0, proc_fs_cifs, |
495 | 405 | &cifs_security_flags_proc_fops); | |
496 | pde = create_proc_read_entry("OplockEnabled", 0, proc_fs_cifs, | 406 | proc_create("LookupCacheEnabled", 0, proc_fs_cifs, |
497 | oplockEnabled_read, NULL); | 407 | &cifs_lookup_cache_proc_fops); |
498 | if (pde) | ||
499 | pde->write_proc = oplockEnabled_write; | ||
500 | |||
501 | pde = create_proc_read_entry("Experimental", 0, proc_fs_cifs, | ||
502 | experimEnabled_read, NULL); | ||
503 | if (pde) | ||
504 | pde->write_proc = experimEnabled_write; | ||
505 | |||
506 | pde = create_proc_read_entry("LinuxExtensionsEnabled", 0, proc_fs_cifs, | ||
507 | linuxExtensionsEnabled_read, NULL); | ||
508 | if (pde) | ||
509 | pde->write_proc = linuxExtensionsEnabled_write; | ||
510 | |||
511 | pde = | ||
512 | create_proc_read_entry("MultiuserMount", 0, proc_fs_cifs, | ||
513 | multiuser_mount_read, NULL); | ||
514 | if (pde) | ||
515 | pde->write_proc = multiuser_mount_write; | ||
516 | |||
517 | pde = | ||
518 | create_proc_read_entry("SecurityFlags", 0, proc_fs_cifs, | ||
519 | security_flags_read, NULL); | ||
520 | if (pde) | ||
521 | pde->write_proc = security_flags_write; | ||
522 | |||
523 | pde = | ||
524 | create_proc_read_entry("LookupCacheEnabled", 0, proc_fs_cifs, | ||
525 | lookupFlag_read, NULL); | ||
526 | if (pde) | ||
527 | pde->write_proc = lookupFlag_write; | ||
528 | |||
529 | /* pde = | ||
530 | create_proc_read_entry("NTLMV2Enabled", 0, proc_fs_cifs, | ||
531 | ntlmv2_enabled_read, NULL); | ||
532 | if (pde) | ||
533 | pde->write_proc = ntlmv2_enabled_write; | ||
534 | |||
535 | pde = | ||
536 | create_proc_read_entry("PacketSigningEnabled", 0, proc_fs_cifs, | ||
537 | packet_signing_enabled_read, NULL); | ||
538 | if (pde) | ||
539 | pde->write_proc = packet_signing_enabled_write;*/ | ||
540 | } | 408 | } |
541 | 409 | ||
542 | void | 410 | void |
@@ -553,39 +421,26 @@ cifs_proc_clean(void) | |||
553 | #endif | 421 | #endif |
554 | remove_proc_entry("MultiuserMount", proc_fs_cifs); | 422 | remove_proc_entry("MultiuserMount", proc_fs_cifs); |
555 | remove_proc_entry("OplockEnabled", proc_fs_cifs); | 423 | remove_proc_entry("OplockEnabled", proc_fs_cifs); |
556 | /* remove_proc_entry("NTLMV2Enabled",proc_fs_cifs); */ | ||
557 | remove_proc_entry("SecurityFlags", proc_fs_cifs); | 424 | remove_proc_entry("SecurityFlags", proc_fs_cifs); |
558 | /* remove_proc_entry("PacketSigningEnabled", proc_fs_cifs); */ | ||
559 | remove_proc_entry("LinuxExtensionsEnabled", proc_fs_cifs); | 425 | remove_proc_entry("LinuxExtensionsEnabled", proc_fs_cifs); |
560 | remove_proc_entry("Experimental", proc_fs_cifs); | 426 | remove_proc_entry("Experimental", proc_fs_cifs); |
561 | remove_proc_entry("LookupCacheEnabled", proc_fs_cifs); | 427 | remove_proc_entry("LookupCacheEnabled", proc_fs_cifs); |
562 | remove_proc_entry("fs/cifs", NULL); | 428 | remove_proc_entry("fs/cifs", NULL); |
563 | } | 429 | } |
564 | 430 | ||
565 | static int | 431 | static int cifsFYI_proc_show(struct seq_file *m, void *v) |
566 | cifsFYI_read(char *page, char **start, off_t off, int count, | ||
567 | int *eof, void *data) | ||
568 | { | 432 | { |
569 | int len; | 433 | seq_printf(m, "%d\n", cifsFYI); |
570 | 434 | return 0; | |
571 | len = sprintf(page, "%d\n", cifsFYI); | 435 | } |
572 | |||
573 | len -= off; | ||
574 | *start = page + off; | ||
575 | |||
576 | if (len > count) | ||
577 | len = count; | ||
578 | else | ||
579 | *eof = 1; | ||
580 | |||
581 | if (len < 0) | ||
582 | len = 0; | ||
583 | 436 | ||
584 | return len; | 437 | static int cifsFYI_proc_open(struct inode *inode, struct file *file) |
438 | { | ||
439 | return single_open(file, cifsFYI_proc_show, NULL); | ||
585 | } | 440 | } |
586 | static int | 441 | |
587 | cifsFYI_write(struct file *file, const char __user *buffer, | 442 | static ssize_t cifsFYI_proc_write(struct file *file, const char __user *buffer, |
588 | unsigned long count, void *data) | 443 | size_t count, loff_t *ppos) |
589 | { | 444 | { |
590 | char c; | 445 | char c; |
591 | int rc; | 446 | int rc; |
@@ -603,30 +458,28 @@ cifsFYI_write(struct file *file, const char __user *buffer, | |||
603 | return count; | 458 | return count; |
604 | } | 459 | } |
605 | 460 | ||
606 | static int | 461 | static const struct file_operations cifsFYI_proc_fops = { |
607 | oplockEnabled_read(char *page, char **start, off_t off, | 462 | .owner = THIS_MODULE, |
608 | int count, int *eof, void *data) | 463 | .open = cifsFYI_proc_open, |
609 | { | 464 | .read = seq_read, |
610 | int len; | 465 | .llseek = seq_lseek, |
611 | 466 | .release = single_release, | |
612 | len = sprintf(page, "%d\n", oplockEnabled); | 467 | .write = cifsFYI_proc_write, |
613 | 468 | }; | |
614 | len -= off; | ||
615 | *start = page + off; | ||
616 | |||
617 | if (len > count) | ||
618 | len = count; | ||
619 | else | ||
620 | *eof = 1; | ||
621 | 469 | ||
622 | if (len < 0) | 470 | static int cifs_oplock_proc_show(struct seq_file *m, void *v) |
623 | len = 0; | 471 | { |
472 | seq_printf(m, "%d\n", oplockEnabled); | ||
473 | return 0; | ||
474 | } | ||
624 | 475 | ||
625 | return len; | 476 | static int cifs_oplock_proc_open(struct inode *inode, struct file *file) |
477 | { | ||
478 | return single_open(file, cifs_oplock_proc_show, NULL); | ||
626 | } | 479 | } |
627 | static int | 480 | |
628 | oplockEnabled_write(struct file *file, const char __user *buffer, | 481 | static ssize_t cifs_oplock_proc_write(struct file *file, |
629 | unsigned long count, void *data) | 482 | const char __user *buffer, size_t count, loff_t *ppos) |
630 | { | 483 | { |
631 | char c; | 484 | char c; |
632 | int rc; | 485 | int rc; |
@@ -642,30 +495,28 @@ oplockEnabled_write(struct file *file, const char __user *buffer, | |||
642 | return count; | 495 | return count; |
643 | } | 496 | } |
644 | 497 | ||
645 | static int | 498 | static const struct file_operations cifs_oplock_proc_fops = { |
646 | experimEnabled_read(char *page, char **start, off_t off, | 499 | .owner = THIS_MODULE, |
647 | int count, int *eof, void *data) | 500 | .open = cifs_oplock_proc_open, |
648 | { | 501 | .read = seq_read, |
649 | int len; | 502 | .llseek = seq_lseek, |
650 | 503 | .release = single_release, | |
651 | len = sprintf(page, "%d\n", experimEnabled); | 504 | .write = cifs_oplock_proc_write, |
652 | 505 | }; | |
653 | len -= off; | ||
654 | *start = page + off; | ||
655 | 506 | ||
656 | if (len > count) | 507 | static int cifs_experimental_proc_show(struct seq_file *m, void *v) |
657 | len = count; | 508 | { |
658 | else | 509 | seq_printf(m, "%d\n", experimEnabled); |
659 | *eof = 1; | 510 | return 0; |
660 | 511 | } | |
661 | if (len < 0) | ||
662 | len = 0; | ||
663 | 512 | ||
664 | return len; | 513 | static int cifs_experimental_proc_open(struct inode *inode, struct file *file) |
514 | { | ||
515 | return single_open(file, cifs_experimental_proc_show, NULL); | ||
665 | } | 516 | } |
666 | static int | 517 | |
667 | experimEnabled_write(struct file *file, const char __user *buffer, | 518 | static ssize_t cifs_experimental_proc_write(struct file *file, |
668 | unsigned long count, void *data) | 519 | const char __user *buffer, size_t count, loff_t *ppos) |
669 | { | 520 | { |
670 | char c; | 521 | char c; |
671 | int rc; | 522 | int rc; |
@@ -683,29 +534,28 @@ experimEnabled_write(struct file *file, const char __user *buffer, | |||
683 | return count; | 534 | return count; |
684 | } | 535 | } |
685 | 536 | ||
686 | static int | 537 | static const struct file_operations cifs_experimental_proc_fops = { |
687 | linuxExtensionsEnabled_read(char *page, char **start, off_t off, | 538 | .owner = THIS_MODULE, |
688 | int count, int *eof, void *data) | 539 | .open = cifs_experimental_proc_open, |
689 | { | 540 | .read = seq_read, |
690 | int len; | 541 | .llseek = seq_lseek, |
691 | 542 | .release = single_release, | |
692 | len = sprintf(page, "%d\n", linuxExtEnabled); | 543 | .write = cifs_experimental_proc_write, |
693 | len -= off; | 544 | }; |
694 | *start = page + off; | ||
695 | 545 | ||
696 | if (len > count) | 546 | static int cifs_linux_ext_proc_show(struct seq_file *m, void *v) |
697 | len = count; | 547 | { |
698 | else | 548 | seq_printf(m, "%d\n", linuxExtEnabled); |
699 | *eof = 1; | 549 | return 0; |
700 | 550 | } | |
701 | if (len < 0) | ||
702 | len = 0; | ||
703 | 551 | ||
704 | return len; | 552 | static int cifs_linux_ext_proc_open(struct inode *inode, struct file *file) |
553 | { | ||
554 | return single_open(file, cifs_linux_ext_proc_show, NULL); | ||
705 | } | 555 | } |
706 | static int | 556 | |
707 | linuxExtensionsEnabled_write(struct file *file, const char __user *buffer, | 557 | static ssize_t cifs_linux_ext_proc_write(struct file *file, |
708 | unsigned long count, void *data) | 558 | const char __user *buffer, size_t count, loff_t *ppos) |
709 | { | 559 | { |
710 | char c; | 560 | char c; |
711 | int rc; | 561 | int rc; |
@@ -721,31 +571,28 @@ linuxExtensionsEnabled_write(struct file *file, const char __user *buffer, | |||
721 | return count; | 571 | return count; |
722 | } | 572 | } |
723 | 573 | ||
574 | static const struct file_operations cifs_linux_ext_proc_fops = { | ||
575 | .owner = THIS_MODULE, | ||
576 | .open = cifs_linux_ext_proc_open, | ||
577 | .read = seq_read, | ||
578 | .llseek = seq_lseek, | ||
579 | .release = single_release, | ||
580 | .write = cifs_linux_ext_proc_write, | ||
581 | }; | ||
724 | 582 | ||
725 | static int | 583 | static int cifs_lookup_cache_proc_show(struct seq_file *m, void *v) |
726 | lookupFlag_read(char *page, char **start, off_t off, | ||
727 | int count, int *eof, void *data) | ||
728 | { | 584 | { |
729 | int len; | 585 | seq_printf(m, "%d\n", lookupCacheEnabled); |
730 | 586 | return 0; | |
731 | len = sprintf(page, "%d\n", lookupCacheEnabled); | 587 | } |
732 | |||
733 | len -= off; | ||
734 | *start = page + off; | ||
735 | |||
736 | if (len > count) | ||
737 | len = count; | ||
738 | else | ||
739 | *eof = 1; | ||
740 | |||
741 | if (len < 0) | ||
742 | len = 0; | ||
743 | 588 | ||
744 | return len; | 589 | static int cifs_lookup_cache_proc_open(struct inode *inode, struct file *file) |
590 | { | ||
591 | return single_open(file, cifs_lookup_cache_proc_show, NULL); | ||
745 | } | 592 | } |
746 | static int | 593 | |
747 | lookupFlag_write(struct file *file, const char __user *buffer, | 594 | static ssize_t cifs_lookup_cache_proc_write(struct file *file, |
748 | unsigned long count, void *data) | 595 | const char __user *buffer, size_t count, loff_t *ppos) |
749 | { | 596 | { |
750 | char c; | 597 | char c; |
751 | int rc; | 598 | int rc; |
@@ -760,30 +607,29 @@ lookupFlag_write(struct file *file, const char __user *buffer, | |||
760 | 607 | ||
761 | return count; | 608 | return count; |
762 | } | 609 | } |
763 | static int | ||
764 | traceSMB_read(char *page, char **start, off_t off, int count, | ||
765 | int *eof, void *data) | ||
766 | { | ||
767 | int len; | ||
768 | |||
769 | len = sprintf(page, "%d\n", traceSMB); | ||
770 | |||
771 | len -= off; | ||
772 | *start = page + off; | ||
773 | 610 | ||
774 | if (len > count) | 611 | static const struct file_operations cifs_lookup_cache_proc_fops = { |
775 | len = count; | 612 | .owner = THIS_MODULE, |
776 | else | 613 | .open = cifs_lookup_cache_proc_open, |
777 | *eof = 1; | 614 | .read = seq_read, |
615 | .llseek = seq_lseek, | ||
616 | .release = single_release, | ||
617 | .write = cifs_lookup_cache_proc_write, | ||
618 | }; | ||
778 | 619 | ||
779 | if (len < 0) | 620 | static int traceSMB_proc_show(struct seq_file *m, void *v) |
780 | len = 0; | 621 | { |
622 | seq_printf(m, "%d\n", traceSMB); | ||
623 | return 0; | ||
624 | } | ||
781 | 625 | ||
782 | return len; | 626 | static int traceSMB_proc_open(struct inode *inode, struct file *file) |
627 | { | ||
628 | return single_open(file, traceSMB_proc_show, NULL); | ||
783 | } | 629 | } |
784 | static int | 630 | |
785 | traceSMB_write(struct file *file, const char __user *buffer, | 631 | static ssize_t traceSMB_proc_write(struct file *file, const char __user *buffer, |
786 | unsigned long count, void *data) | 632 | size_t count, loff_t *ppos) |
787 | { | 633 | { |
788 | char c; | 634 | char c; |
789 | int rc; | 635 | int rc; |
@@ -799,30 +645,28 @@ traceSMB_write(struct file *file, const char __user *buffer, | |||
799 | return count; | 645 | return count; |
800 | } | 646 | } |
801 | 647 | ||
802 | static int | 648 | static const struct file_operations traceSMB_proc_fops = { |
803 | multiuser_mount_read(char *page, char **start, off_t off, | 649 | .owner = THIS_MODULE, |
804 | int count, int *eof, void *data) | 650 | .open = traceSMB_proc_open, |
805 | { | 651 | .read = seq_read, |
806 | int len; | 652 | .llseek = seq_lseek, |
807 | 653 | .release = single_release, | |
808 | len = sprintf(page, "%d\n", multiuser_mount); | 654 | .write = traceSMB_proc_write, |
809 | 655 | }; | |
810 | len -= off; | ||
811 | *start = page + off; | ||
812 | 656 | ||
813 | if (len > count) | 657 | static int cifs_multiuser_mount_proc_show(struct seq_file *m, void *v) |
814 | len = count; | 658 | { |
815 | else | 659 | seq_printf(m, "%d\n", multiuser_mount); |
816 | *eof = 1; | 660 | return 0; |
817 | 661 | } | |
818 | if (len < 0) | ||
819 | len = 0; | ||
820 | 662 | ||
821 | return len; | 663 | static int cifs_multiuser_mount_proc_open(struct inode *inode, struct file *fh) |
664 | { | ||
665 | return single_open(fh, cifs_multiuser_mount_proc_show, NULL); | ||
822 | } | 666 | } |
823 | static int | 667 | |
824 | multiuser_mount_write(struct file *file, const char __user *buffer, | 668 | static ssize_t cifs_multiuser_mount_proc_write(struct file *file, |
825 | unsigned long count, void *data) | 669 | const char __user *buffer, size_t count, loff_t *ppos) |
826 | { | 670 | { |
827 | char c; | 671 | char c; |
828 | int rc; | 672 | int rc; |
@@ -838,30 +682,28 @@ multiuser_mount_write(struct file *file, const char __user *buffer, | |||
838 | return count; | 682 | return count; |
839 | } | 683 | } |
840 | 684 | ||
841 | static int | 685 | static const struct file_operations cifs_multiuser_mount_proc_fops = { |
842 | security_flags_read(char *page, char **start, off_t off, | 686 | .owner = THIS_MODULE, |
843 | int count, int *eof, void *data) | 687 | .open = cifs_multiuser_mount_proc_open, |
844 | { | 688 | .read = seq_read, |
845 | int len; | 689 | .llseek = seq_lseek, |
846 | 690 | .release = single_release, | |
847 | len = sprintf(page, "0x%x\n", extended_security); | 691 | .write = cifs_multiuser_mount_proc_write, |
848 | 692 | }; | |
849 | len -= off; | ||
850 | *start = page + off; | ||
851 | 693 | ||
852 | if (len > count) | 694 | static int cifs_security_flags_proc_show(struct seq_file *m, void *v) |
853 | len = count; | 695 | { |
854 | else | 696 | seq_printf(m, "0x%x\n", extended_security); |
855 | *eof = 1; | 697 | return 0; |
856 | 698 | } | |
857 | if (len < 0) | ||
858 | len = 0; | ||
859 | 699 | ||
860 | return len; | 700 | static int cifs_security_flags_proc_open(struct inode *inode, struct file *file) |
701 | { | ||
702 | return single_open(file, cifs_security_flags_proc_show, NULL); | ||
861 | } | 703 | } |
862 | static int | 704 | |
863 | security_flags_write(struct file *file, const char __user *buffer, | 705 | static ssize_t cifs_security_flags_proc_write(struct file *file, |
864 | unsigned long count, void *data) | 706 | const char __user *buffer, size_t count, loff_t *ppos) |
865 | { | 707 | { |
866 | unsigned int flags; | 708 | unsigned int flags; |
867 | char flags_string[12]; | 709 | char flags_string[12]; |
@@ -917,6 +759,15 @@ security_flags_write(struct file *file, const char __user *buffer, | |||
917 | /* BB should we turn on MAY flags for other MUST options? */ | 759 | /* BB should we turn on MAY flags for other MUST options? */ |
918 | return count; | 760 | return count; |
919 | } | 761 | } |
762 | |||
763 | static const struct file_operations cifs_security_flags_proc_fops = { | ||
764 | .owner = THIS_MODULE, | ||
765 | .open = cifs_security_flags_proc_open, | ||
766 | .read = seq_read, | ||
767 | .llseek = seq_lseek, | ||
768 | .release = single_release, | ||
769 | .write = cifs_security_flags_proc_write, | ||
770 | }; | ||
920 | #else | 771 | #else |
921 | inline void cifs_proc_init(void) | 772 | inline void cifs_proc_init(void) |
922 | { | 773 | { |
diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c index 0e9fc2ba90ee..57ecdc83c26f 100644 --- a/fs/cifs/cifsacl.c +++ b/fs/cifs/cifsacl.c | |||
@@ -56,7 +56,7 @@ int match_sid(struct cifs_sid *ctsid) | |||
56 | struct cifs_sid *cwsid; | 56 | struct cifs_sid *cwsid; |
57 | 57 | ||
58 | if (!ctsid) | 58 | if (!ctsid) |
59 | return (-1); | 59 | return -1; |
60 | 60 | ||
61 | for (i = 0; i < NUM_WK_SIDS; ++i) { | 61 | for (i = 0; i < NUM_WK_SIDS; ++i) { |
62 | cwsid = &(wksidarr[i].cifssid); | 62 | cwsid = &(wksidarr[i].cifssid); |
@@ -87,11 +87,11 @@ int match_sid(struct cifs_sid *ctsid) | |||
87 | } | 87 | } |
88 | 88 | ||
89 | cFYI(1, ("matching sid: %s\n", wksidarr[i].sidname)); | 89 | cFYI(1, ("matching sid: %s\n", wksidarr[i].sidname)); |
90 | return (0); /* sids compare/match */ | 90 | return 0; /* sids compare/match */ |
91 | } | 91 | } |
92 | 92 | ||
93 | cFYI(1, ("No matching sid")); | 93 | cFYI(1, ("No matching sid")); |
94 | return (-1); | 94 | return -1; |
95 | } | 95 | } |
96 | 96 | ||
97 | /* if the two SIDs (roughly equivalent to a UUID for a user or group) are | 97 | /* if the two SIDs (roughly equivalent to a UUID for a user or group) are |
@@ -102,16 +102,16 @@ int compare_sids(const struct cifs_sid *ctsid, const struct cifs_sid *cwsid) | |||
102 | int num_subauth, num_sat, num_saw; | 102 | int num_subauth, num_sat, num_saw; |
103 | 103 | ||
104 | if ((!ctsid) || (!cwsid)) | 104 | if ((!ctsid) || (!cwsid)) |
105 | return (0); | 105 | return 0; |
106 | 106 | ||
107 | /* compare the revision */ | 107 | /* compare the revision */ |
108 | if (ctsid->revision != cwsid->revision) | 108 | if (ctsid->revision != cwsid->revision) |
109 | return (0); | 109 | return 0; |
110 | 110 | ||
111 | /* compare all of the six auth values */ | 111 | /* compare all of the six auth values */ |
112 | for (i = 0; i < 6; ++i) { | 112 | for (i = 0; i < 6; ++i) { |
113 | if (ctsid->authority[i] != cwsid->authority[i]) | 113 | if (ctsid->authority[i] != cwsid->authority[i]) |
114 | return (0); | 114 | return 0; |
115 | } | 115 | } |
116 | 116 | ||
117 | /* compare all of the subauth values if any */ | 117 | /* compare all of the subauth values if any */ |
@@ -121,11 +121,11 @@ int compare_sids(const struct cifs_sid *ctsid, const struct cifs_sid *cwsid) | |||
121 | if (num_subauth) { | 121 | if (num_subauth) { |
122 | for (i = 0; i < num_subauth; ++i) { | 122 | for (i = 0; i < num_subauth; ++i) { |
123 | if (ctsid->sub_auth[i] != cwsid->sub_auth[i]) | 123 | if (ctsid->sub_auth[i] != cwsid->sub_auth[i]) |
124 | return (0); | 124 | return 0; |
125 | } | 125 | } |
126 | } | 126 | } |
127 | 127 | ||
128 | return (1); /* sids compare/match */ | 128 | return 1; /* sids compare/match */ |
129 | } | 129 | } |
130 | 130 | ||
131 | 131 | ||
@@ -169,8 +169,7 @@ static void copy_sec_desc(const struct cifs_ntsd *pntsd, | |||
169 | for (i = 0; i < 6; i++) | 169 | for (i = 0; i < 6; i++) |
170 | ngroup_sid_ptr->authority[i] = group_sid_ptr->authority[i]; | 170 | ngroup_sid_ptr->authority[i] = group_sid_ptr->authority[i]; |
171 | for (i = 0; i < 5; i++) | 171 | for (i = 0; i < 5; i++) |
172 | ngroup_sid_ptr->sub_auth[i] = | 172 | ngroup_sid_ptr->sub_auth[i] = group_sid_ptr->sub_auth[i]; |
173 | cpu_to_le32(group_sid_ptr->sub_auth[i]); | ||
174 | 173 | ||
175 | return; | 174 | return; |
176 | } | 175 | } |
@@ -285,7 +284,7 @@ static __u16 fill_ace_for_sid(struct cifs_ace *pntace, | |||
285 | size = 1 + 1 + 2 + 4 + 1 + 1 + 6 + (psid->num_subauth * 4); | 284 | size = 1 + 1 + 2 + 4 + 1 + 1 + 6 + (psid->num_subauth * 4); |
286 | pntace->size = cpu_to_le16(size); | 285 | pntace->size = cpu_to_le16(size); |
287 | 286 | ||
288 | return (size); | 287 | return size; |
289 | } | 288 | } |
290 | 289 | ||
291 | 290 | ||
@@ -426,7 +425,7 @@ static int set_chmod_dacl(struct cifs_acl *pndacl, struct cifs_sid *pownersid, | |||
426 | pndacl->size = cpu_to_le16(size + sizeof(struct cifs_acl)); | 425 | pndacl->size = cpu_to_le16(size + sizeof(struct cifs_acl)); |
427 | pndacl->num_aces = cpu_to_le32(3); | 426 | pndacl->num_aces = cpu_to_le32(3); |
428 | 427 | ||
429 | return (0); | 428 | return 0; |
430 | } | 429 | } |
431 | 430 | ||
432 | 431 | ||
@@ -510,7 +509,7 @@ static int parse_sec_desc(struct cifs_ntsd *pntsd, int acl_len, | |||
510 | sizeof(struct cifs_sid)); */ | 509 | sizeof(struct cifs_sid)); */ |
511 | 510 | ||
512 | 511 | ||
513 | return (0); | 512 | return 0; |
514 | } | 513 | } |
515 | 514 | ||
516 | 515 | ||
@@ -527,7 +526,7 @@ static int build_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd, | |||
527 | struct cifs_acl *ndacl_ptr = NULL; /* no need for SACL ptr */ | 526 | struct cifs_acl *ndacl_ptr = NULL; /* no need for SACL ptr */ |
528 | 527 | ||
529 | if ((inode == NULL) || (pntsd == NULL) || (pnntsd == NULL)) | 528 | if ((inode == NULL) || (pntsd == NULL) || (pnntsd == NULL)) |
530 | return (-EIO); | 529 | return -EIO; |
531 | 530 | ||
532 | owner_sid_ptr = (struct cifs_sid *)((char *)pntsd + | 531 | owner_sid_ptr = (struct cifs_sid *)((char *)pntsd + |
533 | le32_to_cpu(pntsd->osidoffset)); | 532 | le32_to_cpu(pntsd->osidoffset)); |
@@ -550,7 +549,7 @@ static int build_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd, | |||
550 | /* copy security descriptor control portion and owner and group sid */ | 549 | /* copy security descriptor control portion and owner and group sid */ |
551 | copy_sec_desc(pntsd, pnntsd, sidsoffset); | 550 | copy_sec_desc(pntsd, pnntsd, sidsoffset); |
552 | 551 | ||
553 | return (rc); | 552 | return rc; |
554 | } | 553 | } |
555 | 554 | ||
556 | 555 | ||
@@ -629,11 +628,11 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen, | |||
629 | cFYI(DBG2, ("set ACL for %s from mode 0x%x", path, inode->i_mode)); | 628 | cFYI(DBG2, ("set ACL for %s from mode 0x%x", path, inode->i_mode)); |
630 | 629 | ||
631 | if (!inode) | 630 | if (!inode) |
632 | return (rc); | 631 | return rc; |
633 | 632 | ||
634 | sb = inode->i_sb; | 633 | sb = inode->i_sb; |
635 | if (sb == NULL) | 634 | if (sb == NULL) |
636 | return (rc); | 635 | return rc; |
637 | 636 | ||
638 | cifs_sb = CIFS_SB(sb); | 637 | cifs_sb = CIFS_SB(sb); |
639 | xid = GetXid(); | 638 | xid = GetXid(); |
@@ -652,7 +651,7 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen, | |||
652 | if (rc != 0) { | 651 | if (rc != 0) { |
653 | cERROR(1, ("Unable to open file to set ACL")); | 652 | cERROR(1, ("Unable to open file to set ACL")); |
654 | FreeXid(xid); | 653 | FreeXid(xid); |
655 | return (rc); | 654 | return rc; |
656 | } | 655 | } |
657 | } | 656 | } |
658 | 657 | ||
@@ -665,7 +664,7 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen, | |||
665 | 664 | ||
666 | FreeXid(xid); | 665 | FreeXid(xid); |
667 | 666 | ||
668 | return (rc); | 667 | return rc; |
669 | } | 668 | } |
670 | 669 | ||
671 | /* Translate the CIFS ACL (simlar to NTFS ACL) for a file into mode bits */ | 670 | /* Translate the CIFS ACL (simlar to NTFS ACL) for a file into mode bits */ |
@@ -715,7 +714,7 @@ int mode_to_acl(struct inode *inode, const char *path, __u64 nmode) | |||
715 | if (!pnntsd) { | 714 | if (!pnntsd) { |
716 | cERROR(1, ("Unable to allocate security descriptor")); | 715 | cERROR(1, ("Unable to allocate security descriptor")); |
717 | kfree(pntsd); | 716 | kfree(pntsd); |
718 | return (-ENOMEM); | 717 | return -ENOMEM; |
719 | } | 718 | } |
720 | 719 | ||
721 | rc = build_sec_desc(pntsd, pnntsd, inode, nmode); | 720 | rc = build_sec_desc(pntsd, pnntsd, inode, nmode); |
@@ -732,6 +731,6 @@ int mode_to_acl(struct inode *inode, const char *path, __u64 nmode) | |||
732 | kfree(pntsd); | 731 | kfree(pntsd); |
733 | } | 732 | } |
734 | 733 | ||
735 | return (rc); | 734 | return rc; |
736 | } | 735 | } |
737 | #endif /* CONFIG_CIFS_EXPERIMENTAL */ | 736 | #endif /* CONFIG_CIFS_EXPERIMENTAL */ |
diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c index 4ff8939c6cc7..83fd40dc1ef0 100644 --- a/fs/cifs/cifsencrypt.c +++ b/fs/cifs/cifsencrypt.c | |||
@@ -310,9 +310,8 @@ void calc_lanman_hash(struct cifsSesInfo *ses, char *lnm_session_key) | |||
310 | utf8 and other multibyte codepages each need their own strupper | 310 | utf8 and other multibyte codepages each need their own strupper |
311 | function since a byte at a time will ont work. */ | 311 | function since a byte at a time will ont work. */ |
312 | 312 | ||
313 | for (i = 0; i < CIFS_ENCPWD_SIZE; i++) { | 313 | for (i = 0; i < CIFS_ENCPWD_SIZE; i++) |
314 | password_with_pad[i] = toupper(password_with_pad[i]); | 314 | password_with_pad[i] = toupper(password_with_pad[i]); |
315 | } | ||
316 | 315 | ||
317 | SMBencrypt(password_with_pad, ses->server->cryptKey, lnm_session_key); | 316 | SMBencrypt(password_with_pad, ses->server->cryptKey, lnm_session_key); |
318 | /* clear password before we return/free memory */ | 317 | /* clear password before we return/free memory */ |
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 22857c639df5..1ec7076f7b24 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c | |||
@@ -267,7 +267,7 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
267 | return 0; | 267 | return 0; |
268 | } | 268 | } |
269 | 269 | ||
270 | static int cifs_permission(struct inode *inode, int mask, struct nameidata *nd) | 270 | static int cifs_permission(struct inode *inode, int mask) |
271 | { | 271 | { |
272 | struct cifs_sb_info *cifs_sb; | 272 | struct cifs_sb_info *cifs_sb; |
273 | 273 | ||
@@ -766,7 +766,7 @@ const struct file_operations cifs_dir_ops = { | |||
766 | }; | 766 | }; |
767 | 767 | ||
768 | static void | 768 | static void |
769 | cifs_init_once(struct kmem_cache *cachep, void *inode) | 769 | cifs_init_once(void *inode) |
770 | { | 770 | { |
771 | struct cifsInodeInfo *cifsi = inode; | 771 | struct cifsInodeInfo *cifsi = inode; |
772 | 772 | ||
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 9cfcf326ead3..7e1cf262effe 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h | |||
@@ -27,7 +27,7 @@ | |||
27 | #define MAX_SES_INFO 2 | 27 | #define MAX_SES_INFO 2 |
28 | #define MAX_TCON_INFO 4 | 28 | #define MAX_TCON_INFO 4 |
29 | 29 | ||
30 | #define MAX_TREE_SIZE 2 + MAX_SERVER_SIZE + 1 + MAX_SHARE_SIZE + 1 | 30 | #define MAX_TREE_SIZE (2 + MAX_SERVER_SIZE + 1 + MAX_SHARE_SIZE + 1) |
31 | #define MAX_SERVER_SIZE 15 | 31 | #define MAX_SERVER_SIZE 15 |
32 | #define MAX_SHARE_SIZE 64 /* used to be 20, this should still be enough */ | 32 | #define MAX_SHARE_SIZE 64 /* used to be 20, this should still be enough */ |
33 | #define MAX_USERNAME_SIZE 32 /* 32 is to allow for 15 char names + null | 33 | #define MAX_USERNAME_SIZE 32 /* 32 is to allow for 15 char names + null |
@@ -537,8 +537,8 @@ require use of the stronger protocol */ | |||
537 | #endif /* WEAK_PW_HASH */ | 537 | #endif /* WEAK_PW_HASH */ |
538 | #define CIFSSEC_MUST_SEAL 0x40040 /* not supported yet */ | 538 | #define CIFSSEC_MUST_SEAL 0x40040 /* not supported yet */ |
539 | 539 | ||
540 | #define CIFSSEC_DEF CIFSSEC_MAY_SIGN | CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2 | 540 | #define CIFSSEC_DEF (CIFSSEC_MAY_SIGN | CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2) |
541 | #define CIFSSEC_MAX CIFSSEC_MUST_SIGN | CIFSSEC_MUST_NTLMV2 | 541 | #define CIFSSEC_MAX (CIFSSEC_MUST_SIGN | CIFSSEC_MUST_NTLMV2) |
542 | #define CIFSSEC_AUTH_MASK (CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2 | CIFSSEC_MAY_LANMAN | CIFSSEC_MAY_PLNTXT | CIFSSEC_MAY_KRB5) | 542 | #define CIFSSEC_AUTH_MASK (CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2 | CIFSSEC_MAY_LANMAN | CIFSSEC_MAY_PLNTXT | CIFSSEC_MAY_KRB5) |
543 | /* | 543 | /* |
544 | ***************************************************************** | 544 | ***************************************************************** |
diff --git a/fs/cifs/cifspdu.h b/fs/cifs/cifspdu.h index 0f327c224da3..409abce12732 100644 --- a/fs/cifs/cifspdu.h +++ b/fs/cifs/cifspdu.h | |||
@@ -31,7 +31,7 @@ | |||
31 | #else | 31 | #else |
32 | #define CIFS_PROT 0 | 32 | #define CIFS_PROT 0 |
33 | #endif | 33 | #endif |
34 | #define POSIX_PROT CIFS_PROT+1 | 34 | #define POSIX_PROT (CIFS_PROT+1) |
35 | #define BAD_PROT 0xFFFF | 35 | #define BAD_PROT 0xFFFF |
36 | 36 | ||
37 | /* SMB command codes */ | 37 | /* SMB command codes */ |
@@ -341,7 +341,7 @@ | |||
341 | #define CREATE_COMPLETE_IF_OPLK 0x00000100 /* should be zero */ | 341 | #define CREATE_COMPLETE_IF_OPLK 0x00000100 /* should be zero */ |
342 | #define CREATE_NO_EA_KNOWLEDGE 0x00000200 | 342 | #define CREATE_NO_EA_KNOWLEDGE 0x00000200 |
343 | #define CREATE_EIGHT_DOT_THREE 0x00000400 /* doc says this is obsolete | 343 | #define CREATE_EIGHT_DOT_THREE 0x00000400 /* doc says this is obsolete |
344 | "open for recovery" flag - should | 344 | "open for recovery" flag should |
345 | be zero in any case */ | 345 | be zero in any case */ |
346 | #define CREATE_OPEN_FOR_RECOVERY 0x00000400 | 346 | #define CREATE_OPEN_FOR_RECOVERY 0x00000400 |
347 | #define CREATE_RANDOM_ACCESS 0x00000800 | 347 | #define CREATE_RANDOM_ACCESS 0x00000800 |
@@ -414,8 +414,8 @@ struct smb_hdr { | |||
414 | __u8 WordCount; | 414 | __u8 WordCount; |
415 | } __attribute__((packed)); | 415 | } __attribute__((packed)); |
416 | /* given a pointer to an smb_hdr retrieve the value of byte count */ | 416 | /* given a pointer to an smb_hdr retrieve the value of byte count */ |
417 | #define BCC(smb_var) ( *(__u16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount))) | 417 | #define BCC(smb_var) (*(__u16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount))) |
418 | #define BCC_LE(smb_var) ( *(__le16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount))) | 418 | #define BCC_LE(smb_var) (*(__le16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount))) |
419 | /* given a pointer to an smb_hdr retrieve the pointer to the byte area */ | 419 | /* given a pointer to an smb_hdr retrieve the pointer to the byte area */ |
420 | #define pByteArea(smb_var) ((unsigned char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount) + 2) | 420 | #define pByteArea(smb_var) ((unsigned char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount) + 2) |
421 | 421 | ||
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 4511b708f0f3..c621ffa2ca90 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c | |||
@@ -686,11 +686,10 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses) | |||
686 | SecurityBlob, | 686 | SecurityBlob, |
687 | count - 16, | 687 | count - 16, |
688 | &server->secType); | 688 | &server->secType); |
689 | if (rc == 1) { | 689 | if (rc == 1) |
690 | rc = 0; | 690 | rc = 0; |
691 | } else { | 691 | else |
692 | rc = -EINVAL; | 692 | rc = -EINVAL; |
693 | } | ||
694 | } | 693 | } |
695 | } else | 694 | } else |
696 | server->capabilities &= ~CAP_EXTENDED_SECURITY; | 695 | server->capabilities &= ~CAP_EXTENDED_SECURITY; |
@@ -3914,7 +3913,10 @@ parse_DFS_referrals(TRANSACTION2_GET_DFS_REFER_RSP *pSMBr, | |||
3914 | bool is_unicode; | 3913 | bool is_unicode; |
3915 | struct dfs_referral_level_3 *ref; | 3914 | struct dfs_referral_level_3 *ref; |
3916 | 3915 | ||
3917 | is_unicode = pSMBr->hdr.Flags2 & SMBFLG2_UNICODE; | 3916 | if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) |
3917 | is_unicode = true; | ||
3918 | else | ||
3919 | is_unicode = false; | ||
3918 | *num_of_nodes = le16_to_cpu(pSMBr->NumberOfReferrals); | 3920 | *num_of_nodes = le16_to_cpu(pSMBr->NumberOfReferrals); |
3919 | 3921 | ||
3920 | if (*num_of_nodes < 1) { | 3922 | if (*num_of_nodes < 1) { |
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index e8fa46c7cff2..b51d5777cde6 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -455,7 +455,7 @@ incomplete_rcv: | |||
455 | /* Note that FC 1001 length is big endian on the wire, | 455 | /* Note that FC 1001 length is big endian on the wire, |
456 | but we convert it here so it is always manipulated | 456 | but we convert it here so it is always manipulated |
457 | as host byte order */ | 457 | as host byte order */ |
458 | pdu_length = ntohl(smb_buffer->smb_buf_length); | 458 | pdu_length = be32_to_cpu((__force __be32)smb_buffer->smb_buf_length); |
459 | smb_buffer->smb_buf_length = pdu_length; | 459 | smb_buffer->smb_buf_length = pdu_length; |
460 | 460 | ||
461 | cFYI(1, ("rfc1002 length 0x%x", pdu_length+4)); | 461 | cFYI(1, ("rfc1002 length 0x%x", pdu_length+4)); |
@@ -1461,6 +1461,39 @@ get_dfs_path(int xid, struct cifsSesInfo *pSesInfo, const char *old_path, | |||
1461 | return rc; | 1461 | return rc; |
1462 | } | 1462 | } |
1463 | 1463 | ||
1464 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
1465 | static struct lock_class_key cifs_key[2]; | ||
1466 | static struct lock_class_key cifs_slock_key[2]; | ||
1467 | |||
1468 | static inline void | ||
1469 | cifs_reclassify_socket4(struct socket *sock) | ||
1470 | { | ||
1471 | struct sock *sk = sock->sk; | ||
1472 | BUG_ON(sock_owned_by_user(sk)); | ||
1473 | sock_lock_init_class_and_name(sk, "slock-AF_INET-CIFS", | ||
1474 | &cifs_slock_key[0], "sk_lock-AF_INET-CIFS", &cifs_key[0]); | ||
1475 | } | ||
1476 | |||
1477 | static inline void | ||
1478 | cifs_reclassify_socket6(struct socket *sock) | ||
1479 | { | ||
1480 | struct sock *sk = sock->sk; | ||
1481 | BUG_ON(sock_owned_by_user(sk)); | ||
1482 | sock_lock_init_class_and_name(sk, "slock-AF_INET6-CIFS", | ||
1483 | &cifs_slock_key[1], "sk_lock-AF_INET6-CIFS", &cifs_key[1]); | ||
1484 | } | ||
1485 | #else | ||
1486 | static inline void | ||
1487 | cifs_reclassify_socket4(struct socket *sock) | ||
1488 | { | ||
1489 | } | ||
1490 | |||
1491 | static inline void | ||
1492 | cifs_reclassify_socket6(struct socket *sock) | ||
1493 | { | ||
1494 | } | ||
1495 | #endif | ||
1496 | |||
1464 | /* See RFC1001 section 14 on representation of Netbios names */ | 1497 | /* See RFC1001 section 14 on representation of Netbios names */ |
1465 | static void rfc1002mangle(char *target, char *source, unsigned int length) | 1498 | static void rfc1002mangle(char *target, char *source, unsigned int length) |
1466 | { | 1499 | { |
@@ -1495,6 +1528,7 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, | |||
1495 | /* BB other socket options to set KEEPALIVE, NODELAY? */ | 1528 | /* BB other socket options to set KEEPALIVE, NODELAY? */ |
1496 | cFYI(1, ("Socket created")); | 1529 | cFYI(1, ("Socket created")); |
1497 | (*csocket)->sk->sk_allocation = GFP_NOFS; | 1530 | (*csocket)->sk->sk_allocation = GFP_NOFS; |
1531 | cifs_reclassify_socket4(*csocket); | ||
1498 | } | 1532 | } |
1499 | } | 1533 | } |
1500 | 1534 | ||
@@ -1627,6 +1661,7 @@ ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket) | |||
1627 | /* BB other socket options to set KEEPALIVE, NODELAY? */ | 1661 | /* BB other socket options to set KEEPALIVE, NODELAY? */ |
1628 | cFYI(1, ("ipv6 Socket created")); | 1662 | cFYI(1, ("ipv6 Socket created")); |
1629 | (*csocket)->sk->sk_allocation = GFP_NOFS; | 1663 | (*csocket)->sk->sk_allocation = GFP_NOFS; |
1664 | cifs_reclassify_socket6(*csocket); | ||
1630 | } | 1665 | } |
1631 | } | 1666 | } |
1632 | 1667 | ||
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index 2e904bd111c8..46e54d39461d 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c | |||
@@ -1413,6 +1413,82 @@ out_busy: | |||
1413 | return -ETXTBSY; | 1413 | return -ETXTBSY; |
1414 | } | 1414 | } |
1415 | 1415 | ||
1416 | static int | ||
1417 | cifs_set_file_size(struct inode *inode, struct iattr *attrs, | ||
1418 | int xid, char *full_path) | ||
1419 | { | ||
1420 | int rc; | ||
1421 | struct cifsFileInfo *open_file; | ||
1422 | struct cifsInodeInfo *cifsInode = CIFS_I(inode); | ||
1423 | struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); | ||
1424 | struct cifsTconInfo *pTcon = cifs_sb->tcon; | ||
1425 | |||
1426 | /* | ||
1427 | * To avoid spurious oplock breaks from server, in the case of | ||
1428 | * inodes that we already have open, avoid doing path based | ||
1429 | * setting of file size if we can do it by handle. | ||
1430 | * This keeps our caching token (oplock) and avoids timeouts | ||
1431 | * when the local oplock break takes longer to flush | ||
1432 | * writebehind data than the SMB timeout for the SetPathInfo | ||
1433 | * request would allow | ||
1434 | */ | ||
1435 | open_file = find_writable_file(cifsInode); | ||
1436 | if (open_file) { | ||
1437 | __u16 nfid = open_file->netfid; | ||
1438 | __u32 npid = open_file->pid; | ||
1439 | rc = CIFSSMBSetFileSize(xid, pTcon, attrs->ia_size, nfid, | ||
1440 | npid, false); | ||
1441 | atomic_dec(&open_file->wrtPending); | ||
1442 | cFYI(1, ("SetFSize for attrs rc = %d", rc)); | ||
1443 | if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) { | ||
1444 | unsigned int bytes_written; | ||
1445 | rc = CIFSSMBWrite(xid, pTcon, nfid, 0, attrs->ia_size, | ||
1446 | &bytes_written, NULL, NULL, 1); | ||
1447 | cFYI(1, ("Wrt seteof rc %d", rc)); | ||
1448 | } | ||
1449 | } else | ||
1450 | rc = -EINVAL; | ||
1451 | |||
1452 | if (rc != 0) { | ||
1453 | /* Set file size by pathname rather than by handle | ||
1454 | either because no valid, writeable file handle for | ||
1455 | it was found or because there was an error setting | ||
1456 | it by handle */ | ||
1457 | rc = CIFSSMBSetEOF(xid, pTcon, full_path, attrs->ia_size, | ||
1458 | false, cifs_sb->local_nls, | ||
1459 | cifs_sb->mnt_cifs_flags & | ||
1460 | CIFS_MOUNT_MAP_SPECIAL_CHR); | ||
1461 | cFYI(1, ("SetEOF by path (setattrs) rc = %d", rc)); | ||
1462 | if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) { | ||
1463 | __u16 netfid; | ||
1464 | int oplock = 0; | ||
1465 | |||
1466 | rc = SMBLegacyOpen(xid, pTcon, full_path, | ||
1467 | FILE_OPEN, GENERIC_WRITE, | ||
1468 | CREATE_NOT_DIR, &netfid, &oplock, NULL, | ||
1469 | cifs_sb->local_nls, | ||
1470 | cifs_sb->mnt_cifs_flags & | ||
1471 | CIFS_MOUNT_MAP_SPECIAL_CHR); | ||
1472 | if (rc == 0) { | ||
1473 | unsigned int bytes_written; | ||
1474 | rc = CIFSSMBWrite(xid, pTcon, netfid, 0, | ||
1475 | attrs->ia_size, | ||
1476 | &bytes_written, NULL, | ||
1477 | NULL, 1); | ||
1478 | cFYI(1, ("wrt seteof rc %d", rc)); | ||
1479 | CIFSSMBClose(xid, pTcon, netfid); | ||
1480 | } | ||
1481 | } | ||
1482 | } | ||
1483 | |||
1484 | if (rc == 0) { | ||
1485 | rc = cifs_vmtruncate(inode, attrs->ia_size); | ||
1486 | cifs_truncate_page(inode->i_mapping, inode->i_size); | ||
1487 | } | ||
1488 | |||
1489 | return rc; | ||
1490 | } | ||
1491 | |||
1416 | int cifs_setattr(struct dentry *direntry, struct iattr *attrs) | 1492 | int cifs_setattr(struct dentry *direntry, struct iattr *attrs) |
1417 | { | 1493 | { |
1418 | int xid; | 1494 | int xid; |
@@ -1420,7 +1496,6 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) | |||
1420 | struct cifsTconInfo *pTcon; | 1496 | struct cifsTconInfo *pTcon; |
1421 | char *full_path = NULL; | 1497 | char *full_path = NULL; |
1422 | int rc = -EACCES; | 1498 | int rc = -EACCES; |
1423 | struct cifsFileInfo *open_file = NULL; | ||
1424 | FILE_BASIC_INFO time_buf; | 1499 | FILE_BASIC_INFO time_buf; |
1425 | bool set_time = false; | 1500 | bool set_time = false; |
1426 | bool set_dosattr = false; | 1501 | bool set_dosattr = false; |
@@ -1472,78 +1547,8 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) | |||
1472 | } | 1547 | } |
1473 | 1548 | ||
1474 | if (attrs->ia_valid & ATTR_SIZE) { | 1549 | if (attrs->ia_valid & ATTR_SIZE) { |
1475 | /* To avoid spurious oplock breaks from server, in the case of | 1550 | rc = cifs_set_file_size(inode, attrs, xid, full_path); |
1476 | inodes that we already have open, avoid doing path based | 1551 | if (rc != 0) |
1477 | setting of file size if we can do it by handle. | ||
1478 | This keeps our caching token (oplock) and avoids timeouts | ||
1479 | when the local oplock break takes longer to flush | ||
1480 | writebehind data than the SMB timeout for the SetPathInfo | ||
1481 | request would allow */ | ||
1482 | |||
1483 | open_file = find_writable_file(cifsInode); | ||
1484 | if (open_file) { | ||
1485 | __u16 nfid = open_file->netfid; | ||
1486 | __u32 npid = open_file->pid; | ||
1487 | rc = CIFSSMBSetFileSize(xid, pTcon, attrs->ia_size, | ||
1488 | nfid, npid, false); | ||
1489 | atomic_dec(&open_file->wrtPending); | ||
1490 | cFYI(1, ("SetFSize for attrs rc = %d", rc)); | ||
1491 | if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) { | ||
1492 | unsigned int bytes_written; | ||
1493 | rc = CIFSSMBWrite(xid, pTcon, | ||
1494 | nfid, 0, attrs->ia_size, | ||
1495 | &bytes_written, NULL, NULL, | ||
1496 | 1 /* 45 seconds */); | ||
1497 | cFYI(1, ("Wrt seteof rc %d", rc)); | ||
1498 | } | ||
1499 | } else | ||
1500 | rc = -EINVAL; | ||
1501 | |||
1502 | if (rc != 0) { | ||
1503 | /* Set file size by pathname rather than by handle | ||
1504 | either because no valid, writeable file handle for | ||
1505 | it was found or because there was an error setting | ||
1506 | it by handle */ | ||
1507 | rc = CIFSSMBSetEOF(xid, pTcon, full_path, | ||
1508 | attrs->ia_size, false, | ||
1509 | cifs_sb->local_nls, | ||
1510 | cifs_sb->mnt_cifs_flags & | ||
1511 | CIFS_MOUNT_MAP_SPECIAL_CHR); | ||
1512 | cFYI(1, ("SetEOF by path (setattrs) rc = %d", rc)); | ||
1513 | if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) { | ||
1514 | __u16 netfid; | ||
1515 | int oplock = 0; | ||
1516 | |||
1517 | rc = SMBLegacyOpen(xid, pTcon, full_path, | ||
1518 | FILE_OPEN, GENERIC_WRITE, | ||
1519 | CREATE_NOT_DIR, &netfid, &oplock, | ||
1520 | NULL, cifs_sb->local_nls, | ||
1521 | cifs_sb->mnt_cifs_flags & | ||
1522 | CIFS_MOUNT_MAP_SPECIAL_CHR); | ||
1523 | if (rc == 0) { | ||
1524 | unsigned int bytes_written; | ||
1525 | rc = CIFSSMBWrite(xid, pTcon, | ||
1526 | netfid, 0, | ||
1527 | attrs->ia_size, | ||
1528 | &bytes_written, NULL, | ||
1529 | NULL, 1 /* 45 sec */); | ||
1530 | cFYI(1, ("wrt seteof rc %d", rc)); | ||
1531 | CIFSSMBClose(xid, pTcon, netfid); | ||
1532 | } | ||
1533 | |||
1534 | } | ||
1535 | } | ||
1536 | |||
1537 | /* Server is ok setting allocation size implicitly - no need | ||
1538 | to call: | ||
1539 | CIFSSMBSetEOF(xid, pTcon, full_path, attrs->ia_size, true, | ||
1540 | cifs_sb->local_nls); | ||
1541 | */ | ||
1542 | |||
1543 | if (rc == 0) { | ||
1544 | rc = cifs_vmtruncate(inode, attrs->ia_size); | ||
1545 | cifs_truncate_page(inode->i_mapping, inode->i_size); | ||
1546 | } else | ||
1547 | goto cifs_setattr_exit; | 1552 | goto cifs_setattr_exit; |
1548 | } | 1553 | } |
1549 | 1554 | ||
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c index 83f306954883..5f40ed3473f5 100644 --- a/fs/cifs/readdir.c +++ b/fs/cifs/readdir.c | |||
@@ -690,6 +690,7 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon, | |||
690 | else | 690 | else |
691 | cifs_buf_release(cifsFile->srch_inf. | 691 | cifs_buf_release(cifsFile->srch_inf. |
692 | ntwrk_buf_start); | 692 | ntwrk_buf_start); |
693 | cifsFile->srch_inf.ntwrk_buf_start = NULL; | ||
693 | } | 694 | } |
694 | rc = initiate_cifs_search(xid, file); | 695 | rc = initiate_cifs_search(xid, file); |
695 | if (rc) { | 696 | if (rc) { |
diff --git a/fs/coda/dir.c b/fs/coda/dir.c index 3d2580e00a3e..c5916228243c 100644 --- a/fs/coda/dir.c +++ b/fs/coda/dir.c | |||
@@ -137,9 +137,11 @@ exit: | |||
137 | } | 137 | } |
138 | 138 | ||
139 | 139 | ||
140 | int coda_permission(struct inode *inode, int mask, struct nameidata *nd) | 140 | int coda_permission(struct inode *inode, int mask) |
141 | { | 141 | { |
142 | int error = 0; | 142 | int error = 0; |
143 | |||
144 | mask &= MAY_READ | MAY_WRITE | MAY_EXEC; | ||
143 | 145 | ||
144 | if (!mask) | 146 | if (!mask) |
145 | return 0; | 147 | return 0; |
diff --git a/fs/coda/inode.c b/fs/coda/inode.c index 2f58dfc70083..830f51abb971 100644 --- a/fs/coda/inode.c +++ b/fs/coda/inode.c | |||
@@ -58,7 +58,7 @@ static void coda_destroy_inode(struct inode *inode) | |||
58 | kmem_cache_free(coda_inode_cachep, ITOC(inode)); | 58 | kmem_cache_free(coda_inode_cachep, ITOC(inode)); |
59 | } | 59 | } |
60 | 60 | ||
61 | static void init_once(struct kmem_cache * cachep, void *foo) | 61 | static void init_once(void *foo) |
62 | { | 62 | { |
63 | struct coda_inode_info *ei = (struct coda_inode_info *) foo; | 63 | struct coda_inode_info *ei = (struct coda_inode_info *) foo; |
64 | 64 | ||
diff --git a/fs/coda/pioctl.c b/fs/coda/pioctl.c index c21a1f552a63..c51365422aa8 100644 --- a/fs/coda/pioctl.c +++ b/fs/coda/pioctl.c | |||
@@ -24,8 +24,7 @@ | |||
24 | #include <linux/coda_psdev.h> | 24 | #include <linux/coda_psdev.h> |
25 | 25 | ||
26 | /* pioctl ops */ | 26 | /* pioctl ops */ |
27 | static int coda_ioctl_permission(struct inode *inode, int mask, | 27 | static int coda_ioctl_permission(struct inode *inode, int mask); |
28 | struct nameidata *nd); | ||
29 | static int coda_pioctl(struct inode * inode, struct file * filp, | 28 | static int coda_pioctl(struct inode * inode, struct file * filp, |
30 | unsigned int cmd, unsigned long user_data); | 29 | unsigned int cmd, unsigned long user_data); |
31 | 30 | ||
@@ -42,8 +41,7 @@ const struct file_operations coda_ioctl_operations = { | |||
42 | }; | 41 | }; |
43 | 42 | ||
44 | /* the coda pioctl inode ops */ | 43 | /* the coda pioctl inode ops */ |
45 | static int coda_ioctl_permission(struct inode *inode, int mask, | 44 | static int coda_ioctl_permission(struct inode *inode, int mask) |
46 | struct nameidata *nd) | ||
47 | { | 45 | { |
48 | return 0; | 46 | return 0; |
49 | } | 47 | } |
@@ -51,7 +49,7 @@ static int coda_ioctl_permission(struct inode *inode, int mask, | |||
51 | static int coda_pioctl(struct inode * inode, struct file * filp, | 49 | static int coda_pioctl(struct inode * inode, struct file * filp, |
52 | unsigned int cmd, unsigned long user_data) | 50 | unsigned int cmd, unsigned long user_data) |
53 | { | 51 | { |
54 | struct nameidata nd; | 52 | struct path path; |
55 | int error; | 53 | int error; |
56 | struct PioctlData data; | 54 | struct PioctlData data; |
57 | struct inode *target_inode = NULL; | 55 | struct inode *target_inode = NULL; |
@@ -66,21 +64,21 @@ static int coda_pioctl(struct inode * inode, struct file * filp, | |||
66 | * Look up the pathname. Note that the pathname is in | 64 | * Look up the pathname. Note that the pathname is in |
67 | * user memory, and namei takes care of this | 65 | * user memory, and namei takes care of this |
68 | */ | 66 | */ |
69 | if ( data.follow ) { | 67 | if (data.follow) { |
70 | error = user_path_walk(data.path, &nd); | 68 | error = user_path(data.path, &path); |
71 | } else { | 69 | } else { |
72 | error = user_path_walk_link(data.path, &nd); | 70 | error = user_lpath(data.path, &path); |
73 | } | 71 | } |
74 | 72 | ||
75 | if ( error ) { | 73 | if ( error ) { |
76 | return error; | 74 | return error; |
77 | } else { | 75 | } else { |
78 | target_inode = nd.path.dentry->d_inode; | 76 | target_inode = path.dentry->d_inode; |
79 | } | 77 | } |
80 | 78 | ||
81 | /* return if it is not a Coda inode */ | 79 | /* return if it is not a Coda inode */ |
82 | if ( target_inode->i_sb != inode->i_sb ) { | 80 | if ( target_inode->i_sb != inode->i_sb ) { |
83 | path_put(&nd.path); | 81 | path_put(&path); |
84 | return -EINVAL; | 82 | return -EINVAL; |
85 | } | 83 | } |
86 | 84 | ||
@@ -89,7 +87,7 @@ static int coda_pioctl(struct inode * inode, struct file * filp, | |||
89 | 87 | ||
90 | error = venus_pioctl(inode->i_sb, &(cnp->c_fid), cmd, &data); | 88 | error = venus_pioctl(inode->i_sb, &(cnp->c_fid), cmd, &data); |
91 | 89 | ||
92 | path_put(&nd.path); | 90 | path_put(&path); |
93 | return error; | 91 | return error; |
94 | } | 92 | } |
95 | 93 | ||
diff --git a/fs/compat.c b/fs/compat.c index 106eba28ec5a..c9d1472e65c5 100644 --- a/fs/compat.c +++ b/fs/compat.c | |||
@@ -234,18 +234,18 @@ static int put_compat_statfs(struct compat_statfs __user *ubuf, struct kstatfs * | |||
234 | * The following statfs calls are copies of code from fs/open.c and | 234 | * The following statfs calls are copies of code from fs/open.c and |
235 | * should be checked against those from time to time | 235 | * should be checked against those from time to time |
236 | */ | 236 | */ |
237 | asmlinkage long compat_sys_statfs(const char __user *path, struct compat_statfs __user *buf) | 237 | asmlinkage long compat_sys_statfs(const char __user *pathname, struct compat_statfs __user *buf) |
238 | { | 238 | { |
239 | struct nameidata nd; | 239 | struct path path; |
240 | int error; | 240 | int error; |
241 | 241 | ||
242 | error = user_path_walk(path, &nd); | 242 | error = user_path(pathname, &path); |
243 | if (!error) { | 243 | if (!error) { |
244 | struct kstatfs tmp; | 244 | struct kstatfs tmp; |
245 | error = vfs_statfs(nd.path.dentry, &tmp); | 245 | error = vfs_statfs(path.dentry, &tmp); |
246 | if (!error) | 246 | if (!error) |
247 | error = put_compat_statfs(buf, &tmp); | 247 | error = put_compat_statfs(buf, &tmp); |
248 | path_put(&nd.path); | 248 | path_put(&path); |
249 | } | 249 | } |
250 | return error; | 250 | return error; |
251 | } | 251 | } |
@@ -299,21 +299,21 @@ static int put_compat_statfs64(struct compat_statfs64 __user *ubuf, struct kstat | |||
299 | return 0; | 299 | return 0; |
300 | } | 300 | } |
301 | 301 | ||
302 | asmlinkage long compat_sys_statfs64(const char __user *path, compat_size_t sz, struct compat_statfs64 __user *buf) | 302 | asmlinkage long compat_sys_statfs64(const char __user *pathname, compat_size_t sz, struct compat_statfs64 __user *buf) |
303 | { | 303 | { |
304 | struct nameidata nd; | 304 | struct path path; |
305 | int error; | 305 | int error; |
306 | 306 | ||
307 | if (sz != sizeof(*buf)) | 307 | if (sz != sizeof(*buf)) |
308 | return -EINVAL; | 308 | return -EINVAL; |
309 | 309 | ||
310 | error = user_path_walk(path, &nd); | 310 | error = user_path(pathname, &path); |
311 | if (!error) { | 311 | if (!error) { |
312 | struct kstatfs tmp; | 312 | struct kstatfs tmp; |
313 | error = vfs_statfs(nd.path.dentry, &tmp); | 313 | error = vfs_statfs(path.dentry, &tmp); |
314 | if (!error) | 314 | if (!error) |
315 | error = put_compat_statfs64(buf, &tmp); | 315 | error = put_compat_statfs64(buf, &tmp); |
316 | path_put(&nd.path); | 316 | path_put(&path); |
317 | } | 317 | } |
318 | return error; | 318 | return error; |
319 | } | 319 | } |
diff --git a/fs/dcache.c b/fs/dcache.c index 3818d6ab76ca..f2584d22cb45 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
@@ -487,6 +487,7 @@ restart: | |||
487 | if (!cnt) | 487 | if (!cnt) |
488 | break; | 488 | break; |
489 | } | 489 | } |
490 | cond_resched_lock(&dcache_lock); | ||
490 | } | 491 | } |
491 | } | 492 | } |
492 | while (!list_empty(&tmp)) { | 493 | while (!list_empty(&tmp)) { |
diff --git a/fs/direct-io.c b/fs/direct-io.c index 9e81addbd6ea..9606ee848fd8 100644 --- a/fs/direct-io.c +++ b/fs/direct-io.c | |||
@@ -150,17 +150,11 @@ static int dio_refill_pages(struct dio *dio) | |||
150 | int nr_pages; | 150 | int nr_pages; |
151 | 151 | ||
152 | nr_pages = min(dio->total_pages - dio->curr_page, DIO_PAGES); | 152 | nr_pages = min(dio->total_pages - dio->curr_page, DIO_PAGES); |
153 | down_read(¤t->mm->mmap_sem); | 153 | ret = get_user_pages_fast( |
154 | ret = get_user_pages( | ||
155 | current, /* Task for fault acounting */ | ||
156 | current->mm, /* whose pages? */ | ||
157 | dio->curr_user_address, /* Where from? */ | 154 | dio->curr_user_address, /* Where from? */ |
158 | nr_pages, /* How many pages? */ | 155 | nr_pages, /* How many pages? */ |
159 | dio->rw == READ, /* Write to memory? */ | 156 | dio->rw == READ, /* Write to memory? */ |
160 | 0, /* force (?) */ | 157 | &dio->pages[0]); /* Put results here */ |
161 | &dio->pages[0], | ||
162 | NULL); /* vmas */ | ||
163 | up_read(¤t->mm->mmap_sem); | ||
164 | 158 | ||
165 | if (ret < 0 && dio->blocks_available && (dio->rw & WRITE)) { | 159 | if (ret < 0 && dio->blocks_available && (dio->rw & WRITE)) { |
166 | struct page *page = ZERO_PAGE(0); | 160 | struct page *page = ZERO_PAGE(0); |
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index d755455e3bff..89209f00f9c7 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c | |||
@@ -465,7 +465,6 @@ static int ecryptfs_symlink(struct inode *dir, struct dentry *dentry, | |||
465 | int rc; | 465 | int rc; |
466 | struct dentry *lower_dentry; | 466 | struct dentry *lower_dentry; |
467 | struct dentry *lower_dir_dentry; | 467 | struct dentry *lower_dir_dentry; |
468 | umode_t mode; | ||
469 | char *encoded_symname; | 468 | char *encoded_symname; |
470 | int encoded_symlen; | 469 | int encoded_symlen; |
471 | struct ecryptfs_crypt_stat *crypt_stat = NULL; | 470 | struct ecryptfs_crypt_stat *crypt_stat = NULL; |
@@ -473,7 +472,6 @@ static int ecryptfs_symlink(struct inode *dir, struct dentry *dentry, | |||
473 | lower_dentry = ecryptfs_dentry_to_lower(dentry); | 472 | lower_dentry = ecryptfs_dentry_to_lower(dentry); |
474 | dget(lower_dentry); | 473 | dget(lower_dentry); |
475 | lower_dir_dentry = lock_parent(lower_dentry); | 474 | lower_dir_dentry = lock_parent(lower_dentry); |
476 | mode = S_IALLUGO; | ||
477 | encoded_symlen = ecryptfs_encode_filename(crypt_stat, symname, | 475 | encoded_symlen = ecryptfs_encode_filename(crypt_stat, symname, |
478 | strlen(symname), | 476 | strlen(symname), |
479 | &encoded_symname); | 477 | &encoded_symname); |
@@ -482,7 +480,7 @@ static int ecryptfs_symlink(struct inode *dir, struct dentry *dentry, | |||
482 | goto out_lock; | 480 | goto out_lock; |
483 | } | 481 | } |
484 | rc = vfs_symlink(lower_dir_dentry->d_inode, lower_dentry, | 482 | rc = vfs_symlink(lower_dir_dentry->d_inode, lower_dentry, |
485 | encoded_symname, mode); | 483 | encoded_symname); |
486 | kfree(encoded_symname); | 484 | kfree(encoded_symname); |
487 | if (rc || !lower_dentry->d_inode) | 485 | if (rc || !lower_dentry->d_inode) |
488 | goto out_lock; | 486 | goto out_lock; |
@@ -830,22 +828,9 @@ out: | |||
830 | } | 828 | } |
831 | 829 | ||
832 | static int | 830 | static int |
833 | ecryptfs_permission(struct inode *inode, int mask, struct nameidata *nd) | 831 | ecryptfs_permission(struct inode *inode, int mask) |
834 | { | 832 | { |
835 | int rc; | 833 | return inode_permission(ecryptfs_inode_to_lower(inode), mask); |
836 | |||
837 | if (nd) { | ||
838 | struct vfsmount *vfsmnt_save = nd->path.mnt; | ||
839 | struct dentry *dentry_save = nd->path.dentry; | ||
840 | |||
841 | nd->path.mnt = ecryptfs_dentry_to_lower_mnt(nd->path.dentry); | ||
842 | nd->path.dentry = ecryptfs_dentry_to_lower(nd->path.dentry); | ||
843 | rc = permission(ecryptfs_inode_to_lower(inode), mask, nd); | ||
844 | nd->path.mnt = vfsmnt_save; | ||
845 | nd->path.dentry = dentry_save; | ||
846 | } else | ||
847 | rc = permission(ecryptfs_inode_to_lower(inode), mask, NULL); | ||
848 | return rc; | ||
849 | } | 834 | } |
850 | 835 | ||
851 | /** | 836 | /** |
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c index 6f403cfba14f..448dfd597b5f 100644 --- a/fs/ecryptfs/main.c +++ b/fs/ecryptfs/main.c | |||
@@ -578,7 +578,7 @@ static struct file_system_type ecryptfs_fs_type = { | |||
578 | * Initializes the ecryptfs_inode_info_cache when it is created | 578 | * Initializes the ecryptfs_inode_info_cache when it is created |
579 | */ | 579 | */ |
580 | static void | 580 | static void |
581 | inode_info_init_once(struct kmem_cache *cachep, void *vptr) | 581 | inode_info_init_once(void *vptr) |
582 | { | 582 | { |
583 | struct ecryptfs_inode_info *ei = (struct ecryptfs_inode_info *)vptr; | 583 | struct ecryptfs_inode_info *ei = (struct ecryptfs_inode_info *)vptr; |
584 | 584 | ||
@@ -589,7 +589,7 @@ static struct ecryptfs_cache_info { | |||
589 | struct kmem_cache **cache; | 589 | struct kmem_cache **cache; |
590 | const char *name; | 590 | const char *name; |
591 | size_t size; | 591 | size_t size; |
592 | void (*ctor)(struct kmem_cache *cache, void *obj); | 592 | void (*ctor)(void *obj); |
593 | } ecryptfs_cache_infos[] = { | 593 | } ecryptfs_cache_infos[] = { |
594 | { | 594 | { |
595 | .cache = &ecryptfs_auth_tok_list_item_cache, | 595 | .cache = &ecryptfs_auth_tok_list_item_cache, |
diff --git a/fs/efs/super.c b/fs/efs/super.c index d733531b55e2..567b134fa1f1 100644 --- a/fs/efs/super.c +++ b/fs/efs/super.c | |||
@@ -70,7 +70,7 @@ static void efs_destroy_inode(struct inode *inode) | |||
70 | kmem_cache_free(efs_inode_cachep, INODE_INFO(inode)); | 70 | kmem_cache_free(efs_inode_cachep, INODE_INFO(inode)); |
71 | } | 71 | } |
72 | 72 | ||
73 | static void init_once(struct kmem_cache *cachep, void *foo) | 73 | static void init_once(void *foo) |
74 | { | 74 | { |
75 | struct efs_inode_info *ei = (struct efs_inode_info *) foo; | 75 | struct efs_inode_info *ei = (struct efs_inode_info *) foo; |
76 | 76 | ||
@@ -42,13 +42,13 @@ | |||
42 | #include <linux/module.h> | 42 | #include <linux/module.h> |
43 | #include <linux/namei.h> | 43 | #include <linux/namei.h> |
44 | #include <linux/proc_fs.h> | 44 | #include <linux/proc_fs.h> |
45 | #include <linux/ptrace.h> | ||
46 | #include <linux/mount.h> | 45 | #include <linux/mount.h> |
47 | #include <linux/security.h> | 46 | #include <linux/security.h> |
48 | #include <linux/syscalls.h> | 47 | #include <linux/syscalls.h> |
49 | #include <linux/tsacct_kern.h> | 48 | #include <linux/tsacct_kern.h> |
50 | #include <linux/cn_proc.h> | 49 | #include <linux/cn_proc.h> |
51 | #include <linux/audit.h> | 50 | #include <linux/audit.h> |
51 | #include <linux/tracehook.h> | ||
52 | 52 | ||
53 | #include <asm/uaccess.h> | 53 | #include <asm/uaccess.h> |
54 | #include <asm/mmu_context.h> | 54 | #include <asm/mmu_context.h> |
@@ -106,11 +106,17 @@ static inline void put_binfmt(struct linux_binfmt * fmt) | |||
106 | */ | 106 | */ |
107 | asmlinkage long sys_uselib(const char __user * library) | 107 | asmlinkage long sys_uselib(const char __user * library) |
108 | { | 108 | { |
109 | struct file * file; | 109 | struct file *file; |
110 | struct nameidata nd; | 110 | struct nameidata nd; |
111 | int error; | 111 | char *tmp = getname(library); |
112 | 112 | int error = PTR_ERR(tmp); | |
113 | error = __user_path_lookup_open(library, LOOKUP_FOLLOW, &nd, FMODE_READ|FMODE_EXEC); | 113 | |
114 | if (!IS_ERR(tmp)) { | ||
115 | error = path_lookup_open(AT_FDCWD, tmp, | ||
116 | LOOKUP_FOLLOW, &nd, | ||
117 | FMODE_READ|FMODE_EXEC); | ||
118 | putname(tmp); | ||
119 | } | ||
114 | if (error) | 120 | if (error) |
115 | goto out; | 121 | goto out; |
116 | 122 | ||
@@ -118,7 +124,11 @@ asmlinkage long sys_uselib(const char __user * library) | |||
118 | if (!S_ISREG(nd.path.dentry->d_inode->i_mode)) | 124 | if (!S_ISREG(nd.path.dentry->d_inode->i_mode)) |
119 | goto exit; | 125 | goto exit; |
120 | 126 | ||
121 | error = vfs_permission(&nd, MAY_READ | MAY_EXEC); | 127 | error = -EACCES; |
128 | if (nd.path.mnt->mnt_flags & MNT_NOEXEC) | ||
129 | goto exit; | ||
130 | |||
131 | error = vfs_permission(&nd, MAY_READ | MAY_EXEC | MAY_OPEN); | ||
122 | if (error) | 132 | if (error) |
123 | goto exit; | 133 | goto exit; |
124 | 134 | ||
@@ -656,38 +666,43 @@ EXPORT_SYMBOL(setup_arg_pages); | |||
656 | struct file *open_exec(const char *name) | 666 | struct file *open_exec(const char *name) |
657 | { | 667 | { |
658 | struct nameidata nd; | 668 | struct nameidata nd; |
659 | int err; | ||
660 | struct file *file; | 669 | struct file *file; |
670 | int err; | ||
661 | 671 | ||
662 | err = path_lookup_open(AT_FDCWD, name, LOOKUP_FOLLOW, &nd, FMODE_READ|FMODE_EXEC); | 672 | err = path_lookup_open(AT_FDCWD, name, LOOKUP_FOLLOW, &nd, |
663 | file = ERR_PTR(err); | 673 | FMODE_READ|FMODE_EXEC); |
664 | 674 | if (err) | |
665 | if (!err) { | 675 | goto out; |
666 | struct inode *inode = nd.path.dentry->d_inode; | 676 | |
667 | file = ERR_PTR(-EACCES); | 677 | err = -EACCES; |
668 | if (S_ISREG(inode->i_mode)) { | 678 | if (!S_ISREG(nd.path.dentry->d_inode->i_mode)) |
669 | int err = vfs_permission(&nd, MAY_EXEC); | 679 | goto out_path_put; |
670 | file = ERR_PTR(err); | 680 | |
671 | if (!err) { | 681 | if (nd.path.mnt->mnt_flags & MNT_NOEXEC) |
672 | file = nameidata_to_filp(&nd, | 682 | goto out_path_put; |
673 | O_RDONLY|O_LARGEFILE); | 683 | |
674 | if (!IS_ERR(file)) { | 684 | err = vfs_permission(&nd, MAY_EXEC | MAY_OPEN); |
675 | err = deny_write_access(file); | 685 | if (err) |
676 | if (err) { | 686 | goto out_path_put; |
677 | fput(file); | 687 | |
678 | file = ERR_PTR(err); | 688 | file = nameidata_to_filp(&nd, O_RDONLY|O_LARGEFILE); |
679 | } | 689 | if (IS_ERR(file)) |
680 | } | 690 | return file; |
681 | out: | 691 | |
682 | return file; | 692 | err = deny_write_access(file); |
683 | } | 693 | if (err) { |
684 | } | 694 | fput(file); |
685 | release_open_intent(&nd); | 695 | goto out; |
686 | path_put(&nd.path); | ||
687 | } | 696 | } |
688 | goto out; | ||
689 | } | ||
690 | 697 | ||
698 | return file; | ||
699 | |||
700 | out_path_put: | ||
701 | release_open_intent(&nd); | ||
702 | path_put(&nd.path); | ||
703 | out: | ||
704 | return ERR_PTR(err); | ||
705 | } | ||
691 | EXPORT_SYMBOL(open_exec); | 706 | EXPORT_SYMBOL(open_exec); |
692 | 707 | ||
693 | int kernel_read(struct file *file, unsigned long offset, | 708 | int kernel_read(struct file *file, unsigned long offset, |
@@ -1071,13 +1086,8 @@ EXPORT_SYMBOL(prepare_binprm); | |||
1071 | 1086 | ||
1072 | static int unsafe_exec(struct task_struct *p) | 1087 | static int unsafe_exec(struct task_struct *p) |
1073 | { | 1088 | { |
1074 | int unsafe = 0; | 1089 | int unsafe = tracehook_unsafe_exec(p); |
1075 | if (p->ptrace & PT_PTRACED) { | 1090 | |
1076 | if (p->ptrace & PT_PTRACE_CAP) | ||
1077 | unsafe |= LSM_UNSAFE_PTRACE_CAP; | ||
1078 | else | ||
1079 | unsafe |= LSM_UNSAFE_PTRACE; | ||
1080 | } | ||
1081 | if (atomic_read(&p->fs->count) > 1 || | 1091 | if (atomic_read(&p->fs->count) > 1 || |
1082 | atomic_read(&p->files->count) > 1 || | 1092 | atomic_read(&p->files->count) > 1 || |
1083 | atomic_read(&p->sighand->count) > 1) | 1093 | atomic_read(&p->sighand->count) > 1) |
@@ -1214,6 +1224,7 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs) | |||
1214 | read_unlock(&binfmt_lock); | 1224 | read_unlock(&binfmt_lock); |
1215 | retval = fn(bprm, regs); | 1225 | retval = fn(bprm, regs); |
1216 | if (retval >= 0) { | 1226 | if (retval >= 0) { |
1227 | tracehook_report_exec(fmt, bprm, regs); | ||
1217 | put_binfmt(fmt); | 1228 | put_binfmt(fmt); |
1218 | allow_write_access(bprm->file); | 1229 | allow_write_access(bprm->file); |
1219 | if (bprm->file) | 1230 | if (bprm->file) |
diff --git a/fs/ext2/acl.c b/fs/ext2/acl.c index e58669e1b87c..ae8c4f850b27 100644 --- a/fs/ext2/acl.c +++ b/fs/ext2/acl.c | |||
@@ -294,7 +294,7 @@ ext2_check_acl(struct inode *inode, int mask) | |||
294 | } | 294 | } |
295 | 295 | ||
296 | int | 296 | int |
297 | ext2_permission(struct inode *inode, int mask, struct nameidata *nd) | 297 | ext2_permission(struct inode *inode, int mask) |
298 | { | 298 | { |
299 | return generic_permission(inode, mask, ext2_check_acl); | 299 | return generic_permission(inode, mask, ext2_check_acl); |
300 | } | 300 | } |
diff --git a/fs/ext2/acl.h b/fs/ext2/acl.h index 0bde85bafe38..b42cf578554b 100644 --- a/fs/ext2/acl.h +++ b/fs/ext2/acl.h | |||
@@ -58,7 +58,7 @@ static inline int ext2_acl_count(size_t size) | |||
58 | #define EXT2_ACL_NOT_CACHED ((void *)-1) | 58 | #define EXT2_ACL_NOT_CACHED ((void *)-1) |
59 | 59 | ||
60 | /* acl.c */ | 60 | /* acl.c */ |
61 | extern int ext2_permission (struct inode *, int, struct nameidata *); | 61 | extern int ext2_permission (struct inode *, int); |
62 | extern int ext2_acl_chmod (struct inode *); | 62 | extern int ext2_acl_chmod (struct inode *); |
63 | extern int ext2_init_acl (struct inode *, struct inode *); | 63 | extern int ext2_init_acl (struct inode *, struct inode *); |
64 | 64 | ||
diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 31308a3b0b8b..fd88c7b43e66 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c | |||
@@ -159,7 +159,7 @@ static void ext2_destroy_inode(struct inode *inode) | |||
159 | kmem_cache_free(ext2_inode_cachep, EXT2_I(inode)); | 159 | kmem_cache_free(ext2_inode_cachep, EXT2_I(inode)); |
160 | } | 160 | } |
161 | 161 | ||
162 | static void init_once(struct kmem_cache * cachep, void *foo) | 162 | static void init_once(void *foo) |
163 | { | 163 | { |
164 | struct ext2_inode_info *ei = (struct ext2_inode_info *) foo; | 164 | struct ext2_inode_info *ei = (struct ext2_inode_info *) foo; |
165 | 165 | ||
diff --git a/fs/ext3/acl.c b/fs/ext3/acl.c index a754d1848173..b60bb241880c 100644 --- a/fs/ext3/acl.c +++ b/fs/ext3/acl.c | |||
@@ -299,7 +299,7 @@ ext3_check_acl(struct inode *inode, int mask) | |||
299 | } | 299 | } |
300 | 300 | ||
301 | int | 301 | int |
302 | ext3_permission(struct inode *inode, int mask, struct nameidata *nd) | 302 | ext3_permission(struct inode *inode, int mask) |
303 | { | 303 | { |
304 | return generic_permission(inode, mask, ext3_check_acl); | 304 | return generic_permission(inode, mask, ext3_check_acl); |
305 | } | 305 | } |
diff --git a/fs/ext3/acl.h b/fs/ext3/acl.h index 0d1e6279cbfd..42da16b8cac0 100644 --- a/fs/ext3/acl.h +++ b/fs/ext3/acl.h | |||
@@ -58,7 +58,7 @@ static inline int ext3_acl_count(size_t size) | |||
58 | #define EXT3_ACL_NOT_CACHED ((void *)-1) | 58 | #define EXT3_ACL_NOT_CACHED ((void *)-1) |
59 | 59 | ||
60 | /* acl.c */ | 60 | /* acl.c */ |
61 | extern int ext3_permission (struct inode *, int, struct nameidata *); | 61 | extern int ext3_permission (struct inode *, int); |
62 | extern int ext3_acl_chmod (struct inode *); | 62 | extern int ext3_acl_chmod (struct inode *); |
63 | extern int ext3_init_acl (handle_t *, struct inode *, struct inode *); | 63 | extern int ext3_init_acl (handle_t *, struct inode *, struct inode *); |
64 | 64 | ||
diff --git a/fs/ext3/super.c b/fs/ext3/super.c index 615788c6843a..8ddced384674 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c | |||
@@ -472,7 +472,7 @@ static void ext3_destroy_inode(struct inode *inode) | |||
472 | kmem_cache_free(ext3_inode_cachep, EXT3_I(inode)); | 472 | kmem_cache_free(ext3_inode_cachep, EXT3_I(inode)); |
473 | } | 473 | } |
474 | 474 | ||
475 | static void init_once(struct kmem_cache * cachep, void *foo) | 475 | static void init_once(void *foo) |
476 | { | 476 | { |
477 | struct ext3_inode_info *ei = (struct ext3_inode_info *) foo; | 477 | struct ext3_inode_info *ei = (struct ext3_inode_info *) foo; |
478 | 478 | ||
diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c index 3c8dab880d91..c7d04e165446 100644 --- a/fs/ext4/acl.c +++ b/fs/ext4/acl.c | |||
@@ -299,7 +299,7 @@ ext4_check_acl(struct inode *inode, int mask) | |||
299 | } | 299 | } |
300 | 300 | ||
301 | int | 301 | int |
302 | ext4_permission(struct inode *inode, int mask, struct nameidata *nd) | 302 | ext4_permission(struct inode *inode, int mask) |
303 | { | 303 | { |
304 | return generic_permission(inode, mask, ext4_check_acl); | 304 | return generic_permission(inode, mask, ext4_check_acl); |
305 | } | 305 | } |
diff --git a/fs/ext4/acl.h b/fs/ext4/acl.h index 26a5c1abf147..cd2b855a07d6 100644 --- a/fs/ext4/acl.h +++ b/fs/ext4/acl.h | |||
@@ -58,7 +58,7 @@ static inline int ext4_acl_count(size_t size) | |||
58 | #define EXT4_ACL_NOT_CACHED ((void *)-1) | 58 | #define EXT4_ACL_NOT_CACHED ((void *)-1) |
59 | 59 | ||
60 | /* acl.c */ | 60 | /* acl.c */ |
61 | extern int ext4_permission (struct inode *, int, struct nameidata *); | 61 | extern int ext4_permission (struct inode *, int); |
62 | extern int ext4_acl_chmod (struct inode *); | 62 | extern int ext4_acl_chmod (struct inode *); |
63 | extern int ext4_init_acl (handle_t *, struct inode *, struct inode *); | 63 | extern int ext4_init_acl (handle_t *, struct inode *, struct inode *); |
64 | 64 | ||
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 1cb371dcd609..b5479b1dff14 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -595,7 +595,7 @@ static void ext4_destroy_inode(struct inode *inode) | |||
595 | kmem_cache_free(ext4_inode_cachep, EXT4_I(inode)); | 595 | kmem_cache_free(ext4_inode_cachep, EXT4_I(inode)); |
596 | } | 596 | } |
597 | 597 | ||
598 | static void init_once(struct kmem_cache *cachep, void *foo) | 598 | static void init_once(void *foo) |
599 | { | 599 | { |
600 | struct ext4_inode_info *ei = (struct ext4_inode_info *) foo; | 600 | struct ext4_inode_info *ei = (struct ext4_inode_info *) foo; |
601 | 601 | ||
diff --git a/fs/fat/cache.c b/fs/fat/cache.c index 3a9ecac8d61f..3222f51c41cf 100644 --- a/fs/fat/cache.c +++ b/fs/fat/cache.c | |||
@@ -36,7 +36,7 @@ static inline int fat_max_cache(struct inode *inode) | |||
36 | 36 | ||
37 | static struct kmem_cache *fat_cache_cachep; | 37 | static struct kmem_cache *fat_cache_cachep; |
38 | 38 | ||
39 | static void init_once(struct kmem_cache *cachep, void *foo) | 39 | static void init_once(void *foo) |
40 | { | 40 | { |
41 | struct fat_cache *cache = (struct fat_cache *)foo; | 41 | struct fat_cache *cache = (struct fat_cache *)foo; |
42 | 42 | ||
diff --git a/fs/fat/file.c b/fs/fat/file.c index c672df4036e9..8707a8cfa02c 100644 --- a/fs/fat/file.c +++ b/fs/fat/file.c | |||
@@ -15,6 +15,8 @@ | |||
15 | #include <linux/writeback.h> | 15 | #include <linux/writeback.h> |
16 | #include <linux/backing-dev.h> | 16 | #include <linux/backing-dev.h> |
17 | #include <linux/blkdev.h> | 17 | #include <linux/blkdev.h> |
18 | #include <linux/fsnotify.h> | ||
19 | #include <linux/security.h> | ||
18 | 20 | ||
19 | int fat_generic_ioctl(struct inode *inode, struct file *filp, | 21 | int fat_generic_ioctl(struct inode *inode, struct file *filp, |
20 | unsigned int cmd, unsigned long arg) | 22 | unsigned int cmd, unsigned long arg) |
@@ -64,6 +66,7 @@ int fat_generic_ioctl(struct inode *inode, struct file *filp, | |||
64 | 66 | ||
65 | /* Equivalent to a chmod() */ | 67 | /* Equivalent to a chmod() */ |
66 | ia.ia_valid = ATTR_MODE | ATTR_CTIME; | 68 | ia.ia_valid = ATTR_MODE | ATTR_CTIME; |
69 | ia.ia_ctime = current_fs_time(inode->i_sb); | ||
67 | if (is_dir) { | 70 | if (is_dir) { |
68 | ia.ia_mode = MSDOS_MKMODE(attr, | 71 | ia.ia_mode = MSDOS_MKMODE(attr, |
69 | S_IRWXUGO & ~sbi->options.fs_dmask) | 72 | S_IRWXUGO & ~sbi->options.fs_dmask) |
@@ -90,11 +93,21 @@ int fat_generic_ioctl(struct inode *inode, struct file *filp, | |||
90 | } | 93 | } |
91 | } | 94 | } |
92 | 95 | ||
96 | /* | ||
97 | * The security check is questionable... We single | ||
98 | * out the RO attribute for checking by the security | ||
99 | * module, just because it maps to a file mode. | ||
100 | */ | ||
101 | err = security_inode_setattr(filp->f_path.dentry, &ia); | ||
102 | if (err) | ||
103 | goto up; | ||
104 | |||
93 | /* This MUST be done before doing anything irreversible... */ | 105 | /* This MUST be done before doing anything irreversible... */ |
94 | err = notify_change(filp->f_path.dentry, &ia); | 106 | err = fat_setattr(filp->f_path.dentry, &ia); |
95 | if (err) | 107 | if (err) |
96 | goto up; | 108 | goto up; |
97 | 109 | ||
110 | fsnotify_change(filp->f_path.dentry, ia.ia_valid); | ||
98 | if (sbi->options.sys_immutable) { | 111 | if (sbi->options.sys_immutable) { |
99 | if (attr & ATTR_SYS) | 112 | if (attr & ATTR_SYS) |
100 | inode->i_flags |= S_IMMUTABLE; | 113 | inode->i_flags |= S_IMMUTABLE; |
diff --git a/fs/fat/inode.c b/fs/fat/inode.c index 23676f9d79ce..6d266d793e2c 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c | |||
@@ -498,7 +498,7 @@ static void fat_destroy_inode(struct inode *inode) | |||
498 | kmem_cache_free(fat_inode_cachep, MSDOS_I(inode)); | 498 | kmem_cache_free(fat_inode_cachep, MSDOS_I(inode)); |
499 | } | 499 | } |
500 | 500 | ||
501 | static void init_once(struct kmem_cache *cachep, void *foo) | 501 | static void init_once(void *foo) |
502 | { | 502 | { |
503 | struct msdos_inode_info *ei = (struct msdos_inode_info *)foo; | 503 | struct msdos_inode_info *ei = (struct msdos_inode_info *)foo; |
504 | 504 | ||
diff --git a/fs/fcntl.c b/fs/fcntl.c index 9679fcbdeaa0..61d625136813 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c | |||
@@ -64,11 +64,6 @@ static int locate_fd(unsigned int orig_start, int cloexec) | |||
64 | struct fdtable *fdt; | 64 | struct fdtable *fdt; |
65 | 65 | ||
66 | spin_lock(&files->file_lock); | 66 | spin_lock(&files->file_lock); |
67 | |||
68 | error = -EINVAL; | ||
69 | if (orig_start >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur) | ||
70 | goto out; | ||
71 | |||
72 | repeat: | 67 | repeat: |
73 | fdt = files_fdtable(files); | 68 | fdt = files_fdtable(files); |
74 | /* | 69 | /* |
@@ -83,10 +78,6 @@ repeat: | |||
83 | if (start < fdt->max_fds) | 78 | if (start < fdt->max_fds) |
84 | newfd = find_next_zero_bit(fdt->open_fds->fds_bits, | 79 | newfd = find_next_zero_bit(fdt->open_fds->fds_bits, |
85 | fdt->max_fds, start); | 80 | fdt->max_fds, start); |
86 | |||
87 | error = -EMFILE; | ||
88 | if (newfd >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur) | ||
89 | goto out; | ||
90 | 81 | ||
91 | error = expand_files(files, newfd); | 82 | error = expand_files(files, newfd); |
92 | if (error < 0) | 83 | if (error < 0) |
@@ -135,20 +126,20 @@ asmlinkage long sys_dup3(unsigned int oldfd, unsigned int newfd, int flags) | |||
135 | if ((flags & ~O_CLOEXEC) != 0) | 126 | if ((flags & ~O_CLOEXEC) != 0) |
136 | return -EINVAL; | 127 | return -EINVAL; |
137 | 128 | ||
129 | if (unlikely(oldfd == newfd)) | ||
130 | return -EINVAL; | ||
131 | |||
138 | spin_lock(&files->file_lock); | 132 | spin_lock(&files->file_lock); |
139 | if (!(file = fcheck(oldfd))) | 133 | if (!(file = fcheck(oldfd))) |
140 | goto out_unlock; | 134 | goto out_unlock; |
141 | err = newfd; | ||
142 | if (newfd == oldfd) | ||
143 | goto out_unlock; | ||
144 | err = -EBADF; | ||
145 | if (newfd >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur) | ||
146 | goto out_unlock; | ||
147 | get_file(file); /* We are now finished with oldfd */ | 135 | get_file(file); /* We are now finished with oldfd */ |
148 | 136 | ||
149 | err = expand_files(files, newfd); | 137 | err = expand_files(files, newfd); |
150 | if (err < 0) | 138 | if (unlikely(err < 0)) { |
139 | if (err == -EMFILE) | ||
140 | err = -EBADF; | ||
151 | goto out_fput; | 141 | goto out_fput; |
142 | } | ||
152 | 143 | ||
153 | /* To avoid races with open() and dup(), we will mark the fd as | 144 | /* To avoid races with open() and dup(), we will mark the fd as |
154 | * in-use in the open-file bitmap throughout the entire dup2() | 145 | * in-use in the open-file bitmap throughout the entire dup2() |
@@ -189,6 +180,14 @@ out_fput: | |||
189 | 180 | ||
190 | asmlinkage long sys_dup2(unsigned int oldfd, unsigned int newfd) | 181 | asmlinkage long sys_dup2(unsigned int oldfd, unsigned int newfd) |
191 | { | 182 | { |
183 | if (unlikely(newfd == oldfd)) { /* corner case */ | ||
184 | struct files_struct *files = current->files; | ||
185 | rcu_read_lock(); | ||
186 | if (!fcheck_files(files, oldfd)) | ||
187 | oldfd = -EBADF; | ||
188 | rcu_read_unlock(); | ||
189 | return oldfd; | ||
190 | } | ||
192 | return sys_dup3(oldfd, newfd, 0); | 191 | return sys_dup3(oldfd, newfd, 0); |
193 | } | 192 | } |
194 | 193 | ||
@@ -321,6 +320,8 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg, | |||
321 | switch (cmd) { | 320 | switch (cmd) { |
322 | case F_DUPFD: | 321 | case F_DUPFD: |
323 | case F_DUPFD_CLOEXEC: | 322 | case F_DUPFD_CLOEXEC: |
323 | if (arg >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur) | ||
324 | break; | ||
324 | get_file(filp); | 325 | get_file(filp); |
325 | err = dupfd(filp, arg, cmd == F_DUPFD_CLOEXEC); | 326 | err = dupfd(filp, arg, cmd == F_DUPFD_CLOEXEC); |
326 | break; | 327 | break; |
@@ -57,7 +57,7 @@ static int fifo_open(struct inode *inode, struct file *filp) | |||
57 | * POSIX.1 says that O_NONBLOCK means return with the FIFO | 57 | * POSIX.1 says that O_NONBLOCK means return with the FIFO |
58 | * opened, even when there is no process writing the FIFO. | 58 | * opened, even when there is no process writing the FIFO. |
59 | */ | 59 | */ |
60 | filp->f_op = &read_fifo_fops; | 60 | filp->f_op = &read_pipefifo_fops; |
61 | pipe->r_counter++; | 61 | pipe->r_counter++; |
62 | if (pipe->readers++ == 0) | 62 | if (pipe->readers++ == 0) |
63 | wake_up_partner(inode); | 63 | wake_up_partner(inode); |
@@ -86,7 +86,7 @@ static int fifo_open(struct inode *inode, struct file *filp) | |||
86 | if ((filp->f_flags & O_NONBLOCK) && !pipe->readers) | 86 | if ((filp->f_flags & O_NONBLOCK) && !pipe->readers) |
87 | goto err; | 87 | goto err; |
88 | 88 | ||
89 | filp->f_op = &write_fifo_fops; | 89 | filp->f_op = &write_pipefifo_fops; |
90 | pipe->w_counter++; | 90 | pipe->w_counter++; |
91 | if (!pipe->writers++) | 91 | if (!pipe->writers++) |
92 | wake_up_partner(inode); | 92 | wake_up_partner(inode); |
@@ -105,7 +105,7 @@ static int fifo_open(struct inode *inode, struct file *filp) | |||
105 | * This implementation will NEVER block on a O_RDWR open, since | 105 | * This implementation will NEVER block on a O_RDWR open, since |
106 | * the process can at least talk to itself. | 106 | * the process can at least talk to itself. |
107 | */ | 107 | */ |
108 | filp->f_op = &rdwr_fifo_fops; | 108 | filp->f_op = &rdwr_pipefifo_fops; |
109 | 109 | ||
110 | pipe->readers++; | 110 | pipe->readers++; |
111 | pipe->writers++; | 111 | pipe->writers++; |
@@ -151,5 +151,5 @@ err_nocleanup: | |||
151 | * depending on the access mode of the file... | 151 | * depending on the access mode of the file... |
152 | */ | 152 | */ |
153 | const struct file_operations def_fifo_fops = { | 153 | const struct file_operations def_fifo_fops = { |
154 | .open = fifo_open, /* will set read or write pipe_fops */ | 154 | .open = fifo_open, /* will set read_ or write_pipefifo_fops */ |
155 | }; | 155 | }; |
@@ -250,9 +250,18 @@ int expand_files(struct files_struct *files, int nr) | |||
250 | struct fdtable *fdt; | 250 | struct fdtable *fdt; |
251 | 251 | ||
252 | fdt = files_fdtable(files); | 252 | fdt = files_fdtable(files); |
253 | |||
254 | /* | ||
255 | * N.B. For clone tasks sharing a files structure, this test | ||
256 | * will limit the total number of files that can be opened. | ||
257 | */ | ||
258 | if (nr >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur) | ||
259 | return -EMFILE; | ||
260 | |||
253 | /* Do we need to expand? */ | 261 | /* Do we need to expand? */ |
254 | if (nr < fdt->max_fds) | 262 | if (nr < fdt->max_fds) |
255 | return 0; | 263 | return 0; |
264 | |||
256 | /* Can we expand? */ | 265 | /* Can we expand? */ |
257 | if (nr >= sysctl_nr_open) | 266 | if (nr >= sysctl_nr_open) |
258 | return -EMFILE; | 267 | return -EMFILE; |
diff --git a/fs/file_table.c b/fs/file_table.c index 83084225b4c3..f45a4493f9e7 100644 --- a/fs/file_table.c +++ b/fs/file_table.c | |||
@@ -120,7 +120,7 @@ struct file *get_empty_filp(void) | |||
120 | 120 | ||
121 | tsk = current; | 121 | tsk = current; |
122 | INIT_LIST_HEAD(&f->f_u.fu_list); | 122 | INIT_LIST_HEAD(&f->f_u.fu_list); |
123 | atomic_set(&f->f_count, 1); | 123 | atomic_long_set(&f->f_count, 1); |
124 | rwlock_init(&f->f_owner.lock); | 124 | rwlock_init(&f->f_owner.lock); |
125 | f->f_uid = tsk->fsuid; | 125 | f->f_uid = tsk->fsuid; |
126 | f->f_gid = tsk->fsgid; | 126 | f->f_gid = tsk->fsgid; |
@@ -219,7 +219,7 @@ EXPORT_SYMBOL(init_file); | |||
219 | 219 | ||
220 | void fput(struct file *file) | 220 | void fput(struct file *file) |
221 | { | 221 | { |
222 | if (atomic_dec_and_test(&file->f_count)) | 222 | if (atomic_long_dec_and_test(&file->f_count)) |
223 | __fput(file); | 223 | __fput(file); |
224 | } | 224 | } |
225 | 225 | ||
@@ -294,7 +294,7 @@ struct file *fget(unsigned int fd) | |||
294 | rcu_read_lock(); | 294 | rcu_read_lock(); |
295 | file = fcheck_files(files, fd); | 295 | file = fcheck_files(files, fd); |
296 | if (file) { | 296 | if (file) { |
297 | if (!atomic_inc_not_zero(&file->f_count)) { | 297 | if (!atomic_long_inc_not_zero(&file->f_count)) { |
298 | /* File object ref couldn't be taken */ | 298 | /* File object ref couldn't be taken */ |
299 | rcu_read_unlock(); | 299 | rcu_read_unlock(); |
300 | return NULL; | 300 | return NULL; |
@@ -326,7 +326,7 @@ struct file *fget_light(unsigned int fd, int *fput_needed) | |||
326 | rcu_read_lock(); | 326 | rcu_read_lock(); |
327 | file = fcheck_files(files, fd); | 327 | file = fcheck_files(files, fd); |
328 | if (file) { | 328 | if (file) { |
329 | if (atomic_inc_not_zero(&file->f_count)) | 329 | if (atomic_long_inc_not_zero(&file->f_count)) |
330 | *fput_needed = 1; | 330 | *fput_needed = 1; |
331 | else | 331 | else |
332 | /* Didn't get the reference, someone's freed */ | 332 | /* Didn't get the reference, someone's freed */ |
@@ -341,7 +341,7 @@ struct file *fget_light(unsigned int fd, int *fput_needed) | |||
341 | 341 | ||
342 | void put_filp(struct file *file) | 342 | void put_filp(struct file *file) |
343 | { | 343 | { |
344 | if (atomic_dec_and_test(&file->f_count)) { | 344 | if (atomic_long_dec_and_test(&file->f_count)) { |
345 | security_file_free(file); | 345 | security_file_free(file); |
346 | file_kill(file); | 346 | file_kill(file); |
347 | file_free(file); | 347 | file_free(file); |
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 51d0035ff07e..fd03330cadeb 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c | |||
@@ -898,7 +898,7 @@ static int fuse_access(struct inode *inode, int mask) | |||
898 | return PTR_ERR(req); | 898 | return PTR_ERR(req); |
899 | 899 | ||
900 | memset(&inarg, 0, sizeof(inarg)); | 900 | memset(&inarg, 0, sizeof(inarg)); |
901 | inarg.mask = mask; | 901 | inarg.mask = mask & (MAY_READ | MAY_WRITE | MAY_EXEC); |
902 | req->in.h.opcode = FUSE_ACCESS; | 902 | req->in.h.opcode = FUSE_ACCESS; |
903 | req->in.h.nodeid = get_node_id(inode); | 903 | req->in.h.nodeid = get_node_id(inode); |
904 | req->in.numargs = 1; | 904 | req->in.numargs = 1; |
@@ -927,7 +927,7 @@ static int fuse_access(struct inode *inode, int mask) | |||
927 | * access request is sent. Execute permission is still checked | 927 | * access request is sent. Execute permission is still checked |
928 | * locally based on file mode. | 928 | * locally based on file mode. |
929 | */ | 929 | */ |
930 | static int fuse_permission(struct inode *inode, int mask, struct nameidata *nd) | 930 | static int fuse_permission(struct inode *inode, int mask) |
931 | { | 931 | { |
932 | struct fuse_conn *fc = get_fuse_conn(inode); | 932 | struct fuse_conn *fc = get_fuse_conn(inode); |
933 | bool refreshed = false; | 933 | bool refreshed = false; |
@@ -962,7 +962,7 @@ static int fuse_permission(struct inode *inode, int mask, struct nameidata *nd) | |||
962 | exist. So if permissions are revoked this won't be | 962 | exist. So if permissions are revoked this won't be |
963 | noticed immediately, only after the attribute | 963 | noticed immediately, only after the attribute |
964 | timeout has expired */ | 964 | timeout has expired */ |
965 | } else if (nd && (nd->flags & (LOOKUP_ACCESS | LOOKUP_CHDIR))) { | 965 | } else if (mask & MAY_ACCESS) { |
966 | err = fuse_access(inode, mask); | 966 | err = fuse_access(inode, mask); |
967 | } else if ((mask & MAY_EXEC) && S_ISREG(inode->i_mode)) { | 967 | } else if ((mask & MAY_EXEC) && S_ISREG(inode->i_mode)) { |
968 | if (!(inode->i_mode & S_IXUGO)) { | 968 | if (!(inode->i_mode & S_IXUGO)) { |
diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 67ff2c6a8f63..2bada6bbc317 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c | |||
@@ -893,7 +893,7 @@ static ssize_t fuse_file_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
893 | if (count == 0) | 893 | if (count == 0) |
894 | goto out; | 894 | goto out; |
895 | 895 | ||
896 | err = remove_suid(file->f_path.dentry); | 896 | err = file_remove_suid(file); |
897 | if (err) | 897 | if (err) |
898 | goto out; | 898 | goto out; |
899 | 899 | ||
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 7d2f7d6e22e2..d2249f174e20 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c | |||
@@ -956,7 +956,7 @@ static inline void unregister_fuseblk(void) | |||
956 | } | 956 | } |
957 | #endif | 957 | #endif |
958 | 958 | ||
959 | static void fuse_inode_init_once(struct kmem_cache *cachep, void *foo) | 959 | static void fuse_inode_init_once(void *foo) |
960 | { | 960 | { |
961 | struct inode * inode = foo; | 961 | struct inode * inode = foo; |
962 | 962 | ||
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 6da0ab355b8a..8b0806a32948 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c | |||
@@ -448,7 +448,7 @@ struct inode *gfs2_lookup_simple(struct inode *dip, const char *name) | |||
448 | struct qstr qstr; | 448 | struct qstr qstr; |
449 | struct inode *inode; | 449 | struct inode *inode; |
450 | gfs2_str2qstr(&qstr, name); | 450 | gfs2_str2qstr(&qstr, name); |
451 | inode = gfs2_lookupi(dip, &qstr, 1, NULL); | 451 | inode = gfs2_lookupi(dip, &qstr, 1); |
452 | /* gfs2_lookupi has inconsistent callers: vfs | 452 | /* gfs2_lookupi has inconsistent callers: vfs |
453 | * related routines expect NULL for no entry found, | 453 | * related routines expect NULL for no entry found, |
454 | * gfs2_lookup_simple callers expect ENOENT | 454 | * gfs2_lookup_simple callers expect ENOENT |
@@ -477,7 +477,7 @@ struct inode *gfs2_lookup_simple(struct inode *dip, const char *name) | |||
477 | */ | 477 | */ |
478 | 478 | ||
479 | struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name, | 479 | struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name, |
480 | int is_root, struct nameidata *nd) | 480 | int is_root) |
481 | { | 481 | { |
482 | struct super_block *sb = dir->i_sb; | 482 | struct super_block *sb = dir->i_sb; |
483 | struct gfs2_inode *dip = GFS2_I(dir); | 483 | struct gfs2_inode *dip = GFS2_I(dir); |
@@ -1173,7 +1173,7 @@ int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to) | |||
1173 | break; | 1173 | break; |
1174 | } | 1174 | } |
1175 | 1175 | ||
1176 | tmp = gfs2_lookupi(dir, &dotdot, 1, NULL); | 1176 | tmp = gfs2_lookupi(dir, &dotdot, 1); |
1177 | if (IS_ERR(tmp)) { | 1177 | if (IS_ERR(tmp)) { |
1178 | error = PTR_ERR(tmp); | 1178 | error = PTR_ERR(tmp); |
1179 | break; | 1179 | break; |
diff --git a/fs/gfs2/inode.h b/fs/gfs2/inode.h index 6074c2506f75..58f9607d6a86 100644 --- a/fs/gfs2/inode.h +++ b/fs/gfs2/inode.h | |||
@@ -83,7 +83,7 @@ int gfs2_inode_refresh(struct gfs2_inode *ip); | |||
83 | int gfs2_dinode_dealloc(struct gfs2_inode *inode); | 83 | int gfs2_dinode_dealloc(struct gfs2_inode *inode); |
84 | int gfs2_change_nlink(struct gfs2_inode *ip, int diff); | 84 | int gfs2_change_nlink(struct gfs2_inode *ip, int diff); |
85 | struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name, | 85 | struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name, |
86 | int is_root, struct nameidata *nd); | 86 | int is_root); |
87 | struct inode *gfs2_createi(struct gfs2_holder *ghs, const struct qstr *name, | 87 | struct inode *gfs2_createi(struct gfs2_holder *ghs, const struct qstr *name, |
88 | unsigned int mode, dev_t dev); | 88 | unsigned int mode, dev_t dev); |
89 | int gfs2_rmdiri(struct gfs2_inode *dip, const struct qstr *name, | 89 | int gfs2_rmdiri(struct gfs2_inode *dip, const struct qstr *name, |
diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c index bcc668d0fadd..bb2cc303ac29 100644 --- a/fs/gfs2/main.c +++ b/fs/gfs2/main.c | |||
@@ -24,7 +24,7 @@ | |||
24 | #include "util.h" | 24 | #include "util.h" |
25 | #include "glock.h" | 25 | #include "glock.h" |
26 | 26 | ||
27 | static void gfs2_init_inode_once(struct kmem_cache *cachep, void *foo) | 27 | static void gfs2_init_inode_once(void *foo) |
28 | { | 28 | { |
29 | struct gfs2_inode *ip = foo; | 29 | struct gfs2_inode *ip = foo; |
30 | 30 | ||
@@ -33,7 +33,7 @@ static void gfs2_init_inode_once(struct kmem_cache *cachep, void *foo) | |||
33 | ip->i_alloc = NULL; | 33 | ip->i_alloc = NULL; |
34 | } | 34 | } |
35 | 35 | ||
36 | static void gfs2_init_glock_once(struct kmem_cache *cachep, void *foo) | 36 | static void gfs2_init_glock_once(void *foo) |
37 | { | 37 | { |
38 | struct gfs2_glock *gl = foo; | 38 | struct gfs2_glock *gl = foo; |
39 | 39 | ||
diff --git a/fs/gfs2/ops_export.c b/fs/gfs2/ops_export.c index 990d9f4bc463..9cda8536530c 100644 --- a/fs/gfs2/ops_export.c +++ b/fs/gfs2/ops_export.c | |||
@@ -134,7 +134,7 @@ static struct dentry *gfs2_get_parent(struct dentry *child) | |||
134 | struct dentry *dentry; | 134 | struct dentry *dentry; |
135 | 135 | ||
136 | gfs2_str2qstr(&dotdot, ".."); | 136 | gfs2_str2qstr(&dotdot, ".."); |
137 | inode = gfs2_lookupi(child->d_inode, &dotdot, 1, NULL); | 137 | inode = gfs2_lookupi(child->d_inode, &dotdot, 1); |
138 | 138 | ||
139 | if (!inode) | 139 | if (!inode) |
140 | return ERR_PTR(-ENOENT); | 140 | return ERR_PTR(-ENOENT); |
diff --git a/fs/gfs2/ops_inode.c b/fs/gfs2/ops_inode.c index 1e252dfc5294..e2c62f73a778 100644 --- a/fs/gfs2/ops_inode.c +++ b/fs/gfs2/ops_inode.c | |||
@@ -74,7 +74,7 @@ static int gfs2_create(struct inode *dir, struct dentry *dentry, | |||
74 | return PTR_ERR(inode); | 74 | return PTR_ERR(inode); |
75 | } | 75 | } |
76 | 76 | ||
77 | inode = gfs2_lookupi(dir, &dentry->d_name, 0, nd); | 77 | inode = gfs2_lookupi(dir, &dentry->d_name, 0); |
78 | if (inode) { | 78 | if (inode) { |
79 | if (!IS_ERR(inode)) { | 79 | if (!IS_ERR(inode)) { |
80 | gfs2_holder_uninit(ghs); | 80 | gfs2_holder_uninit(ghs); |
@@ -109,7 +109,7 @@ static struct dentry *gfs2_lookup(struct inode *dir, struct dentry *dentry, | |||
109 | 109 | ||
110 | dentry->d_op = &gfs2_dops; | 110 | dentry->d_op = &gfs2_dops; |
111 | 111 | ||
112 | inode = gfs2_lookupi(dir, &dentry->d_name, 0, nd); | 112 | inode = gfs2_lookupi(dir, &dentry->d_name, 0); |
113 | if (inode && IS_ERR(inode)) | 113 | if (inode && IS_ERR(inode)) |
114 | return ERR_CAST(inode); | 114 | return ERR_CAST(inode); |
115 | 115 | ||
@@ -915,12 +915,6 @@ int gfs2_permission(struct inode *inode, int mask) | |||
915 | return error; | 915 | return error; |
916 | } | 916 | } |
917 | 917 | ||
918 | static int gfs2_iop_permission(struct inode *inode, int mask, | ||
919 | struct nameidata *nd) | ||
920 | { | ||
921 | return gfs2_permission(inode, mask); | ||
922 | } | ||
923 | |||
924 | static int setattr_size(struct inode *inode, struct iattr *attr) | 918 | static int setattr_size(struct inode *inode, struct iattr *attr) |
925 | { | 919 | { |
926 | struct gfs2_inode *ip = GFS2_I(inode); | 920 | struct gfs2_inode *ip = GFS2_I(inode); |
@@ -1150,7 +1144,7 @@ static int gfs2_removexattr(struct dentry *dentry, const char *name) | |||
1150 | } | 1144 | } |
1151 | 1145 | ||
1152 | const struct inode_operations gfs2_file_iops = { | 1146 | const struct inode_operations gfs2_file_iops = { |
1153 | .permission = gfs2_iop_permission, | 1147 | .permission = gfs2_permission, |
1154 | .setattr = gfs2_setattr, | 1148 | .setattr = gfs2_setattr, |
1155 | .getattr = gfs2_getattr, | 1149 | .getattr = gfs2_getattr, |
1156 | .setxattr = gfs2_setxattr, | 1150 | .setxattr = gfs2_setxattr, |
@@ -1169,7 +1163,7 @@ const struct inode_operations gfs2_dir_iops = { | |||
1169 | .rmdir = gfs2_rmdir, | 1163 | .rmdir = gfs2_rmdir, |
1170 | .mknod = gfs2_mknod, | 1164 | .mknod = gfs2_mknod, |
1171 | .rename = gfs2_rename, | 1165 | .rename = gfs2_rename, |
1172 | .permission = gfs2_iop_permission, | 1166 | .permission = gfs2_permission, |
1173 | .setattr = gfs2_setattr, | 1167 | .setattr = gfs2_setattr, |
1174 | .getattr = gfs2_getattr, | 1168 | .getattr = gfs2_getattr, |
1175 | .setxattr = gfs2_setxattr, | 1169 | .setxattr = gfs2_setxattr, |
@@ -1181,7 +1175,7 @@ const struct inode_operations gfs2_dir_iops = { | |||
1181 | const struct inode_operations gfs2_symlink_iops = { | 1175 | const struct inode_operations gfs2_symlink_iops = { |
1182 | .readlink = gfs2_readlink, | 1176 | .readlink = gfs2_readlink, |
1183 | .follow_link = gfs2_follow_link, | 1177 | .follow_link = gfs2_follow_link, |
1184 | .permission = gfs2_iop_permission, | 1178 | .permission = gfs2_permission, |
1185 | .setattr = gfs2_setattr, | 1179 | .setattr = gfs2_setattr, |
1186 | .getattr = gfs2_getattr, | 1180 | .getattr = gfs2_getattr, |
1187 | .setxattr = gfs2_setxattr, | 1181 | .setxattr = gfs2_setxattr, |
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index 63a8a902d9db..ca831991cbc2 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c | |||
@@ -389,7 +389,7 @@ int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ji_gh) | |||
389 | break; | 389 | break; |
390 | 390 | ||
391 | INIT_LIST_HEAD(&jd->extent_list); | 391 | INIT_LIST_HEAD(&jd->extent_list); |
392 | jd->jd_inode = gfs2_lookupi(sdp->sd_jindex, &name, 1, NULL); | 392 | jd->jd_inode = gfs2_lookupi(sdp->sd_jindex, &name, 1); |
393 | if (!jd->jd_inode || IS_ERR(jd->jd_inode)) { | 393 | if (!jd->jd_inode || IS_ERR(jd->jd_inode)) { |
394 | if (!jd->jd_inode) | 394 | if (!jd->jd_inode) |
395 | error = -ENOENT; | 395 | error = -ENOENT; |
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c index dc4ec640e875..7e19835efa2e 100644 --- a/fs/hfs/inode.c +++ b/fs/hfs/inode.c | |||
@@ -511,8 +511,7 @@ void hfs_clear_inode(struct inode *inode) | |||
511 | } | 511 | } |
512 | } | 512 | } |
513 | 513 | ||
514 | static int hfs_permission(struct inode *inode, int mask, | 514 | static int hfs_permission(struct inode *inode, int mask) |
515 | struct nameidata *nd) | ||
516 | { | 515 | { |
517 | if (S_ISREG(inode->i_mode) && mask & MAY_EXEC) | 516 | if (S_ISREG(inode->i_mode) && mask & MAY_EXEC) |
518 | return 0; | 517 | return 0; |
@@ -523,8 +522,6 @@ static int hfs_file_open(struct inode *inode, struct file *file) | |||
523 | { | 522 | { |
524 | if (HFS_IS_RSRC(inode)) | 523 | if (HFS_IS_RSRC(inode)) |
525 | inode = HFS_I(inode)->rsrc_inode; | 524 | inode = HFS_I(inode)->rsrc_inode; |
526 | if (atomic_read(&file->f_count) != 1) | ||
527 | return 0; | ||
528 | atomic_inc(&HFS_I(inode)->opencnt); | 525 | atomic_inc(&HFS_I(inode)->opencnt); |
529 | return 0; | 526 | return 0; |
530 | } | 527 | } |
@@ -535,8 +532,6 @@ static int hfs_file_release(struct inode *inode, struct file *file) | |||
535 | 532 | ||
536 | if (HFS_IS_RSRC(inode)) | 533 | if (HFS_IS_RSRC(inode)) |
537 | inode = HFS_I(inode)->rsrc_inode; | 534 | inode = HFS_I(inode)->rsrc_inode; |
538 | if (atomic_read(&file->f_count) != 0) | ||
539 | return 0; | ||
540 | if (atomic_dec_and_test(&HFS_I(inode)->opencnt)) { | 535 | if (atomic_dec_and_test(&HFS_I(inode)->opencnt)) { |
541 | mutex_lock(&inode->i_mutex); | 536 | mutex_lock(&inode->i_mutex); |
542 | hfs_file_truncate(inode); | 537 | hfs_file_truncate(inode); |
diff --git a/fs/hfs/super.c b/fs/hfs/super.c index ac2ec5ef66e4..4abb1047c689 100644 --- a/fs/hfs/super.c +++ b/fs/hfs/super.c | |||
@@ -432,7 +432,7 @@ static struct file_system_type hfs_fs_type = { | |||
432 | .fs_flags = FS_REQUIRES_DEV, | 432 | .fs_flags = FS_REQUIRES_DEV, |
433 | }; | 433 | }; |
434 | 434 | ||
435 | static void hfs_init_once(struct kmem_cache *cachep, void *p) | 435 | static void hfs_init_once(void *p) |
436 | { | 436 | { |
437 | struct hfs_inode_info *i = p; | 437 | struct hfs_inode_info *i = p; |
438 | 438 | ||
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c index cc3b5e24339b..b085d64a2b67 100644 --- a/fs/hfsplus/inode.c +++ b/fs/hfsplus/inode.c | |||
@@ -238,7 +238,7 @@ static void hfsplus_set_perms(struct inode *inode, struct hfsplus_perm *perms) | |||
238 | perms->dev = cpu_to_be32(HFSPLUS_I(inode).dev); | 238 | perms->dev = cpu_to_be32(HFSPLUS_I(inode).dev); |
239 | } | 239 | } |
240 | 240 | ||
241 | static int hfsplus_permission(struct inode *inode, int mask, struct nameidata *nd) | 241 | static int hfsplus_permission(struct inode *inode, int mask) |
242 | { | 242 | { |
243 | /* MAY_EXEC is also used for lookup, if no x bit is set allow lookup, | 243 | /* MAY_EXEC is also used for lookup, if no x bit is set allow lookup, |
244 | * open_exec has the same test, so it's still not executable, if a x bit | 244 | * open_exec has the same test, so it's still not executable, if a x bit |
@@ -254,8 +254,6 @@ static int hfsplus_file_open(struct inode *inode, struct file *file) | |||
254 | { | 254 | { |
255 | if (HFSPLUS_IS_RSRC(inode)) | 255 | if (HFSPLUS_IS_RSRC(inode)) |
256 | inode = HFSPLUS_I(inode).rsrc_inode; | 256 | inode = HFSPLUS_I(inode).rsrc_inode; |
257 | if (atomic_read(&file->f_count) != 1) | ||
258 | return 0; | ||
259 | atomic_inc(&HFSPLUS_I(inode).opencnt); | 257 | atomic_inc(&HFSPLUS_I(inode).opencnt); |
260 | return 0; | 258 | return 0; |
261 | } | 259 | } |
@@ -266,8 +264,6 @@ static int hfsplus_file_release(struct inode *inode, struct file *file) | |||
266 | 264 | ||
267 | if (HFSPLUS_IS_RSRC(inode)) | 265 | if (HFSPLUS_IS_RSRC(inode)) |
268 | inode = HFSPLUS_I(inode).rsrc_inode; | 266 | inode = HFSPLUS_I(inode).rsrc_inode; |
269 | if (atomic_read(&file->f_count) != 0) | ||
270 | return 0; | ||
271 | if (atomic_dec_and_test(&HFSPLUS_I(inode).opencnt)) { | 267 | if (atomic_dec_and_test(&HFSPLUS_I(inode).opencnt)) { |
272 | mutex_lock(&inode->i_mutex); | 268 | mutex_lock(&inode->i_mutex); |
273 | hfsplus_file_truncate(inode); | 269 | hfsplus_file_truncate(inode); |
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c index 3859118531c7..e834e578c93f 100644 --- a/fs/hfsplus/super.c +++ b/fs/hfsplus/super.c | |||
@@ -485,7 +485,7 @@ static struct file_system_type hfsplus_fs_type = { | |||
485 | .fs_flags = FS_REQUIRES_DEV, | 485 | .fs_flags = FS_REQUIRES_DEV, |
486 | }; | 486 | }; |
487 | 487 | ||
488 | static void hfsplus_init_once(struct kmem_cache *cachep, void *p) | 488 | static void hfsplus_init_once(void *p) |
489 | { | 489 | { |
490 | struct hfsplus_inode_info *i = p; | 490 | struct hfsplus_inode_info *i = p; |
491 | 491 | ||
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c index 5222345ddccf..d6ecabf4d231 100644 --- a/fs/hostfs/hostfs_kern.c +++ b/fs/hostfs/hostfs_kern.c | |||
@@ -822,7 +822,7 @@ int hostfs_rename(struct inode *from_ino, struct dentry *from, | |||
822 | return err; | 822 | return err; |
823 | } | 823 | } |
824 | 824 | ||
825 | int hostfs_permission(struct inode *ino, int desired, struct nameidata *nd) | 825 | int hostfs_permission(struct inode *ino, int desired) |
826 | { | 826 | { |
827 | char *name; | 827 | char *name; |
828 | int r = 0, w = 0, x = 0, err; | 828 | int r = 0, w = 0, x = 0, err; |
diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c index d256559b4104..d9c59a775449 100644 --- a/fs/hpfs/namei.c +++ b/fs/hpfs/namei.c | |||
@@ -415,7 +415,7 @@ again: | |||
415 | d_drop(dentry); | 415 | d_drop(dentry); |
416 | spin_lock(&dentry->d_lock); | 416 | spin_lock(&dentry->d_lock); |
417 | if (atomic_read(&dentry->d_count) > 1 || | 417 | if (atomic_read(&dentry->d_count) > 1 || |
418 | permission(inode, MAY_WRITE, NULL) || | 418 | generic_permission(inode, MAY_WRITE, NULL) || |
419 | !S_ISREG(inode->i_mode) || | 419 | !S_ISREG(inode->i_mode) || |
420 | get_write_access(inode)) { | 420 | get_write_access(inode)) { |
421 | spin_unlock(&dentry->d_lock); | 421 | spin_unlock(&dentry->d_lock); |
diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c index f63a699ec659..b8ae9c90ada0 100644 --- a/fs/hpfs/super.c +++ b/fs/hpfs/super.c | |||
@@ -173,7 +173,7 @@ static void hpfs_destroy_inode(struct inode *inode) | |||
173 | kmem_cache_free(hpfs_inode_cachep, hpfs_i(inode)); | 173 | kmem_cache_free(hpfs_inode_cachep, hpfs_i(inode)); |
174 | } | 174 | } |
175 | 175 | ||
176 | static void init_once(struct kmem_cache *cachep, void *foo) | 176 | static void init_once(void *foo) |
177 | { | 177 | { |
178 | struct hpfs_inode_info *ei = (struct hpfs_inode_info *) foo; | 178 | struct hpfs_inode_info *ei = (struct hpfs_inode_info *) foo; |
179 | 179 | ||
diff --git a/fs/hppfs/hppfs.c b/fs/hppfs/hppfs.c index 65077aa90f0a..2b3d1828db99 100644 --- a/fs/hppfs/hppfs.c +++ b/fs/hppfs/hppfs.c | |||
@@ -655,20 +655,13 @@ static void *hppfs_follow_link(struct dentry *dentry, struct nameidata *nd) | |||
655 | return proc_dentry->d_inode->i_op->follow_link(proc_dentry, nd); | 655 | return proc_dentry->d_inode->i_op->follow_link(proc_dentry, nd); |
656 | } | 656 | } |
657 | 657 | ||
658 | int hppfs_permission(struct inode *inode, int mask, struct nameidata *nd) | ||
659 | { | ||
660 | return generic_permission(inode, mask, NULL); | ||
661 | } | ||
662 | |||
663 | static const struct inode_operations hppfs_dir_iops = { | 658 | static const struct inode_operations hppfs_dir_iops = { |
664 | .lookup = hppfs_lookup, | 659 | .lookup = hppfs_lookup, |
665 | .permission = hppfs_permission, | ||
666 | }; | 660 | }; |
667 | 661 | ||
668 | static const struct inode_operations hppfs_link_iops = { | 662 | static const struct inode_operations hppfs_link_iops = { |
669 | .readlink = hppfs_readlink, | 663 | .readlink = hppfs_readlink, |
670 | .follow_link = hppfs_follow_link, | 664 | .follow_link = hppfs_follow_link, |
671 | .permission = hppfs_permission, | ||
672 | }; | 665 | }; |
673 | 666 | ||
674 | static struct inode *get_inode(struct super_block *sb, struct dentry *dentry) | 667 | static struct inode *get_inode(struct super_block *sb, struct dentry *dentry) |
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index dbd01d262ca4..3f58923fb39b 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c | |||
@@ -705,7 +705,7 @@ static const struct address_space_operations hugetlbfs_aops = { | |||
705 | }; | 705 | }; |
706 | 706 | ||
707 | 707 | ||
708 | static void init_once(struct kmem_cache *cachep, void *foo) | 708 | static void init_once(void *foo) |
709 | { | 709 | { |
710 | struct hugetlbfs_inode_info *ei = (struct hugetlbfs_inode_info *)foo; | 710 | struct hugetlbfs_inode_info *ei = (struct hugetlbfs_inode_info *)foo; |
711 | 711 | ||
diff --git a/fs/inode.c b/fs/inode.c index c36d9480335c..b6726f644530 100644 --- a/fs/inode.c +++ b/fs/inode.c | |||
@@ -209,7 +209,7 @@ void inode_init_once(struct inode *inode) | |||
209 | INIT_LIST_HEAD(&inode->i_dentry); | 209 | INIT_LIST_HEAD(&inode->i_dentry); |
210 | INIT_LIST_HEAD(&inode->i_devices); | 210 | INIT_LIST_HEAD(&inode->i_devices); |
211 | INIT_RADIX_TREE(&inode->i_data.page_tree, GFP_ATOMIC); | 211 | INIT_RADIX_TREE(&inode->i_data.page_tree, GFP_ATOMIC); |
212 | rwlock_init(&inode->i_data.tree_lock); | 212 | spin_lock_init(&inode->i_data.tree_lock); |
213 | spin_lock_init(&inode->i_data.i_mmap_lock); | 213 | spin_lock_init(&inode->i_data.i_mmap_lock); |
214 | INIT_LIST_HEAD(&inode->i_data.private_list); | 214 | INIT_LIST_HEAD(&inode->i_data.private_list); |
215 | spin_lock_init(&inode->i_data.private_lock); | 215 | spin_lock_init(&inode->i_data.private_lock); |
@@ -224,7 +224,7 @@ void inode_init_once(struct inode *inode) | |||
224 | 224 | ||
225 | EXPORT_SYMBOL(inode_init_once); | 225 | EXPORT_SYMBOL(inode_init_once); |
226 | 226 | ||
227 | static void init_once(struct kmem_cache * cachep, void *foo) | 227 | static void init_once(void *foo) |
228 | { | 228 | { |
229 | struct inode * inode = (struct inode *) foo; | 229 | struct inode * inode = (struct inode *) foo; |
230 | 230 | ||
diff --git a/fs/inotify_user.c b/fs/inotify_user.c index fe79c25d95dc..60249429a253 100644 --- a/fs/inotify_user.c +++ b/fs/inotify_user.c | |||
@@ -354,20 +354,20 @@ static void inotify_dev_event_dequeue(struct inotify_device *dev) | |||
354 | } | 354 | } |
355 | 355 | ||
356 | /* | 356 | /* |
357 | * find_inode - resolve a user-given path to a specific inode and return a nd | 357 | * find_inode - resolve a user-given path to a specific inode |
358 | */ | 358 | */ |
359 | static int find_inode(const char __user *dirname, struct nameidata *nd, | 359 | static int find_inode(const char __user *dirname, struct path *path, |
360 | unsigned flags) | 360 | unsigned flags) |
361 | { | 361 | { |
362 | int error; | 362 | int error; |
363 | 363 | ||
364 | error = __user_walk(dirname, flags, nd); | 364 | error = user_path_at(AT_FDCWD, dirname, flags, path); |
365 | if (error) | 365 | if (error) |
366 | return error; | 366 | return error; |
367 | /* you can only watch an inode if you have read permissions on it */ | 367 | /* you can only watch an inode if you have read permissions on it */ |
368 | error = vfs_permission(nd, MAY_READ); | 368 | error = inode_permission(path->dentry->d_inode, MAY_READ); |
369 | if (error) | 369 | if (error) |
370 | path_put(&nd->path); | 370 | path_put(path); |
371 | return error; | 371 | return error; |
372 | } | 372 | } |
373 | 373 | ||
@@ -650,11 +650,11 @@ asmlinkage long sys_inotify_init(void) | |||
650 | return sys_inotify_init1(0); | 650 | return sys_inotify_init1(0); |
651 | } | 651 | } |
652 | 652 | ||
653 | asmlinkage long sys_inotify_add_watch(int fd, const char __user *path, u32 mask) | 653 | asmlinkage long sys_inotify_add_watch(int fd, const char __user *pathname, u32 mask) |
654 | { | 654 | { |
655 | struct inode *inode; | 655 | struct inode *inode; |
656 | struct inotify_device *dev; | 656 | struct inotify_device *dev; |
657 | struct nameidata nd; | 657 | struct path path; |
658 | struct file *filp; | 658 | struct file *filp; |
659 | int ret, fput_needed; | 659 | int ret, fput_needed; |
660 | unsigned flags = 0; | 660 | unsigned flags = 0; |
@@ -674,12 +674,12 @@ asmlinkage long sys_inotify_add_watch(int fd, const char __user *path, u32 mask) | |||
674 | if (mask & IN_ONLYDIR) | 674 | if (mask & IN_ONLYDIR) |
675 | flags |= LOOKUP_DIRECTORY; | 675 | flags |= LOOKUP_DIRECTORY; |
676 | 676 | ||
677 | ret = find_inode(path, &nd, flags); | 677 | ret = find_inode(pathname, &path, flags); |
678 | if (unlikely(ret)) | 678 | if (unlikely(ret)) |
679 | goto fput_and_out; | 679 | goto fput_and_out; |
680 | 680 | ||
681 | /* inode held in place by reference to nd; dev by fget on fd */ | 681 | /* inode held in place by reference to path; dev by fget on fd */ |
682 | inode = nd.path.dentry->d_inode; | 682 | inode = path.dentry->d_inode; |
683 | dev = filp->private_data; | 683 | dev = filp->private_data; |
684 | 684 | ||
685 | mutex_lock(&dev->up_mutex); | 685 | mutex_lock(&dev->up_mutex); |
@@ -688,7 +688,7 @@ asmlinkage long sys_inotify_add_watch(int fd, const char __user *path, u32 mask) | |||
688 | ret = create_watch(dev, inode, mask); | 688 | ret = create_watch(dev, inode, mask); |
689 | mutex_unlock(&dev->up_mutex); | 689 | mutex_unlock(&dev->up_mutex); |
690 | 690 | ||
691 | path_put(&nd.path); | 691 | path_put(&path); |
692 | fput_and_out: | 692 | fput_and_out: |
693 | fput_light(filp, fput_needed); | 693 | fput_light(filp, fput_needed); |
694 | return ret; | 694 | return ret; |
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c index 044a254d526b..26948a6033b6 100644 --- a/fs/isofs/inode.c +++ b/fs/isofs/inode.c | |||
@@ -73,7 +73,7 @@ static void isofs_destroy_inode(struct inode *inode) | |||
73 | kmem_cache_free(isofs_inode_cachep, ISOFS_I(inode)); | 73 | kmem_cache_free(isofs_inode_cachep, ISOFS_I(inode)); |
74 | } | 74 | } |
75 | 75 | ||
76 | static void init_once(struct kmem_cache *cachep, void *foo) | 76 | static void init_once(void *foo) |
77 | { | 77 | { |
78 | struct iso_inode_info *ei = foo; | 78 | struct iso_inode_info *ei = foo; |
79 | 79 | ||
diff --git a/fs/jffs2/acl.c b/fs/jffs2/acl.c index 4c80404a9aba..d98713777a1b 100644 --- a/fs/jffs2/acl.c +++ b/fs/jffs2/acl.c | |||
@@ -314,7 +314,7 @@ static int jffs2_check_acl(struct inode *inode, int mask) | |||
314 | return -EAGAIN; | 314 | return -EAGAIN; |
315 | } | 315 | } |
316 | 316 | ||
317 | int jffs2_permission(struct inode *inode, int mask, struct nameidata *nd) | 317 | int jffs2_permission(struct inode *inode, int mask) |
318 | { | 318 | { |
319 | return generic_permission(inode, mask, jffs2_check_acl); | 319 | return generic_permission(inode, mask, jffs2_check_acl); |
320 | } | 320 | } |
diff --git a/fs/jffs2/acl.h b/fs/jffs2/acl.h index 0bb7f003fd80..8ca058aed384 100644 --- a/fs/jffs2/acl.h +++ b/fs/jffs2/acl.h | |||
@@ -28,7 +28,7 @@ struct jffs2_acl_header { | |||
28 | 28 | ||
29 | #define JFFS2_ACL_NOT_CACHED ((void *)-1) | 29 | #define JFFS2_ACL_NOT_CACHED ((void *)-1) |
30 | 30 | ||
31 | extern int jffs2_permission(struct inode *, int, struct nameidata *); | 31 | extern int jffs2_permission(struct inode *, int); |
32 | extern int jffs2_acl_chmod(struct inode *); | 32 | extern int jffs2_acl_chmod(struct inode *); |
33 | extern int jffs2_init_acl_pre(struct inode *, struct inode *, int *); | 33 | extern int jffs2_init_acl_pre(struct inode *, struct inode *, int *); |
34 | extern int jffs2_init_acl_post(struct inode *); | 34 | extern int jffs2_init_acl_post(struct inode *); |
diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c index c0c141f6fde1..cd219ef55254 100644 --- a/fs/jffs2/dir.c +++ b/fs/jffs2/dir.c | |||
@@ -38,7 +38,7 @@ const struct file_operations jffs2_dir_operations = | |||
38 | { | 38 | { |
39 | .read = generic_read_dir, | 39 | .read = generic_read_dir, |
40 | .readdir = jffs2_readdir, | 40 | .readdir = jffs2_readdir, |
41 | .ioctl = jffs2_ioctl, | 41 | .unlocked_ioctl=jffs2_ioctl, |
42 | .fsync = jffs2_fsync | 42 | .fsync = jffs2_fsync |
43 | }; | 43 | }; |
44 | 44 | ||
diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c index 5e920343b2c5..5a98aa87c853 100644 --- a/fs/jffs2/file.c +++ b/fs/jffs2/file.c | |||
@@ -46,7 +46,7 @@ const struct file_operations jffs2_file_operations = | |||
46 | .aio_read = generic_file_aio_read, | 46 | .aio_read = generic_file_aio_read, |
47 | .write = do_sync_write, | 47 | .write = do_sync_write, |
48 | .aio_write = generic_file_aio_write, | 48 | .aio_write = generic_file_aio_write, |
49 | .ioctl = jffs2_ioctl, | 49 | .unlocked_ioctl=jffs2_ioctl, |
50 | .mmap = generic_file_readonly_mmap, | 50 | .mmap = generic_file_readonly_mmap, |
51 | .fsync = jffs2_fsync, | 51 | .fsync = jffs2_fsync, |
52 | .splice_read = generic_file_splice_read, | 52 | .splice_read = generic_file_splice_read, |
diff --git a/fs/jffs2/ioctl.c b/fs/jffs2/ioctl.c index e2177210f621..9d41f43e47bb 100644 --- a/fs/jffs2/ioctl.c +++ b/fs/jffs2/ioctl.c | |||
@@ -12,8 +12,7 @@ | |||
12 | #include <linux/fs.h> | 12 | #include <linux/fs.h> |
13 | #include "nodelist.h" | 13 | #include "nodelist.h" |
14 | 14 | ||
15 | int jffs2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, | 15 | long jffs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) |
16 | unsigned long arg) | ||
17 | { | 16 | { |
18 | /* Later, this will provide for lsattr.jffs2 and chattr.jffs2, which | 17 | /* Later, this will provide for lsattr.jffs2 and chattr.jffs2, which |
19 | will include compression support etc. */ | 18 | will include compression support etc. */ |
diff --git a/fs/jffs2/os-linux.h b/fs/jffs2/os-linux.h index 2cc866cf134f..5e194a5c8e29 100644 --- a/fs/jffs2/os-linux.h +++ b/fs/jffs2/os-linux.h | |||
@@ -167,7 +167,7 @@ int jffs2_fsync(struct file *, struct dentry *, int); | |||
167 | int jffs2_do_readpage_unlock (struct inode *inode, struct page *pg); | 167 | int jffs2_do_readpage_unlock (struct inode *inode, struct page *pg); |
168 | 168 | ||
169 | /* ioctl.c */ | 169 | /* ioctl.c */ |
170 | int jffs2_ioctl(struct inode *, struct file *, unsigned int, unsigned long); | 170 | long jffs2_ioctl(struct file *, unsigned int, unsigned long); |
171 | 171 | ||
172 | /* symlink.c */ | 172 | /* symlink.c */ |
173 | extern const struct inode_operations jffs2_symlink_inode_operations; | 173 | extern const struct inode_operations jffs2_symlink_inode_operations; |
diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c index 7da69eae49e4..efd401257ed9 100644 --- a/fs/jffs2/super.c +++ b/fs/jffs2/super.c | |||
@@ -44,7 +44,7 @@ static void jffs2_destroy_inode(struct inode *inode) | |||
44 | kmem_cache_free(jffs2_inode_cachep, JFFS2_INODE_INFO(inode)); | 44 | kmem_cache_free(jffs2_inode_cachep, JFFS2_INODE_INFO(inode)); |
45 | } | 45 | } |
46 | 46 | ||
47 | static void jffs2_i_init_once(struct kmem_cache *cachep, void *foo) | 47 | static void jffs2_i_init_once(void *foo) |
48 | { | 48 | { |
49 | struct jffs2_inode_info *f = foo; | 49 | struct jffs2_inode_info *f = foo; |
50 | 50 | ||
diff --git a/fs/jfs/acl.c b/fs/jfs/acl.c index 4d84bdc88299..d3e5c33665de 100644 --- a/fs/jfs/acl.c +++ b/fs/jfs/acl.c | |||
@@ -140,7 +140,7 @@ static int jfs_check_acl(struct inode *inode, int mask) | |||
140 | return -EAGAIN; | 140 | return -EAGAIN; |
141 | } | 141 | } |
142 | 142 | ||
143 | int jfs_permission(struct inode *inode, int mask, struct nameidata *nd) | 143 | int jfs_permission(struct inode *inode, int mask) |
144 | { | 144 | { |
145 | return generic_permission(inode, mask, jfs_check_acl); | 145 | return generic_permission(inode, mask, jfs_check_acl); |
146 | } | 146 | } |
diff --git a/fs/jfs/jfs_acl.h b/fs/jfs/jfs_acl.h index 455fa4292045..88475f10a389 100644 --- a/fs/jfs/jfs_acl.h +++ b/fs/jfs/jfs_acl.h | |||
@@ -20,7 +20,7 @@ | |||
20 | 20 | ||
21 | #ifdef CONFIG_JFS_POSIX_ACL | 21 | #ifdef CONFIG_JFS_POSIX_ACL |
22 | 22 | ||
23 | int jfs_permission(struct inode *, int, struct nameidata *); | 23 | int jfs_permission(struct inode *, int); |
24 | int jfs_init_acl(tid_t, struct inode *, struct inode *); | 24 | int jfs_init_acl(tid_t, struct inode *, struct inode *); |
25 | int jfs_setattr(struct dentry *, struct iattr *); | 25 | int jfs_setattr(struct dentry *, struct iattr *); |
26 | 26 | ||
diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c index 854ff0ec574f..c350057087dd 100644 --- a/fs/jfs/jfs_metapage.c +++ b/fs/jfs/jfs_metapage.c | |||
@@ -182,7 +182,7 @@ static inline void remove_metapage(struct page *page, struct metapage *mp) | |||
182 | 182 | ||
183 | #endif | 183 | #endif |
184 | 184 | ||
185 | static void init_once(struct kmem_cache *cachep, void *foo) | 185 | static void init_once(void *foo) |
186 | { | 186 | { |
187 | struct metapage *mp = (struct metapage *)foo; | 187 | struct metapage *mp = (struct metapage *)foo; |
188 | 188 | ||
diff --git a/fs/jfs/super.c b/fs/jfs/super.c index 359c091d8965..3630718be395 100644 --- a/fs/jfs/super.c +++ b/fs/jfs/super.c | |||
@@ -760,7 +760,7 @@ static struct file_system_type jfs_fs_type = { | |||
760 | .fs_flags = FS_REQUIRES_DEV, | 760 | .fs_flags = FS_REQUIRES_DEV, |
761 | }; | 761 | }; |
762 | 762 | ||
763 | static void init_once(struct kmem_cache *cachep, void *foo) | 763 | static void init_once(void *foo) |
764 | { | 764 | { |
765 | struct jfs_inode_info *jfs_ip = (struct jfs_inode_info *) foo; | 765 | struct jfs_inode_info *jfs_ip = (struct jfs_inode_info *) foo; |
766 | 766 | ||
diff --git a/fs/locks.c b/fs/locks.c index 01490300f7cb..5eb259e3cd38 100644 --- a/fs/locks.c +++ b/fs/locks.c | |||
@@ -201,7 +201,7 @@ EXPORT_SYMBOL(locks_init_lock); | |||
201 | * Initialises the fields of the file lock which are invariant for | 201 | * Initialises the fields of the file lock which are invariant for |
202 | * free file_locks. | 202 | * free file_locks. |
203 | */ | 203 | */ |
204 | static void init_once(struct kmem_cache *cache, void *foo) | 204 | static void init_once(void *foo) |
205 | { | 205 | { |
206 | struct file_lock *lock = (struct file_lock *) foo; | 206 | struct file_lock *lock = (struct file_lock *) foo; |
207 | 207 | ||
diff --git a/fs/minix/inode.c b/fs/minix/inode.c index 523d73713418..d1d1eb84679d 100644 --- a/fs/minix/inode.c +++ b/fs/minix/inode.c | |||
@@ -68,7 +68,7 @@ static void minix_destroy_inode(struct inode *inode) | |||
68 | kmem_cache_free(minix_inode_cachep, minix_i(inode)); | 68 | kmem_cache_free(minix_inode_cachep, minix_i(inode)); |
69 | } | 69 | } |
70 | 70 | ||
71 | static void init_once(struct kmem_cache * cachep, void *foo) | 71 | static void init_once(void *foo) |
72 | { | 72 | { |
73 | struct minix_inode_info *ei = (struct minix_inode_info *) foo; | 73 | struct minix_inode_info *ei = (struct minix_inode_info *) foo; |
74 | 74 | ||
diff --git a/fs/namei.c b/fs/namei.c index 01e67dddcc3d..a7b0a0b80128 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -31,7 +31,6 @@ | |||
31 | #include <linux/file.h> | 31 | #include <linux/file.h> |
32 | #include <linux/fcntl.h> | 32 | #include <linux/fcntl.h> |
33 | #include <linux/device_cgroup.h> | 33 | #include <linux/device_cgroup.h> |
34 | #include <asm/namei.h> | ||
35 | #include <asm/uaccess.h> | 34 | #include <asm/uaccess.h> |
36 | 35 | ||
37 | #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE]) | 36 | #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE]) |
@@ -185,6 +184,8 @@ int generic_permission(struct inode *inode, int mask, | |||
185 | { | 184 | { |
186 | umode_t mode = inode->i_mode; | 185 | umode_t mode = inode->i_mode; |
187 | 186 | ||
187 | mask &= MAY_READ | MAY_WRITE | MAY_EXEC; | ||
188 | |||
188 | if (current->fsuid == inode->i_uid) | 189 | if (current->fsuid == inode->i_uid) |
189 | mode >>= 6; | 190 | mode >>= 6; |
190 | else { | 191 | else { |
@@ -203,7 +204,7 @@ int generic_permission(struct inode *inode, int mask, | |||
203 | /* | 204 | /* |
204 | * If the DACs are ok we don't need any capability check. | 205 | * If the DACs are ok we don't need any capability check. |
205 | */ | 206 | */ |
206 | if (((mode & mask & (MAY_READ|MAY_WRITE|MAY_EXEC)) == mask)) | 207 | if ((mask & ~mode) == 0) |
207 | return 0; | 208 | return 0; |
208 | 209 | ||
209 | check_capabilities: | 210 | check_capabilities: |
@@ -226,13 +227,9 @@ int generic_permission(struct inode *inode, int mask, | |||
226 | return -EACCES; | 227 | return -EACCES; |
227 | } | 228 | } |
228 | 229 | ||
229 | int permission(struct inode *inode, int mask, struct nameidata *nd) | 230 | int inode_permission(struct inode *inode, int mask) |
230 | { | 231 | { |
231 | int retval, submask; | 232 | int retval; |
232 | struct vfsmount *mnt = NULL; | ||
233 | |||
234 | if (nd) | ||
235 | mnt = nd->path.mnt; | ||
236 | 233 | ||
237 | if (mask & MAY_WRITE) { | 234 | if (mask & MAY_WRITE) { |
238 | umode_t mode = inode->i_mode; | 235 | umode_t mode = inode->i_mode; |
@@ -251,19 +248,9 @@ int permission(struct inode *inode, int mask, struct nameidata *nd) | |||
251 | return -EACCES; | 248 | return -EACCES; |
252 | } | 249 | } |
253 | 250 | ||
254 | if ((mask & MAY_EXEC) && S_ISREG(inode->i_mode)) { | ||
255 | /* | ||
256 | * MAY_EXEC on regular files is denied if the fs is mounted | ||
257 | * with the "noexec" flag. | ||
258 | */ | ||
259 | if (mnt && (mnt->mnt_flags & MNT_NOEXEC)) | ||
260 | return -EACCES; | ||
261 | } | ||
262 | |||
263 | /* Ordinary permission routines do not understand MAY_APPEND. */ | 251 | /* Ordinary permission routines do not understand MAY_APPEND. */ |
264 | submask = mask & ~MAY_APPEND; | ||
265 | if (inode->i_op && inode->i_op->permission) { | 252 | if (inode->i_op && inode->i_op->permission) { |
266 | retval = inode->i_op->permission(inode, submask, nd); | 253 | retval = inode->i_op->permission(inode, mask); |
267 | if (!retval) { | 254 | if (!retval) { |
268 | /* | 255 | /* |
269 | * Exec permission on a regular file is denied if none | 256 | * Exec permission on a regular file is denied if none |
@@ -277,7 +264,7 @@ int permission(struct inode *inode, int mask, struct nameidata *nd) | |||
277 | return -EACCES; | 264 | return -EACCES; |
278 | } | 265 | } |
279 | } else { | 266 | } else { |
280 | retval = generic_permission(inode, submask, NULL); | 267 | retval = generic_permission(inode, mask, NULL); |
281 | } | 268 | } |
282 | if (retval) | 269 | if (retval) |
283 | return retval; | 270 | return retval; |
@@ -286,7 +273,8 @@ int permission(struct inode *inode, int mask, struct nameidata *nd) | |||
286 | if (retval) | 273 | if (retval) |
287 | return retval; | 274 | return retval; |
288 | 275 | ||
289 | return security_inode_permission(inode, mask, nd); | 276 | return security_inode_permission(inode, |
277 | mask & (MAY_READ|MAY_WRITE|MAY_EXEC)); | ||
290 | } | 278 | } |
291 | 279 | ||
292 | /** | 280 | /** |
@@ -301,7 +289,7 @@ int permission(struct inode *inode, int mask, struct nameidata *nd) | |||
301 | */ | 289 | */ |
302 | int vfs_permission(struct nameidata *nd, int mask) | 290 | int vfs_permission(struct nameidata *nd, int mask) |
303 | { | 291 | { |
304 | return permission(nd->path.dentry->d_inode, mask, nd); | 292 | return inode_permission(nd->path.dentry->d_inode, mask); |
305 | } | 293 | } |
306 | 294 | ||
307 | /** | 295 | /** |
@@ -318,7 +306,7 @@ int vfs_permission(struct nameidata *nd, int mask) | |||
318 | */ | 306 | */ |
319 | int file_permission(struct file *file, int mask) | 307 | int file_permission(struct file *file, int mask) |
320 | { | 308 | { |
321 | return permission(file->f_path.dentry->d_inode, mask, NULL); | 309 | return inode_permission(file->f_path.dentry->d_inode, mask); |
322 | } | 310 | } |
323 | 311 | ||
324 | /* | 312 | /* |
@@ -459,8 +447,7 @@ static struct dentry * cached_lookup(struct dentry * parent, struct qstr * name, | |||
459 | * short-cut DAC fails, then call permission() to do more | 447 | * short-cut DAC fails, then call permission() to do more |
460 | * complete permission check. | 448 | * complete permission check. |
461 | */ | 449 | */ |
462 | static int exec_permission_lite(struct inode *inode, | 450 | static int exec_permission_lite(struct inode *inode) |
463 | struct nameidata *nd) | ||
464 | { | 451 | { |
465 | umode_t mode = inode->i_mode; | 452 | umode_t mode = inode->i_mode; |
466 | 453 | ||
@@ -486,7 +473,7 @@ static int exec_permission_lite(struct inode *inode, | |||
486 | 473 | ||
487 | return -EACCES; | 474 | return -EACCES; |
488 | ok: | 475 | ok: |
489 | return security_inode_permission(inode, MAY_EXEC, nd); | 476 | return security_inode_permission(inode, MAY_EXEC); |
490 | } | 477 | } |
491 | 478 | ||
492 | /* | 479 | /* |
@@ -519,7 +506,14 @@ static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, s | |||
519 | */ | 506 | */ |
520 | result = d_lookup(parent, name); | 507 | result = d_lookup(parent, name); |
521 | if (!result) { | 508 | if (!result) { |
522 | struct dentry * dentry = d_alloc(parent, name); | 509 | struct dentry *dentry; |
510 | |||
511 | /* Don't create child dentry for a dead directory. */ | ||
512 | result = ERR_PTR(-ENOENT); | ||
513 | if (IS_DEADDIR(dir)) | ||
514 | goto out_unlock; | ||
515 | |||
516 | dentry = d_alloc(parent, name); | ||
523 | result = ERR_PTR(-ENOMEM); | 517 | result = ERR_PTR(-ENOMEM); |
524 | if (dentry) { | 518 | if (dentry) { |
525 | result = dir->i_op->lookup(dir, dentry, nd); | 519 | result = dir->i_op->lookup(dir, dentry, nd); |
@@ -528,6 +522,7 @@ static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, s | |||
528 | else | 522 | else |
529 | result = dentry; | 523 | result = dentry; |
530 | } | 524 | } |
525 | out_unlock: | ||
531 | mutex_unlock(&dir->i_mutex); | 526 | mutex_unlock(&dir->i_mutex); |
532 | return result; | 527 | return result; |
533 | } | 528 | } |
@@ -545,27 +540,16 @@ static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, s | |||
545 | return result; | 540 | return result; |
546 | } | 541 | } |
547 | 542 | ||
548 | static int __emul_lookup_dentry(const char *, struct nameidata *); | ||
549 | |||
550 | /* SMP-safe */ | 543 | /* SMP-safe */ |
551 | static __always_inline int | 544 | static __always_inline void |
552 | walk_init_root(const char *name, struct nameidata *nd) | 545 | walk_init_root(const char *name, struct nameidata *nd) |
553 | { | 546 | { |
554 | struct fs_struct *fs = current->fs; | 547 | struct fs_struct *fs = current->fs; |
555 | 548 | ||
556 | read_lock(&fs->lock); | 549 | read_lock(&fs->lock); |
557 | if (fs->altroot.dentry && !(nd->flags & LOOKUP_NOALT)) { | ||
558 | nd->path = fs->altroot; | ||
559 | path_get(&fs->altroot); | ||
560 | read_unlock(&fs->lock); | ||
561 | if (__emul_lookup_dentry(name,nd)) | ||
562 | return 0; | ||
563 | read_lock(&fs->lock); | ||
564 | } | ||
565 | nd->path = fs->root; | 550 | nd->path = fs->root; |
566 | path_get(&fs->root); | 551 | path_get(&fs->root); |
567 | read_unlock(&fs->lock); | 552 | read_unlock(&fs->lock); |
568 | return 1; | ||
569 | } | 553 | } |
570 | 554 | ||
571 | /* | 555 | /* |
@@ -606,12 +590,9 @@ static __always_inline int __vfs_follow_link(struct nameidata *nd, const char *l | |||
606 | 590 | ||
607 | if (*link == '/') { | 591 | if (*link == '/') { |
608 | path_put(&nd->path); | 592 | path_put(&nd->path); |
609 | if (!walk_init_root(link, nd)) | 593 | walk_init_root(link, nd); |
610 | /* weird __emul_prefix() stuff did it */ | ||
611 | goto out; | ||
612 | } | 594 | } |
613 | res = link_path_walk(link, nd); | 595 | res = link_path_walk(link, nd); |
614 | out: | ||
615 | if (nd->depth || res || nd->last_type!=LAST_NORM) | 596 | if (nd->depth || res || nd->last_type!=LAST_NORM) |
616 | return res; | 597 | return res; |
617 | /* | 598 | /* |
@@ -889,7 +870,7 @@ static int __link_path_walk(const char *name, struct nameidata *nd) | |||
889 | unsigned int c; | 870 | unsigned int c; |
890 | 871 | ||
891 | nd->flags |= LOOKUP_CONTINUE; | 872 | nd->flags |= LOOKUP_CONTINUE; |
892 | err = exec_permission_lite(inode, nd); | 873 | err = exec_permission_lite(inode); |
893 | if (err == -EAGAIN) | 874 | if (err == -EAGAIN) |
894 | err = vfs_permission(nd, MAY_EXEC); | 875 | err = vfs_permission(nd, MAY_EXEC); |
895 | if (err) | 876 | if (err) |
@@ -1060,67 +1041,6 @@ static int path_walk(const char *name, struct nameidata *nd) | |||
1060 | return link_path_walk(name, nd); | 1041 | return link_path_walk(name, nd); |
1061 | } | 1042 | } |
1062 | 1043 | ||
1063 | /* | ||
1064 | * SMP-safe: Returns 1 and nd will have valid dentry and mnt, if | ||
1065 | * everything is done. Returns 0 and drops input nd, if lookup failed; | ||
1066 | */ | ||
1067 | static int __emul_lookup_dentry(const char *name, struct nameidata *nd) | ||
1068 | { | ||
1069 | if (path_walk(name, nd)) | ||
1070 | return 0; /* something went wrong... */ | ||
1071 | |||
1072 | if (!nd->path.dentry->d_inode || | ||
1073 | S_ISDIR(nd->path.dentry->d_inode->i_mode)) { | ||
1074 | struct path old_path = nd->path; | ||
1075 | struct qstr last = nd->last; | ||
1076 | int last_type = nd->last_type; | ||
1077 | struct fs_struct *fs = current->fs; | ||
1078 | |||
1079 | /* | ||
1080 | * NAME was not found in alternate root or it's a directory. | ||
1081 | * Try to find it in the normal root: | ||
1082 | */ | ||
1083 | nd->last_type = LAST_ROOT; | ||
1084 | read_lock(&fs->lock); | ||
1085 | nd->path = fs->root; | ||
1086 | path_get(&fs->root); | ||
1087 | read_unlock(&fs->lock); | ||
1088 | if (path_walk(name, nd) == 0) { | ||
1089 | if (nd->path.dentry->d_inode) { | ||
1090 | path_put(&old_path); | ||
1091 | return 1; | ||
1092 | } | ||
1093 | path_put(&nd->path); | ||
1094 | } | ||
1095 | nd->path = old_path; | ||
1096 | nd->last = last; | ||
1097 | nd->last_type = last_type; | ||
1098 | } | ||
1099 | return 1; | ||
1100 | } | ||
1101 | |||
1102 | void set_fs_altroot(void) | ||
1103 | { | ||
1104 | char *emul = __emul_prefix(); | ||
1105 | struct nameidata nd; | ||
1106 | struct path path = {}, old_path; | ||
1107 | int err; | ||
1108 | struct fs_struct *fs = current->fs; | ||
1109 | |||
1110 | if (!emul) | ||
1111 | goto set_it; | ||
1112 | err = path_lookup(emul, LOOKUP_FOLLOW|LOOKUP_DIRECTORY|LOOKUP_NOALT, &nd); | ||
1113 | if (!err) | ||
1114 | path = nd.path; | ||
1115 | set_it: | ||
1116 | write_lock(&fs->lock); | ||
1117 | old_path = fs->altroot; | ||
1118 | fs->altroot = path; | ||
1119 | write_unlock(&fs->lock); | ||
1120 | if (old_path.dentry) | ||
1121 | path_put(&old_path); | ||
1122 | } | ||
1123 | |||
1124 | /* Returns 0 and nd will be valid on success; Retuns error, otherwise. */ | 1044 | /* Returns 0 and nd will be valid on success; Retuns error, otherwise. */ |
1125 | static int do_path_lookup(int dfd, const char *name, | 1045 | static int do_path_lookup(int dfd, const char *name, |
1126 | unsigned int flags, struct nameidata *nd) | 1046 | unsigned int flags, struct nameidata *nd) |
@@ -1136,14 +1056,6 @@ static int do_path_lookup(int dfd, const char *name, | |||
1136 | 1056 | ||
1137 | if (*name=='/') { | 1057 | if (*name=='/') { |
1138 | read_lock(&fs->lock); | 1058 | read_lock(&fs->lock); |
1139 | if (fs->altroot.dentry && !(nd->flags & LOOKUP_NOALT)) { | ||
1140 | nd->path = fs->altroot; | ||
1141 | path_get(&fs->altroot); | ||
1142 | read_unlock(&fs->lock); | ||
1143 | if (__emul_lookup_dentry(name,nd)) | ||
1144 | goto out; /* found in altroot */ | ||
1145 | read_lock(&fs->lock); | ||
1146 | } | ||
1147 | nd->path = fs->root; | 1059 | nd->path = fs->root; |
1148 | path_get(&fs->root); | 1060 | path_get(&fs->root); |
1149 | read_unlock(&fs->lock); | 1061 | read_unlock(&fs->lock); |
@@ -1177,7 +1089,6 @@ static int do_path_lookup(int dfd, const char *name, | |||
1177 | } | 1089 | } |
1178 | 1090 | ||
1179 | retval = path_walk(name, nd); | 1091 | retval = path_walk(name, nd); |
1180 | out: | ||
1181 | if (unlikely(!retval && !audit_dummy_context() && nd->path.dentry && | 1092 | if (unlikely(!retval && !audit_dummy_context() && nd->path.dentry && |
1182 | nd->path.dentry->d_inode)) | 1093 | nd->path.dentry->d_inode)) |
1183 | audit_inode(name, nd->path.dentry); | 1094 | audit_inode(name, nd->path.dentry); |
@@ -1282,19 +1193,6 @@ static int path_lookup_create(int dfd, const char *name, | |||
1282 | nd, open_flags, create_mode); | 1193 | nd, open_flags, create_mode); |
1283 | } | 1194 | } |
1284 | 1195 | ||
1285 | int __user_path_lookup_open(const char __user *name, unsigned int lookup_flags, | ||
1286 | struct nameidata *nd, int open_flags) | ||
1287 | { | ||
1288 | char *tmp = getname(name); | ||
1289 | int err = PTR_ERR(tmp); | ||
1290 | |||
1291 | if (!IS_ERR(tmp)) { | ||
1292 | err = __path_lookup_intent_open(AT_FDCWD, tmp, lookup_flags, nd, open_flags, 0); | ||
1293 | putname(tmp); | ||
1294 | } | ||
1295 | return err; | ||
1296 | } | ||
1297 | |||
1298 | static struct dentry *__lookup_hash(struct qstr *name, | 1196 | static struct dentry *__lookup_hash(struct qstr *name, |
1299 | struct dentry *base, struct nameidata *nd) | 1197 | struct dentry *base, struct nameidata *nd) |
1300 | { | 1198 | { |
@@ -1317,7 +1215,14 @@ static struct dentry *__lookup_hash(struct qstr *name, | |||
1317 | 1215 | ||
1318 | dentry = cached_lookup(base, name, nd); | 1216 | dentry = cached_lookup(base, name, nd); |
1319 | if (!dentry) { | 1217 | if (!dentry) { |
1320 | struct dentry *new = d_alloc(base, name); | 1218 | struct dentry *new; |
1219 | |||
1220 | /* Don't create child dentry for a dead directory. */ | ||
1221 | dentry = ERR_PTR(-ENOENT); | ||
1222 | if (IS_DEADDIR(inode)) | ||
1223 | goto out; | ||
1224 | |||
1225 | new = d_alloc(base, name); | ||
1321 | dentry = ERR_PTR(-ENOMEM); | 1226 | dentry = ERR_PTR(-ENOMEM); |
1322 | if (!new) | 1227 | if (!new) |
1323 | goto out; | 1228 | goto out; |
@@ -1340,7 +1245,7 @@ static struct dentry *lookup_hash(struct nameidata *nd) | |||
1340 | { | 1245 | { |
1341 | int err; | 1246 | int err; |
1342 | 1247 | ||
1343 | err = permission(nd->path.dentry->d_inode, MAY_EXEC, nd); | 1248 | err = inode_permission(nd->path.dentry->d_inode, MAY_EXEC); |
1344 | if (err) | 1249 | if (err) |
1345 | return ERR_PTR(err); | 1250 | return ERR_PTR(err); |
1346 | return __lookup_hash(&nd->last, nd->path.dentry, nd); | 1251 | return __lookup_hash(&nd->last, nd->path.dentry, nd); |
@@ -1388,7 +1293,7 @@ struct dentry *lookup_one_len(const char *name, struct dentry *base, int len) | |||
1388 | if (err) | 1293 | if (err) |
1389 | return ERR_PTR(err); | 1294 | return ERR_PTR(err); |
1390 | 1295 | ||
1391 | err = permission(base->d_inode, MAY_EXEC, NULL); | 1296 | err = inode_permission(base->d_inode, MAY_EXEC); |
1392 | if (err) | 1297 | if (err) |
1393 | return ERR_PTR(err); | 1298 | return ERR_PTR(err); |
1394 | return __lookup_hash(&this, base, NULL); | 1299 | return __lookup_hash(&this, base, NULL); |
@@ -1416,22 +1321,40 @@ struct dentry *lookup_one_noperm(const char *name, struct dentry *base) | |||
1416 | return __lookup_hash(&this, base, NULL); | 1321 | return __lookup_hash(&this, base, NULL); |
1417 | } | 1322 | } |
1418 | 1323 | ||
1419 | int __user_walk_fd(int dfd, const char __user *name, unsigned flags, | 1324 | int user_path_at(int dfd, const char __user *name, unsigned flags, |
1420 | struct nameidata *nd) | 1325 | struct path *path) |
1421 | { | 1326 | { |
1327 | struct nameidata nd; | ||
1422 | char *tmp = getname(name); | 1328 | char *tmp = getname(name); |
1423 | int err = PTR_ERR(tmp); | 1329 | int err = PTR_ERR(tmp); |
1424 | |||
1425 | if (!IS_ERR(tmp)) { | 1330 | if (!IS_ERR(tmp)) { |
1426 | err = do_path_lookup(dfd, tmp, flags, nd); | 1331 | |
1332 | BUG_ON(flags & LOOKUP_PARENT); | ||
1333 | |||
1334 | err = do_path_lookup(dfd, tmp, flags, &nd); | ||
1427 | putname(tmp); | 1335 | putname(tmp); |
1336 | if (!err) | ||
1337 | *path = nd.path; | ||
1428 | } | 1338 | } |
1429 | return err; | 1339 | return err; |
1430 | } | 1340 | } |
1431 | 1341 | ||
1432 | int __user_walk(const char __user *name, unsigned flags, struct nameidata *nd) | 1342 | static int user_path_parent(int dfd, const char __user *path, |
1343 | struct nameidata *nd, char **name) | ||
1433 | { | 1344 | { |
1434 | return __user_walk_fd(AT_FDCWD, name, flags, nd); | 1345 | char *s = getname(path); |
1346 | int error; | ||
1347 | |||
1348 | if (IS_ERR(s)) | ||
1349 | return PTR_ERR(s); | ||
1350 | |||
1351 | error = do_path_lookup(dfd, s, LOOKUP_PARENT, nd); | ||
1352 | if (error) | ||
1353 | putname(s); | ||
1354 | else | ||
1355 | *name = s; | ||
1356 | |||
1357 | return error; | ||
1435 | } | 1358 | } |
1436 | 1359 | ||
1437 | /* | 1360 | /* |
@@ -1478,7 +1401,7 @@ static int may_delete(struct inode *dir,struct dentry *victim,int isdir) | |||
1478 | BUG_ON(victim->d_parent->d_inode != dir); | 1401 | BUG_ON(victim->d_parent->d_inode != dir); |
1479 | audit_inode_child(victim->d_name.name, victim, dir); | 1402 | audit_inode_child(victim->d_name.name, victim, dir); |
1480 | 1403 | ||
1481 | error = permission(dir,MAY_WRITE | MAY_EXEC, NULL); | 1404 | error = inode_permission(dir, MAY_WRITE | MAY_EXEC); |
1482 | if (error) | 1405 | if (error) |
1483 | return error; | 1406 | return error; |
1484 | if (IS_APPEND(dir)) | 1407 | if (IS_APPEND(dir)) |
@@ -1515,7 +1438,7 @@ static inline int may_create(struct inode *dir, struct dentry *child, | |||
1515 | return -EEXIST; | 1438 | return -EEXIST; |
1516 | if (IS_DEADDIR(dir)) | 1439 | if (IS_DEADDIR(dir)) |
1517 | return -ENOENT; | 1440 | return -ENOENT; |
1518 | return permission(dir,MAY_WRITE | MAY_EXEC, nd); | 1441 | return inode_permission(dir, MAY_WRITE | MAY_EXEC); |
1519 | } | 1442 | } |
1520 | 1443 | ||
1521 | /* | 1444 | /* |
@@ -1755,7 +1678,7 @@ struct file *do_filp_open(int dfd, const char *pathname, | |||
1755 | int will_write; | 1678 | int will_write; |
1756 | int flag = open_to_namei_flags(open_flag); | 1679 | int flag = open_to_namei_flags(open_flag); |
1757 | 1680 | ||
1758 | acc_mode = ACC_MODE(flag); | 1681 | acc_mode = MAY_OPEN | ACC_MODE(flag); |
1759 | 1682 | ||
1760 | /* O_TRUNC implies we need access checks for write permissions */ | 1683 | /* O_TRUNC implies we need access checks for write permissions */ |
1761 | if (flag & O_TRUNC) | 1684 | if (flag & O_TRUNC) |
@@ -2071,20 +1994,18 @@ static int may_mknod(mode_t mode) | |||
2071 | asmlinkage long sys_mknodat(int dfd, const char __user *filename, int mode, | 1994 | asmlinkage long sys_mknodat(int dfd, const char __user *filename, int mode, |
2072 | unsigned dev) | 1995 | unsigned dev) |
2073 | { | 1996 | { |
2074 | int error = 0; | 1997 | int error; |
2075 | char * tmp; | 1998 | char *tmp; |
2076 | struct dentry * dentry; | 1999 | struct dentry *dentry; |
2077 | struct nameidata nd; | 2000 | struct nameidata nd; |
2078 | 2001 | ||
2079 | if (S_ISDIR(mode)) | 2002 | if (S_ISDIR(mode)) |
2080 | return -EPERM; | 2003 | return -EPERM; |
2081 | tmp = getname(filename); | ||
2082 | if (IS_ERR(tmp)) | ||
2083 | return PTR_ERR(tmp); | ||
2084 | 2004 | ||
2085 | error = do_path_lookup(dfd, tmp, LOOKUP_PARENT, &nd); | 2005 | error = user_path_parent(dfd, filename, &nd, &tmp); |
2086 | if (error) | 2006 | if (error) |
2087 | goto out; | 2007 | return error; |
2008 | |||
2088 | dentry = lookup_create(&nd, 0); | 2009 | dentry = lookup_create(&nd, 0); |
2089 | if (IS_ERR(dentry)) { | 2010 | if (IS_ERR(dentry)) { |
2090 | error = PTR_ERR(dentry); | 2011 | error = PTR_ERR(dentry); |
@@ -2116,7 +2037,6 @@ out_dput: | |||
2116 | out_unlock: | 2037 | out_unlock: |
2117 | mutex_unlock(&nd.path.dentry->d_inode->i_mutex); | 2038 | mutex_unlock(&nd.path.dentry->d_inode->i_mutex); |
2118 | path_put(&nd.path); | 2039 | path_put(&nd.path); |
2119 | out: | ||
2120 | putname(tmp); | 2040 | putname(tmp); |
2121 | 2041 | ||
2122 | return error; | 2042 | return error; |
@@ -2156,14 +2076,10 @@ asmlinkage long sys_mkdirat(int dfd, const char __user *pathname, int mode) | |||
2156 | struct dentry *dentry; | 2076 | struct dentry *dentry; |
2157 | struct nameidata nd; | 2077 | struct nameidata nd; |
2158 | 2078 | ||
2159 | tmp = getname(pathname); | 2079 | error = user_path_parent(dfd, pathname, &nd, &tmp); |
2160 | error = PTR_ERR(tmp); | 2080 | if (error) |
2161 | if (IS_ERR(tmp)) | ||
2162 | goto out_err; | 2081 | goto out_err; |
2163 | 2082 | ||
2164 | error = do_path_lookup(dfd, tmp, LOOKUP_PARENT, &nd); | ||
2165 | if (error) | ||
2166 | goto out; | ||
2167 | dentry = lookup_create(&nd, 1); | 2083 | dentry = lookup_create(&nd, 1); |
2168 | error = PTR_ERR(dentry); | 2084 | error = PTR_ERR(dentry); |
2169 | if (IS_ERR(dentry)) | 2085 | if (IS_ERR(dentry)) |
@@ -2181,7 +2097,6 @@ out_dput: | |||
2181 | out_unlock: | 2097 | out_unlock: |
2182 | mutex_unlock(&nd.path.dentry->d_inode->i_mutex); | 2098 | mutex_unlock(&nd.path.dentry->d_inode->i_mutex); |
2183 | path_put(&nd.path); | 2099 | path_put(&nd.path); |
2184 | out: | ||
2185 | putname(tmp); | 2100 | putname(tmp); |
2186 | out_err: | 2101 | out_err: |
2187 | return error; | 2102 | return error; |
@@ -2259,13 +2174,9 @@ static long do_rmdir(int dfd, const char __user *pathname) | |||
2259 | struct dentry *dentry; | 2174 | struct dentry *dentry; |
2260 | struct nameidata nd; | 2175 | struct nameidata nd; |
2261 | 2176 | ||
2262 | name = getname(pathname); | 2177 | error = user_path_parent(dfd, pathname, &nd, &name); |
2263 | if(IS_ERR(name)) | ||
2264 | return PTR_ERR(name); | ||
2265 | |||
2266 | error = do_path_lookup(dfd, name, LOOKUP_PARENT, &nd); | ||
2267 | if (error) | 2178 | if (error) |
2268 | goto exit; | 2179 | return error; |
2269 | 2180 | ||
2270 | switch(nd.last_type) { | 2181 | switch(nd.last_type) { |
2271 | case LAST_DOTDOT: | 2182 | case LAST_DOTDOT: |
@@ -2294,7 +2205,6 @@ exit2: | |||
2294 | mutex_unlock(&nd.path.dentry->d_inode->i_mutex); | 2205 | mutex_unlock(&nd.path.dentry->d_inode->i_mutex); |
2295 | exit1: | 2206 | exit1: |
2296 | path_put(&nd.path); | 2207 | path_put(&nd.path); |
2297 | exit: | ||
2298 | putname(name); | 2208 | putname(name); |
2299 | return error; | 2209 | return error; |
2300 | } | 2210 | } |
@@ -2343,19 +2253,16 @@ int vfs_unlink(struct inode *dir, struct dentry *dentry) | |||
2343 | */ | 2253 | */ |
2344 | static long do_unlinkat(int dfd, const char __user *pathname) | 2254 | static long do_unlinkat(int dfd, const char __user *pathname) |
2345 | { | 2255 | { |
2346 | int error = 0; | 2256 | int error; |
2347 | char * name; | 2257 | char *name; |
2348 | struct dentry *dentry; | 2258 | struct dentry *dentry; |
2349 | struct nameidata nd; | 2259 | struct nameidata nd; |
2350 | struct inode *inode = NULL; | 2260 | struct inode *inode = NULL; |
2351 | 2261 | ||
2352 | name = getname(pathname); | 2262 | error = user_path_parent(dfd, pathname, &nd, &name); |
2353 | if(IS_ERR(name)) | ||
2354 | return PTR_ERR(name); | ||
2355 | |||
2356 | error = do_path_lookup(dfd, name, LOOKUP_PARENT, &nd); | ||
2357 | if (error) | 2263 | if (error) |
2358 | goto exit; | 2264 | return error; |
2265 | |||
2359 | error = -EISDIR; | 2266 | error = -EISDIR; |
2360 | if (nd.last_type != LAST_NORM) | 2267 | if (nd.last_type != LAST_NORM) |
2361 | goto exit1; | 2268 | goto exit1; |
@@ -2382,7 +2289,6 @@ static long do_unlinkat(int dfd, const char __user *pathname) | |||
2382 | iput(inode); /* truncate the inode here */ | 2289 | iput(inode); /* truncate the inode here */ |
2383 | exit1: | 2290 | exit1: |
2384 | path_put(&nd.path); | 2291 | path_put(&nd.path); |
2385 | exit: | ||
2386 | putname(name); | 2292 | putname(name); |
2387 | return error; | 2293 | return error; |
2388 | 2294 | ||
@@ -2408,7 +2314,7 @@ asmlinkage long sys_unlink(const char __user *pathname) | |||
2408 | return do_unlinkat(AT_FDCWD, pathname); | 2314 | return do_unlinkat(AT_FDCWD, pathname); |
2409 | } | 2315 | } |
2410 | 2316 | ||
2411 | int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname, int mode) | 2317 | int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname) |
2412 | { | 2318 | { |
2413 | int error = may_create(dir, dentry, NULL); | 2319 | int error = may_create(dir, dentry, NULL); |
2414 | 2320 | ||
@@ -2432,23 +2338,20 @@ int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname, i | |||
2432 | asmlinkage long sys_symlinkat(const char __user *oldname, | 2338 | asmlinkage long sys_symlinkat(const char __user *oldname, |
2433 | int newdfd, const char __user *newname) | 2339 | int newdfd, const char __user *newname) |
2434 | { | 2340 | { |
2435 | int error = 0; | 2341 | int error; |
2436 | char * from; | 2342 | char *from; |
2437 | char * to; | 2343 | char *to; |
2438 | struct dentry *dentry; | 2344 | struct dentry *dentry; |
2439 | struct nameidata nd; | 2345 | struct nameidata nd; |
2440 | 2346 | ||
2441 | from = getname(oldname); | 2347 | from = getname(oldname); |
2442 | if(IS_ERR(from)) | 2348 | if (IS_ERR(from)) |
2443 | return PTR_ERR(from); | 2349 | return PTR_ERR(from); |
2444 | to = getname(newname); | ||
2445 | error = PTR_ERR(to); | ||
2446 | if (IS_ERR(to)) | ||
2447 | goto out_putname; | ||
2448 | 2350 | ||
2449 | error = do_path_lookup(newdfd, to, LOOKUP_PARENT, &nd); | 2351 | error = user_path_parent(newdfd, newname, &nd, &to); |
2450 | if (error) | 2352 | if (error) |
2451 | goto out; | 2353 | goto out_putname; |
2354 | |||
2452 | dentry = lookup_create(&nd, 0); | 2355 | dentry = lookup_create(&nd, 0); |
2453 | error = PTR_ERR(dentry); | 2356 | error = PTR_ERR(dentry); |
2454 | if (IS_ERR(dentry)) | 2357 | if (IS_ERR(dentry)) |
@@ -2457,14 +2360,13 @@ asmlinkage long sys_symlinkat(const char __user *oldname, | |||
2457 | error = mnt_want_write(nd.path.mnt); | 2360 | error = mnt_want_write(nd.path.mnt); |
2458 | if (error) | 2361 | if (error) |
2459 | goto out_dput; | 2362 | goto out_dput; |
2460 | error = vfs_symlink(nd.path.dentry->d_inode, dentry, from, S_IALLUGO); | 2363 | error = vfs_symlink(nd.path.dentry->d_inode, dentry, from); |
2461 | mnt_drop_write(nd.path.mnt); | 2364 | mnt_drop_write(nd.path.mnt); |
2462 | out_dput: | 2365 | out_dput: |
2463 | dput(dentry); | 2366 | dput(dentry); |
2464 | out_unlock: | 2367 | out_unlock: |
2465 | mutex_unlock(&nd.path.dentry->d_inode->i_mutex); | 2368 | mutex_unlock(&nd.path.dentry->d_inode->i_mutex); |
2466 | path_put(&nd.path); | 2369 | path_put(&nd.path); |
2467 | out: | ||
2468 | putname(to); | 2370 | putname(to); |
2469 | out_putname: | 2371 | out_putname: |
2470 | putname(from); | 2372 | putname(from); |
@@ -2498,19 +2400,19 @@ int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_de | |||
2498 | return -EPERM; | 2400 | return -EPERM; |
2499 | if (!dir->i_op || !dir->i_op->link) | 2401 | if (!dir->i_op || !dir->i_op->link) |
2500 | return -EPERM; | 2402 | return -EPERM; |
2501 | if (S_ISDIR(old_dentry->d_inode->i_mode)) | 2403 | if (S_ISDIR(inode->i_mode)) |
2502 | return -EPERM; | 2404 | return -EPERM; |
2503 | 2405 | ||
2504 | error = security_inode_link(old_dentry, dir, new_dentry); | 2406 | error = security_inode_link(old_dentry, dir, new_dentry); |
2505 | if (error) | 2407 | if (error) |
2506 | return error; | 2408 | return error; |
2507 | 2409 | ||
2508 | mutex_lock(&old_dentry->d_inode->i_mutex); | 2410 | mutex_lock(&inode->i_mutex); |
2509 | DQUOT_INIT(dir); | 2411 | DQUOT_INIT(dir); |
2510 | error = dir->i_op->link(old_dentry, dir, new_dentry); | 2412 | error = dir->i_op->link(old_dentry, dir, new_dentry); |
2511 | mutex_unlock(&old_dentry->d_inode->i_mutex); | 2413 | mutex_unlock(&inode->i_mutex); |
2512 | if (!error) | 2414 | if (!error) |
2513 | fsnotify_link(dir, old_dentry->d_inode, new_dentry); | 2415 | fsnotify_link(dir, inode, new_dentry); |
2514 | return error; | 2416 | return error; |
2515 | } | 2417 | } |
2516 | 2418 | ||
@@ -2528,27 +2430,25 @@ asmlinkage long sys_linkat(int olddfd, const char __user *oldname, | |||
2528 | int flags) | 2430 | int flags) |
2529 | { | 2431 | { |
2530 | struct dentry *new_dentry; | 2432 | struct dentry *new_dentry; |
2531 | struct nameidata nd, old_nd; | 2433 | struct nameidata nd; |
2434 | struct path old_path; | ||
2532 | int error; | 2435 | int error; |
2533 | char * to; | 2436 | char *to; |
2534 | 2437 | ||
2535 | if ((flags & ~AT_SYMLINK_FOLLOW) != 0) | 2438 | if ((flags & ~AT_SYMLINK_FOLLOW) != 0) |
2536 | return -EINVAL; | 2439 | return -EINVAL; |
2537 | 2440 | ||
2538 | to = getname(newname); | 2441 | error = user_path_at(olddfd, oldname, |
2539 | if (IS_ERR(to)) | 2442 | flags & AT_SYMLINK_FOLLOW ? LOOKUP_FOLLOW : 0, |
2540 | return PTR_ERR(to); | 2443 | &old_path); |
2541 | |||
2542 | error = __user_walk_fd(olddfd, oldname, | ||
2543 | flags & AT_SYMLINK_FOLLOW ? LOOKUP_FOLLOW : 0, | ||
2544 | &old_nd); | ||
2545 | if (error) | 2444 | if (error) |
2546 | goto exit; | 2445 | return error; |
2547 | error = do_path_lookup(newdfd, to, LOOKUP_PARENT, &nd); | 2446 | |
2447 | error = user_path_parent(newdfd, newname, &nd, &to); | ||
2548 | if (error) | 2448 | if (error) |
2549 | goto out; | 2449 | goto out; |
2550 | error = -EXDEV; | 2450 | error = -EXDEV; |
2551 | if (old_nd.path.mnt != nd.path.mnt) | 2451 | if (old_path.mnt != nd.path.mnt) |
2552 | goto out_release; | 2452 | goto out_release; |
2553 | new_dentry = lookup_create(&nd, 0); | 2453 | new_dentry = lookup_create(&nd, 0); |
2554 | error = PTR_ERR(new_dentry); | 2454 | error = PTR_ERR(new_dentry); |
@@ -2557,7 +2457,7 @@ asmlinkage long sys_linkat(int olddfd, const char __user *oldname, | |||
2557 | error = mnt_want_write(nd.path.mnt); | 2457 | error = mnt_want_write(nd.path.mnt); |
2558 | if (error) | 2458 | if (error) |
2559 | goto out_dput; | 2459 | goto out_dput; |
2560 | error = vfs_link(old_nd.path.dentry, nd.path.dentry->d_inode, new_dentry); | 2460 | error = vfs_link(old_path.dentry, nd.path.dentry->d_inode, new_dentry); |
2561 | mnt_drop_write(nd.path.mnt); | 2461 | mnt_drop_write(nd.path.mnt); |
2562 | out_dput: | 2462 | out_dput: |
2563 | dput(new_dentry); | 2463 | dput(new_dentry); |
@@ -2565,10 +2465,9 @@ out_unlock: | |||
2565 | mutex_unlock(&nd.path.dentry->d_inode->i_mutex); | 2465 | mutex_unlock(&nd.path.dentry->d_inode->i_mutex); |
2566 | out_release: | 2466 | out_release: |
2567 | path_put(&nd.path); | 2467 | path_put(&nd.path); |
2568 | out: | ||
2569 | path_put(&old_nd.path); | ||
2570 | exit: | ||
2571 | putname(to); | 2468 | putname(to); |
2469 | out: | ||
2470 | path_put(&old_path); | ||
2572 | 2471 | ||
2573 | return error; | 2472 | return error; |
2574 | } | 2473 | } |
@@ -2621,7 +2520,7 @@ static int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry, | |||
2621 | * we'll need to flip '..'. | 2520 | * we'll need to flip '..'. |
2622 | */ | 2521 | */ |
2623 | if (new_dir != old_dir) { | 2522 | if (new_dir != old_dir) { |
2624 | error = permission(old_dentry->d_inode, MAY_WRITE, NULL); | 2523 | error = inode_permission(old_dentry->d_inode, MAY_WRITE); |
2625 | if (error) | 2524 | if (error) |
2626 | return error; | 2525 | return error; |
2627 | } | 2526 | } |
@@ -2724,20 +2623,22 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
2724 | return error; | 2623 | return error; |
2725 | } | 2624 | } |
2726 | 2625 | ||
2727 | static int do_rename(int olddfd, const char *oldname, | 2626 | asmlinkage long sys_renameat(int olddfd, const char __user *oldname, |
2728 | int newdfd, const char *newname) | 2627 | int newdfd, const char __user *newname) |
2729 | { | 2628 | { |
2730 | int error = 0; | 2629 | struct dentry *old_dir, *new_dir; |
2731 | struct dentry * old_dir, * new_dir; | 2630 | struct dentry *old_dentry, *new_dentry; |
2732 | struct dentry * old_dentry, *new_dentry; | 2631 | struct dentry *trap; |
2733 | struct dentry * trap; | ||
2734 | struct nameidata oldnd, newnd; | 2632 | struct nameidata oldnd, newnd; |
2633 | char *from; | ||
2634 | char *to; | ||
2635 | int error; | ||
2735 | 2636 | ||
2736 | error = do_path_lookup(olddfd, oldname, LOOKUP_PARENT, &oldnd); | 2637 | error = user_path_parent(olddfd, oldname, &oldnd, &from); |
2737 | if (error) | 2638 | if (error) |
2738 | goto exit; | 2639 | goto exit; |
2739 | 2640 | ||
2740 | error = do_path_lookup(newdfd, newname, LOOKUP_PARENT, &newnd); | 2641 | error = user_path_parent(newdfd, newname, &newnd, &to); |
2741 | if (error) | 2642 | if (error) |
2742 | goto exit1; | 2643 | goto exit1; |
2743 | 2644 | ||
@@ -2799,29 +2700,11 @@ exit3: | |||
2799 | unlock_rename(new_dir, old_dir); | 2700 | unlock_rename(new_dir, old_dir); |
2800 | exit2: | 2701 | exit2: |
2801 | path_put(&newnd.path); | 2702 | path_put(&newnd.path); |
2703 | putname(to); | ||
2802 | exit1: | 2704 | exit1: |
2803 | path_put(&oldnd.path); | 2705 | path_put(&oldnd.path); |
2804 | exit: | ||
2805 | return error; | ||
2806 | } | ||
2807 | |||
2808 | asmlinkage long sys_renameat(int olddfd, const char __user *oldname, | ||
2809 | int newdfd, const char __user *newname) | ||
2810 | { | ||
2811 | int error; | ||
2812 | char * from; | ||
2813 | char * to; | ||
2814 | |||
2815 | from = getname(oldname); | ||
2816 | if(IS_ERR(from)) | ||
2817 | return PTR_ERR(from); | ||
2818 | to = getname(newname); | ||
2819 | error = PTR_ERR(to); | ||
2820 | if (!IS_ERR(to)) { | ||
2821 | error = do_rename(olddfd, from, newdfd, to); | ||
2822 | putname(to); | ||
2823 | } | ||
2824 | putname(from); | 2706 | putname(from); |
2707 | exit: | ||
2825 | return error; | 2708 | return error; |
2826 | } | 2709 | } |
2827 | 2710 | ||
@@ -2959,8 +2842,7 @@ const struct inode_operations page_symlink_inode_operations = { | |||
2959 | .put_link = page_put_link, | 2842 | .put_link = page_put_link, |
2960 | }; | 2843 | }; |
2961 | 2844 | ||
2962 | EXPORT_SYMBOL(__user_walk); | 2845 | EXPORT_SYMBOL(user_path_at); |
2963 | EXPORT_SYMBOL(__user_walk_fd); | ||
2964 | EXPORT_SYMBOL(follow_down); | 2846 | EXPORT_SYMBOL(follow_down); |
2965 | EXPORT_SYMBOL(follow_up); | 2847 | EXPORT_SYMBOL(follow_up); |
2966 | EXPORT_SYMBOL(get_write_access); /* binfmt_aout */ | 2848 | EXPORT_SYMBOL(get_write_access); /* binfmt_aout */ |
@@ -2975,7 +2857,7 @@ EXPORT_SYMBOL(page_symlink); | |||
2975 | EXPORT_SYMBOL(page_symlink_inode_operations); | 2857 | EXPORT_SYMBOL(page_symlink_inode_operations); |
2976 | EXPORT_SYMBOL(path_lookup); | 2858 | EXPORT_SYMBOL(path_lookup); |
2977 | EXPORT_SYMBOL(vfs_path_lookup); | 2859 | EXPORT_SYMBOL(vfs_path_lookup); |
2978 | EXPORT_SYMBOL(permission); | 2860 | EXPORT_SYMBOL(inode_permission); |
2979 | EXPORT_SYMBOL(vfs_permission); | 2861 | EXPORT_SYMBOL(vfs_permission); |
2980 | EXPORT_SYMBOL(file_permission); | 2862 | EXPORT_SYMBOL(file_permission); |
2981 | EXPORT_SYMBOL(unlock_rename); | 2863 | EXPORT_SYMBOL(unlock_rename); |
diff --git a/fs/namespace.c b/fs/namespace.c index 4f6f7635b59c..411728c0c8bb 100644 --- a/fs/namespace.c +++ b/fs/namespace.c | |||
@@ -112,9 +112,13 @@ struct vfsmount *alloc_vfsmnt(const char *name) | |||
112 | int err; | 112 | int err; |
113 | 113 | ||
114 | err = mnt_alloc_id(mnt); | 114 | err = mnt_alloc_id(mnt); |
115 | if (err) { | 115 | if (err) |
116 | kmem_cache_free(mnt_cache, mnt); | 116 | goto out_free_cache; |
117 | return NULL; | 117 | |
118 | if (name) { | ||
119 | mnt->mnt_devname = kstrdup(name, GFP_KERNEL); | ||
120 | if (!mnt->mnt_devname) | ||
121 | goto out_free_id; | ||
118 | } | 122 | } |
119 | 123 | ||
120 | atomic_set(&mnt->mnt_count, 1); | 124 | atomic_set(&mnt->mnt_count, 1); |
@@ -127,16 +131,14 @@ struct vfsmount *alloc_vfsmnt(const char *name) | |||
127 | INIT_LIST_HEAD(&mnt->mnt_slave_list); | 131 | INIT_LIST_HEAD(&mnt->mnt_slave_list); |
128 | INIT_LIST_HEAD(&mnt->mnt_slave); | 132 | INIT_LIST_HEAD(&mnt->mnt_slave); |
129 | atomic_set(&mnt->__mnt_writers, 0); | 133 | atomic_set(&mnt->__mnt_writers, 0); |
130 | if (name) { | ||
131 | int size = strlen(name) + 1; | ||
132 | char *newname = kmalloc(size, GFP_KERNEL); | ||
133 | if (newname) { | ||
134 | memcpy(newname, name, size); | ||
135 | mnt->mnt_devname = newname; | ||
136 | } | ||
137 | } | ||
138 | } | 134 | } |
139 | return mnt; | 135 | return mnt; |
136 | |||
137 | out_free_id: | ||
138 | mnt_free_id(mnt); | ||
139 | out_free_cache: | ||
140 | kmem_cache_free(mnt_cache, mnt); | ||
141 | return NULL; | ||
140 | } | 142 | } |
141 | 143 | ||
142 | /* | 144 | /* |
@@ -309,10 +311,9 @@ static void handle_write_count_underflow(struct vfsmount *mnt) | |||
309 | */ | 311 | */ |
310 | if ((atomic_read(&mnt->__mnt_writers) < 0) && | 312 | if ((atomic_read(&mnt->__mnt_writers) < 0) && |
311 | !(mnt->mnt_flags & MNT_IMBALANCED_WRITE_COUNT)) { | 313 | !(mnt->mnt_flags & MNT_IMBALANCED_WRITE_COUNT)) { |
312 | printk(KERN_DEBUG "leak detected on mount(%p) writers " | 314 | WARN(1, KERN_DEBUG "leak detected on mount(%p) writers " |
313 | "count: %d\n", | 315 | "count: %d\n", |
314 | mnt, atomic_read(&mnt->__mnt_writers)); | 316 | mnt, atomic_read(&mnt->__mnt_writers)); |
315 | WARN_ON(1); | ||
316 | /* use the flag to keep the dmesg spam down */ | 317 | /* use the flag to keep the dmesg spam down */ |
317 | mnt->mnt_flags |= MNT_IMBALANCED_WRITE_COUNT; | 318 | mnt->mnt_flags |= MNT_IMBALANCED_WRITE_COUNT; |
318 | } | 319 | } |
@@ -1129,27 +1130,27 @@ static int do_umount(struct vfsmount *mnt, int flags) | |||
1129 | 1130 | ||
1130 | asmlinkage long sys_umount(char __user * name, int flags) | 1131 | asmlinkage long sys_umount(char __user * name, int flags) |
1131 | { | 1132 | { |
1132 | struct nameidata nd; | 1133 | struct path path; |
1133 | int retval; | 1134 | int retval; |
1134 | 1135 | ||
1135 | retval = __user_walk(name, LOOKUP_FOLLOW, &nd); | 1136 | retval = user_path(name, &path); |
1136 | if (retval) | 1137 | if (retval) |
1137 | goto out; | 1138 | goto out; |
1138 | retval = -EINVAL; | 1139 | retval = -EINVAL; |
1139 | if (nd.path.dentry != nd.path.mnt->mnt_root) | 1140 | if (path.dentry != path.mnt->mnt_root) |
1140 | goto dput_and_out; | 1141 | goto dput_and_out; |
1141 | if (!check_mnt(nd.path.mnt)) | 1142 | if (!check_mnt(path.mnt)) |
1142 | goto dput_and_out; | 1143 | goto dput_and_out; |
1143 | 1144 | ||
1144 | retval = -EPERM; | 1145 | retval = -EPERM; |
1145 | if (!capable(CAP_SYS_ADMIN)) | 1146 | if (!capable(CAP_SYS_ADMIN)) |
1146 | goto dput_and_out; | 1147 | goto dput_and_out; |
1147 | 1148 | ||
1148 | retval = do_umount(nd.path.mnt, flags); | 1149 | retval = do_umount(path.mnt, flags); |
1149 | dput_and_out: | 1150 | dput_and_out: |
1150 | /* we mustn't call path_put() as that would clear mnt_expiry_mark */ | 1151 | /* we mustn't call path_put() as that would clear mnt_expiry_mark */ |
1151 | dput(nd.path.dentry); | 1152 | dput(path.dentry); |
1152 | mntput_no_expire(nd.path.mnt); | 1153 | mntput_no_expire(path.mnt); |
1153 | out: | 1154 | out: |
1154 | return retval; | 1155 | return retval; |
1155 | } | 1156 | } |
@@ -1973,7 +1974,7 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns, | |||
1973 | struct fs_struct *fs) | 1974 | struct fs_struct *fs) |
1974 | { | 1975 | { |
1975 | struct mnt_namespace *new_ns; | 1976 | struct mnt_namespace *new_ns; |
1976 | struct vfsmount *rootmnt = NULL, *pwdmnt = NULL, *altrootmnt = NULL; | 1977 | struct vfsmount *rootmnt = NULL, *pwdmnt = NULL; |
1977 | struct vfsmount *p, *q; | 1978 | struct vfsmount *p, *q; |
1978 | 1979 | ||
1979 | new_ns = kmalloc(sizeof(struct mnt_namespace), GFP_KERNEL); | 1980 | new_ns = kmalloc(sizeof(struct mnt_namespace), GFP_KERNEL); |
@@ -2016,10 +2017,6 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns, | |||
2016 | pwdmnt = p; | 2017 | pwdmnt = p; |
2017 | fs->pwd.mnt = mntget(q); | 2018 | fs->pwd.mnt = mntget(q); |
2018 | } | 2019 | } |
2019 | if (p == fs->altroot.mnt) { | ||
2020 | altrootmnt = p; | ||
2021 | fs->altroot.mnt = mntget(q); | ||
2022 | } | ||
2023 | } | 2020 | } |
2024 | p = next_mnt(p, mnt_ns->root); | 2021 | p = next_mnt(p, mnt_ns->root); |
2025 | q = next_mnt(q, new_ns->root); | 2022 | q = next_mnt(q, new_ns->root); |
@@ -2030,8 +2027,6 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns, | |||
2030 | mntput(rootmnt); | 2027 | mntput(rootmnt); |
2031 | if (pwdmnt) | 2028 | if (pwdmnt) |
2032 | mntput(pwdmnt); | 2029 | mntput(pwdmnt); |
2033 | if (altrootmnt) | ||
2034 | mntput(altrootmnt); | ||
2035 | 2030 | ||
2036 | return new_ns; | 2031 | return new_ns; |
2037 | } | 2032 | } |
@@ -2184,28 +2179,26 @@ asmlinkage long sys_pivot_root(const char __user * new_root, | |||
2184 | const char __user * put_old) | 2179 | const char __user * put_old) |
2185 | { | 2180 | { |
2186 | struct vfsmount *tmp; | 2181 | struct vfsmount *tmp; |
2187 | struct nameidata new_nd, old_nd; | 2182 | struct path new, old, parent_path, root_parent, root; |
2188 | struct path parent_path, root_parent, root; | ||
2189 | int error; | 2183 | int error; |
2190 | 2184 | ||
2191 | if (!capable(CAP_SYS_ADMIN)) | 2185 | if (!capable(CAP_SYS_ADMIN)) |
2192 | return -EPERM; | 2186 | return -EPERM; |
2193 | 2187 | ||
2194 | error = __user_walk(new_root, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, | 2188 | error = user_path_dir(new_root, &new); |
2195 | &new_nd); | ||
2196 | if (error) | 2189 | if (error) |
2197 | goto out0; | 2190 | goto out0; |
2198 | error = -EINVAL; | 2191 | error = -EINVAL; |
2199 | if (!check_mnt(new_nd.path.mnt)) | 2192 | if (!check_mnt(new.mnt)) |
2200 | goto out1; | 2193 | goto out1; |
2201 | 2194 | ||
2202 | error = __user_walk(put_old, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, &old_nd); | 2195 | error = user_path_dir(put_old, &old); |
2203 | if (error) | 2196 | if (error) |
2204 | goto out1; | 2197 | goto out1; |
2205 | 2198 | ||
2206 | error = security_sb_pivotroot(&old_nd.path, &new_nd.path); | 2199 | error = security_sb_pivotroot(&old, &new); |
2207 | if (error) { | 2200 | if (error) { |
2208 | path_put(&old_nd.path); | 2201 | path_put(&old); |
2209 | goto out1; | 2202 | goto out1; |
2210 | } | 2203 | } |
2211 | 2204 | ||
@@ -2214,69 +2207,69 @@ asmlinkage long sys_pivot_root(const char __user * new_root, | |||
2214 | path_get(¤t->fs->root); | 2207 | path_get(¤t->fs->root); |
2215 | read_unlock(¤t->fs->lock); | 2208 | read_unlock(¤t->fs->lock); |
2216 | down_write(&namespace_sem); | 2209 | down_write(&namespace_sem); |
2217 | mutex_lock(&old_nd.path.dentry->d_inode->i_mutex); | 2210 | mutex_lock(&old.dentry->d_inode->i_mutex); |
2218 | error = -EINVAL; | 2211 | error = -EINVAL; |
2219 | if (IS_MNT_SHARED(old_nd.path.mnt) || | 2212 | if (IS_MNT_SHARED(old.mnt) || |
2220 | IS_MNT_SHARED(new_nd.path.mnt->mnt_parent) || | 2213 | IS_MNT_SHARED(new.mnt->mnt_parent) || |
2221 | IS_MNT_SHARED(root.mnt->mnt_parent)) | 2214 | IS_MNT_SHARED(root.mnt->mnt_parent)) |
2222 | goto out2; | 2215 | goto out2; |
2223 | if (!check_mnt(root.mnt)) | 2216 | if (!check_mnt(root.mnt)) |
2224 | goto out2; | 2217 | goto out2; |
2225 | error = -ENOENT; | 2218 | error = -ENOENT; |
2226 | if (IS_DEADDIR(new_nd.path.dentry->d_inode)) | 2219 | if (IS_DEADDIR(new.dentry->d_inode)) |
2227 | goto out2; | 2220 | goto out2; |
2228 | if (d_unhashed(new_nd.path.dentry) && !IS_ROOT(new_nd.path.dentry)) | 2221 | if (d_unhashed(new.dentry) && !IS_ROOT(new.dentry)) |
2229 | goto out2; | 2222 | goto out2; |
2230 | if (d_unhashed(old_nd.path.dentry) && !IS_ROOT(old_nd.path.dentry)) | 2223 | if (d_unhashed(old.dentry) && !IS_ROOT(old.dentry)) |
2231 | goto out2; | 2224 | goto out2; |
2232 | error = -EBUSY; | 2225 | error = -EBUSY; |
2233 | if (new_nd.path.mnt == root.mnt || | 2226 | if (new.mnt == root.mnt || |
2234 | old_nd.path.mnt == root.mnt) | 2227 | old.mnt == root.mnt) |
2235 | goto out2; /* loop, on the same file system */ | 2228 | goto out2; /* loop, on the same file system */ |
2236 | error = -EINVAL; | 2229 | error = -EINVAL; |
2237 | if (root.mnt->mnt_root != root.dentry) | 2230 | if (root.mnt->mnt_root != root.dentry) |
2238 | goto out2; /* not a mountpoint */ | 2231 | goto out2; /* not a mountpoint */ |
2239 | if (root.mnt->mnt_parent == root.mnt) | 2232 | if (root.mnt->mnt_parent == root.mnt) |
2240 | goto out2; /* not attached */ | 2233 | goto out2; /* not attached */ |
2241 | if (new_nd.path.mnt->mnt_root != new_nd.path.dentry) | 2234 | if (new.mnt->mnt_root != new.dentry) |
2242 | goto out2; /* not a mountpoint */ | 2235 | goto out2; /* not a mountpoint */ |
2243 | if (new_nd.path.mnt->mnt_parent == new_nd.path.mnt) | 2236 | if (new.mnt->mnt_parent == new.mnt) |
2244 | goto out2; /* not attached */ | 2237 | goto out2; /* not attached */ |
2245 | /* make sure we can reach put_old from new_root */ | 2238 | /* make sure we can reach put_old from new_root */ |
2246 | tmp = old_nd.path.mnt; | 2239 | tmp = old.mnt; |
2247 | spin_lock(&vfsmount_lock); | 2240 | spin_lock(&vfsmount_lock); |
2248 | if (tmp != new_nd.path.mnt) { | 2241 | if (tmp != new.mnt) { |
2249 | for (;;) { | 2242 | for (;;) { |
2250 | if (tmp->mnt_parent == tmp) | 2243 | if (tmp->mnt_parent == tmp) |
2251 | goto out3; /* already mounted on put_old */ | 2244 | goto out3; /* already mounted on put_old */ |
2252 | if (tmp->mnt_parent == new_nd.path.mnt) | 2245 | if (tmp->mnt_parent == new.mnt) |
2253 | break; | 2246 | break; |
2254 | tmp = tmp->mnt_parent; | 2247 | tmp = tmp->mnt_parent; |
2255 | } | 2248 | } |
2256 | if (!is_subdir(tmp->mnt_mountpoint, new_nd.path.dentry)) | 2249 | if (!is_subdir(tmp->mnt_mountpoint, new.dentry)) |
2257 | goto out3; | 2250 | goto out3; |
2258 | } else if (!is_subdir(old_nd.path.dentry, new_nd.path.dentry)) | 2251 | } else if (!is_subdir(old.dentry, new.dentry)) |
2259 | goto out3; | 2252 | goto out3; |
2260 | detach_mnt(new_nd.path.mnt, &parent_path); | 2253 | detach_mnt(new.mnt, &parent_path); |
2261 | detach_mnt(root.mnt, &root_parent); | 2254 | detach_mnt(root.mnt, &root_parent); |
2262 | /* mount old root on put_old */ | 2255 | /* mount old root on put_old */ |
2263 | attach_mnt(root.mnt, &old_nd.path); | 2256 | attach_mnt(root.mnt, &old); |
2264 | /* mount new_root on / */ | 2257 | /* mount new_root on / */ |
2265 | attach_mnt(new_nd.path.mnt, &root_parent); | 2258 | attach_mnt(new.mnt, &root_parent); |
2266 | touch_mnt_namespace(current->nsproxy->mnt_ns); | 2259 | touch_mnt_namespace(current->nsproxy->mnt_ns); |
2267 | spin_unlock(&vfsmount_lock); | 2260 | spin_unlock(&vfsmount_lock); |
2268 | chroot_fs_refs(&root, &new_nd.path); | 2261 | chroot_fs_refs(&root, &new); |
2269 | security_sb_post_pivotroot(&root, &new_nd.path); | 2262 | security_sb_post_pivotroot(&root, &new); |
2270 | error = 0; | 2263 | error = 0; |
2271 | path_put(&root_parent); | 2264 | path_put(&root_parent); |
2272 | path_put(&parent_path); | 2265 | path_put(&parent_path); |
2273 | out2: | 2266 | out2: |
2274 | mutex_unlock(&old_nd.path.dentry->d_inode->i_mutex); | 2267 | mutex_unlock(&old.dentry->d_inode->i_mutex); |
2275 | up_write(&namespace_sem); | 2268 | up_write(&namespace_sem); |
2276 | path_put(&root); | 2269 | path_put(&root); |
2277 | path_put(&old_nd.path); | 2270 | path_put(&old); |
2278 | out1: | 2271 | out1: |
2279 | path_put(&new_nd.path); | 2272 | path_put(&new); |
2280 | out0: | 2273 | out0: |
2281 | return error; | 2274 | return error; |
2282 | out3: | 2275 | out3: |
diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c index 011ef0b6d2d4..07e9715b8658 100644 --- a/fs/ncpfs/dir.c +++ b/fs/ncpfs/dir.c | |||
@@ -266,7 +266,7 @@ leave_me:; | |||
266 | 266 | ||
267 | 267 | ||
268 | static int | 268 | static int |
269 | __ncp_lookup_validate(struct dentry * dentry, struct nameidata *nd) | 269 | __ncp_lookup_validate(struct dentry *dentry) |
270 | { | 270 | { |
271 | struct ncp_server *server; | 271 | struct ncp_server *server; |
272 | struct dentry *parent; | 272 | struct dentry *parent; |
@@ -340,7 +340,7 @@ ncp_lookup_validate(struct dentry * dentry, struct nameidata *nd) | |||
340 | { | 340 | { |
341 | int res; | 341 | int res; |
342 | lock_kernel(); | 342 | lock_kernel(); |
343 | res = __ncp_lookup_validate(dentry, nd); | 343 | res = __ncp_lookup_validate(dentry); |
344 | unlock_kernel(); | 344 | unlock_kernel(); |
345 | return res; | 345 | return res; |
346 | } | 346 | } |
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c index 2e5ab1204dec..d642f0e5b365 100644 --- a/fs/ncpfs/inode.c +++ b/fs/ncpfs/inode.c | |||
@@ -64,7 +64,7 @@ static void ncp_destroy_inode(struct inode *inode) | |||
64 | kmem_cache_free(ncp_inode_cachep, NCP_FINFO(inode)); | 64 | kmem_cache_free(ncp_inode_cachep, NCP_FINFO(inode)); |
65 | } | 65 | } |
66 | 66 | ||
67 | static void init_once(struct kmem_cache *cachep, void *foo) | 67 | static void init_once(void *foo) |
68 | { | 68 | { |
69 | struct ncp_inode_info *ei = (struct ncp_inode_info *) foo; | 69 | struct ncp_inode_info *ei = (struct ncp_inode_info *) foo; |
70 | 70 | ||
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 28a238dab23a..74f92b717f78 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c | |||
@@ -1884,7 +1884,7 @@ static int nfs_do_access(struct inode *inode, struct rpc_cred *cred, int mask) | |||
1884 | return status; | 1884 | return status; |
1885 | nfs_access_add_cache(inode, &cache); | 1885 | nfs_access_add_cache(inode, &cache); |
1886 | out: | 1886 | out: |
1887 | if ((cache.mask & mask) == mask) | 1887 | if ((mask & ~cache.mask & (MAY_READ | MAY_WRITE | MAY_EXEC)) == 0) |
1888 | return 0; | 1888 | return 0; |
1889 | return -EACCES; | 1889 | return -EACCES; |
1890 | } | 1890 | } |
@@ -1907,17 +1907,17 @@ int nfs_may_open(struct inode *inode, struct rpc_cred *cred, int openflags) | |||
1907 | return nfs_do_access(inode, cred, nfs_open_permission_mask(openflags)); | 1907 | return nfs_do_access(inode, cred, nfs_open_permission_mask(openflags)); |
1908 | } | 1908 | } |
1909 | 1909 | ||
1910 | int nfs_permission(struct inode *inode, int mask, struct nameidata *nd) | 1910 | int nfs_permission(struct inode *inode, int mask) |
1911 | { | 1911 | { |
1912 | struct rpc_cred *cred; | 1912 | struct rpc_cred *cred; |
1913 | int res = 0; | 1913 | int res = 0; |
1914 | 1914 | ||
1915 | nfs_inc_stats(inode, NFSIOS_VFSACCESS); | 1915 | nfs_inc_stats(inode, NFSIOS_VFSACCESS); |
1916 | 1916 | ||
1917 | if (mask == 0) | 1917 | if ((mask & (MAY_READ | MAY_WRITE | MAY_EXEC)) == 0) |
1918 | goto out; | 1918 | goto out; |
1919 | /* Is this sys_access() ? */ | 1919 | /* Is this sys_access() ? */ |
1920 | if (nd != NULL && (nd->flags & LOOKUP_ACCESS)) | 1920 | if (mask & MAY_ACCESS) |
1921 | goto force_lookup; | 1921 | goto force_lookup; |
1922 | 1922 | ||
1923 | switch (inode->i_mode & S_IFMT) { | 1923 | switch (inode->i_mode & S_IFMT) { |
@@ -1926,8 +1926,7 @@ int nfs_permission(struct inode *inode, int mask, struct nameidata *nd) | |||
1926 | case S_IFREG: | 1926 | case S_IFREG: |
1927 | /* NFSv4 has atomic_open... */ | 1927 | /* NFSv4 has atomic_open... */ |
1928 | if (nfs_server_capable(inode, NFS_CAP_ATOMIC_OPEN) | 1928 | if (nfs_server_capable(inode, NFS_CAP_ATOMIC_OPEN) |
1929 | && nd != NULL | 1929 | && (mask & MAY_OPEN)) |
1930 | && (nd->flags & LOOKUP_OPEN)) | ||
1931 | goto out; | 1930 | goto out; |
1932 | break; | 1931 | break; |
1933 | case S_IFDIR: | 1932 | case S_IFDIR: |
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index df23f987da6b..52daefa2f521 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c | |||
@@ -1242,7 +1242,7 @@ static inline void nfs4_init_once(struct nfs_inode *nfsi) | |||
1242 | #endif | 1242 | #endif |
1243 | } | 1243 | } |
1244 | 1244 | ||
1245 | static void init_once(struct kmem_cache * cachep, void *foo) | 1245 | static void init_once(void *foo) |
1246 | { | 1246 | { |
1247 | struct nfs_inode *nfsi = (struct nfs_inode *) foo; | 1247 | struct nfs_inode *nfsi = (struct nfs_inode *) foo; |
1248 | 1248 | ||
diff --git a/fs/nfs/super.c b/fs/nfs/super.c index 1b94e3650f5c..9abcd2b329f7 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c | |||
@@ -1718,9 +1718,9 @@ nfs_remount(struct super_block *sb, int *flags, char *raw_data) | |||
1718 | * ones were explicitly specified. Fall back to legacy behavior and | 1718 | * ones were explicitly specified. Fall back to legacy behavior and |
1719 | * just return success. | 1719 | * just return success. |
1720 | */ | 1720 | */ |
1721 | if ((nfsvers == 4 && options4->version == 1) || | 1721 | if ((nfsvers == 4 && (!options4 || options4->version == 1)) || |
1722 | (nfsvers <= 3 && options->version >= 1 && | 1722 | (nfsvers <= 3 && (!options || (options->version >= 1 && |
1723 | options->version <= 6)) | 1723 | options->version <= 6)))) |
1724 | return 0; | 1724 | return 0; |
1725 | 1725 | ||
1726 | data = kzalloc(sizeof(*data), GFP_KERNEL); | 1726 | data = kzalloc(sizeof(*data), GFP_KERNEL); |
diff --git a/fs/nfs/unlink.c b/fs/nfs/unlink.c index 3adf8b266461..f089e5839d7d 100644 --- a/fs/nfs/unlink.c +++ b/fs/nfs/unlink.c | |||
@@ -95,10 +95,11 @@ static void nfs_async_unlink_done(struct rpc_task *task, void *calldata) | |||
95 | static void nfs_async_unlink_release(void *calldata) | 95 | static void nfs_async_unlink_release(void *calldata) |
96 | { | 96 | { |
97 | struct nfs_unlinkdata *data = calldata; | 97 | struct nfs_unlinkdata *data = calldata; |
98 | struct super_block *sb = data->dir->i_sb; | ||
98 | 99 | ||
99 | nfs_dec_sillycount(data->dir); | 100 | nfs_dec_sillycount(data->dir); |
100 | nfs_sb_deactive(NFS_SERVER(data->dir)); | ||
101 | nfs_free_unlinkdata(data); | 101 | nfs_free_unlinkdata(data); |
102 | nfs_sb_deactive(NFS_SB(sb)); | ||
102 | } | 103 | } |
103 | 104 | ||
104 | static const struct rpc_call_ops nfs_unlink_ops = { | 105 | static const struct rpc_call_ops nfs_unlink_ops = { |
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index 1955a2702e60..c53e65f8f3a2 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/time.h> | 12 | #include <linux/time.h> |
13 | #include <linux/errno.h> | 13 | #include <linux/errno.h> |
14 | #include <linux/fs.h> | 14 | #include <linux/fs.h> |
15 | #include <linux/namei.h> | ||
15 | #include <linux/fcntl.h> | 16 | #include <linux/fcntl.h> |
16 | #include <linux/net.h> | 17 | #include <linux/net.h> |
17 | #include <linux/in.h> | 18 | #include <linux/in.h> |
diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c index f45451eb1e38..ea37c96f0445 100644 --- a/fs/nfsd/nfsfh.c +++ b/fs/nfsd/nfsfh.c | |||
@@ -51,7 +51,7 @@ static int nfsd_acceptable(void *expv, struct dentry *dentry) | |||
51 | /* make sure parents give x permission to user */ | 51 | /* make sure parents give x permission to user */ |
52 | int err; | 52 | int err; |
53 | parent = dget_parent(tdentry); | 53 | parent = dget_parent(tdentry); |
54 | err = permission(parent->d_inode, MAY_EXEC, NULL); | 54 | err = inode_permission(parent->d_inode, MAY_EXEC); |
55 | if (err < 0) { | 55 | if (err < 0) { |
56 | dput(parent); | 56 | dput(parent); |
57 | break; | 57 | break; |
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 0f4481e0502d..18060bed5267 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c | |||
@@ -1516,7 +1516,6 @@ nfsd_symlink(struct svc_rqst *rqstp, struct svc_fh *fhp, | |||
1516 | struct dentry *dentry, *dnew; | 1516 | struct dentry *dentry, *dnew; |
1517 | __be32 err, cerr; | 1517 | __be32 err, cerr; |
1518 | int host_err; | 1518 | int host_err; |
1519 | umode_t mode; | ||
1520 | 1519 | ||
1521 | err = nfserr_noent; | 1520 | err = nfserr_noent; |
1522 | if (!flen || !plen) | 1521 | if (!flen || !plen) |
@@ -1535,11 +1534,6 @@ nfsd_symlink(struct svc_rqst *rqstp, struct svc_fh *fhp, | |||
1535 | if (IS_ERR(dnew)) | 1534 | if (IS_ERR(dnew)) |
1536 | goto out_nfserr; | 1535 | goto out_nfserr; |
1537 | 1536 | ||
1538 | mode = S_IALLUGO; | ||
1539 | /* Only the MODE ATTRibute is even vaguely meaningful */ | ||
1540 | if (iap && (iap->ia_valid & ATTR_MODE)) | ||
1541 | mode = iap->ia_mode & S_IALLUGO; | ||
1542 | |||
1543 | host_err = mnt_want_write(fhp->fh_export->ex_path.mnt); | 1537 | host_err = mnt_want_write(fhp->fh_export->ex_path.mnt); |
1544 | if (host_err) | 1538 | if (host_err) |
1545 | goto out_nfserr; | 1539 | goto out_nfserr; |
@@ -1551,11 +1545,11 @@ nfsd_symlink(struct svc_rqst *rqstp, struct svc_fh *fhp, | |||
1551 | else { | 1545 | else { |
1552 | strncpy(path_alloced, path, plen); | 1546 | strncpy(path_alloced, path, plen); |
1553 | path_alloced[plen] = 0; | 1547 | path_alloced[plen] = 0; |
1554 | host_err = vfs_symlink(dentry->d_inode, dnew, path_alloced, mode); | 1548 | host_err = vfs_symlink(dentry->d_inode, dnew, path_alloced); |
1555 | kfree(path_alloced); | 1549 | kfree(path_alloced); |
1556 | } | 1550 | } |
1557 | } else | 1551 | } else |
1558 | host_err = vfs_symlink(dentry->d_inode, dnew, path, mode); | 1552 | host_err = vfs_symlink(dentry->d_inode, dnew, path); |
1559 | 1553 | ||
1560 | if (!host_err) { | 1554 | if (!host_err) { |
1561 | if (EX_ISSYNC(fhp->fh_export)) | 1555 | if (EX_ISSYNC(fhp->fh_export)) |
@@ -1959,12 +1953,12 @@ nfsd_permission(struct svc_rqst *rqstp, struct svc_export *exp, | |||
1959 | return 0; | 1953 | return 0; |
1960 | 1954 | ||
1961 | /* This assumes NFSD_MAY_{READ,WRITE,EXEC} == MAY_{READ,WRITE,EXEC} */ | 1955 | /* This assumes NFSD_MAY_{READ,WRITE,EXEC} == MAY_{READ,WRITE,EXEC} */ |
1962 | err = permission(inode, acc & (MAY_READ|MAY_WRITE|MAY_EXEC), NULL); | 1956 | err = inode_permission(inode, acc & (MAY_READ|MAY_WRITE|MAY_EXEC)); |
1963 | 1957 | ||
1964 | /* Allow read access to binaries even when mode 111 */ | 1958 | /* Allow read access to binaries even when mode 111 */ |
1965 | if (err == -EACCES && S_ISREG(inode->i_mode) && | 1959 | if (err == -EACCES && S_ISREG(inode->i_mode) && |
1966 | acc == (NFSD_MAY_READ | NFSD_MAY_OWNER_OVERRIDE)) | 1960 | acc == (NFSD_MAY_READ | NFSD_MAY_OWNER_OVERRIDE)) |
1967 | err = permission(inode, MAY_EXEC, NULL); | 1961 | err = inode_permission(inode, MAY_EXEC); |
1968 | 1962 | ||
1969 | return err? nfserrno(err) : 0; | 1963 | return err? nfserrno(err) : 0; |
1970 | } | 1964 | } |
diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c index 3c5550cd11d6..d020866d4232 100644 --- a/fs/ntfs/file.c +++ b/fs/ntfs/file.c | |||
@@ -2118,7 +2118,7 @@ static ssize_t ntfs_file_aio_write_nolock(struct kiocb *iocb, | |||
2118 | goto out; | 2118 | goto out; |
2119 | if (!count) | 2119 | if (!count) |
2120 | goto out; | 2120 | goto out; |
2121 | err = remove_suid(file->f_path.dentry); | 2121 | err = file_remove_suid(file); |
2122 | if (err) | 2122 | if (err) |
2123 | goto out; | 2123 | goto out; |
2124 | file_update_time(file); | 2124 | file_update_time(file); |
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c index 3e76f3b216bc..4a46743b5077 100644 --- a/fs/ntfs/super.c +++ b/fs/ntfs/super.c | |||
@@ -3080,7 +3080,7 @@ struct kmem_cache *ntfs_inode_cache; | |||
3080 | struct kmem_cache *ntfs_big_inode_cache; | 3080 | struct kmem_cache *ntfs_big_inode_cache; |
3081 | 3081 | ||
3082 | /* Init once constructor for the inode slab cache. */ | 3082 | /* Init once constructor for the inode slab cache. */ |
3083 | static void ntfs_big_inode_init_once(struct kmem_cache *cachep, void *foo) | 3083 | static void ntfs_big_inode_init_once(void *foo) |
3084 | { | 3084 | { |
3085 | ntfs_inode *ni = (ntfs_inode *)foo; | 3085 | ntfs_inode *ni = (ntfs_inode *)foo; |
3086 | 3086 | ||
diff --git a/fs/ocfs2/dlm/dlmfs.c b/fs/ocfs2/dlm/dlmfs.c index e48aba698b77..533a789c3ef8 100644 --- a/fs/ocfs2/dlm/dlmfs.c +++ b/fs/ocfs2/dlm/dlmfs.c | |||
@@ -267,8 +267,7 @@ static ssize_t dlmfs_file_write(struct file *filp, | |||
267 | return writelen; | 267 | return writelen; |
268 | } | 268 | } |
269 | 269 | ||
270 | static void dlmfs_init_once(struct kmem_cache *cachep, | 270 | static void dlmfs_init_once(void *foo) |
271 | void *foo) | ||
272 | { | 271 | { |
273 | struct dlmfs_inode_private *ip = | 272 | struct dlmfs_inode_private *ip = |
274 | (struct dlmfs_inode_private *) foo; | 273 | (struct dlmfs_inode_private *) foo; |
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index e8514e8b6ce8..be2dd95d3a1d 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c | |||
@@ -1176,7 +1176,7 @@ bail: | |||
1176 | return err; | 1176 | return err; |
1177 | } | 1177 | } |
1178 | 1178 | ||
1179 | int ocfs2_permission(struct inode *inode, int mask, struct nameidata *nd) | 1179 | int ocfs2_permission(struct inode *inode, int mask) |
1180 | { | 1180 | { |
1181 | int ret; | 1181 | int ret; |
1182 | 1182 | ||
diff --git a/fs/ocfs2/file.h b/fs/ocfs2/file.h index 048ddcaf5c80..1e27b4d017ea 100644 --- a/fs/ocfs2/file.h +++ b/fs/ocfs2/file.h | |||
@@ -62,8 +62,7 @@ int ocfs2_lock_allocators(struct inode *inode, struct ocfs2_dinode *di, | |||
62 | int ocfs2_setattr(struct dentry *dentry, struct iattr *attr); | 62 | int ocfs2_setattr(struct dentry *dentry, struct iattr *attr); |
63 | int ocfs2_getattr(struct vfsmount *mnt, struct dentry *dentry, | 63 | int ocfs2_getattr(struct vfsmount *mnt, struct dentry *dentry, |
64 | struct kstat *stat); | 64 | struct kstat *stat); |
65 | int ocfs2_permission(struct inode *inode, int mask, | 65 | int ocfs2_permission(struct inode *inode, int mask); |
66 | struct nameidata *nd); | ||
67 | 66 | ||
68 | int ocfs2_should_update_atime(struct inode *inode, | 67 | int ocfs2_should_update_atime(struct inode *inode, |
69 | struct vfsmount *vfsmnt); | 68 | struct vfsmount *vfsmnt); |
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index ccecfe5094fa..2560b33889aa 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c | |||
@@ -1118,7 +1118,7 @@ bail: | |||
1118 | return status; | 1118 | return status; |
1119 | } | 1119 | } |
1120 | 1120 | ||
1121 | static void ocfs2_inode_init_once(struct kmem_cache *cachep, void *data) | 1121 | static void ocfs2_inode_init_once(void *data) |
1122 | { | 1122 | { |
1123 | struct ocfs2_inode_info *oi = data; | 1123 | struct ocfs2_inode_info *oi = data; |
1124 | 1124 | ||
diff --git a/fs/omfs/Makefile b/fs/omfs/Makefile new file mode 100644 index 000000000000..8b82b63f1129 --- /dev/null +++ b/fs/omfs/Makefile | |||
@@ -0,0 +1,4 @@ | |||
1 | |||
2 | obj-$(CONFIG_OMFS_FS) += omfs.o | ||
3 | |||
4 | omfs-y := bitmap.o dir.o file.o inode.o | ||
diff --git a/fs/omfs/bitmap.c b/fs/omfs/bitmap.c new file mode 100644 index 000000000000..dc75f22be3f2 --- /dev/null +++ b/fs/omfs/bitmap.c | |||
@@ -0,0 +1,192 @@ | |||
1 | #include <linux/kernel.h> | ||
2 | #include <linux/fs.h> | ||
3 | #include <linux/buffer_head.h> | ||
4 | #include <asm/div64.h> | ||
5 | #include "omfs.h" | ||
6 | |||
7 | unsigned long omfs_count_free(struct super_block *sb) | ||
8 | { | ||
9 | unsigned int i; | ||
10 | unsigned long sum = 0; | ||
11 | struct omfs_sb_info *sbi = OMFS_SB(sb); | ||
12 | int nbits = sb->s_blocksize * 8; | ||
13 | |||
14 | for (i = 0; i < sbi->s_imap_size; i++) | ||
15 | sum += nbits - bitmap_weight(sbi->s_imap[i], nbits); | ||
16 | |||
17 | return sum; | ||
18 | } | ||
19 | |||
20 | /* | ||
21 | * Counts the run of zero bits starting at bit up to max. | ||
22 | * It handles the case where a run might spill over a buffer. | ||
23 | * Called with bitmap lock. | ||
24 | */ | ||
25 | static int count_run(unsigned long **addr, int nbits, | ||
26 | int addrlen, int bit, int max) | ||
27 | { | ||
28 | int count = 0; | ||
29 | int x; | ||
30 | |||
31 | for (; addrlen > 0; addrlen--, addr++) { | ||
32 | x = find_next_bit(*addr, nbits, bit); | ||
33 | count += x - bit; | ||
34 | |||
35 | if (x < nbits || count > max) | ||
36 | return min(count, max); | ||
37 | |||
38 | bit = 0; | ||
39 | } | ||
40 | return min(count, max); | ||
41 | } | ||
42 | |||
43 | /* | ||
44 | * Sets or clears the run of count bits starting with bit. | ||
45 | * Called with bitmap lock. | ||
46 | */ | ||
47 | static int set_run(struct super_block *sb, int map, | ||
48 | int nbits, int bit, int count, int set) | ||
49 | { | ||
50 | int i; | ||
51 | int err; | ||
52 | struct buffer_head *bh; | ||
53 | struct omfs_sb_info *sbi = OMFS_SB(sb); | ||
54 | |||
55 | err = -ENOMEM; | ||
56 | bh = sb_bread(sb, clus_to_blk(sbi, sbi->s_bitmap_ino) + map); | ||
57 | if (!bh) | ||
58 | goto out; | ||
59 | |||
60 | for (i = 0; i < count; i++, bit++) { | ||
61 | if (bit >= nbits) { | ||
62 | bit = 0; | ||
63 | map++; | ||
64 | |||
65 | mark_buffer_dirty(bh); | ||
66 | brelse(bh); | ||
67 | bh = sb_bread(sb, | ||
68 | clus_to_blk(sbi, sbi->s_bitmap_ino) + map); | ||
69 | if (!bh) | ||
70 | goto out; | ||
71 | } | ||
72 | if (set) { | ||
73 | set_bit(bit, sbi->s_imap[map]); | ||
74 | set_bit(bit, (long *) bh->b_data); | ||
75 | } else { | ||
76 | clear_bit(bit, sbi->s_imap[map]); | ||
77 | clear_bit(bit, (long *) bh->b_data); | ||
78 | } | ||
79 | } | ||
80 | mark_buffer_dirty(bh); | ||
81 | brelse(bh); | ||
82 | err = 0; | ||
83 | out: | ||
84 | return err; | ||
85 | } | ||
86 | |||
87 | /* | ||
88 | * Tries to allocate exactly one block. Returns true if sucessful. | ||
89 | */ | ||
90 | int omfs_allocate_block(struct super_block *sb, u64 block) | ||
91 | { | ||
92 | struct buffer_head *bh; | ||
93 | struct omfs_sb_info *sbi = OMFS_SB(sb); | ||
94 | int bits_per_entry = 8 * sb->s_blocksize; | ||
95 | int map, bit; | ||
96 | int ret = 0; | ||
97 | u64 tmp; | ||
98 | |||
99 | tmp = block; | ||
100 | bit = do_div(tmp, bits_per_entry); | ||
101 | map = tmp; | ||
102 | |||
103 | mutex_lock(&sbi->s_bitmap_lock); | ||
104 | if (map >= sbi->s_imap_size || test_and_set_bit(bit, sbi->s_imap[map])) | ||
105 | goto out; | ||
106 | |||
107 | if (sbi->s_bitmap_ino > 0) { | ||
108 | bh = sb_bread(sb, clus_to_blk(sbi, sbi->s_bitmap_ino) + map); | ||
109 | if (!bh) | ||
110 | goto out; | ||
111 | |||
112 | set_bit(bit, (long *) bh->b_data); | ||
113 | mark_buffer_dirty(bh); | ||
114 | brelse(bh); | ||
115 | } | ||
116 | ret = 1; | ||
117 | out: | ||
118 | mutex_unlock(&sbi->s_bitmap_lock); | ||
119 | return ret; | ||
120 | } | ||
121 | |||
122 | |||
123 | /* | ||
124 | * Tries to allocate a set of blocks. The request size depends on the | ||
125 | * type: for inodes, we must allocate sbi->s_mirrors blocks, and for file | ||
126 | * blocks, we try to allocate sbi->s_clustersize, but can always get away | ||
127 | * with just one block. | ||
128 | */ | ||
129 | int omfs_allocate_range(struct super_block *sb, | ||
130 | int min_request, | ||
131 | int max_request, | ||
132 | u64 *return_block, | ||
133 | int *return_size) | ||
134 | { | ||
135 | struct omfs_sb_info *sbi = OMFS_SB(sb); | ||
136 | int bits_per_entry = 8 * sb->s_blocksize; | ||
137 | int ret = 0; | ||
138 | int i, run, bit; | ||
139 | |||
140 | mutex_lock(&sbi->s_bitmap_lock); | ||
141 | for (i = 0; i < sbi->s_imap_size; i++) { | ||
142 | bit = 0; | ||
143 | while (bit < bits_per_entry) { | ||
144 | bit = find_next_zero_bit(sbi->s_imap[i], bits_per_entry, | ||
145 | bit); | ||
146 | |||
147 | if (bit == bits_per_entry) | ||
148 | break; | ||
149 | |||
150 | run = count_run(&sbi->s_imap[i], bits_per_entry, | ||
151 | sbi->s_imap_size-i, bit, max_request); | ||
152 | |||
153 | if (run >= min_request) | ||
154 | goto found; | ||
155 | bit += run; | ||
156 | } | ||
157 | } | ||
158 | ret = -ENOSPC; | ||
159 | goto out; | ||
160 | |||
161 | found: | ||
162 | *return_block = i * bits_per_entry + bit; | ||
163 | *return_size = run; | ||
164 | ret = set_run(sb, i, bits_per_entry, bit, run, 1); | ||
165 | |||
166 | out: | ||
167 | mutex_unlock(&sbi->s_bitmap_lock); | ||
168 | return ret; | ||
169 | } | ||
170 | |||
171 | /* | ||
172 | * Clears count bits starting at a given block. | ||
173 | */ | ||
174 | int omfs_clear_range(struct super_block *sb, u64 block, int count) | ||
175 | { | ||
176 | struct omfs_sb_info *sbi = OMFS_SB(sb); | ||
177 | int bits_per_entry = 8 * sb->s_blocksize; | ||
178 | u64 tmp; | ||
179 | int map, bit, ret; | ||
180 | |||
181 | tmp = block; | ||
182 | bit = do_div(tmp, bits_per_entry); | ||
183 | map = tmp; | ||
184 | |||
185 | if (map >= sbi->s_imap_size) | ||
186 | return 0; | ||
187 | |||
188 | mutex_lock(&sbi->s_bitmap_lock); | ||
189 | ret = set_run(sb, map, bits_per_entry, bit, count, 0); | ||
190 | mutex_unlock(&sbi->s_bitmap_lock); | ||
191 | return ret; | ||
192 | } | ||
diff --git a/fs/omfs/dir.c b/fs/omfs/dir.c new file mode 100644 index 000000000000..05a5bc31e4bd --- /dev/null +++ b/fs/omfs/dir.c | |||
@@ -0,0 +1,504 @@ | |||
1 | /* | ||
2 | * OMFS (as used by RIO Karma) directory operations. | ||
3 | * Copyright (C) 2005 Bob Copeland <me@bobcopeland.com> | ||
4 | * Released under GPL v2. | ||
5 | */ | ||
6 | |||
7 | #include <linux/fs.h> | ||
8 | #include <linux/ctype.h> | ||
9 | #include <linux/buffer_head.h> | ||
10 | #include "omfs.h" | ||
11 | |||
12 | static int omfs_hash(const char *name, int namelen, int mod) | ||
13 | { | ||
14 | int i, hash = 0; | ||
15 | for (i = 0; i < namelen; i++) | ||
16 | hash ^= tolower(name[i]) << (i % 24); | ||
17 | return hash % mod; | ||
18 | } | ||
19 | |||
20 | /* | ||
21 | * Finds the bucket for a given name and reads the containing block; | ||
22 | * *ofs is set to the offset of the first list entry. | ||
23 | */ | ||
24 | static struct buffer_head *omfs_get_bucket(struct inode *dir, | ||
25 | const char *name, int namelen, int *ofs) | ||
26 | { | ||
27 | int nbuckets = (dir->i_size - OMFS_DIR_START)/8; | ||
28 | int block = clus_to_blk(OMFS_SB(dir->i_sb), dir->i_ino); | ||
29 | int bucket = omfs_hash(name, namelen, nbuckets); | ||
30 | |||
31 | *ofs = OMFS_DIR_START + bucket * 8; | ||
32 | return sb_bread(dir->i_sb, block); | ||
33 | } | ||
34 | |||
35 | static struct buffer_head *omfs_scan_list(struct inode *dir, u64 block, | ||
36 | const char *name, int namelen, | ||
37 | u64 *prev_block) | ||
38 | { | ||
39 | struct buffer_head *bh; | ||
40 | struct omfs_inode *oi; | ||
41 | int err = -ENOENT; | ||
42 | *prev_block = ~0; | ||
43 | |||
44 | while (block != ~0) { | ||
45 | bh = sb_bread(dir->i_sb, | ||
46 | clus_to_blk(OMFS_SB(dir->i_sb), block)); | ||
47 | if (!bh) { | ||
48 | err = -EIO; | ||
49 | goto err; | ||
50 | } | ||
51 | |||
52 | oi = (struct omfs_inode *) bh->b_data; | ||
53 | if (omfs_is_bad(OMFS_SB(dir->i_sb), &oi->i_head, block)) { | ||
54 | brelse(bh); | ||
55 | goto err; | ||
56 | } | ||
57 | |||
58 | if (strncmp(oi->i_name, name, namelen) == 0) | ||
59 | return bh; | ||
60 | |||
61 | *prev_block = block; | ||
62 | block = be64_to_cpu(oi->i_sibling); | ||
63 | brelse(bh); | ||
64 | } | ||
65 | err: | ||
66 | return ERR_PTR(err); | ||
67 | } | ||
68 | |||
69 | static struct buffer_head *omfs_find_entry(struct inode *dir, | ||
70 | const char *name, int namelen) | ||
71 | { | ||
72 | struct buffer_head *bh; | ||
73 | int ofs; | ||
74 | u64 block, dummy; | ||
75 | |||
76 | bh = omfs_get_bucket(dir, name, namelen, &ofs); | ||
77 | if (!bh) | ||
78 | return ERR_PTR(-EIO); | ||
79 | |||
80 | block = be64_to_cpu(*((__be64 *) &bh->b_data[ofs])); | ||
81 | brelse(bh); | ||
82 | |||
83 | return omfs_scan_list(dir, block, name, namelen, &dummy); | ||
84 | } | ||
85 | |||
86 | int omfs_make_empty(struct inode *inode, struct super_block *sb) | ||
87 | { | ||
88 | struct omfs_sb_info *sbi = OMFS_SB(sb); | ||
89 | int block = clus_to_blk(sbi, inode->i_ino); | ||
90 | struct buffer_head *bh; | ||
91 | struct omfs_inode *oi; | ||
92 | |||
93 | bh = sb_bread(sb, block); | ||
94 | if (!bh) | ||
95 | return -ENOMEM; | ||
96 | |||
97 | memset(bh->b_data, 0, sizeof(struct omfs_inode)); | ||
98 | |||
99 | if (inode->i_mode & S_IFDIR) { | ||
100 | memset(&bh->b_data[OMFS_DIR_START], 0xff, | ||
101 | sbi->s_sys_blocksize - OMFS_DIR_START); | ||
102 | } else | ||
103 | omfs_make_empty_table(bh, OMFS_EXTENT_START); | ||
104 | |||
105 | oi = (struct omfs_inode *) bh->b_data; | ||
106 | oi->i_head.h_self = cpu_to_be64(inode->i_ino); | ||
107 | oi->i_sibling = ~0ULL; | ||
108 | |||
109 | mark_buffer_dirty(bh); | ||
110 | brelse(bh); | ||
111 | return 0; | ||
112 | } | ||
113 | |||
114 | static int omfs_add_link(struct dentry *dentry, struct inode *inode) | ||
115 | { | ||
116 | struct inode *dir = dentry->d_parent->d_inode; | ||
117 | const char *name = dentry->d_name.name; | ||
118 | int namelen = dentry->d_name.len; | ||
119 | struct omfs_inode *oi; | ||
120 | struct buffer_head *bh; | ||
121 | u64 block; | ||
122 | __be64 *entry; | ||
123 | int ofs; | ||
124 | |||
125 | /* just prepend to head of queue in proper bucket */ | ||
126 | bh = omfs_get_bucket(dir, name, namelen, &ofs); | ||
127 | if (!bh) | ||
128 | goto out; | ||
129 | |||
130 | entry = (__be64 *) &bh->b_data[ofs]; | ||
131 | block = be64_to_cpu(*entry); | ||
132 | *entry = cpu_to_be64(inode->i_ino); | ||
133 | mark_buffer_dirty(bh); | ||
134 | brelse(bh); | ||
135 | |||
136 | /* now set the sibling and parent pointers on the new inode */ | ||
137 | bh = sb_bread(dir->i_sb, clus_to_blk(OMFS_SB(dir->i_sb), inode->i_ino)); | ||
138 | if (!bh) | ||
139 | goto out; | ||
140 | |||
141 | oi = (struct omfs_inode *) bh->b_data; | ||
142 | memcpy(oi->i_name, name, namelen); | ||
143 | memset(oi->i_name + namelen, 0, OMFS_NAMELEN - namelen); | ||
144 | oi->i_sibling = cpu_to_be64(block); | ||
145 | oi->i_parent = cpu_to_be64(dir->i_ino); | ||
146 | mark_buffer_dirty(bh); | ||
147 | brelse(bh); | ||
148 | |||
149 | dir->i_ctime = CURRENT_TIME_SEC; | ||
150 | |||
151 | /* mark affected inodes dirty to rebuild checksums */ | ||
152 | mark_inode_dirty(dir); | ||
153 | mark_inode_dirty(inode); | ||
154 | return 0; | ||
155 | out: | ||
156 | return -ENOMEM; | ||
157 | } | ||
158 | |||
159 | static int omfs_delete_entry(struct dentry *dentry) | ||
160 | { | ||
161 | struct inode *dir = dentry->d_parent->d_inode; | ||
162 | struct inode *dirty; | ||
163 | const char *name = dentry->d_name.name; | ||
164 | int namelen = dentry->d_name.len; | ||
165 | struct omfs_inode *oi; | ||
166 | struct buffer_head *bh, *bh2; | ||
167 | __be64 *entry, next; | ||
168 | u64 block, prev; | ||
169 | int ofs; | ||
170 | int err = -ENOMEM; | ||
171 | |||
172 | /* delete the proper node in the bucket's linked list */ | ||
173 | bh = omfs_get_bucket(dir, name, namelen, &ofs); | ||
174 | if (!bh) | ||
175 | goto out; | ||
176 | |||
177 | entry = (__be64 *) &bh->b_data[ofs]; | ||
178 | block = be64_to_cpu(*entry); | ||
179 | |||
180 | bh2 = omfs_scan_list(dir, block, name, namelen, &prev); | ||
181 | if (IS_ERR(bh2)) { | ||
182 | err = PTR_ERR(bh2); | ||
183 | goto out_free_bh; | ||
184 | } | ||
185 | |||
186 | oi = (struct omfs_inode *) bh2->b_data; | ||
187 | next = oi->i_sibling; | ||
188 | brelse(bh2); | ||
189 | |||
190 | if (prev != ~0) { | ||
191 | /* found in middle of list, get list ptr */ | ||
192 | brelse(bh); | ||
193 | bh = sb_bread(dir->i_sb, | ||
194 | clus_to_blk(OMFS_SB(dir->i_sb), prev)); | ||
195 | if (!bh) | ||
196 | goto out; | ||
197 | |||
198 | oi = (struct omfs_inode *) bh->b_data; | ||
199 | entry = &oi->i_sibling; | ||
200 | } | ||
201 | |||
202 | *entry = next; | ||
203 | mark_buffer_dirty(bh); | ||
204 | |||
205 | if (prev != ~0) { | ||
206 | dirty = omfs_iget(dir->i_sb, prev); | ||
207 | if (!IS_ERR(dirty)) { | ||
208 | mark_inode_dirty(dirty); | ||
209 | iput(dirty); | ||
210 | } | ||
211 | } | ||
212 | |||
213 | err = 0; | ||
214 | out_free_bh: | ||
215 | brelse(bh); | ||
216 | out: | ||
217 | return err; | ||
218 | } | ||
219 | |||
220 | static int omfs_dir_is_empty(struct inode *inode) | ||
221 | { | ||
222 | int nbuckets = (inode->i_size - OMFS_DIR_START) / 8; | ||
223 | struct buffer_head *bh; | ||
224 | u64 *ptr; | ||
225 | int i; | ||
226 | |||
227 | bh = sb_bread(inode->i_sb, clus_to_blk(OMFS_SB(inode->i_sb), | ||
228 | inode->i_ino)); | ||
229 | |||
230 | if (!bh) | ||
231 | return 0; | ||
232 | |||
233 | ptr = (u64 *) &bh->b_data[OMFS_DIR_START]; | ||
234 | |||
235 | for (i = 0; i < nbuckets; i++, ptr++) | ||
236 | if (*ptr != ~0) | ||
237 | break; | ||
238 | |||
239 | brelse(bh); | ||
240 | return *ptr != ~0; | ||
241 | } | ||
242 | |||
243 | static int omfs_unlink(struct inode *dir, struct dentry *dentry) | ||
244 | { | ||
245 | int ret; | ||
246 | struct inode *inode = dentry->d_inode; | ||
247 | |||
248 | ret = omfs_delete_entry(dentry); | ||
249 | if (ret) | ||
250 | goto end_unlink; | ||
251 | |||
252 | inode_dec_link_count(inode); | ||
253 | mark_inode_dirty(dir); | ||
254 | |||
255 | end_unlink: | ||
256 | return ret; | ||
257 | } | ||
258 | |||
259 | static int omfs_rmdir(struct inode *dir, struct dentry *dentry) | ||
260 | { | ||
261 | int err = -ENOTEMPTY; | ||
262 | struct inode *inode = dentry->d_inode; | ||
263 | |||
264 | if (omfs_dir_is_empty(inode)) { | ||
265 | err = omfs_unlink(dir, dentry); | ||
266 | if (!err) | ||
267 | inode_dec_link_count(inode); | ||
268 | } | ||
269 | return err; | ||
270 | } | ||
271 | |||
272 | static int omfs_add_node(struct inode *dir, struct dentry *dentry, int mode) | ||
273 | { | ||
274 | int err; | ||
275 | struct inode *inode = omfs_new_inode(dir, mode); | ||
276 | |||
277 | if (IS_ERR(inode)) | ||
278 | return PTR_ERR(inode); | ||
279 | |||
280 | err = omfs_make_empty(inode, dir->i_sb); | ||
281 | if (err) | ||
282 | goto out_free_inode; | ||
283 | |||
284 | err = omfs_add_link(dentry, inode); | ||
285 | if (err) | ||
286 | goto out_free_inode; | ||
287 | |||
288 | d_instantiate(dentry, inode); | ||
289 | return 0; | ||
290 | |||
291 | out_free_inode: | ||
292 | iput(inode); | ||
293 | return err; | ||
294 | } | ||
295 | |||
296 | static int omfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | ||
297 | { | ||
298 | return omfs_add_node(dir, dentry, mode | S_IFDIR); | ||
299 | } | ||
300 | |||
301 | static int omfs_create(struct inode *dir, struct dentry *dentry, int mode, | ||
302 | struct nameidata *nd) | ||
303 | { | ||
304 | return omfs_add_node(dir, dentry, mode | S_IFREG); | ||
305 | } | ||
306 | |||
307 | static struct dentry *omfs_lookup(struct inode *dir, struct dentry *dentry, | ||
308 | struct nameidata *nd) | ||
309 | { | ||
310 | struct buffer_head *bh; | ||
311 | struct inode *inode = NULL; | ||
312 | |||
313 | if (dentry->d_name.len > OMFS_NAMELEN) | ||
314 | return ERR_PTR(-ENAMETOOLONG); | ||
315 | |||
316 | bh = omfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len); | ||
317 | if (!IS_ERR(bh)) { | ||
318 | struct omfs_inode *oi = (struct omfs_inode *)bh->b_data; | ||
319 | ino_t ino = be64_to_cpu(oi->i_head.h_self); | ||
320 | brelse(bh); | ||
321 | inode = omfs_iget(dir->i_sb, ino); | ||
322 | if (IS_ERR(inode)) | ||
323 | return ERR_CAST(inode); | ||
324 | } | ||
325 | d_add(dentry, inode); | ||
326 | return NULL; | ||
327 | } | ||
328 | |||
329 | /* sanity check block's self pointer */ | ||
330 | int omfs_is_bad(struct omfs_sb_info *sbi, struct omfs_header *header, | ||
331 | u64 fsblock) | ||
332 | { | ||
333 | int is_bad; | ||
334 | u64 ino = be64_to_cpu(header->h_self); | ||
335 | is_bad = ((ino != fsblock) || (ino < sbi->s_root_ino) || | ||
336 | (ino > sbi->s_num_blocks)); | ||
337 | |||
338 | if (is_bad) | ||
339 | printk(KERN_WARNING "omfs: bad hash chain detected\n"); | ||
340 | |||
341 | return is_bad; | ||
342 | } | ||
343 | |||
344 | static int omfs_fill_chain(struct file *filp, void *dirent, filldir_t filldir, | ||
345 | u64 fsblock, int hindex) | ||
346 | { | ||
347 | struct inode *dir = filp->f_dentry->d_inode; | ||
348 | struct buffer_head *bh; | ||
349 | struct omfs_inode *oi; | ||
350 | u64 self; | ||
351 | int res = 0; | ||
352 | unsigned char d_type; | ||
353 | |||
354 | /* follow chain in this bucket */ | ||
355 | while (fsblock != ~0) { | ||
356 | bh = sb_bread(dir->i_sb, clus_to_blk(OMFS_SB(dir->i_sb), | ||
357 | fsblock)); | ||
358 | if (!bh) | ||
359 | goto out; | ||
360 | |||
361 | oi = (struct omfs_inode *) bh->b_data; | ||
362 | if (omfs_is_bad(OMFS_SB(dir->i_sb), &oi->i_head, fsblock)) { | ||
363 | brelse(bh); | ||
364 | goto out; | ||
365 | } | ||
366 | |||
367 | self = fsblock; | ||
368 | fsblock = be64_to_cpu(oi->i_sibling); | ||
369 | |||
370 | /* skip visited nodes */ | ||
371 | if (hindex) { | ||
372 | hindex--; | ||
373 | brelse(bh); | ||
374 | continue; | ||
375 | } | ||
376 | |||
377 | d_type = (oi->i_type == OMFS_DIR) ? DT_DIR : DT_REG; | ||
378 | |||
379 | res = filldir(dirent, oi->i_name, strnlen(oi->i_name, | ||
380 | OMFS_NAMELEN), filp->f_pos, self, d_type); | ||
381 | if (res == 0) | ||
382 | filp->f_pos++; | ||
383 | brelse(bh); | ||
384 | } | ||
385 | out: | ||
386 | return res; | ||
387 | } | ||
388 | |||
389 | static int omfs_rename(struct inode *old_dir, struct dentry *old_dentry, | ||
390 | struct inode *new_dir, struct dentry *new_dentry) | ||
391 | { | ||
392 | struct inode *new_inode = new_dentry->d_inode; | ||
393 | struct inode *old_inode = old_dentry->d_inode; | ||
394 | struct buffer_head *bh; | ||
395 | int is_dir; | ||
396 | int err; | ||
397 | |||
398 | is_dir = S_ISDIR(old_inode->i_mode); | ||
399 | |||
400 | if (new_inode) { | ||
401 | /* overwriting existing file/dir */ | ||
402 | err = -ENOTEMPTY; | ||
403 | if (is_dir && !omfs_dir_is_empty(new_inode)) | ||
404 | goto out; | ||
405 | |||
406 | err = -ENOENT; | ||
407 | bh = omfs_find_entry(new_dir, new_dentry->d_name.name, | ||
408 | new_dentry->d_name.len); | ||
409 | if (IS_ERR(bh)) | ||
410 | goto out; | ||
411 | brelse(bh); | ||
412 | |||
413 | err = omfs_unlink(new_dir, new_dentry); | ||
414 | if (err) | ||
415 | goto out; | ||
416 | } | ||
417 | |||
418 | /* since omfs locates files by name, we need to unlink _before_ | ||
419 | * adding the new link or we won't find the old one */ | ||
420 | inode_inc_link_count(old_inode); | ||
421 | err = omfs_unlink(old_dir, old_dentry); | ||
422 | if (err) { | ||
423 | inode_dec_link_count(old_inode); | ||
424 | goto out; | ||
425 | } | ||
426 | |||
427 | err = omfs_add_link(new_dentry, old_inode); | ||
428 | if (err) | ||
429 | goto out; | ||
430 | |||
431 | old_inode->i_ctime = CURRENT_TIME_SEC; | ||
432 | out: | ||
433 | return err; | ||
434 | } | ||
435 | |||
436 | static int omfs_readdir(struct file *filp, void *dirent, filldir_t filldir) | ||
437 | { | ||
438 | struct inode *dir = filp->f_dentry->d_inode; | ||
439 | struct buffer_head *bh; | ||
440 | loff_t offset, res; | ||
441 | unsigned int hchain, hindex; | ||
442 | int nbuckets; | ||
443 | u64 fsblock; | ||
444 | int ret = -EINVAL; | ||
445 | |||
446 | if (filp->f_pos >> 32) | ||
447 | goto success; | ||
448 | |||
449 | switch ((unsigned long) filp->f_pos) { | ||
450 | case 0: | ||
451 | if (filldir(dirent, ".", 1, 0, dir->i_ino, DT_DIR) < 0) | ||
452 | goto success; | ||
453 | filp->f_pos++; | ||
454 | /* fall through */ | ||
455 | case 1: | ||
456 | if (filldir(dirent, "..", 2, 1, | ||
457 | parent_ino(filp->f_dentry), DT_DIR) < 0) | ||
458 | goto success; | ||
459 | filp->f_pos = 1 << 20; | ||
460 | /* fall through */ | ||
461 | } | ||
462 | |||
463 | nbuckets = (dir->i_size - OMFS_DIR_START) / 8; | ||
464 | |||
465 | /* high 12 bits store bucket + 1 and low 20 bits store hash index */ | ||
466 | hchain = (filp->f_pos >> 20) - 1; | ||
467 | hindex = filp->f_pos & 0xfffff; | ||
468 | |||
469 | bh = sb_bread(dir->i_sb, clus_to_blk(OMFS_SB(dir->i_sb), dir->i_ino)); | ||
470 | if (!bh) | ||
471 | goto out; | ||
472 | |||
473 | offset = OMFS_DIR_START + hchain * 8; | ||
474 | |||
475 | for (; hchain < nbuckets; hchain++, offset += 8) { | ||
476 | fsblock = be64_to_cpu(*((__be64 *) &bh->b_data[offset])); | ||
477 | |||
478 | res = omfs_fill_chain(filp, dirent, filldir, fsblock, hindex); | ||
479 | hindex = 0; | ||
480 | if (res < 0) | ||
481 | break; | ||
482 | |||
483 | filp->f_pos = (hchain+2) << 20; | ||
484 | } | ||
485 | brelse(bh); | ||
486 | success: | ||
487 | ret = 0; | ||
488 | out: | ||
489 | return ret; | ||
490 | } | ||
491 | |||
492 | struct inode_operations omfs_dir_inops = { | ||
493 | .lookup = omfs_lookup, | ||
494 | .mkdir = omfs_mkdir, | ||
495 | .rename = omfs_rename, | ||
496 | .create = omfs_create, | ||
497 | .unlink = omfs_unlink, | ||
498 | .rmdir = omfs_rmdir, | ||
499 | }; | ||
500 | |||
501 | struct file_operations omfs_dir_operations = { | ||
502 | .read = generic_read_dir, | ||
503 | .readdir = omfs_readdir, | ||
504 | }; | ||
diff --git a/fs/omfs/file.c b/fs/omfs/file.c new file mode 100644 index 000000000000..66e01fae4384 --- /dev/null +++ b/fs/omfs/file.c | |||
@@ -0,0 +1,346 @@ | |||
1 | /* | ||
2 | * OMFS (as used by RIO Karma) file operations. | ||
3 | * Copyright (C) 2005 Bob Copeland <me@bobcopeland.com> | ||
4 | * Released under GPL v2. | ||
5 | */ | ||
6 | |||
7 | #include <linux/version.h> | ||
8 | #include <linux/module.h> | ||
9 | #include <linux/fs.h> | ||
10 | #include <linux/buffer_head.h> | ||
11 | #include <linux/mpage.h> | ||
12 | #include "omfs.h" | ||
13 | |||
14 | static int omfs_sync_file(struct file *file, struct dentry *dentry, | ||
15 | int datasync) | ||
16 | { | ||
17 | struct inode *inode = dentry->d_inode; | ||
18 | int err; | ||
19 | |||
20 | err = sync_mapping_buffers(inode->i_mapping); | ||
21 | if (!(inode->i_state & I_DIRTY)) | ||
22 | return err; | ||
23 | if (datasync && !(inode->i_state & I_DIRTY_DATASYNC)) | ||
24 | return err; | ||
25 | err |= omfs_sync_inode(inode); | ||
26 | return err ? -EIO : 0; | ||
27 | } | ||
28 | |||
29 | void omfs_make_empty_table(struct buffer_head *bh, int offset) | ||
30 | { | ||
31 | struct omfs_extent *oe = (struct omfs_extent *) &bh->b_data[offset]; | ||
32 | |||
33 | oe->e_next = ~0ULL; | ||
34 | oe->e_extent_count = cpu_to_be32(1), | ||
35 | oe->e_fill = cpu_to_be32(0x22), | ||
36 | oe->e_entry.e_cluster = ~0ULL; | ||
37 | oe->e_entry.e_blocks = ~0ULL; | ||
38 | } | ||
39 | |||
40 | int omfs_shrink_inode(struct inode *inode) | ||
41 | { | ||
42 | struct omfs_sb_info *sbi = OMFS_SB(inode->i_sb); | ||
43 | struct omfs_extent *oe; | ||
44 | struct omfs_extent_entry *entry; | ||
45 | struct buffer_head *bh; | ||
46 | u64 next, last; | ||
47 | u32 extent_count; | ||
48 | int ret; | ||
49 | |||
50 | /* traverse extent table, freeing each entry that is greater | ||
51 | * than inode->i_size; | ||
52 | */ | ||
53 | next = inode->i_ino; | ||
54 | |||
55 | /* only support truncate -> 0 for now */ | ||
56 | ret = -EIO; | ||
57 | if (inode->i_size != 0) | ||
58 | goto out; | ||
59 | |||
60 | bh = sb_bread(inode->i_sb, clus_to_blk(sbi, next)); | ||
61 | if (!bh) | ||
62 | goto out; | ||
63 | |||
64 | oe = (struct omfs_extent *)(&bh->b_data[OMFS_EXTENT_START]); | ||
65 | |||
66 | for (;;) { | ||
67 | |||
68 | if (omfs_is_bad(sbi, (struct omfs_header *) bh->b_data, next)) { | ||
69 | brelse(bh); | ||
70 | goto out; | ||
71 | } | ||
72 | |||
73 | extent_count = be32_to_cpu(oe->e_extent_count); | ||
74 | last = next; | ||
75 | next = be64_to_cpu(oe->e_next); | ||
76 | entry = &oe->e_entry; | ||
77 | |||
78 | /* ignore last entry as it is the terminator */ | ||
79 | for (; extent_count > 1; extent_count--) { | ||
80 | u64 start, count; | ||
81 | start = be64_to_cpu(entry->e_cluster); | ||
82 | count = be64_to_cpu(entry->e_blocks); | ||
83 | |||
84 | omfs_clear_range(inode->i_sb, start, (int) count); | ||
85 | entry++; | ||
86 | } | ||
87 | omfs_make_empty_table(bh, (char *) oe - bh->b_data); | ||
88 | mark_buffer_dirty(bh); | ||
89 | brelse(bh); | ||
90 | |||
91 | if (last != inode->i_ino) | ||
92 | omfs_clear_range(inode->i_sb, last, sbi->s_mirrors); | ||
93 | |||
94 | if (next == ~0) | ||
95 | break; | ||
96 | |||
97 | bh = sb_bread(inode->i_sb, clus_to_blk(sbi, next)); | ||
98 | if (!bh) | ||
99 | goto out; | ||
100 | oe = (struct omfs_extent *) (&bh->b_data[OMFS_EXTENT_CONT]); | ||
101 | } | ||
102 | ret = 0; | ||
103 | out: | ||
104 | return ret; | ||
105 | } | ||
106 | |||
107 | static void omfs_truncate(struct inode *inode) | ||
108 | { | ||
109 | omfs_shrink_inode(inode); | ||
110 | mark_inode_dirty(inode); | ||
111 | } | ||
112 | |||
113 | /* | ||
114 | * Add new blocks to the current extent, or create new entries/continuations | ||
115 | * as necessary. | ||
116 | */ | ||
117 | static int omfs_grow_extent(struct inode *inode, struct omfs_extent *oe, | ||
118 | u64 *ret_block) | ||
119 | { | ||
120 | struct omfs_extent_entry *terminator; | ||
121 | struct omfs_extent_entry *entry = &oe->e_entry; | ||
122 | struct omfs_sb_info *sbi = OMFS_SB(inode->i_sb); | ||
123 | u32 extent_count = be32_to_cpu(oe->e_extent_count); | ||
124 | u64 new_block = 0; | ||
125 | u32 max_count; | ||
126 | int new_count; | ||
127 | int ret = 0; | ||
128 | |||
129 | /* reached the end of the extent table with no blocks mapped. | ||
130 | * there are three possibilities for adding: grow last extent, | ||
131 | * add a new extent to the current extent table, and add a | ||
132 | * continuation inode. in last two cases need an allocator for | ||
133 | * sbi->s_cluster_size | ||
134 | */ | ||
135 | |||
136 | /* TODO: handle holes */ | ||
137 | |||
138 | /* should always have a terminator */ | ||
139 | if (extent_count < 1) | ||
140 | return -EIO; | ||
141 | |||
142 | /* trivially grow current extent, if next block is not taken */ | ||
143 | terminator = entry + extent_count - 1; | ||
144 | if (extent_count > 1) { | ||
145 | entry = terminator-1; | ||
146 | new_block = be64_to_cpu(entry->e_cluster) + | ||
147 | be64_to_cpu(entry->e_blocks); | ||
148 | |||
149 | if (omfs_allocate_block(inode->i_sb, new_block)) { | ||
150 | entry->e_blocks = | ||
151 | cpu_to_be64(be64_to_cpu(entry->e_blocks) + 1); | ||
152 | terminator->e_blocks = ~(cpu_to_be64( | ||
153 | be64_to_cpu(~terminator->e_blocks) + 1)); | ||
154 | goto out; | ||
155 | } | ||
156 | } | ||
157 | max_count = (sbi->s_sys_blocksize - OMFS_EXTENT_START - | ||
158 | sizeof(struct omfs_extent)) / | ||
159 | sizeof(struct omfs_extent_entry) + 1; | ||
160 | |||
161 | /* TODO: add a continuation block here */ | ||
162 | if (be32_to_cpu(oe->e_extent_count) > max_count-1) | ||
163 | return -EIO; | ||
164 | |||
165 | /* try to allocate a new cluster */ | ||
166 | ret = omfs_allocate_range(inode->i_sb, 1, sbi->s_clustersize, | ||
167 | &new_block, &new_count); | ||
168 | if (ret) | ||
169 | goto out_fail; | ||
170 | |||
171 | /* copy terminator down an entry */ | ||
172 | entry = terminator; | ||
173 | terminator++; | ||
174 | memcpy(terminator, entry, sizeof(struct omfs_extent_entry)); | ||
175 | |||
176 | entry->e_cluster = cpu_to_be64(new_block); | ||
177 | entry->e_blocks = cpu_to_be64((u64) new_count); | ||
178 | |||
179 | terminator->e_blocks = ~(cpu_to_be64( | ||
180 | be64_to_cpu(~terminator->e_blocks) + (u64) new_count)); | ||
181 | |||
182 | /* write in new entry */ | ||
183 | oe->e_extent_count = cpu_to_be32(1 + be32_to_cpu(oe->e_extent_count)); | ||
184 | |||
185 | out: | ||
186 | *ret_block = new_block; | ||
187 | out_fail: | ||
188 | return ret; | ||
189 | } | ||
190 | |||
191 | /* | ||
192 | * Scans across the directory table for a given file block number. | ||
193 | * If block not found, return 0. | ||
194 | */ | ||
195 | static sector_t find_block(struct inode *inode, struct omfs_extent_entry *ent, | ||
196 | sector_t block, int count, int *left) | ||
197 | { | ||
198 | /* count > 1 because of terminator */ | ||
199 | sector_t searched = 0; | ||
200 | for (; count > 1; count--) { | ||
201 | int numblocks = clus_to_blk(OMFS_SB(inode->i_sb), | ||
202 | be64_to_cpu(ent->e_blocks)); | ||
203 | |||
204 | if (block >= searched && | ||
205 | block < searched + numblocks) { | ||
206 | /* | ||
207 | * found it at cluster + (block - searched) | ||
208 | * numblocks - (block - searched) is remainder | ||
209 | */ | ||
210 | *left = numblocks - (block - searched); | ||
211 | return clus_to_blk(OMFS_SB(inode->i_sb), | ||
212 | be64_to_cpu(ent->e_cluster)) + | ||
213 | block - searched; | ||
214 | } | ||
215 | searched += numblocks; | ||
216 | ent++; | ||
217 | } | ||
218 | return 0; | ||
219 | } | ||
220 | |||
221 | static int omfs_get_block(struct inode *inode, sector_t block, | ||
222 | struct buffer_head *bh_result, int create) | ||
223 | { | ||
224 | struct buffer_head *bh; | ||
225 | sector_t next, offset; | ||
226 | int ret; | ||
227 | u64 new_block; | ||
228 | int extent_count; | ||
229 | struct omfs_extent *oe; | ||
230 | struct omfs_extent_entry *entry; | ||
231 | struct omfs_sb_info *sbi = OMFS_SB(inode->i_sb); | ||
232 | int max_blocks = bh_result->b_size >> inode->i_blkbits; | ||
233 | int remain; | ||
234 | |||
235 | ret = -EIO; | ||
236 | bh = sb_bread(inode->i_sb, clus_to_blk(sbi, inode->i_ino)); | ||
237 | if (!bh) | ||
238 | goto out; | ||
239 | |||
240 | oe = (struct omfs_extent *)(&bh->b_data[OMFS_EXTENT_START]); | ||
241 | next = inode->i_ino; | ||
242 | |||
243 | for (;;) { | ||
244 | |||
245 | if (omfs_is_bad(sbi, (struct omfs_header *) bh->b_data, next)) | ||
246 | goto out_brelse; | ||
247 | |||
248 | extent_count = be32_to_cpu(oe->e_extent_count); | ||
249 | next = be64_to_cpu(oe->e_next); | ||
250 | entry = &oe->e_entry; | ||
251 | |||
252 | offset = find_block(inode, entry, block, extent_count, &remain); | ||
253 | if (offset > 0) { | ||
254 | ret = 0; | ||
255 | map_bh(bh_result, inode->i_sb, offset); | ||
256 | if (remain > max_blocks) | ||
257 | remain = max_blocks; | ||
258 | bh_result->b_size = (remain << inode->i_blkbits); | ||
259 | goto out_brelse; | ||
260 | } | ||
261 | if (next == ~0) | ||
262 | break; | ||
263 | |||
264 | brelse(bh); | ||
265 | bh = sb_bread(inode->i_sb, clus_to_blk(sbi, next)); | ||
266 | if (!bh) | ||
267 | goto out; | ||
268 | oe = (struct omfs_extent *) (&bh->b_data[OMFS_EXTENT_CONT]); | ||
269 | } | ||
270 | if (create) { | ||
271 | ret = omfs_grow_extent(inode, oe, &new_block); | ||
272 | if (ret == 0) { | ||
273 | mark_buffer_dirty(bh); | ||
274 | mark_inode_dirty(inode); | ||
275 | map_bh(bh_result, inode->i_sb, | ||
276 | clus_to_blk(sbi, new_block)); | ||
277 | } | ||
278 | } | ||
279 | out_brelse: | ||
280 | brelse(bh); | ||
281 | out: | ||
282 | return ret; | ||
283 | } | ||
284 | |||
285 | static int omfs_readpage(struct file *file, struct page *page) | ||
286 | { | ||
287 | return block_read_full_page(page, omfs_get_block); | ||
288 | } | ||
289 | |||
290 | static int omfs_readpages(struct file *file, struct address_space *mapping, | ||
291 | struct list_head *pages, unsigned nr_pages) | ||
292 | { | ||
293 | return mpage_readpages(mapping, pages, nr_pages, omfs_get_block); | ||
294 | } | ||
295 | |||
296 | static int omfs_writepage(struct page *page, struct writeback_control *wbc) | ||
297 | { | ||
298 | return block_write_full_page(page, omfs_get_block, wbc); | ||
299 | } | ||
300 | |||
301 | static int | ||
302 | omfs_writepages(struct address_space *mapping, struct writeback_control *wbc) | ||
303 | { | ||
304 | return mpage_writepages(mapping, wbc, omfs_get_block); | ||
305 | } | ||
306 | |||
307 | static int omfs_write_begin(struct file *file, struct address_space *mapping, | ||
308 | loff_t pos, unsigned len, unsigned flags, | ||
309 | struct page **pagep, void **fsdata) | ||
310 | { | ||
311 | *pagep = NULL; | ||
312 | return block_write_begin(file, mapping, pos, len, flags, | ||
313 | pagep, fsdata, omfs_get_block); | ||
314 | } | ||
315 | |||
316 | static sector_t omfs_bmap(struct address_space *mapping, sector_t block) | ||
317 | { | ||
318 | return generic_block_bmap(mapping, block, omfs_get_block); | ||
319 | } | ||
320 | |||
321 | struct file_operations omfs_file_operations = { | ||
322 | .llseek = generic_file_llseek, | ||
323 | .read = do_sync_read, | ||
324 | .write = do_sync_write, | ||
325 | .aio_read = generic_file_aio_read, | ||
326 | .aio_write = generic_file_aio_write, | ||
327 | .mmap = generic_file_mmap, | ||
328 | .fsync = omfs_sync_file, | ||
329 | .splice_read = generic_file_splice_read, | ||
330 | }; | ||
331 | |||
332 | struct inode_operations omfs_file_inops = { | ||
333 | .truncate = omfs_truncate | ||
334 | }; | ||
335 | |||
336 | struct address_space_operations omfs_aops = { | ||
337 | .readpage = omfs_readpage, | ||
338 | .readpages = omfs_readpages, | ||
339 | .writepage = omfs_writepage, | ||
340 | .writepages = omfs_writepages, | ||
341 | .sync_page = block_sync_page, | ||
342 | .write_begin = omfs_write_begin, | ||
343 | .write_end = generic_write_end, | ||
344 | .bmap = omfs_bmap, | ||
345 | }; | ||
346 | |||
diff --git a/fs/omfs/inode.c b/fs/omfs/inode.c new file mode 100644 index 000000000000..d865f5535436 --- /dev/null +++ b/fs/omfs/inode.c | |||
@@ -0,0 +1,553 @@ | |||
1 | /* | ||
2 | * Optimized MPEG FS - inode and super operations. | ||
3 | * Copyright (C) 2006 Bob Copeland <me@bobcopeland.com> | ||
4 | * Released under GPL v2. | ||
5 | */ | ||
6 | #include <linux/version.h> | ||
7 | #include <linux/module.h> | ||
8 | #include <linux/sched.h> | ||
9 | #include <linux/fs.h> | ||
10 | #include <linux/vfs.h> | ||
11 | #include <linux/parser.h> | ||
12 | #include <linux/buffer_head.h> | ||
13 | #include <linux/vmalloc.h> | ||
14 | #include <linux/crc-itu-t.h> | ||
15 | #include "omfs.h" | ||
16 | |||
17 | MODULE_AUTHOR("Bob Copeland <me@bobcopeland.com>"); | ||
18 | MODULE_DESCRIPTION("OMFS (ReplayTV/Karma) Filesystem for Linux"); | ||
19 | MODULE_LICENSE("GPL"); | ||
20 | |||
21 | struct inode *omfs_new_inode(struct inode *dir, int mode) | ||
22 | { | ||
23 | struct inode *inode; | ||
24 | u64 new_block; | ||
25 | int err; | ||
26 | int len; | ||
27 | struct omfs_sb_info *sbi = OMFS_SB(dir->i_sb); | ||
28 | |||
29 | inode = new_inode(dir->i_sb); | ||
30 | if (!inode) | ||
31 | return ERR_PTR(-ENOMEM); | ||
32 | |||
33 | err = omfs_allocate_range(dir->i_sb, sbi->s_mirrors, sbi->s_mirrors, | ||
34 | &new_block, &len); | ||
35 | if (err) | ||
36 | goto fail; | ||
37 | |||
38 | inode->i_ino = new_block; | ||
39 | inode->i_mode = mode; | ||
40 | inode->i_uid = current->fsuid; | ||
41 | inode->i_gid = current->fsgid; | ||
42 | inode->i_blocks = 0; | ||
43 | inode->i_mapping->a_ops = &omfs_aops; | ||
44 | |||
45 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; | ||
46 | switch (mode & S_IFMT) { | ||
47 | case S_IFDIR: | ||
48 | inode->i_op = &omfs_dir_inops; | ||
49 | inode->i_fop = &omfs_dir_operations; | ||
50 | inode->i_size = sbi->s_sys_blocksize; | ||
51 | inc_nlink(inode); | ||
52 | break; | ||
53 | case S_IFREG: | ||
54 | inode->i_op = &omfs_file_inops; | ||
55 | inode->i_fop = &omfs_file_operations; | ||
56 | inode->i_size = 0; | ||
57 | break; | ||
58 | } | ||
59 | |||
60 | insert_inode_hash(inode); | ||
61 | mark_inode_dirty(inode); | ||
62 | return inode; | ||
63 | fail: | ||
64 | make_bad_inode(inode); | ||
65 | iput(inode); | ||
66 | return ERR_PTR(err); | ||
67 | } | ||
68 | |||
69 | /* | ||
70 | * Update the header checksums for a dirty inode based on its contents. | ||
71 | * Caller is expected to hold the buffer head underlying oi and mark it | ||
72 | * dirty. | ||
73 | */ | ||
74 | static void omfs_update_checksums(struct omfs_inode *oi) | ||
75 | { | ||
76 | int xor, i, ofs = 0, count; | ||
77 | u16 crc = 0; | ||
78 | unsigned char *ptr = (unsigned char *) oi; | ||
79 | |||
80 | count = be32_to_cpu(oi->i_head.h_body_size); | ||
81 | ofs = sizeof(struct omfs_header); | ||
82 | |||
83 | crc = crc_itu_t(crc, ptr + ofs, count); | ||
84 | oi->i_head.h_crc = cpu_to_be16(crc); | ||
85 | |||
86 | xor = ptr[0]; | ||
87 | for (i = 1; i < OMFS_XOR_COUNT; i++) | ||
88 | xor ^= ptr[i]; | ||
89 | |||
90 | oi->i_head.h_check_xor = xor; | ||
91 | } | ||
92 | |||
93 | static int omfs_write_inode(struct inode *inode, int wait) | ||
94 | { | ||
95 | struct omfs_inode *oi; | ||
96 | struct omfs_sb_info *sbi = OMFS_SB(inode->i_sb); | ||
97 | struct buffer_head *bh, *bh2; | ||
98 | unsigned int block; | ||
99 | u64 ctime; | ||
100 | int i; | ||
101 | int ret = -EIO; | ||
102 | int sync_failed = 0; | ||
103 | |||
104 | /* get current inode since we may have written sibling ptrs etc. */ | ||
105 | block = clus_to_blk(sbi, inode->i_ino); | ||
106 | bh = sb_bread(inode->i_sb, block); | ||
107 | if (!bh) | ||
108 | goto out; | ||
109 | |||
110 | oi = (struct omfs_inode *) bh->b_data; | ||
111 | |||
112 | oi->i_head.h_self = cpu_to_be64(inode->i_ino); | ||
113 | if (S_ISDIR(inode->i_mode)) | ||
114 | oi->i_type = OMFS_DIR; | ||
115 | else if (S_ISREG(inode->i_mode)) | ||
116 | oi->i_type = OMFS_FILE; | ||
117 | else { | ||
118 | printk(KERN_WARNING "omfs: unknown file type: %d\n", | ||
119 | inode->i_mode); | ||
120 | goto out_brelse; | ||
121 | } | ||
122 | |||
123 | oi->i_head.h_body_size = cpu_to_be32(sbi->s_sys_blocksize - | ||
124 | sizeof(struct omfs_header)); | ||
125 | oi->i_head.h_version = 1; | ||
126 | oi->i_head.h_type = OMFS_INODE_NORMAL; | ||
127 | oi->i_head.h_magic = OMFS_IMAGIC; | ||
128 | oi->i_size = cpu_to_be64(inode->i_size); | ||
129 | |||
130 | ctime = inode->i_ctime.tv_sec * 1000LL + | ||
131 | ((inode->i_ctime.tv_nsec + 999)/1000); | ||
132 | oi->i_ctime = cpu_to_be64(ctime); | ||
133 | |||
134 | omfs_update_checksums(oi); | ||
135 | |||
136 | mark_buffer_dirty(bh); | ||
137 | if (wait) { | ||
138 | sync_dirty_buffer(bh); | ||
139 | if (buffer_req(bh) && !buffer_uptodate(bh)) | ||
140 | sync_failed = 1; | ||
141 | } | ||
142 | |||
143 | /* if mirroring writes, copy to next fsblock */ | ||
144 | for (i = 1; i < sbi->s_mirrors; i++) { | ||
145 | bh2 = sb_bread(inode->i_sb, block + i * | ||
146 | (sbi->s_blocksize / sbi->s_sys_blocksize)); | ||
147 | if (!bh2) | ||
148 | goto out_brelse; | ||
149 | |||
150 | memcpy(bh2->b_data, bh->b_data, bh->b_size); | ||
151 | mark_buffer_dirty(bh2); | ||
152 | if (wait) { | ||
153 | sync_dirty_buffer(bh2); | ||
154 | if (buffer_req(bh2) && !buffer_uptodate(bh2)) | ||
155 | sync_failed = 1; | ||
156 | } | ||
157 | brelse(bh2); | ||
158 | } | ||
159 | ret = (sync_failed) ? -EIO : 0; | ||
160 | out_brelse: | ||
161 | brelse(bh); | ||
162 | out: | ||
163 | return ret; | ||
164 | } | ||
165 | |||
166 | int omfs_sync_inode(struct inode *inode) | ||
167 | { | ||
168 | return omfs_write_inode(inode, 1); | ||
169 | } | ||
170 | |||
171 | /* | ||
172 | * called when an entry is deleted, need to clear the bits in the | ||
173 | * bitmaps. | ||
174 | */ | ||
175 | static void omfs_delete_inode(struct inode *inode) | ||
176 | { | ||
177 | truncate_inode_pages(&inode->i_data, 0); | ||
178 | |||
179 | if (S_ISREG(inode->i_mode)) { | ||
180 | inode->i_size = 0; | ||
181 | omfs_shrink_inode(inode); | ||
182 | } | ||
183 | |||
184 | omfs_clear_range(inode->i_sb, inode->i_ino, 2); | ||
185 | clear_inode(inode); | ||
186 | } | ||
187 | |||
188 | struct inode *omfs_iget(struct super_block *sb, ino_t ino) | ||
189 | { | ||
190 | struct omfs_sb_info *sbi = OMFS_SB(sb); | ||
191 | struct omfs_inode *oi; | ||
192 | struct buffer_head *bh; | ||
193 | unsigned int block; | ||
194 | u64 ctime; | ||
195 | unsigned long nsecs; | ||
196 | struct inode *inode; | ||
197 | |||
198 | inode = iget_locked(sb, ino); | ||
199 | if (!inode) | ||
200 | return ERR_PTR(-ENOMEM); | ||
201 | if (!(inode->i_state & I_NEW)) | ||
202 | return inode; | ||
203 | |||
204 | block = clus_to_blk(sbi, ino); | ||
205 | bh = sb_bread(inode->i_sb, block); | ||
206 | if (!bh) | ||
207 | goto iget_failed; | ||
208 | |||
209 | oi = (struct omfs_inode *)bh->b_data; | ||
210 | |||
211 | /* check self */ | ||
212 | if (ino != be64_to_cpu(oi->i_head.h_self)) | ||
213 | goto fail_bh; | ||
214 | |||
215 | inode->i_uid = sbi->s_uid; | ||
216 | inode->i_gid = sbi->s_gid; | ||
217 | |||
218 | ctime = be64_to_cpu(oi->i_ctime); | ||
219 | nsecs = do_div(ctime, 1000) * 1000L; | ||
220 | |||
221 | inode->i_atime.tv_sec = ctime; | ||
222 | inode->i_mtime.tv_sec = ctime; | ||
223 | inode->i_ctime.tv_sec = ctime; | ||
224 | inode->i_atime.tv_nsec = nsecs; | ||
225 | inode->i_mtime.tv_nsec = nsecs; | ||
226 | inode->i_ctime.tv_nsec = nsecs; | ||
227 | |||
228 | inode->i_mapping->a_ops = &omfs_aops; | ||
229 | |||
230 | switch (oi->i_type) { | ||
231 | case OMFS_DIR: | ||
232 | inode->i_mode = S_IFDIR | (S_IRWXUGO & ~sbi->s_dmask); | ||
233 | inode->i_op = &omfs_dir_inops; | ||
234 | inode->i_fop = &omfs_dir_operations; | ||
235 | inode->i_size = be32_to_cpu(oi->i_head.h_body_size) + | ||
236 | sizeof(struct omfs_header); | ||
237 | inc_nlink(inode); | ||
238 | break; | ||
239 | case OMFS_FILE: | ||
240 | inode->i_mode = S_IFREG | (S_IRWXUGO & ~sbi->s_fmask); | ||
241 | inode->i_fop = &omfs_file_operations; | ||
242 | inode->i_size = be64_to_cpu(oi->i_size); | ||
243 | break; | ||
244 | } | ||
245 | brelse(bh); | ||
246 | unlock_new_inode(inode); | ||
247 | return inode; | ||
248 | fail_bh: | ||
249 | brelse(bh); | ||
250 | iget_failed: | ||
251 | iget_failed(inode); | ||
252 | return ERR_PTR(-EIO); | ||
253 | } | ||
254 | |||
255 | static void omfs_put_super(struct super_block *sb) | ||
256 | { | ||
257 | struct omfs_sb_info *sbi = OMFS_SB(sb); | ||
258 | kfree(sbi->s_imap); | ||
259 | kfree(sbi); | ||
260 | sb->s_fs_info = NULL; | ||
261 | } | ||
262 | |||
263 | static int omfs_statfs(struct dentry *dentry, struct kstatfs *buf) | ||
264 | { | ||
265 | struct super_block *s = dentry->d_sb; | ||
266 | struct omfs_sb_info *sbi = OMFS_SB(s); | ||
267 | buf->f_type = OMFS_MAGIC; | ||
268 | buf->f_bsize = sbi->s_blocksize; | ||
269 | buf->f_blocks = sbi->s_num_blocks; | ||
270 | buf->f_files = sbi->s_num_blocks; | ||
271 | buf->f_namelen = OMFS_NAMELEN; | ||
272 | |||
273 | buf->f_bfree = buf->f_bavail = buf->f_ffree = | ||
274 | omfs_count_free(s); | ||
275 | return 0; | ||
276 | } | ||
277 | |||
278 | static struct super_operations omfs_sops = { | ||
279 | .write_inode = omfs_write_inode, | ||
280 | .delete_inode = omfs_delete_inode, | ||
281 | .put_super = omfs_put_super, | ||
282 | .statfs = omfs_statfs, | ||
283 | .show_options = generic_show_options, | ||
284 | }; | ||
285 | |||
286 | /* | ||
287 | * For Rio Karma, there is an on-disk free bitmap whose location is | ||
288 | * stored in the root block. For ReplayTV, there is no such free bitmap | ||
289 | * so we have to walk the tree. Both inodes and file data are allocated | ||
290 | * from the same map. This array can be big (300k) so we allocate | ||
291 | * in units of the blocksize. | ||
292 | */ | ||
293 | static int omfs_get_imap(struct super_block *sb) | ||
294 | { | ||
295 | int bitmap_size; | ||
296 | int array_size; | ||
297 | int count; | ||
298 | struct omfs_sb_info *sbi = OMFS_SB(sb); | ||
299 | struct buffer_head *bh; | ||
300 | unsigned long **ptr; | ||
301 | sector_t block; | ||
302 | |||
303 | bitmap_size = DIV_ROUND_UP(sbi->s_num_blocks, 8); | ||
304 | array_size = DIV_ROUND_UP(bitmap_size, sb->s_blocksize); | ||
305 | |||
306 | if (sbi->s_bitmap_ino == ~0ULL) | ||
307 | goto out; | ||
308 | |||
309 | sbi->s_imap_size = array_size; | ||
310 | sbi->s_imap = kzalloc(array_size * sizeof(unsigned long *), GFP_KERNEL); | ||
311 | if (!sbi->s_imap) | ||
312 | goto nomem; | ||
313 | |||
314 | block = clus_to_blk(sbi, sbi->s_bitmap_ino); | ||
315 | ptr = sbi->s_imap; | ||
316 | for (count = bitmap_size; count > 0; count -= sb->s_blocksize) { | ||
317 | bh = sb_bread(sb, block++); | ||
318 | if (!bh) | ||
319 | goto nomem_free; | ||
320 | *ptr = kmalloc(sb->s_blocksize, GFP_KERNEL); | ||
321 | if (!*ptr) { | ||
322 | brelse(bh); | ||
323 | goto nomem_free; | ||
324 | } | ||
325 | memcpy(*ptr, bh->b_data, sb->s_blocksize); | ||
326 | if (count < sb->s_blocksize) | ||
327 | memset((void *)*ptr + count, 0xff, | ||
328 | sb->s_blocksize - count); | ||
329 | brelse(bh); | ||
330 | ptr++; | ||
331 | } | ||
332 | out: | ||
333 | return 0; | ||
334 | |||
335 | nomem_free: | ||
336 | for (count = 0; count < array_size; count++) | ||
337 | kfree(sbi->s_imap[count]); | ||
338 | |||
339 | kfree(sbi->s_imap); | ||
340 | nomem: | ||
341 | sbi->s_imap = NULL; | ||
342 | sbi->s_imap_size = 0; | ||
343 | return -ENOMEM; | ||
344 | } | ||
345 | |||
346 | enum { | ||
347 | Opt_uid, Opt_gid, Opt_umask, Opt_dmask, Opt_fmask | ||
348 | }; | ||
349 | |||
350 | static match_table_t tokens = { | ||
351 | {Opt_uid, "uid=%u"}, | ||
352 | {Opt_gid, "gid=%u"}, | ||
353 | {Opt_umask, "umask=%o"}, | ||
354 | {Opt_dmask, "dmask=%o"}, | ||
355 | {Opt_fmask, "fmask=%o"}, | ||
356 | }; | ||
357 | |||
358 | static int parse_options(char *options, struct omfs_sb_info *sbi) | ||
359 | { | ||
360 | char *p; | ||
361 | substring_t args[MAX_OPT_ARGS]; | ||
362 | int option; | ||
363 | |||
364 | if (!options) | ||
365 | return 1; | ||
366 | |||
367 | while ((p = strsep(&options, ",")) != NULL) { | ||
368 | int token; | ||
369 | if (!*p) | ||
370 | continue; | ||
371 | |||
372 | token = match_token(p, tokens, args); | ||
373 | switch (token) { | ||
374 | case Opt_uid: | ||
375 | if (match_int(&args[0], &option)) | ||
376 | return 0; | ||
377 | sbi->s_uid = option; | ||
378 | break; | ||
379 | case Opt_gid: | ||
380 | if (match_int(&args[0], &option)) | ||
381 | return 0; | ||
382 | sbi->s_gid = option; | ||
383 | break; | ||
384 | case Opt_umask: | ||
385 | if (match_octal(&args[0], &option)) | ||
386 | return 0; | ||
387 | sbi->s_fmask = sbi->s_dmask = option; | ||
388 | break; | ||
389 | case Opt_dmask: | ||
390 | if (match_octal(&args[0], &option)) | ||
391 | return 0; | ||
392 | sbi->s_dmask = option; | ||
393 | break; | ||
394 | case Opt_fmask: | ||
395 | if (match_octal(&args[0], &option)) | ||
396 | return 0; | ||
397 | sbi->s_fmask = option; | ||
398 | break; | ||
399 | default: | ||
400 | return 0; | ||
401 | } | ||
402 | } | ||
403 | return 1; | ||
404 | } | ||
405 | |||
406 | static int omfs_fill_super(struct super_block *sb, void *data, int silent) | ||
407 | { | ||
408 | struct buffer_head *bh, *bh2; | ||
409 | struct omfs_super_block *omfs_sb; | ||
410 | struct omfs_root_block *omfs_rb; | ||
411 | struct omfs_sb_info *sbi; | ||
412 | struct inode *root; | ||
413 | sector_t start; | ||
414 | int ret = -EINVAL; | ||
415 | |||
416 | save_mount_options(sb, (char *) data); | ||
417 | |||
418 | sbi = kzalloc(sizeof(struct omfs_sb_info), GFP_KERNEL); | ||
419 | if (!sbi) | ||
420 | return -ENOMEM; | ||
421 | |||
422 | sb->s_fs_info = sbi; | ||
423 | |||
424 | sbi->s_uid = current->uid; | ||
425 | sbi->s_gid = current->gid; | ||
426 | sbi->s_dmask = sbi->s_fmask = current->fs->umask; | ||
427 | |||
428 | if (!parse_options((char *) data, sbi)) | ||
429 | goto end; | ||
430 | |||
431 | sb->s_maxbytes = 0xffffffff; | ||
432 | |||
433 | sb_set_blocksize(sb, 0x200); | ||
434 | |||
435 | bh = sb_bread(sb, 0); | ||
436 | if (!bh) | ||
437 | goto end; | ||
438 | |||
439 | omfs_sb = (struct omfs_super_block *)bh->b_data; | ||
440 | |||
441 | if (omfs_sb->s_magic != cpu_to_be32(OMFS_MAGIC)) { | ||
442 | if (!silent) | ||
443 | printk(KERN_ERR "omfs: Invalid superblock (%x)\n", | ||
444 | omfs_sb->s_magic); | ||
445 | goto out_brelse_bh; | ||
446 | } | ||
447 | sb->s_magic = OMFS_MAGIC; | ||
448 | |||
449 | sbi->s_num_blocks = be64_to_cpu(omfs_sb->s_num_blocks); | ||
450 | sbi->s_blocksize = be32_to_cpu(omfs_sb->s_blocksize); | ||
451 | sbi->s_mirrors = be32_to_cpu(omfs_sb->s_mirrors); | ||
452 | sbi->s_root_ino = be64_to_cpu(omfs_sb->s_root_block); | ||
453 | sbi->s_sys_blocksize = be32_to_cpu(omfs_sb->s_sys_blocksize); | ||
454 | mutex_init(&sbi->s_bitmap_lock); | ||
455 | |||
456 | if (sbi->s_sys_blocksize > PAGE_SIZE) { | ||
457 | printk(KERN_ERR "omfs: sysblock size (%d) is out of range\n", | ||
458 | sbi->s_sys_blocksize); | ||
459 | goto out_brelse_bh; | ||
460 | } | ||
461 | |||
462 | if (sbi->s_blocksize < sbi->s_sys_blocksize || | ||
463 | sbi->s_blocksize > OMFS_MAX_BLOCK_SIZE) { | ||
464 | printk(KERN_ERR "omfs: block size (%d) is out of range\n", | ||
465 | sbi->s_blocksize); | ||
466 | goto out_brelse_bh; | ||
467 | } | ||
468 | |||
469 | /* | ||
470 | * Use sys_blocksize as the fs block since it is smaller than a | ||
471 | * page while the fs blocksize can be larger. | ||
472 | */ | ||
473 | sb_set_blocksize(sb, sbi->s_sys_blocksize); | ||
474 | |||
475 | /* | ||
476 | * ...and the difference goes into a shift. sys_blocksize is always | ||
477 | * a power of two factor of blocksize. | ||
478 | */ | ||
479 | sbi->s_block_shift = get_bitmask_order(sbi->s_blocksize) - | ||
480 | get_bitmask_order(sbi->s_sys_blocksize); | ||
481 | |||
482 | start = clus_to_blk(sbi, be64_to_cpu(omfs_sb->s_root_block)); | ||
483 | bh2 = sb_bread(sb, start); | ||
484 | if (!bh2) | ||
485 | goto out_brelse_bh; | ||
486 | |||
487 | omfs_rb = (struct omfs_root_block *)bh2->b_data; | ||
488 | |||
489 | sbi->s_bitmap_ino = be64_to_cpu(omfs_rb->r_bitmap); | ||
490 | sbi->s_clustersize = be32_to_cpu(omfs_rb->r_clustersize); | ||
491 | |||
492 | if (sbi->s_num_blocks != be64_to_cpu(omfs_rb->r_num_blocks)) { | ||
493 | printk(KERN_ERR "omfs: block count discrepancy between " | ||
494 | "super and root blocks (%llx, %llx)\n", | ||
495 | sbi->s_num_blocks, be64_to_cpu(omfs_rb->r_num_blocks)); | ||
496 | goto out_brelse_bh2; | ||
497 | } | ||
498 | |||
499 | ret = omfs_get_imap(sb); | ||
500 | if (ret) | ||
501 | goto out_brelse_bh2; | ||
502 | |||
503 | sb->s_op = &omfs_sops; | ||
504 | |||
505 | root = omfs_iget(sb, be64_to_cpu(omfs_rb->r_root_dir)); | ||
506 | if (IS_ERR(root)) { | ||
507 | ret = PTR_ERR(root); | ||
508 | goto out_brelse_bh2; | ||
509 | } | ||
510 | |||
511 | sb->s_root = d_alloc_root(root); | ||
512 | if (!sb->s_root) { | ||
513 | iput(root); | ||
514 | goto out_brelse_bh2; | ||
515 | } | ||
516 | printk(KERN_DEBUG "omfs: Mounted volume %s\n", omfs_rb->r_name); | ||
517 | |||
518 | ret = 0; | ||
519 | out_brelse_bh2: | ||
520 | brelse(bh2); | ||
521 | out_brelse_bh: | ||
522 | brelse(bh); | ||
523 | end: | ||
524 | return ret; | ||
525 | } | ||
526 | |||
527 | static int omfs_get_sb(struct file_system_type *fs_type, | ||
528 | int flags, const char *dev_name, | ||
529 | void *data, struct vfsmount *m) | ||
530 | { | ||
531 | return get_sb_bdev(fs_type, flags, dev_name, data, omfs_fill_super, m); | ||
532 | } | ||
533 | |||
534 | static struct file_system_type omfs_fs_type = { | ||
535 | .owner = THIS_MODULE, | ||
536 | .name = "omfs", | ||
537 | .get_sb = omfs_get_sb, | ||
538 | .kill_sb = kill_block_super, | ||
539 | .fs_flags = FS_REQUIRES_DEV, | ||
540 | }; | ||
541 | |||
542 | static int __init init_omfs_fs(void) | ||
543 | { | ||
544 | return register_filesystem(&omfs_fs_type); | ||
545 | } | ||
546 | |||
547 | static void __exit exit_omfs_fs(void) | ||
548 | { | ||
549 | unregister_filesystem(&omfs_fs_type); | ||
550 | } | ||
551 | |||
552 | module_init(init_omfs_fs); | ||
553 | module_exit(exit_omfs_fs); | ||
diff --git a/fs/omfs/omfs.h b/fs/omfs/omfs.h new file mode 100644 index 000000000000..2bc0f0670406 --- /dev/null +++ b/fs/omfs/omfs.h | |||
@@ -0,0 +1,67 @@ | |||
1 | #ifndef _OMFS_H | ||
2 | #define _OMFS_H | ||
3 | |||
4 | #include <linux/module.h> | ||
5 | #include <linux/fs.h> | ||
6 | |||
7 | #include "omfs_fs.h" | ||
8 | |||
9 | /* In-memory structures */ | ||
10 | struct omfs_sb_info { | ||
11 | u64 s_num_blocks; | ||
12 | u64 s_bitmap_ino; | ||
13 | u64 s_root_ino; | ||
14 | u32 s_blocksize; | ||
15 | u32 s_mirrors; | ||
16 | u32 s_sys_blocksize; | ||
17 | u32 s_clustersize; | ||
18 | int s_block_shift; | ||
19 | unsigned long **s_imap; | ||
20 | int s_imap_size; | ||
21 | struct mutex s_bitmap_lock; | ||
22 | int s_uid; | ||
23 | int s_gid; | ||
24 | int s_dmask; | ||
25 | int s_fmask; | ||
26 | }; | ||
27 | |||
28 | /* convert a cluster number to a scaled block number */ | ||
29 | static inline sector_t clus_to_blk(struct omfs_sb_info *sbi, sector_t block) | ||
30 | { | ||
31 | return block << sbi->s_block_shift; | ||
32 | } | ||
33 | |||
34 | static inline struct omfs_sb_info *OMFS_SB(struct super_block *sb) | ||
35 | { | ||
36 | return sb->s_fs_info; | ||
37 | } | ||
38 | |||
39 | /* bitmap.c */ | ||
40 | extern unsigned long omfs_count_free(struct super_block *sb); | ||
41 | extern int omfs_allocate_block(struct super_block *sb, u64 block); | ||
42 | extern int omfs_allocate_range(struct super_block *sb, int min_request, | ||
43 | int max_request, u64 *return_block, int *return_size); | ||
44 | extern int omfs_clear_range(struct super_block *sb, u64 block, int count); | ||
45 | |||
46 | /* dir.c */ | ||
47 | extern struct file_operations omfs_dir_operations; | ||
48 | extern struct inode_operations omfs_dir_inops; | ||
49 | extern int omfs_make_empty(struct inode *inode, struct super_block *sb); | ||
50 | extern int omfs_is_bad(struct omfs_sb_info *sbi, struct omfs_header *header, | ||
51 | u64 fsblock); | ||
52 | |||
53 | /* file.c */ | ||
54 | extern struct file_operations omfs_file_operations; | ||
55 | extern struct inode_operations omfs_file_inops; | ||
56 | extern struct address_space_operations omfs_aops; | ||
57 | extern void omfs_make_empty_table(struct buffer_head *bh, int offset); | ||
58 | extern int omfs_shrink_inode(struct inode *inode); | ||
59 | |||
60 | /* inode.c */ | ||
61 | extern struct inode *omfs_iget(struct super_block *sb, ino_t inode); | ||
62 | extern struct inode *omfs_new_inode(struct inode *dir, int mode); | ||
63 | extern int omfs_reserve_block(struct super_block *sb, sector_t block); | ||
64 | extern int omfs_find_empty_block(struct super_block *sb, int mode, ino_t *ino); | ||
65 | extern int omfs_sync_inode(struct inode *inode); | ||
66 | |||
67 | #endif | ||
diff --git a/fs/omfs/omfs_fs.h b/fs/omfs/omfs_fs.h new file mode 100644 index 000000000000..12cca245d6e8 --- /dev/null +++ b/fs/omfs/omfs_fs.h | |||
@@ -0,0 +1,80 @@ | |||
1 | #ifndef _OMFS_FS_H | ||
2 | #define _OMFS_FS_H | ||
3 | |||
4 | /* OMFS On-disk structures */ | ||
5 | |||
6 | #define OMFS_MAGIC 0xC2993D87 | ||
7 | #define OMFS_IMAGIC 0xD2 | ||
8 | |||
9 | #define OMFS_DIR 'D' | ||
10 | #define OMFS_FILE 'F' | ||
11 | #define OMFS_INODE_NORMAL 'e' | ||
12 | #define OMFS_INODE_CONTINUATION 'c' | ||
13 | #define OMFS_INODE_SYSTEM 's' | ||
14 | #define OMFS_NAMELEN 256 | ||
15 | #define OMFS_DIR_START 0x1b8 | ||
16 | #define OMFS_EXTENT_START 0x1d0 | ||
17 | #define OMFS_EXTENT_CONT 0x40 | ||
18 | #define OMFS_XOR_COUNT 19 | ||
19 | #define OMFS_MAX_BLOCK_SIZE 8192 | ||
20 | |||
21 | struct omfs_super_block { | ||
22 | char s_fill1[256]; | ||
23 | __be64 s_root_block; /* block number of omfs_root_block */ | ||
24 | __be64 s_num_blocks; /* total number of FS blocks */ | ||
25 | __be32 s_magic; /* OMFS_MAGIC */ | ||
26 | __be32 s_blocksize; /* size of a block */ | ||
27 | __be32 s_mirrors; /* # of mirrors of system blocks */ | ||
28 | __be32 s_sys_blocksize; /* size of non-data blocks */ | ||
29 | }; | ||
30 | |||
31 | struct omfs_header { | ||
32 | __be64 h_self; /* FS block where this is located */ | ||
33 | __be32 h_body_size; /* size of useful data after header */ | ||
34 | __be16 h_crc; /* crc-ccitt of body_size bytes */ | ||
35 | char h_fill1[2]; | ||
36 | u8 h_version; /* version, always 1 */ | ||
37 | char h_type; /* OMFS_INODE_X */ | ||
38 | u8 h_magic; /* OMFS_IMAGIC */ | ||
39 | u8 h_check_xor; /* XOR of header bytes before this */ | ||
40 | __be32 h_fill2; | ||
41 | }; | ||
42 | |||
43 | struct omfs_root_block { | ||
44 | struct omfs_header r_head; /* header */ | ||
45 | __be64 r_fill1; | ||
46 | __be64 r_num_blocks; /* total number of FS blocks */ | ||
47 | __be64 r_root_dir; /* block # of root directory */ | ||
48 | __be64 r_bitmap; /* block # of free space bitmap */ | ||
49 | __be32 r_blocksize; /* size of a block */ | ||
50 | __be32 r_clustersize; /* size allocated for data blocks */ | ||
51 | __be64 r_mirrors; /* # of mirrors of system blocks */ | ||
52 | char r_name[OMFS_NAMELEN]; /* partition label */ | ||
53 | }; | ||
54 | |||
55 | struct omfs_inode { | ||
56 | struct omfs_header i_head; /* header */ | ||
57 | __be64 i_parent; /* parent containing this inode */ | ||
58 | __be64 i_sibling; /* next inode in hash bucket */ | ||
59 | __be64 i_ctime; /* ctime, in milliseconds */ | ||
60 | char i_fill1[35]; | ||
61 | char i_type; /* OMFS_[DIR,FILE] */ | ||
62 | __be32 i_fill2; | ||
63 | char i_fill3[64]; | ||
64 | char i_name[OMFS_NAMELEN]; /* filename */ | ||
65 | __be64 i_size; /* size of file, in bytes */ | ||
66 | }; | ||
67 | |||
68 | struct omfs_extent_entry { | ||
69 | __be64 e_cluster; /* start location of a set of blocks */ | ||
70 | __be64 e_blocks; /* number of blocks after e_cluster */ | ||
71 | }; | ||
72 | |||
73 | struct omfs_extent { | ||
74 | __be64 e_next; /* next extent table location */ | ||
75 | __be32 e_extent_count; /* total # extents in this table */ | ||
76 | __be32 e_fill; | ||
77 | struct omfs_extent_entry e_entry; /* start of extent entries */ | ||
78 | }; | ||
79 | |||
80 | #endif | ||
@@ -122,37 +122,37 @@ static int vfs_statfs64(struct dentry *dentry, struct statfs64 *buf) | |||
122 | return 0; | 122 | return 0; |
123 | } | 123 | } |
124 | 124 | ||
125 | asmlinkage long sys_statfs(const char __user * path, struct statfs __user * buf) | 125 | asmlinkage long sys_statfs(const char __user *pathname, struct statfs __user * buf) |
126 | { | 126 | { |
127 | struct nameidata nd; | 127 | struct path path; |
128 | int error; | 128 | int error; |
129 | 129 | ||
130 | error = user_path_walk(path, &nd); | 130 | error = user_path(pathname, &path); |
131 | if (!error) { | 131 | if (!error) { |
132 | struct statfs tmp; | 132 | struct statfs tmp; |
133 | error = vfs_statfs_native(nd.path.dentry, &tmp); | 133 | error = vfs_statfs_native(path.dentry, &tmp); |
134 | if (!error && copy_to_user(buf, &tmp, sizeof(tmp))) | 134 | if (!error && copy_to_user(buf, &tmp, sizeof(tmp))) |
135 | error = -EFAULT; | 135 | error = -EFAULT; |
136 | path_put(&nd.path); | 136 | path_put(&path); |
137 | } | 137 | } |
138 | return error; | 138 | return error; |
139 | } | 139 | } |
140 | 140 | ||
141 | 141 | ||
142 | asmlinkage long sys_statfs64(const char __user *path, size_t sz, struct statfs64 __user *buf) | 142 | asmlinkage long sys_statfs64(const char __user *pathname, size_t sz, struct statfs64 __user *buf) |
143 | { | 143 | { |
144 | struct nameidata nd; | 144 | struct path path; |
145 | long error; | 145 | long error; |
146 | 146 | ||
147 | if (sz != sizeof(*buf)) | 147 | if (sz != sizeof(*buf)) |
148 | return -EINVAL; | 148 | return -EINVAL; |
149 | error = user_path_walk(path, &nd); | 149 | error = user_path(pathname, &path); |
150 | if (!error) { | 150 | if (!error) { |
151 | struct statfs64 tmp; | 151 | struct statfs64 tmp; |
152 | error = vfs_statfs64(nd.path.dentry, &tmp); | 152 | error = vfs_statfs64(path.dentry, &tmp); |
153 | if (!error && copy_to_user(buf, &tmp, sizeof(tmp))) | 153 | if (!error && copy_to_user(buf, &tmp, sizeof(tmp))) |
154 | error = -EFAULT; | 154 | error = -EFAULT; |
155 | path_put(&nd.path); | 155 | path_put(&path); |
156 | } | 156 | } |
157 | return error; | 157 | return error; |
158 | } | 158 | } |
@@ -223,20 +223,20 @@ int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs, | |||
223 | return err; | 223 | return err; |
224 | } | 224 | } |
225 | 225 | ||
226 | static long do_sys_truncate(const char __user * path, loff_t length) | 226 | static long do_sys_truncate(const char __user *pathname, loff_t length) |
227 | { | 227 | { |
228 | struct nameidata nd; | 228 | struct path path; |
229 | struct inode * inode; | 229 | struct inode *inode; |
230 | int error; | 230 | int error; |
231 | 231 | ||
232 | error = -EINVAL; | 232 | error = -EINVAL; |
233 | if (length < 0) /* sorry, but loff_t says... */ | 233 | if (length < 0) /* sorry, but loff_t says... */ |
234 | goto out; | 234 | goto out; |
235 | 235 | ||
236 | error = user_path_walk(path, &nd); | 236 | error = user_path(pathname, &path); |
237 | if (error) | 237 | if (error) |
238 | goto out; | 238 | goto out; |
239 | inode = nd.path.dentry->d_inode; | 239 | inode = path.dentry->d_inode; |
240 | 240 | ||
241 | /* For directories it's -EISDIR, for other non-regulars - -EINVAL */ | 241 | /* For directories it's -EISDIR, for other non-regulars - -EINVAL */ |
242 | error = -EISDIR; | 242 | error = -EISDIR; |
@@ -247,16 +247,16 @@ static long do_sys_truncate(const char __user * path, loff_t length) | |||
247 | if (!S_ISREG(inode->i_mode)) | 247 | if (!S_ISREG(inode->i_mode)) |
248 | goto dput_and_out; | 248 | goto dput_and_out; |
249 | 249 | ||
250 | error = mnt_want_write(nd.path.mnt); | 250 | error = mnt_want_write(path.mnt); |
251 | if (error) | 251 | if (error) |
252 | goto dput_and_out; | 252 | goto dput_and_out; |
253 | 253 | ||
254 | error = vfs_permission(&nd, MAY_WRITE); | 254 | error = inode_permission(inode, MAY_WRITE); |
255 | if (error) | 255 | if (error) |
256 | goto mnt_drop_write_and_out; | 256 | goto mnt_drop_write_and_out; |
257 | 257 | ||
258 | error = -EPERM; | 258 | error = -EPERM; |
259 | if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) | 259 | if (IS_APPEND(inode)) |
260 | goto mnt_drop_write_and_out; | 260 | goto mnt_drop_write_and_out; |
261 | 261 | ||
262 | error = get_write_access(inode); | 262 | error = get_write_access(inode); |
@@ -274,15 +274,15 @@ static long do_sys_truncate(const char __user * path, loff_t length) | |||
274 | error = locks_verify_truncate(inode, NULL, length); | 274 | error = locks_verify_truncate(inode, NULL, length); |
275 | if (!error) { | 275 | if (!error) { |
276 | DQUOT_INIT(inode); | 276 | DQUOT_INIT(inode); |
277 | error = do_truncate(nd.path.dentry, length, 0, NULL); | 277 | error = do_truncate(path.dentry, length, 0, NULL); |
278 | } | 278 | } |
279 | 279 | ||
280 | put_write_and_out: | 280 | put_write_and_out: |
281 | put_write_access(inode); | 281 | put_write_access(inode); |
282 | mnt_drop_write_and_out: | 282 | mnt_drop_write_and_out: |
283 | mnt_drop_write(nd.path.mnt); | 283 | mnt_drop_write(path.mnt); |
284 | dput_and_out: | 284 | dput_and_out: |
285 | path_put(&nd.path); | 285 | path_put(&path); |
286 | out: | 286 | out: |
287 | return error; | 287 | return error; |
288 | } | 288 | } |
@@ -425,7 +425,8 @@ out: | |||
425 | */ | 425 | */ |
426 | asmlinkage long sys_faccessat(int dfd, const char __user *filename, int mode) | 426 | asmlinkage long sys_faccessat(int dfd, const char __user *filename, int mode) |
427 | { | 427 | { |
428 | struct nameidata nd; | 428 | struct path path; |
429 | struct inode *inode; | ||
429 | int old_fsuid, old_fsgid; | 430 | int old_fsuid, old_fsgid; |
430 | kernel_cap_t uninitialized_var(old_cap); /* !SECURE_NO_SETUID_FIXUP */ | 431 | kernel_cap_t uninitialized_var(old_cap); /* !SECURE_NO_SETUID_FIXUP */ |
431 | int res; | 432 | int res; |
@@ -448,7 +449,7 @@ asmlinkage long sys_faccessat(int dfd, const char __user *filename, int mode) | |||
448 | * FIXME: There is a race here against sys_capset. The | 449 | * FIXME: There is a race here against sys_capset. The |
449 | * capabilities can change yet we will restore the old | 450 | * capabilities can change yet we will restore the old |
450 | * value below. We should hold task_capabilities_lock, | 451 | * value below. We should hold task_capabilities_lock, |
451 | * but we cannot because user_path_walk can sleep. | 452 | * but we cannot because user_path_at can sleep. |
452 | */ | 453 | */ |
453 | #endif /* ndef CONFIG_SECURITY_FILE_CAPABILITIES */ | 454 | #endif /* ndef CONFIG_SECURITY_FILE_CAPABILITIES */ |
454 | if (current->uid) | 455 | if (current->uid) |
@@ -457,14 +458,25 @@ asmlinkage long sys_faccessat(int dfd, const char __user *filename, int mode) | |||
457 | old_cap = cap_set_effective(current->cap_permitted); | 458 | old_cap = cap_set_effective(current->cap_permitted); |
458 | } | 459 | } |
459 | 460 | ||
460 | res = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW|LOOKUP_ACCESS, &nd); | 461 | res = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path); |
461 | if (res) | 462 | if (res) |
462 | goto out; | 463 | goto out; |
463 | 464 | ||
464 | res = vfs_permission(&nd, mode); | 465 | inode = path.dentry->d_inode; |
466 | |||
467 | if ((mode & MAY_EXEC) && S_ISREG(inode->i_mode)) { | ||
468 | /* | ||
469 | * MAY_EXEC on regular files is denied if the fs is mounted | ||
470 | * with the "noexec" flag. | ||
471 | */ | ||
472 | res = -EACCES; | ||
473 | if (path.mnt->mnt_flags & MNT_NOEXEC) | ||
474 | goto out_path_release; | ||
475 | } | ||
476 | |||
477 | res = inode_permission(inode, mode | MAY_ACCESS); | ||
465 | /* SuS v2 requires we report a read only fs too */ | 478 | /* SuS v2 requires we report a read only fs too */ |
466 | if(res || !(mode & S_IWOTH) || | 479 | if (res || !(mode & S_IWOTH) || special_file(inode->i_mode)) |
467 | special_file(nd.path.dentry->d_inode->i_mode)) | ||
468 | goto out_path_release; | 480 | goto out_path_release; |
469 | /* | 481 | /* |
470 | * This is a rare case where using __mnt_is_readonly() | 482 | * This is a rare case where using __mnt_is_readonly() |
@@ -476,11 +488,11 @@ asmlinkage long sys_faccessat(int dfd, const char __user *filename, int mode) | |||
476 | * inherently racy and know that the fs may change | 488 | * inherently racy and know that the fs may change |
477 | * state before we even see this result. | 489 | * state before we even see this result. |
478 | */ | 490 | */ |
479 | if (__mnt_is_readonly(nd.path.mnt)) | 491 | if (__mnt_is_readonly(path.mnt)) |
480 | res = -EROFS; | 492 | res = -EROFS; |
481 | 493 | ||
482 | out_path_release: | 494 | out_path_release: |
483 | path_put(&nd.path); | 495 | path_put(&path); |
484 | out: | 496 | out: |
485 | current->fsuid = old_fsuid; | 497 | current->fsuid = old_fsuid; |
486 | current->fsgid = old_fsgid; | 498 | current->fsgid = old_fsgid; |
@@ -498,22 +510,21 @@ asmlinkage long sys_access(const char __user *filename, int mode) | |||
498 | 510 | ||
499 | asmlinkage long sys_chdir(const char __user * filename) | 511 | asmlinkage long sys_chdir(const char __user * filename) |
500 | { | 512 | { |
501 | struct nameidata nd; | 513 | struct path path; |
502 | int error; | 514 | int error; |
503 | 515 | ||
504 | error = __user_walk(filename, | 516 | error = user_path_dir(filename, &path); |
505 | LOOKUP_FOLLOW|LOOKUP_DIRECTORY|LOOKUP_CHDIR, &nd); | ||
506 | if (error) | 517 | if (error) |
507 | goto out; | 518 | goto out; |
508 | 519 | ||
509 | error = vfs_permission(&nd, MAY_EXEC); | 520 | error = inode_permission(path.dentry->d_inode, MAY_EXEC | MAY_ACCESS); |
510 | if (error) | 521 | if (error) |
511 | goto dput_and_out; | 522 | goto dput_and_out; |
512 | 523 | ||
513 | set_fs_pwd(current->fs, &nd.path); | 524 | set_fs_pwd(current->fs, &path); |
514 | 525 | ||
515 | dput_and_out: | 526 | dput_and_out: |
516 | path_put(&nd.path); | 527 | path_put(&path); |
517 | out: | 528 | out: |
518 | return error; | 529 | return error; |
519 | } | 530 | } |
@@ -535,7 +546,7 @@ asmlinkage long sys_fchdir(unsigned int fd) | |||
535 | if (!S_ISDIR(inode->i_mode)) | 546 | if (!S_ISDIR(inode->i_mode)) |
536 | goto out_putf; | 547 | goto out_putf; |
537 | 548 | ||
538 | error = file_permission(file, MAY_EXEC); | 549 | error = inode_permission(inode, MAY_EXEC | MAY_ACCESS); |
539 | if (!error) | 550 | if (!error) |
540 | set_fs_pwd(current->fs, &file->f_path); | 551 | set_fs_pwd(current->fs, &file->f_path); |
541 | out_putf: | 552 | out_putf: |
@@ -546,14 +557,14 @@ out: | |||
546 | 557 | ||
547 | asmlinkage long sys_chroot(const char __user * filename) | 558 | asmlinkage long sys_chroot(const char __user * filename) |
548 | { | 559 | { |
549 | struct nameidata nd; | 560 | struct path path; |
550 | int error; | 561 | int error; |
551 | 562 | ||
552 | error = __user_walk(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd); | 563 | error = user_path_dir(filename, &path); |
553 | if (error) | 564 | if (error) |
554 | goto out; | 565 | goto out; |
555 | 566 | ||
556 | error = vfs_permission(&nd, MAY_EXEC); | 567 | error = inode_permission(path.dentry->d_inode, MAY_EXEC | MAY_ACCESS); |
557 | if (error) | 568 | if (error) |
558 | goto dput_and_out; | 569 | goto dput_and_out; |
559 | 570 | ||
@@ -561,11 +572,10 @@ asmlinkage long sys_chroot(const char __user * filename) | |||
561 | if (!capable(CAP_SYS_CHROOT)) | 572 | if (!capable(CAP_SYS_CHROOT)) |
562 | goto dput_and_out; | 573 | goto dput_and_out; |
563 | 574 | ||
564 | set_fs_root(current->fs, &nd.path); | 575 | set_fs_root(current->fs, &path); |
565 | set_fs_altroot(); | ||
566 | error = 0; | 576 | error = 0; |
567 | dput_and_out: | 577 | dput_and_out: |
568 | path_put(&nd.path); | 578 | path_put(&path); |
569 | out: | 579 | out: |
570 | return error; | 580 | return error; |
571 | } | 581 | } |
@@ -590,9 +600,6 @@ asmlinkage long sys_fchmod(unsigned int fd, mode_t mode) | |||
590 | err = mnt_want_write(file->f_path.mnt); | 600 | err = mnt_want_write(file->f_path.mnt); |
591 | if (err) | 601 | if (err) |
592 | goto out_putf; | 602 | goto out_putf; |
593 | err = -EPERM; | ||
594 | if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) | ||
595 | goto out_drop_write; | ||
596 | mutex_lock(&inode->i_mutex); | 603 | mutex_lock(&inode->i_mutex); |
597 | if (mode == (mode_t) -1) | 604 | if (mode == (mode_t) -1) |
598 | mode = inode->i_mode; | 605 | mode = inode->i_mode; |
@@ -600,8 +607,6 @@ asmlinkage long sys_fchmod(unsigned int fd, mode_t mode) | |||
600 | newattrs.ia_valid = ATTR_MODE | ATTR_CTIME; | 607 | newattrs.ia_valid = ATTR_MODE | ATTR_CTIME; |
601 | err = notify_change(dentry, &newattrs); | 608 | err = notify_change(dentry, &newattrs); |
602 | mutex_unlock(&inode->i_mutex); | 609 | mutex_unlock(&inode->i_mutex); |
603 | |||
604 | out_drop_write: | ||
605 | mnt_drop_write(file->f_path.mnt); | 610 | mnt_drop_write(file->f_path.mnt); |
606 | out_putf: | 611 | out_putf: |
607 | fput(file); | 612 | fput(file); |
@@ -612,36 +617,29 @@ out: | |||
612 | asmlinkage long sys_fchmodat(int dfd, const char __user *filename, | 617 | asmlinkage long sys_fchmodat(int dfd, const char __user *filename, |
613 | mode_t mode) | 618 | mode_t mode) |
614 | { | 619 | { |
615 | struct nameidata nd; | 620 | struct path path; |
616 | struct inode * inode; | 621 | struct inode *inode; |
617 | int error; | 622 | int error; |
618 | struct iattr newattrs; | 623 | struct iattr newattrs; |
619 | 624 | ||
620 | error = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW, &nd); | 625 | error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path); |
621 | if (error) | 626 | if (error) |
622 | goto out; | 627 | goto out; |
623 | inode = nd.path.dentry->d_inode; | 628 | inode = path.dentry->d_inode; |
624 | 629 | ||
625 | error = mnt_want_write(nd.path.mnt); | 630 | error = mnt_want_write(path.mnt); |
626 | if (error) | 631 | if (error) |
627 | goto dput_and_out; | 632 | goto dput_and_out; |
628 | |||
629 | error = -EPERM; | ||
630 | if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) | ||
631 | goto out_drop_write; | ||
632 | |||
633 | mutex_lock(&inode->i_mutex); | 633 | mutex_lock(&inode->i_mutex); |
634 | if (mode == (mode_t) -1) | 634 | if (mode == (mode_t) -1) |
635 | mode = inode->i_mode; | 635 | mode = inode->i_mode; |
636 | newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO); | 636 | newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO); |
637 | newattrs.ia_valid = ATTR_MODE | ATTR_CTIME; | 637 | newattrs.ia_valid = ATTR_MODE | ATTR_CTIME; |
638 | error = notify_change(nd.path.dentry, &newattrs); | 638 | error = notify_change(path.dentry, &newattrs); |
639 | mutex_unlock(&inode->i_mutex); | 639 | mutex_unlock(&inode->i_mutex); |
640 | 640 | mnt_drop_write(path.mnt); | |
641 | out_drop_write: | ||
642 | mnt_drop_write(nd.path.mnt); | ||
643 | dput_and_out: | 641 | dput_and_out: |
644 | path_put(&nd.path); | 642 | path_put(&path); |
645 | out: | 643 | out: |
646 | return error; | 644 | return error; |
647 | } | 645 | } |
@@ -653,18 +651,10 @@ asmlinkage long sys_chmod(const char __user *filename, mode_t mode) | |||
653 | 651 | ||
654 | static int chown_common(struct dentry * dentry, uid_t user, gid_t group) | 652 | static int chown_common(struct dentry * dentry, uid_t user, gid_t group) |
655 | { | 653 | { |
656 | struct inode * inode; | 654 | struct inode *inode = dentry->d_inode; |
657 | int error; | 655 | int error; |
658 | struct iattr newattrs; | 656 | struct iattr newattrs; |
659 | 657 | ||
660 | error = -ENOENT; | ||
661 | if (!(inode = dentry->d_inode)) { | ||
662 | printk(KERN_ERR "chown_common: NULL inode\n"); | ||
663 | goto out; | ||
664 | } | ||
665 | error = -EPERM; | ||
666 | if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) | ||
667 | goto out; | ||
668 | newattrs.ia_valid = ATTR_CTIME; | 658 | newattrs.ia_valid = ATTR_CTIME; |
669 | if (user != (uid_t) -1) { | 659 | if (user != (uid_t) -1) { |
670 | newattrs.ia_valid |= ATTR_UID; | 660 | newattrs.ia_valid |= ATTR_UID; |
@@ -680,25 +670,25 @@ static int chown_common(struct dentry * dentry, uid_t user, gid_t group) | |||
680 | mutex_lock(&inode->i_mutex); | 670 | mutex_lock(&inode->i_mutex); |
681 | error = notify_change(dentry, &newattrs); | 671 | error = notify_change(dentry, &newattrs); |
682 | mutex_unlock(&inode->i_mutex); | 672 | mutex_unlock(&inode->i_mutex); |
683 | out: | 673 | |
684 | return error; | 674 | return error; |
685 | } | 675 | } |
686 | 676 | ||
687 | asmlinkage long sys_chown(const char __user * filename, uid_t user, gid_t group) | 677 | asmlinkage long sys_chown(const char __user * filename, uid_t user, gid_t group) |
688 | { | 678 | { |
689 | struct nameidata nd; | 679 | struct path path; |
690 | int error; | 680 | int error; |
691 | 681 | ||
692 | error = user_path_walk(filename, &nd); | 682 | error = user_path(filename, &path); |
693 | if (error) | 683 | if (error) |
694 | goto out; | 684 | goto out; |
695 | error = mnt_want_write(nd.path.mnt); | 685 | error = mnt_want_write(path.mnt); |
696 | if (error) | 686 | if (error) |
697 | goto out_release; | 687 | goto out_release; |
698 | error = chown_common(nd.path.dentry, user, group); | 688 | error = chown_common(path.dentry, user, group); |
699 | mnt_drop_write(nd.path.mnt); | 689 | mnt_drop_write(path.mnt); |
700 | out_release: | 690 | out_release: |
701 | path_put(&nd.path); | 691 | path_put(&path); |
702 | out: | 692 | out: |
703 | return error; | 693 | return error; |
704 | } | 694 | } |
@@ -706,7 +696,7 @@ out: | |||
706 | asmlinkage long sys_fchownat(int dfd, const char __user *filename, uid_t user, | 696 | asmlinkage long sys_fchownat(int dfd, const char __user *filename, uid_t user, |
707 | gid_t group, int flag) | 697 | gid_t group, int flag) |
708 | { | 698 | { |
709 | struct nameidata nd; | 699 | struct path path; |
710 | int error = -EINVAL; | 700 | int error = -EINVAL; |
711 | int follow; | 701 | int follow; |
712 | 702 | ||
@@ -714,35 +704,35 @@ asmlinkage long sys_fchownat(int dfd, const char __user *filename, uid_t user, | |||
714 | goto out; | 704 | goto out; |
715 | 705 | ||
716 | follow = (flag & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW; | 706 | follow = (flag & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW; |
717 | error = __user_walk_fd(dfd, filename, follow, &nd); | 707 | error = user_path_at(dfd, filename, follow, &path); |
718 | if (error) | 708 | if (error) |
719 | goto out; | 709 | goto out; |
720 | error = mnt_want_write(nd.path.mnt); | 710 | error = mnt_want_write(path.mnt); |
721 | if (error) | 711 | if (error) |
722 | goto out_release; | 712 | goto out_release; |
723 | error = chown_common(nd.path.dentry, user, group); | 713 | error = chown_common(path.dentry, user, group); |
724 | mnt_drop_write(nd.path.mnt); | 714 | mnt_drop_write(path.mnt); |
725 | out_release: | 715 | out_release: |
726 | path_put(&nd.path); | 716 | path_put(&path); |
727 | out: | 717 | out: |
728 | return error; | 718 | return error; |
729 | } | 719 | } |
730 | 720 | ||
731 | asmlinkage long sys_lchown(const char __user * filename, uid_t user, gid_t group) | 721 | asmlinkage long sys_lchown(const char __user * filename, uid_t user, gid_t group) |
732 | { | 722 | { |
733 | struct nameidata nd; | 723 | struct path path; |
734 | int error; | 724 | int error; |
735 | 725 | ||
736 | error = user_path_walk_link(filename, &nd); | 726 | error = user_lpath(filename, &path); |
737 | if (error) | 727 | if (error) |
738 | goto out; | 728 | goto out; |
739 | error = mnt_want_write(nd.path.mnt); | 729 | error = mnt_want_write(path.mnt); |
740 | if (error) | 730 | if (error) |
741 | goto out_release; | 731 | goto out_release; |
742 | error = chown_common(nd.path.dentry, user, group); | 732 | error = chown_common(path.dentry, user, group); |
743 | mnt_drop_write(nd.path.mnt); | 733 | mnt_drop_write(path.mnt); |
744 | out_release: | 734 | out_release: |
745 | path_put(&nd.path); | 735 | path_put(&path); |
746 | out: | 736 | out: |
747 | return error; | 737 | return error; |
748 | } | 738 | } |
@@ -982,7 +972,6 @@ int get_unused_fd_flags(int flags) | |||
982 | int fd, error; | 972 | int fd, error; |
983 | struct fdtable *fdt; | 973 | struct fdtable *fdt; |
984 | 974 | ||
985 | error = -EMFILE; | ||
986 | spin_lock(&files->file_lock); | 975 | spin_lock(&files->file_lock); |
987 | 976 | ||
988 | repeat: | 977 | repeat: |
@@ -990,13 +979,6 @@ repeat: | |||
990 | fd = find_next_zero_bit(fdt->open_fds->fds_bits, fdt->max_fds, | 979 | fd = find_next_zero_bit(fdt->open_fds->fds_bits, fdt->max_fds, |
991 | files->next_fd); | 980 | files->next_fd); |
992 | 981 | ||
993 | /* | ||
994 | * N.B. For clone tasks sharing a files structure, this test | ||
995 | * will limit the total number of files that can be opened. | ||
996 | */ | ||
997 | if (fd >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur) | ||
998 | goto out; | ||
999 | |||
1000 | /* Do we need to expand the fd array or fd set? */ | 982 | /* Do we need to expand the fd array or fd set? */ |
1001 | error = expand_files(files, fd); | 983 | error = expand_files(files, fd); |
1002 | if (error < 0) | 984 | if (error < 0) |
@@ -1007,7 +989,6 @@ repeat: | |||
1007 | * If we needed to expand the fs array we | 989 | * If we needed to expand the fs array we |
1008 | * might have blocked - try again. | 990 | * might have blocked - try again. |
1009 | */ | 991 | */ |
1010 | error = -EMFILE; | ||
1011 | goto repeat; | 992 | goto repeat; |
1012 | } | 993 | } |
1013 | 994 | ||
diff --git a/fs/openpromfs/inode.c b/fs/openpromfs/inode.c index d17b4fd204e1..9f5b054f06b9 100644 --- a/fs/openpromfs/inode.c +++ b/fs/openpromfs/inode.c | |||
@@ -430,7 +430,7 @@ static struct file_system_type openprom_fs_type = { | |||
430 | .kill_sb = kill_anon_super, | 430 | .kill_sb = kill_anon_super, |
431 | }; | 431 | }; |
432 | 432 | ||
433 | static void op_inode_init_once(struct kmem_cache * cachep, void *data) | 433 | static void op_inode_init_once(void *data) |
434 | { | 434 | { |
435 | struct op_inode_info *oi = (struct op_inode_info *) data; | 435 | struct op_inode_info *oi = (struct op_inode_info *) data; |
436 | 436 | ||
@@ -777,45 +777,10 @@ pipe_rdwr_open(struct inode *inode, struct file *filp) | |||
777 | /* | 777 | /* |
778 | * The file_operations structs are not static because they | 778 | * The file_operations structs are not static because they |
779 | * are also used in linux/fs/fifo.c to do operations on FIFOs. | 779 | * are also used in linux/fs/fifo.c to do operations on FIFOs. |
780 | * | ||
781 | * Pipes reuse fifos' file_operations structs. | ||
780 | */ | 782 | */ |
781 | const struct file_operations read_fifo_fops = { | 783 | const struct file_operations read_pipefifo_fops = { |
782 | .llseek = no_llseek, | ||
783 | .read = do_sync_read, | ||
784 | .aio_read = pipe_read, | ||
785 | .write = bad_pipe_w, | ||
786 | .poll = pipe_poll, | ||
787 | .unlocked_ioctl = pipe_ioctl, | ||
788 | .open = pipe_read_open, | ||
789 | .release = pipe_read_release, | ||
790 | .fasync = pipe_read_fasync, | ||
791 | }; | ||
792 | |||
793 | const struct file_operations write_fifo_fops = { | ||
794 | .llseek = no_llseek, | ||
795 | .read = bad_pipe_r, | ||
796 | .write = do_sync_write, | ||
797 | .aio_write = pipe_write, | ||
798 | .poll = pipe_poll, | ||
799 | .unlocked_ioctl = pipe_ioctl, | ||
800 | .open = pipe_write_open, | ||
801 | .release = pipe_write_release, | ||
802 | .fasync = pipe_write_fasync, | ||
803 | }; | ||
804 | |||
805 | const struct file_operations rdwr_fifo_fops = { | ||
806 | .llseek = no_llseek, | ||
807 | .read = do_sync_read, | ||
808 | .aio_read = pipe_read, | ||
809 | .write = do_sync_write, | ||
810 | .aio_write = pipe_write, | ||
811 | .poll = pipe_poll, | ||
812 | .unlocked_ioctl = pipe_ioctl, | ||
813 | .open = pipe_rdwr_open, | ||
814 | .release = pipe_rdwr_release, | ||
815 | .fasync = pipe_rdwr_fasync, | ||
816 | }; | ||
817 | |||
818 | static const struct file_operations read_pipe_fops = { | ||
819 | .llseek = no_llseek, | 784 | .llseek = no_llseek, |
820 | .read = do_sync_read, | 785 | .read = do_sync_read, |
821 | .aio_read = pipe_read, | 786 | .aio_read = pipe_read, |
@@ -827,7 +792,7 @@ static const struct file_operations read_pipe_fops = { | |||
827 | .fasync = pipe_read_fasync, | 792 | .fasync = pipe_read_fasync, |
828 | }; | 793 | }; |
829 | 794 | ||
830 | static const struct file_operations write_pipe_fops = { | 795 | const struct file_operations write_pipefifo_fops = { |
831 | .llseek = no_llseek, | 796 | .llseek = no_llseek, |
832 | .read = bad_pipe_r, | 797 | .read = bad_pipe_r, |
833 | .write = do_sync_write, | 798 | .write = do_sync_write, |
@@ -839,7 +804,7 @@ static const struct file_operations write_pipe_fops = { | |||
839 | .fasync = pipe_write_fasync, | 804 | .fasync = pipe_write_fasync, |
840 | }; | 805 | }; |
841 | 806 | ||
842 | static const struct file_operations rdwr_pipe_fops = { | 807 | const struct file_operations rdwr_pipefifo_fops = { |
843 | .llseek = no_llseek, | 808 | .llseek = no_llseek, |
844 | .read = do_sync_read, | 809 | .read = do_sync_read, |
845 | .aio_read = pipe_read, | 810 | .aio_read = pipe_read, |
@@ -927,7 +892,7 @@ static struct inode * get_pipe_inode(void) | |||
927 | inode->i_pipe = pipe; | 892 | inode->i_pipe = pipe; |
928 | 893 | ||
929 | pipe->readers = pipe->writers = 1; | 894 | pipe->readers = pipe->writers = 1; |
930 | inode->i_fop = &rdwr_pipe_fops; | 895 | inode->i_fop = &rdwr_pipefifo_fops; |
931 | 896 | ||
932 | /* | 897 | /* |
933 | * Mark the inode dirty from the very beginning, | 898 | * Mark the inode dirty from the very beginning, |
@@ -978,7 +943,7 @@ struct file *create_write_pipe(int flags) | |||
978 | d_instantiate(dentry, inode); | 943 | d_instantiate(dentry, inode); |
979 | 944 | ||
980 | err = -ENFILE; | 945 | err = -ENFILE; |
981 | f = alloc_file(pipe_mnt, dentry, FMODE_WRITE, &write_pipe_fops); | 946 | f = alloc_file(pipe_mnt, dentry, FMODE_WRITE, &write_pipefifo_fops); |
982 | if (!f) | 947 | if (!f) |
983 | goto err_dentry; | 948 | goto err_dentry; |
984 | f->f_mapping = inode->i_mapping; | 949 | f->f_mapping = inode->i_mapping; |
@@ -1020,7 +985,7 @@ struct file *create_read_pipe(struct file *wrf, int flags) | |||
1020 | 985 | ||
1021 | f->f_pos = 0; | 986 | f->f_pos = 0; |
1022 | f->f_flags = O_RDONLY | (flags & O_NONBLOCK); | 987 | f->f_flags = O_RDONLY | (flags & O_NONBLOCK); |
1023 | f->f_op = &read_pipe_fops; | 988 | f->f_op = &read_pipefifo_fops; |
1024 | f->f_mode = FMODE_READ; | 989 | f->f_mode = FMODE_READ; |
1025 | f->f_version = 0; | 990 | f->f_version = 0; |
1026 | 991 | ||
diff --git a/fs/proc/array.c b/fs/proc/array.c index 797d775e0354..0d6eb33597c6 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c | |||
@@ -80,6 +80,7 @@ | |||
80 | #include <linux/delayacct.h> | 80 | #include <linux/delayacct.h> |
81 | #include <linux/seq_file.h> | 81 | #include <linux/seq_file.h> |
82 | #include <linux/pid_namespace.h> | 82 | #include <linux/pid_namespace.h> |
83 | #include <linux/tracehook.h> | ||
83 | 84 | ||
84 | #include <asm/pgtable.h> | 85 | #include <asm/pgtable.h> |
85 | #include <asm/processor.h> | 86 | #include <asm/processor.h> |
@@ -168,8 +169,12 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns, | |||
168 | rcu_read_lock(); | 169 | rcu_read_lock(); |
169 | ppid = pid_alive(p) ? | 170 | ppid = pid_alive(p) ? |
170 | task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0; | 171 | task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0; |
171 | tpid = pid_alive(p) && p->ptrace ? | 172 | tpid = 0; |
172 | task_pid_nr_ns(rcu_dereference(p->parent), ns) : 0; | 173 | if (pid_alive(p)) { |
174 | struct task_struct *tracer = tracehook_tracer_task(p); | ||
175 | if (tracer) | ||
176 | tpid = task_pid_nr_ns(tracer, ns); | ||
177 | } | ||
173 | seq_printf(m, | 178 | seq_printf(m, |
174 | "State:\t%s\n" | 179 | "State:\t%s\n" |
175 | "Tgid:\t%d\n" | 180 | "Tgid:\t%d\n" |
diff --git a/fs/proc/base.c b/fs/proc/base.c index a891fe4cb43b..01ed610f9b87 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -53,6 +53,7 @@ | |||
53 | #include <linux/time.h> | 53 | #include <linux/time.h> |
54 | #include <linux/proc_fs.h> | 54 | #include <linux/proc_fs.h> |
55 | #include <linux/stat.h> | 55 | #include <linux/stat.h> |
56 | #include <linux/task_io_accounting_ops.h> | ||
56 | #include <linux/init.h> | 57 | #include <linux/init.h> |
57 | #include <linux/capability.h> | 58 | #include <linux/capability.h> |
58 | #include <linux/file.h> | 59 | #include <linux/file.h> |
@@ -69,6 +70,7 @@ | |||
69 | #include <linux/mount.h> | 70 | #include <linux/mount.h> |
70 | #include <linux/security.h> | 71 | #include <linux/security.h> |
71 | #include <linux/ptrace.h> | 72 | #include <linux/ptrace.h> |
73 | #include <linux/tracehook.h> | ||
72 | #include <linux/cgroup.h> | 74 | #include <linux/cgroup.h> |
73 | #include <linux/cpuset.h> | 75 | #include <linux/cpuset.h> |
74 | #include <linux/audit.h> | 76 | #include <linux/audit.h> |
@@ -231,10 +233,14 @@ static int check_mem_permission(struct task_struct *task) | |||
231 | * If current is actively ptrace'ing, and would also be | 233 | * If current is actively ptrace'ing, and would also be |
232 | * permitted to freshly attach with ptrace now, permit it. | 234 | * permitted to freshly attach with ptrace now, permit it. |
233 | */ | 235 | */ |
234 | if (task->parent == current && (task->ptrace & PT_PTRACED) && | 236 | if (task_is_stopped_or_traced(task)) { |
235 | task_is_stopped_or_traced(task) && | 237 | int match; |
236 | ptrace_may_access(task, PTRACE_MODE_ATTACH)) | 238 | rcu_read_lock(); |
237 | return 0; | 239 | match = (tracehook_tracer_task(task) == current); |
240 | rcu_read_unlock(); | ||
241 | if (match && ptrace_may_access(task, PTRACE_MODE_ATTACH)) | ||
242 | return 0; | ||
243 | } | ||
238 | 244 | ||
239 | /* | 245 | /* |
240 | * Noone else is allowed. | 246 | * Noone else is allowed. |
@@ -504,6 +510,26 @@ static int proc_pid_limits(struct task_struct *task, char *buffer) | |||
504 | return count; | 510 | return count; |
505 | } | 511 | } |
506 | 512 | ||
513 | #ifdef CONFIG_HAVE_ARCH_TRACEHOOK | ||
514 | static int proc_pid_syscall(struct task_struct *task, char *buffer) | ||
515 | { | ||
516 | long nr; | ||
517 | unsigned long args[6], sp, pc; | ||
518 | |||
519 | if (task_current_syscall(task, &nr, args, 6, &sp, &pc)) | ||
520 | return sprintf(buffer, "running\n"); | ||
521 | |||
522 | if (nr < 0) | ||
523 | return sprintf(buffer, "%ld 0x%lx 0x%lx\n", nr, sp, pc); | ||
524 | |||
525 | return sprintf(buffer, | ||
526 | "%ld 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx\n", | ||
527 | nr, | ||
528 | args[0], args[1], args[2], args[3], args[4], args[5], | ||
529 | sp, pc); | ||
530 | } | ||
531 | #endif /* CONFIG_HAVE_ARCH_TRACEHOOK */ | ||
532 | |||
507 | /************************************************************************/ | 533 | /************************************************************************/ |
508 | /* Here the fs part begins */ | 534 | /* Here the fs part begins */ |
509 | /************************************************************************/ | 535 | /************************************************************************/ |
@@ -1834,8 +1860,7 @@ static const struct file_operations proc_fd_operations = { | |||
1834 | * /proc/pid/fd needs a special permission handler so that a process can still | 1860 | * /proc/pid/fd needs a special permission handler so that a process can still |
1835 | * access /proc/self/fd after it has executed a setuid(). | 1861 | * access /proc/self/fd after it has executed a setuid(). |
1836 | */ | 1862 | */ |
1837 | static int proc_fd_permission(struct inode *inode, int mask, | 1863 | static int proc_fd_permission(struct inode *inode, int mask) |
1838 | struct nameidata *nd) | ||
1839 | { | 1864 | { |
1840 | int rv; | 1865 | int rv; |
1841 | 1866 | ||
@@ -2378,53 +2403,18 @@ static int proc_base_fill_cache(struct file *filp, void *dirent, | |||
2378 | #ifdef CONFIG_TASK_IO_ACCOUNTING | 2403 | #ifdef CONFIG_TASK_IO_ACCOUNTING |
2379 | static int do_io_accounting(struct task_struct *task, char *buffer, int whole) | 2404 | static int do_io_accounting(struct task_struct *task, char *buffer, int whole) |
2380 | { | 2405 | { |
2381 | u64 rchar, wchar, syscr, syscw; | 2406 | struct task_io_accounting acct = task->ioac; |
2382 | struct task_io_accounting ioac; | 2407 | unsigned long flags; |
2383 | |||
2384 | if (!whole) { | ||
2385 | rchar = task->rchar; | ||
2386 | wchar = task->wchar; | ||
2387 | syscr = task->syscr; | ||
2388 | syscw = task->syscw; | ||
2389 | memcpy(&ioac, &task->ioac, sizeof(ioac)); | ||
2390 | } else { | ||
2391 | unsigned long flags; | ||
2392 | struct task_struct *t = task; | ||
2393 | rchar = wchar = syscr = syscw = 0; | ||
2394 | memset(&ioac, 0, sizeof(ioac)); | ||
2395 | |||
2396 | rcu_read_lock(); | ||
2397 | do { | ||
2398 | rchar += t->rchar; | ||
2399 | wchar += t->wchar; | ||
2400 | syscr += t->syscr; | ||
2401 | syscw += t->syscw; | ||
2402 | |||
2403 | ioac.read_bytes += t->ioac.read_bytes; | ||
2404 | ioac.write_bytes += t->ioac.write_bytes; | ||
2405 | ioac.cancelled_write_bytes += | ||
2406 | t->ioac.cancelled_write_bytes; | ||
2407 | t = next_thread(t); | ||
2408 | } while (t != task); | ||
2409 | rcu_read_unlock(); | ||
2410 | |||
2411 | if (lock_task_sighand(task, &flags)) { | ||
2412 | struct signal_struct *sig = task->signal; | ||
2413 | 2408 | ||
2414 | rchar += sig->rchar; | 2409 | if (whole && lock_task_sighand(task, &flags)) { |
2415 | wchar += sig->wchar; | 2410 | struct task_struct *t = task; |
2416 | syscr += sig->syscr; | ||
2417 | syscw += sig->syscw; | ||
2418 | 2411 | ||
2419 | ioac.read_bytes += sig->ioac.read_bytes; | 2412 | task_io_accounting_add(&acct, &task->signal->ioac); |
2420 | ioac.write_bytes += sig->ioac.write_bytes; | 2413 | while_each_thread(task, t) |
2421 | ioac.cancelled_write_bytes += | 2414 | task_io_accounting_add(&acct, &t->ioac); |
2422 | sig->ioac.cancelled_write_bytes; | ||
2423 | 2415 | ||
2424 | unlock_task_sighand(task, &flags); | 2416 | unlock_task_sighand(task, &flags); |
2425 | } | ||
2426 | } | 2417 | } |
2427 | |||
2428 | return sprintf(buffer, | 2418 | return sprintf(buffer, |
2429 | "rchar: %llu\n" | 2419 | "rchar: %llu\n" |
2430 | "wchar: %llu\n" | 2420 | "wchar: %llu\n" |
@@ -2433,13 +2423,10 @@ static int do_io_accounting(struct task_struct *task, char *buffer, int whole) | |||
2433 | "read_bytes: %llu\n" | 2423 | "read_bytes: %llu\n" |
2434 | "write_bytes: %llu\n" | 2424 | "write_bytes: %llu\n" |
2435 | "cancelled_write_bytes: %llu\n", | 2425 | "cancelled_write_bytes: %llu\n", |
2436 | (unsigned long long)rchar, | 2426 | acct.rchar, acct.wchar, |
2437 | (unsigned long long)wchar, | 2427 | acct.syscr, acct.syscw, |
2438 | (unsigned long long)syscr, | 2428 | acct.read_bytes, acct.write_bytes, |
2439 | (unsigned long long)syscw, | 2429 | acct.cancelled_write_bytes); |
2440 | (unsigned long long)ioac.read_bytes, | ||
2441 | (unsigned long long)ioac.write_bytes, | ||
2442 | (unsigned long long)ioac.cancelled_write_bytes); | ||
2443 | } | 2430 | } |
2444 | 2431 | ||
2445 | static int proc_tid_io_accounting(struct task_struct *task, char *buffer) | 2432 | static int proc_tid_io_accounting(struct task_struct *task, char *buffer) |
@@ -2473,6 +2460,9 @@ static const struct pid_entry tgid_base_stuff[] = { | |||
2473 | #ifdef CONFIG_SCHED_DEBUG | 2460 | #ifdef CONFIG_SCHED_DEBUG |
2474 | REG("sched", S_IRUGO|S_IWUSR, pid_sched), | 2461 | REG("sched", S_IRUGO|S_IWUSR, pid_sched), |
2475 | #endif | 2462 | #endif |
2463 | #ifdef CONFIG_HAVE_ARCH_TRACEHOOK | ||
2464 | INF("syscall", S_IRUSR, pid_syscall), | ||
2465 | #endif | ||
2476 | INF("cmdline", S_IRUGO, pid_cmdline), | 2466 | INF("cmdline", S_IRUGO, pid_cmdline), |
2477 | ONE("stat", S_IRUGO, tgid_stat), | 2467 | ONE("stat", S_IRUGO, tgid_stat), |
2478 | ONE("statm", S_IRUGO, pid_statm), | 2468 | ONE("statm", S_IRUGO, pid_statm), |
@@ -2805,6 +2795,9 @@ static const struct pid_entry tid_base_stuff[] = { | |||
2805 | #ifdef CONFIG_SCHED_DEBUG | 2795 | #ifdef CONFIG_SCHED_DEBUG |
2806 | REG("sched", S_IRUGO|S_IWUSR, pid_sched), | 2796 | REG("sched", S_IRUGO|S_IWUSR, pid_sched), |
2807 | #endif | 2797 | #endif |
2798 | #ifdef CONFIG_HAVE_ARCH_TRACEHOOK | ||
2799 | INF("syscall", S_IRUSR, pid_syscall), | ||
2800 | #endif | ||
2808 | INF("cmdline", S_IRUGO, pid_cmdline), | 2801 | INF("cmdline", S_IRUGO, pid_cmdline), |
2809 | ONE("stat", S_IRUGO, tid_stat), | 2802 | ONE("stat", S_IRUGO, tid_stat), |
2810 | ONE("statm", S_IRUGO, pid_statm), | 2803 | ONE("statm", S_IRUGO, pid_statm), |
diff --git a/fs/proc/generic.c b/fs/proc/generic.c index bc0a0dd2d844..cb4096cc3fb7 100644 --- a/fs/proc/generic.c +++ b/fs/proc/generic.c | |||
@@ -806,12 +806,9 @@ continue_removing: | |||
806 | if (S_ISDIR(de->mode)) | 806 | if (S_ISDIR(de->mode)) |
807 | parent->nlink--; | 807 | parent->nlink--; |
808 | de->nlink = 0; | 808 | de->nlink = 0; |
809 | if (de->subdir) { | 809 | WARN(de->subdir, KERN_WARNING "%s: removing non-empty directory " |
810 | printk(KERN_WARNING "%s: removing non-empty directory " | ||
811 | "'%s/%s', leaking at least '%s'\n", __func__, | 810 | "'%s/%s', leaking at least '%s'\n", __func__, |
812 | de->parent->name, de->name, de->subdir->name); | 811 | de->parent->name, de->name, de->subdir->name); |
813 | WARN_ON(1); | ||
814 | } | ||
815 | if (atomic_dec_and_test(&de->count)) | 812 | if (atomic_dec_and_test(&de->count)) |
816 | free_proc_entry(de); | 813 | free_proc_entry(de); |
817 | } | 814 | } |
diff --git a/fs/proc/inode.c b/fs/proc/inode.c index 02eca2ed9dd7..8bb03f056c28 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
19 | #include <linux/smp_lock.h> | 19 | #include <linux/smp_lock.h> |
20 | #include <linux/sysctl.h> | ||
20 | 21 | ||
21 | #include <asm/system.h> | 22 | #include <asm/system.h> |
22 | #include <asm/uaccess.h> | 23 | #include <asm/uaccess.h> |
@@ -65,6 +66,8 @@ static void proc_delete_inode(struct inode *inode) | |||
65 | module_put(de->owner); | 66 | module_put(de->owner); |
66 | de_put(de); | 67 | de_put(de); |
67 | } | 68 | } |
69 | if (PROC_I(inode)->sysctl) | ||
70 | sysctl_head_put(PROC_I(inode)->sysctl); | ||
68 | clear_inode(inode); | 71 | clear_inode(inode); |
69 | } | 72 | } |
70 | 73 | ||
@@ -84,6 +87,8 @@ static struct inode *proc_alloc_inode(struct super_block *sb) | |||
84 | ei->fd = 0; | 87 | ei->fd = 0; |
85 | ei->op.proc_get_link = NULL; | 88 | ei->op.proc_get_link = NULL; |
86 | ei->pde = NULL; | 89 | ei->pde = NULL; |
90 | ei->sysctl = NULL; | ||
91 | ei->sysctl_entry = NULL; | ||
87 | inode = &ei->vfs_inode; | 92 | inode = &ei->vfs_inode; |
88 | inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; | 93 | inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; |
89 | return inode; | 94 | return inode; |
@@ -94,7 +99,7 @@ static void proc_destroy_inode(struct inode *inode) | |||
94 | kmem_cache_free(proc_inode_cachep, PROC_I(inode)); | 99 | kmem_cache_free(proc_inode_cachep, PROC_I(inode)); |
95 | } | 100 | } |
96 | 101 | ||
97 | static void init_once(struct kmem_cache * cachep, void *foo) | 102 | static void init_once(void *foo) |
98 | { | 103 | { |
99 | struct proc_inode *ei = (struct proc_inode *) foo; | 104 | struct proc_inode *ei = (struct proc_inode *) foo; |
100 | 105 | ||
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index 5acc001d49f6..f9a8b892718f 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c | |||
@@ -10,149 +10,110 @@ | |||
10 | static struct dentry_operations proc_sys_dentry_operations; | 10 | static struct dentry_operations proc_sys_dentry_operations; |
11 | static const struct file_operations proc_sys_file_operations; | 11 | static const struct file_operations proc_sys_file_operations; |
12 | static const struct inode_operations proc_sys_inode_operations; | 12 | static const struct inode_operations proc_sys_inode_operations; |
13 | static const struct file_operations proc_sys_dir_file_operations; | ||
14 | static const struct inode_operations proc_sys_dir_operations; | ||
13 | 15 | ||
14 | static void proc_sys_refresh_inode(struct inode *inode, struct ctl_table *table) | 16 | static struct inode *proc_sys_make_inode(struct super_block *sb, |
15 | { | 17 | struct ctl_table_header *head, struct ctl_table *table) |
16 | /* Refresh the cached information bits in the inode */ | ||
17 | if (table) { | ||
18 | inode->i_uid = 0; | ||
19 | inode->i_gid = 0; | ||
20 | inode->i_mode = table->mode; | ||
21 | if (table->proc_handler) { | ||
22 | inode->i_mode |= S_IFREG; | ||
23 | inode->i_nlink = 1; | ||
24 | } else { | ||
25 | inode->i_mode |= S_IFDIR; | ||
26 | inode->i_nlink = 0; /* It is too hard to figure out */ | ||
27 | } | ||
28 | } | ||
29 | } | ||
30 | |||
31 | static struct inode *proc_sys_make_inode(struct inode *dir, struct ctl_table *table) | ||
32 | { | 18 | { |
33 | struct inode *inode; | 19 | struct inode *inode; |
34 | struct proc_inode *dir_ei, *ei; | 20 | struct proc_inode *ei; |
35 | int depth; | ||
36 | 21 | ||
37 | inode = new_inode(dir->i_sb); | 22 | inode = new_inode(sb); |
38 | if (!inode) | 23 | if (!inode) |
39 | goto out; | 24 | goto out; |
40 | 25 | ||
41 | /* A directory is always one deeper than it's parent */ | 26 | sysctl_head_get(head); |
42 | dir_ei = PROC_I(dir); | ||
43 | depth = dir_ei->fd + 1; | ||
44 | |||
45 | ei = PROC_I(inode); | 27 | ei = PROC_I(inode); |
46 | ei->fd = depth; | 28 | ei->sysctl = head; |
29 | ei->sysctl_entry = table; | ||
30 | |||
47 | inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; | 31 | inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; |
48 | inode->i_op = &proc_sys_inode_operations; | ||
49 | inode->i_fop = &proc_sys_file_operations; | ||
50 | inode->i_flags |= S_PRIVATE; /* tell selinux to ignore this inode */ | 32 | inode->i_flags |= S_PRIVATE; /* tell selinux to ignore this inode */ |
51 | proc_sys_refresh_inode(inode, table); | 33 | inode->i_mode = table->mode; |
34 | if (!table->child) { | ||
35 | inode->i_mode |= S_IFREG; | ||
36 | inode->i_op = &proc_sys_inode_operations; | ||
37 | inode->i_fop = &proc_sys_file_operations; | ||
38 | } else { | ||
39 | inode->i_mode |= S_IFDIR; | ||
40 | inode->i_nlink = 0; | ||
41 | inode->i_op = &proc_sys_dir_operations; | ||
42 | inode->i_fop = &proc_sys_dir_file_operations; | ||
43 | } | ||
52 | out: | 44 | out: |
53 | return inode; | 45 | return inode; |
54 | } | 46 | } |
55 | 47 | ||
56 | static struct dentry *proc_sys_ancestor(struct dentry *dentry, int depth) | 48 | static struct ctl_table *find_in_table(struct ctl_table *p, struct qstr *name) |
57 | { | ||
58 | for (;;) { | ||
59 | struct proc_inode *ei; | ||
60 | |||
61 | ei = PROC_I(dentry->d_inode); | ||
62 | if (ei->fd == depth) | ||
63 | break; /* found */ | ||
64 | |||
65 | dentry = dentry->d_parent; | ||
66 | } | ||
67 | return dentry; | ||
68 | } | ||
69 | |||
70 | static struct ctl_table *proc_sys_lookup_table_one(struct ctl_table *table, | ||
71 | struct qstr *name) | ||
72 | { | 49 | { |
73 | int len; | 50 | int len; |
74 | for ( ; table->ctl_name || table->procname; table++) { | 51 | for ( ; p->ctl_name || p->procname; p++) { |
75 | 52 | ||
76 | if (!table->procname) | 53 | if (!p->procname) |
77 | continue; | 54 | continue; |
78 | 55 | ||
79 | len = strlen(table->procname); | 56 | len = strlen(p->procname); |
80 | if (len != name->len) | 57 | if (len != name->len) |
81 | continue; | 58 | continue; |
82 | 59 | ||
83 | if (memcmp(table->procname, name->name, len) != 0) | 60 | if (memcmp(p->procname, name->name, len) != 0) |
84 | continue; | 61 | continue; |
85 | 62 | ||
86 | /* I have a match */ | 63 | /* I have a match */ |
87 | return table; | 64 | return p; |
88 | } | 65 | } |
89 | return NULL; | 66 | return NULL; |
90 | } | 67 | } |
91 | 68 | ||
92 | static struct ctl_table *proc_sys_lookup_table(struct dentry *dentry, | 69 | struct ctl_table_header *grab_header(struct inode *inode) |
93 | struct ctl_table *table) | ||
94 | { | 70 | { |
95 | struct dentry *ancestor; | 71 | if (PROC_I(inode)->sysctl) |
96 | struct proc_inode *ei; | 72 | return sysctl_head_grab(PROC_I(inode)->sysctl); |
97 | int depth, i; | 73 | else |
74 | return sysctl_head_next(NULL); | ||
75 | } | ||
98 | 76 | ||
99 | ei = PROC_I(dentry->d_inode); | 77 | static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry, |
100 | depth = ei->fd; | 78 | struct nameidata *nd) |
79 | { | ||
80 | struct ctl_table_header *head = grab_header(dir); | ||
81 | struct ctl_table *table = PROC_I(dir)->sysctl_entry; | ||
82 | struct ctl_table_header *h = NULL; | ||
83 | struct qstr *name = &dentry->d_name; | ||
84 | struct ctl_table *p; | ||
85 | struct inode *inode; | ||
86 | struct dentry *err = ERR_PTR(-ENOENT); | ||
101 | 87 | ||
102 | if (depth == 0) | 88 | if (IS_ERR(head)) |
103 | return table; | 89 | return ERR_CAST(head); |
104 | 90 | ||
105 | for (i = 1; table && (i <= depth); i++) { | 91 | if (table && !table->child) { |
106 | ancestor = proc_sys_ancestor(dentry, i); | 92 | WARN_ON(1); |
107 | table = proc_sys_lookup_table_one(table, &ancestor->d_name); | 93 | goto out; |
108 | if (table) | ||
109 | table = table->child; | ||
110 | } | 94 | } |
111 | return table; | ||
112 | |||
113 | } | ||
114 | static struct ctl_table *proc_sys_lookup_entry(struct dentry *dparent, | ||
115 | struct qstr *name, | ||
116 | struct ctl_table *table) | ||
117 | { | ||
118 | table = proc_sys_lookup_table(dparent, table); | ||
119 | if (table) | ||
120 | table = proc_sys_lookup_table_one(table, name); | ||
121 | return table; | ||
122 | } | ||
123 | 95 | ||
124 | static struct ctl_table *do_proc_sys_lookup(struct dentry *parent, | 96 | table = table ? table->child : head->ctl_table; |
125 | struct qstr *name, | ||
126 | struct ctl_table_header **ptr) | ||
127 | { | ||
128 | struct ctl_table_header *head; | ||
129 | struct ctl_table *table = NULL; | ||
130 | 97 | ||
131 | for (head = sysctl_head_next(NULL); head; | 98 | p = find_in_table(table, name); |
132 | head = sysctl_head_next(head)) { | 99 | if (!p) { |
133 | table = proc_sys_lookup_entry(parent, name, head->ctl_table); | 100 | for (h = sysctl_head_next(NULL); h; h = sysctl_head_next(h)) { |
134 | if (table) | 101 | if (h->attached_to != table) |
135 | break; | 102 | continue; |
103 | p = find_in_table(h->attached_by, name); | ||
104 | if (p) | ||
105 | break; | ||
106 | } | ||
136 | } | 107 | } |
137 | *ptr = head; | ||
138 | return table; | ||
139 | } | ||
140 | |||
141 | static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry, | ||
142 | struct nameidata *nd) | ||
143 | { | ||
144 | struct ctl_table_header *head; | ||
145 | struct inode *inode; | ||
146 | struct dentry *err; | ||
147 | struct ctl_table *table; | ||
148 | 108 | ||
149 | err = ERR_PTR(-ENOENT); | 109 | if (!p) |
150 | table = do_proc_sys_lookup(dentry->d_parent, &dentry->d_name, &head); | ||
151 | if (!table) | ||
152 | goto out; | 110 | goto out; |
153 | 111 | ||
154 | err = ERR_PTR(-ENOMEM); | 112 | err = ERR_PTR(-ENOMEM); |
155 | inode = proc_sys_make_inode(dir, table); | 113 | inode = proc_sys_make_inode(dir->i_sb, h ? h : head, p); |
114 | if (h) | ||
115 | sysctl_head_finish(h); | ||
116 | |||
156 | if (!inode) | 117 | if (!inode) |
157 | goto out; | 118 | goto out; |
158 | 119 | ||
@@ -168,22 +129,14 @@ out: | |||
168 | static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf, | 129 | static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf, |
169 | size_t count, loff_t *ppos, int write) | 130 | size_t count, loff_t *ppos, int write) |
170 | { | 131 | { |
171 | struct dentry *dentry = filp->f_dentry; | 132 | struct inode *inode = filp->f_path.dentry->d_inode; |
172 | struct ctl_table_header *head; | 133 | struct ctl_table_header *head = grab_header(inode); |
173 | struct ctl_table *table; | 134 | struct ctl_table *table = PROC_I(inode)->sysctl_entry; |
174 | ssize_t error; | 135 | ssize_t error; |
175 | size_t res; | 136 | size_t res; |
176 | 137 | ||
177 | table = do_proc_sys_lookup(dentry->d_parent, &dentry->d_name, &head); | 138 | if (IS_ERR(head)) |
178 | /* Has the sysctl entry disappeared on us? */ | 139 | return PTR_ERR(head); |
179 | error = -ENOENT; | ||
180 | if (!table) | ||
181 | goto out; | ||
182 | |||
183 | /* Has the sysctl entry been replaced by a directory? */ | ||
184 | error = -EISDIR; | ||
185 | if (!table->proc_handler) | ||
186 | goto out; | ||
187 | 140 | ||
188 | /* | 141 | /* |
189 | * At this point we know that the sysctl was not unregistered | 142 | * At this point we know that the sysctl was not unregistered |
@@ -193,6 +146,11 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf, | |||
193 | if (sysctl_perm(head->root, table, write ? MAY_WRITE : MAY_READ)) | 146 | if (sysctl_perm(head->root, table, write ? MAY_WRITE : MAY_READ)) |
194 | goto out; | 147 | goto out; |
195 | 148 | ||
149 | /* if that can happen at all, it should be -EINVAL, not -EISDIR */ | ||
150 | error = -EINVAL; | ||
151 | if (!table->proc_handler) | ||
152 | goto out; | ||
153 | |||
196 | /* careful: calling conventions are nasty here */ | 154 | /* careful: calling conventions are nasty here */ |
197 | res = count; | 155 | res = count; |
198 | error = table->proc_handler(table, write, filp, buf, &res, ppos); | 156 | error = table->proc_handler(table, write, filp, buf, &res, ppos); |
@@ -218,82 +176,86 @@ static ssize_t proc_sys_write(struct file *filp, const char __user *buf, | |||
218 | 176 | ||
219 | 177 | ||
220 | static int proc_sys_fill_cache(struct file *filp, void *dirent, | 178 | static int proc_sys_fill_cache(struct file *filp, void *dirent, |
221 | filldir_t filldir, struct ctl_table *table) | 179 | filldir_t filldir, |
180 | struct ctl_table_header *head, | ||
181 | struct ctl_table *table) | ||
222 | { | 182 | { |
223 | struct ctl_table_header *head; | ||
224 | struct ctl_table *child_table = NULL; | ||
225 | struct dentry *child, *dir = filp->f_path.dentry; | 183 | struct dentry *child, *dir = filp->f_path.dentry; |
226 | struct inode *inode; | 184 | struct inode *inode; |
227 | struct qstr qname; | 185 | struct qstr qname; |
228 | ino_t ino = 0; | 186 | ino_t ino = 0; |
229 | unsigned type = DT_UNKNOWN; | 187 | unsigned type = DT_UNKNOWN; |
230 | int ret; | ||
231 | 188 | ||
232 | qname.name = table->procname; | 189 | qname.name = table->procname; |
233 | qname.len = strlen(table->procname); | 190 | qname.len = strlen(table->procname); |
234 | qname.hash = full_name_hash(qname.name, qname.len); | 191 | qname.hash = full_name_hash(qname.name, qname.len); |
235 | 192 | ||
236 | /* Suppress duplicates. | ||
237 | * Only fill a directory entry if it is the value that | ||
238 | * an ordinary lookup of that name returns. Hide all | ||
239 | * others. | ||
240 | * | ||
241 | * If we ever cache this translation in the dcache | ||
242 | * I should do a dcache lookup first. But for now | ||
243 | * it is just simpler not to. | ||
244 | */ | ||
245 | ret = 0; | ||
246 | child_table = do_proc_sys_lookup(dir, &qname, &head); | ||
247 | sysctl_head_finish(head); | ||
248 | if (child_table != table) | ||
249 | return 0; | ||
250 | |||
251 | child = d_lookup(dir, &qname); | 193 | child = d_lookup(dir, &qname); |
252 | if (!child) { | 194 | if (!child) { |
253 | struct dentry *new; | 195 | child = d_alloc(dir, &qname); |
254 | new = d_alloc(dir, &qname); | 196 | if (child) { |
255 | if (new) { | 197 | inode = proc_sys_make_inode(dir->d_sb, head, table); |
256 | inode = proc_sys_make_inode(dir->d_inode, table); | 198 | if (!inode) { |
257 | if (!inode) | 199 | dput(child); |
258 | child = ERR_PTR(-ENOMEM); | 200 | return -ENOMEM; |
259 | else { | 201 | } else { |
260 | new->d_op = &proc_sys_dentry_operations; | 202 | child->d_op = &proc_sys_dentry_operations; |
261 | d_add(new, inode); | 203 | d_add(child, inode); |
262 | } | 204 | } |
263 | if (child) | 205 | } else { |
264 | dput(new); | 206 | return -ENOMEM; |
265 | else | ||
266 | child = new; | ||
267 | } | 207 | } |
268 | } | 208 | } |
269 | if (!child || IS_ERR(child) || !child->d_inode) | ||
270 | goto end_instantiate; | ||
271 | inode = child->d_inode; | 209 | inode = child->d_inode; |
272 | if (inode) { | 210 | ino = inode->i_ino; |
273 | ino = inode->i_ino; | 211 | type = inode->i_mode >> 12; |
274 | type = inode->i_mode >> 12; | ||
275 | } | ||
276 | dput(child); | 212 | dput(child); |
277 | end_instantiate: | 213 | return !!filldir(dirent, qname.name, qname.len, filp->f_pos, ino, type); |
278 | if (!ino) | 214 | } |
279 | ino= find_inode_number(dir, &qname); | 215 | |
280 | if (!ino) | 216 | static int scan(struct ctl_table_header *head, ctl_table *table, |
281 | ino = 1; | 217 | unsigned long *pos, struct file *file, |
282 | return filldir(dirent, qname.name, qname.len, filp->f_pos, ino, type); | 218 | void *dirent, filldir_t filldir) |
219 | { | ||
220 | |||
221 | for (; table->ctl_name || table->procname; table++, (*pos)++) { | ||
222 | int res; | ||
223 | |||
224 | /* Can't do anything without a proc name */ | ||
225 | if (!table->procname) | ||
226 | continue; | ||
227 | |||
228 | if (*pos < file->f_pos) | ||
229 | continue; | ||
230 | |||
231 | res = proc_sys_fill_cache(file, dirent, filldir, head, table); | ||
232 | if (res) | ||
233 | return res; | ||
234 | |||
235 | file->f_pos = *pos + 1; | ||
236 | } | ||
237 | return 0; | ||
283 | } | 238 | } |
284 | 239 | ||
285 | static int proc_sys_readdir(struct file *filp, void *dirent, filldir_t filldir) | 240 | static int proc_sys_readdir(struct file *filp, void *dirent, filldir_t filldir) |
286 | { | 241 | { |
287 | struct dentry *dentry = filp->f_dentry; | 242 | struct dentry *dentry = filp->f_path.dentry; |
288 | struct inode *inode = dentry->d_inode; | 243 | struct inode *inode = dentry->d_inode; |
289 | struct ctl_table_header *head = NULL; | 244 | struct ctl_table_header *head = grab_header(inode); |
290 | struct ctl_table *table; | 245 | struct ctl_table *table = PROC_I(inode)->sysctl_entry; |
246 | struct ctl_table_header *h = NULL; | ||
291 | unsigned long pos; | 247 | unsigned long pos; |
292 | int ret; | 248 | int ret = -EINVAL; |
249 | |||
250 | if (IS_ERR(head)) | ||
251 | return PTR_ERR(head); | ||
293 | 252 | ||
294 | ret = -ENOTDIR; | 253 | if (table && !table->child) { |
295 | if (!S_ISDIR(inode->i_mode)) | 254 | WARN_ON(1); |
296 | goto out; | 255 | goto out; |
256 | } | ||
257 | |||
258 | table = table ? table->child : head->ctl_table; | ||
297 | 259 | ||
298 | ret = 0; | 260 | ret = 0; |
299 | /* Avoid a switch here: arm builds fail with missing __cmpdi2 */ | 261 | /* Avoid a switch here: arm builds fail with missing __cmpdi2 */ |
@@ -311,30 +273,17 @@ static int proc_sys_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
311 | } | 273 | } |
312 | pos = 2; | 274 | pos = 2; |
313 | 275 | ||
314 | /* - Find each instance of the directory | 276 | ret = scan(head, table, &pos, filp, dirent, filldir); |
315 | * - Read all entries in each instance | 277 | if (ret) |
316 | * - Before returning an entry to user space lookup the entry | 278 | goto out; |
317 | * by name and if I find a different entry don't return | ||
318 | * this one because it means it is a buried dup. | ||
319 | * For sysctl this should only happen for directory entries. | ||
320 | */ | ||
321 | for (head = sysctl_head_next(NULL); head; head = sysctl_head_next(head)) { | ||
322 | table = proc_sys_lookup_table(dentry, head->ctl_table); | ||
323 | 279 | ||
324 | if (!table) | 280 | for (h = sysctl_head_next(NULL); h; h = sysctl_head_next(h)) { |
281 | if (h->attached_to != table) | ||
325 | continue; | 282 | continue; |
326 | 283 | ret = scan(h, h->attached_by, &pos, filp, dirent, filldir); | |
327 | for (; table->ctl_name || table->procname; table++, pos++) { | 284 | if (ret) { |
328 | /* Can't do anything without a proc name */ | 285 | sysctl_head_finish(h); |
329 | if (!table->procname) | 286 | break; |
330 | continue; | ||
331 | |||
332 | if (pos < filp->f_pos) | ||
333 | continue; | ||
334 | |||
335 | if (proc_sys_fill_cache(filp, dirent, filldir, table) < 0) | ||
336 | goto out; | ||
337 | filp->f_pos = pos + 1; | ||
338 | } | 287 | } |
339 | } | 288 | } |
340 | ret = 1; | 289 | ret = 1; |
@@ -343,53 +292,24 @@ out: | |||
343 | return ret; | 292 | return ret; |
344 | } | 293 | } |
345 | 294 | ||
346 | static int proc_sys_permission(struct inode *inode, int mask, struct nameidata *nd) | 295 | static int proc_sys_permission(struct inode *inode, int mask) |
347 | { | 296 | { |
348 | /* | 297 | /* |
349 | * sysctl entries that are not writeable, | 298 | * sysctl entries that are not writeable, |
350 | * are _NOT_ writeable, capabilities or not. | 299 | * are _NOT_ writeable, capabilities or not. |
351 | */ | 300 | */ |
352 | struct ctl_table_header *head; | 301 | struct ctl_table_header *head = grab_header(inode); |
353 | struct ctl_table *table; | 302 | struct ctl_table *table = PROC_I(inode)->sysctl_entry; |
354 | struct dentry *dentry; | ||
355 | int mode; | ||
356 | int depth; | ||
357 | int error; | 303 | int error; |
358 | 304 | ||
359 | head = NULL; | 305 | if (IS_ERR(head)) |
360 | depth = PROC_I(inode)->fd; | 306 | return PTR_ERR(head); |
361 | |||
362 | /* First check the cached permissions, in case we don't have | ||
363 | * enough information to lookup the sysctl table entry. | ||
364 | */ | ||
365 | error = -EACCES; | ||
366 | mode = inode->i_mode; | ||
367 | |||
368 | if (current->euid == 0) | ||
369 | mode >>= 6; | ||
370 | else if (in_group_p(0)) | ||
371 | mode >>= 3; | ||
372 | |||
373 | if ((mode & mask & (MAY_READ|MAY_WRITE|MAY_EXEC)) == mask) | ||
374 | error = 0; | ||
375 | |||
376 | /* If we can't get a sysctl table entry the permission | ||
377 | * checks on the cached mode will have to be enough. | ||
378 | */ | ||
379 | if (!nd || !depth) | ||
380 | goto out; | ||
381 | 307 | ||
382 | dentry = nd->path.dentry; | 308 | if (!table) /* global root - r-xr-xr-x */ |
383 | table = do_proc_sys_lookup(dentry->d_parent, &dentry->d_name, &head); | 309 | error = mask & MAY_WRITE ? -EACCES : 0; |
310 | else /* Use the permissions on the sysctl table entry */ | ||
311 | error = sysctl_perm(head->root, table, mask); | ||
384 | 312 | ||
385 | /* If the entry does not exist deny permission */ | ||
386 | error = -EACCES; | ||
387 | if (!table) | ||
388 | goto out; | ||
389 | |||
390 | /* Use the permissions on the sysctl table entry */ | ||
391 | error = sysctl_perm(head->root, table, mask); | ||
392 | out: | ||
393 | sysctl_head_finish(head); | 313 | sysctl_head_finish(head); |
394 | return error; | 314 | return error; |
395 | } | 315 | } |
@@ -409,33 +329,70 @@ static int proc_sys_setattr(struct dentry *dentry, struct iattr *attr) | |||
409 | return error; | 329 | return error; |
410 | } | 330 | } |
411 | 331 | ||
412 | /* I'm lazy and don't distinguish between files and directories, | 332 | static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) |
413 | * until access time. | 333 | { |
414 | */ | 334 | struct inode *inode = dentry->d_inode; |
335 | struct ctl_table_header *head = grab_header(inode); | ||
336 | struct ctl_table *table = PROC_I(inode)->sysctl_entry; | ||
337 | |||
338 | if (IS_ERR(head)) | ||
339 | return PTR_ERR(head); | ||
340 | |||
341 | generic_fillattr(inode, stat); | ||
342 | if (table) | ||
343 | stat->mode = (stat->mode & S_IFMT) | table->mode; | ||
344 | |||
345 | sysctl_head_finish(head); | ||
346 | return 0; | ||
347 | } | ||
348 | |||
415 | static const struct file_operations proc_sys_file_operations = { | 349 | static const struct file_operations proc_sys_file_operations = { |
416 | .read = proc_sys_read, | 350 | .read = proc_sys_read, |
417 | .write = proc_sys_write, | 351 | .write = proc_sys_write, |
352 | }; | ||
353 | |||
354 | static const struct file_operations proc_sys_dir_file_operations = { | ||
418 | .readdir = proc_sys_readdir, | 355 | .readdir = proc_sys_readdir, |
419 | }; | 356 | }; |
420 | 357 | ||
421 | static const struct inode_operations proc_sys_inode_operations = { | 358 | static const struct inode_operations proc_sys_inode_operations = { |
359 | .permission = proc_sys_permission, | ||
360 | .setattr = proc_sys_setattr, | ||
361 | .getattr = proc_sys_getattr, | ||
362 | }; | ||
363 | |||
364 | static const struct inode_operations proc_sys_dir_operations = { | ||
422 | .lookup = proc_sys_lookup, | 365 | .lookup = proc_sys_lookup, |
423 | .permission = proc_sys_permission, | 366 | .permission = proc_sys_permission, |
424 | .setattr = proc_sys_setattr, | 367 | .setattr = proc_sys_setattr, |
368 | .getattr = proc_sys_getattr, | ||
425 | }; | 369 | }; |
426 | 370 | ||
427 | static int proc_sys_revalidate(struct dentry *dentry, struct nameidata *nd) | 371 | static int proc_sys_revalidate(struct dentry *dentry, struct nameidata *nd) |
428 | { | 372 | { |
429 | struct ctl_table_header *head; | 373 | return !PROC_I(dentry->d_inode)->sysctl->unregistering; |
430 | struct ctl_table *table; | 374 | } |
431 | table = do_proc_sys_lookup(dentry->d_parent, &dentry->d_name, &head); | 375 | |
432 | proc_sys_refresh_inode(dentry->d_inode, table); | 376 | static int proc_sys_delete(struct dentry *dentry) |
433 | sysctl_head_finish(head); | 377 | { |
434 | return !!table; | 378 | return !!PROC_I(dentry->d_inode)->sysctl->unregistering; |
379 | } | ||
380 | |||
381 | static int proc_sys_compare(struct dentry *dir, struct qstr *qstr, | ||
382 | struct qstr *name) | ||
383 | { | ||
384 | struct dentry *dentry = container_of(qstr, struct dentry, d_name); | ||
385 | if (qstr->len != name->len) | ||
386 | return 1; | ||
387 | if (memcmp(qstr->name, name->name, name->len)) | ||
388 | return 1; | ||
389 | return !sysctl_is_seen(PROC_I(dentry->d_inode)->sysctl); | ||
435 | } | 390 | } |
436 | 391 | ||
437 | static struct dentry_operations proc_sys_dentry_operations = { | 392 | static struct dentry_operations proc_sys_dentry_operations = { |
438 | .d_revalidate = proc_sys_revalidate, | 393 | .d_revalidate = proc_sys_revalidate, |
394 | .d_delete = proc_sys_delete, | ||
395 | .d_compare = proc_sys_compare, | ||
439 | }; | 396 | }; |
440 | 397 | ||
441 | static struct proc_dir_entry *proc_sys_root; | 398 | static struct proc_dir_entry *proc_sys_root; |
@@ -443,8 +400,8 @@ static struct proc_dir_entry *proc_sys_root; | |||
443 | int proc_sys_init(void) | 400 | int proc_sys_init(void) |
444 | { | 401 | { |
445 | proc_sys_root = proc_mkdir("sys", NULL); | 402 | proc_sys_root = proc_mkdir("sys", NULL); |
446 | proc_sys_root->proc_iops = &proc_sys_inode_operations; | 403 | proc_sys_root->proc_iops = &proc_sys_dir_operations; |
447 | proc_sys_root->proc_fops = &proc_sys_file_operations; | 404 | proc_sys_root->proc_fops = &proc_sys_dir_file_operations; |
448 | proc_sys_root->nlink = 0; | 405 | proc_sys_root->nlink = 0; |
449 | return 0; | 406 | return 0; |
450 | } | 407 | } |
diff --git a/fs/qnx4/inode.c b/fs/qnx4/inode.c index b31ab78052b3..2aad1044b84c 100644 --- a/fs/qnx4/inode.c +++ b/fs/qnx4/inode.c | |||
@@ -553,7 +553,7 @@ static void qnx4_destroy_inode(struct inode *inode) | |||
553 | kmem_cache_free(qnx4_inode_cachep, qnx4_i(inode)); | 553 | kmem_cache_free(qnx4_inode_cachep, qnx4_i(inode)); |
554 | } | 554 | } |
555 | 555 | ||
556 | static void init_once(struct kmem_cache *cachep, void *foo) | 556 | static void init_once(void *foo) |
557 | { | 557 | { |
558 | struct qnx4_inode_info *ei = (struct qnx4_inode_info *) foo; | 558 | struct qnx4_inode_info *ei = (struct qnx4_inode_info *) foo; |
559 | 559 | ||
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c index 2ec748ba0bd3..879e54d35c2d 100644 --- a/fs/reiserfs/super.c +++ b/fs/reiserfs/super.c | |||
@@ -521,7 +521,7 @@ static void reiserfs_destroy_inode(struct inode *inode) | |||
521 | kmem_cache_free(reiserfs_inode_cachep, REISERFS_I(inode)); | 521 | kmem_cache_free(reiserfs_inode_cachep, REISERFS_I(inode)); |
522 | } | 522 | } |
523 | 523 | ||
524 | static void init_once(struct kmem_cache * cachep, void *foo) | 524 | static void init_once(void *foo) |
525 | { | 525 | { |
526 | struct reiserfs_inode_info *ei = (struct reiserfs_inode_info *)foo; | 526 | struct reiserfs_inode_info *ei = (struct reiserfs_inode_info *)foo; |
527 | 527 | ||
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c index d7c4935c1034..bb3cb5b7cdb2 100644 --- a/fs/reiserfs/xattr.c +++ b/fs/reiserfs/xattr.c | |||
@@ -1250,7 +1250,7 @@ static int reiserfs_check_acl(struct inode *inode, int mask) | |||
1250 | return error; | 1250 | return error; |
1251 | } | 1251 | } |
1252 | 1252 | ||
1253 | int reiserfs_permission(struct inode *inode, int mask, struct nameidata *nd) | 1253 | int reiserfs_permission(struct inode *inode, int mask) |
1254 | { | 1254 | { |
1255 | /* | 1255 | /* |
1256 | * We don't do permission checks on the internal objects. | 1256 | * We don't do permission checks on the internal objects. |
diff --git a/fs/romfs/inode.c b/fs/romfs/inode.c index 3f13d491c7c7..8e51a2aaa977 100644 --- a/fs/romfs/inode.c +++ b/fs/romfs/inode.c | |||
@@ -577,7 +577,7 @@ static void romfs_destroy_inode(struct inode *inode) | |||
577 | kmem_cache_free(romfs_inode_cachep, ROMFS_I(inode)); | 577 | kmem_cache_free(romfs_inode_cachep, ROMFS_I(inode)); |
578 | } | 578 | } |
579 | 579 | ||
580 | static void init_once(struct kmem_cache *cachep, void *foo) | 580 | static void init_once(void *foo) |
581 | { | 581 | { |
582 | struct romfs_inode_info *ei = foo; | 582 | struct romfs_inode_info *ei = foo; |
583 | 583 | ||
diff --git a/fs/smbfs/file.c b/fs/smbfs/file.c index 2294783320cb..e4f8d51a5553 100644 --- a/fs/smbfs/file.c +++ b/fs/smbfs/file.c | |||
@@ -408,7 +408,7 @@ smb_file_release(struct inode *inode, struct file * file) | |||
408 | * privileges, so we need our own check for this. | 408 | * privileges, so we need our own check for this. |
409 | */ | 409 | */ |
410 | static int | 410 | static int |
411 | smb_file_permission(struct inode *inode, int mask, struct nameidata *nd) | 411 | smb_file_permission(struct inode *inode, int mask) |
412 | { | 412 | { |
413 | int mode = inode->i_mode; | 413 | int mode = inode->i_mode; |
414 | int error = 0; | 414 | int error = 0; |
@@ -417,7 +417,7 @@ smb_file_permission(struct inode *inode, int mask, struct nameidata *nd) | |||
417 | 417 | ||
418 | /* Look at user permissions */ | 418 | /* Look at user permissions */ |
419 | mode >>= 6; | 419 | mode >>= 6; |
420 | if ((mode & 7 & mask) != mask) | 420 | if (mask & ~mode & (MAY_READ | MAY_WRITE | MAY_EXEC)) |
421 | error = -EACCES; | 421 | error = -EACCES; |
422 | return error; | 422 | return error; |
423 | } | 423 | } |
diff --git a/fs/smbfs/inode.c b/fs/smbfs/inode.c index 376ef3ee6ed7..3528f40ffb0f 100644 --- a/fs/smbfs/inode.c +++ b/fs/smbfs/inode.c | |||
@@ -67,7 +67,7 @@ static void smb_destroy_inode(struct inode *inode) | |||
67 | kmem_cache_free(smb_inode_cachep, SMB_I(inode)); | 67 | kmem_cache_free(smb_inode_cachep, SMB_I(inode)); |
68 | } | 68 | } |
69 | 69 | ||
70 | static void init_once(struct kmem_cache *cachep, void *foo) | 70 | static void init_once(void *foo) |
71 | { | 71 | { |
72 | struct smb_inode_info *ei = (struct smb_inode_info *) foo; | 72 | struct smb_inode_info *ei = (struct smb_inode_info *) foo; |
73 | 73 | ||
diff --git a/fs/splice.c b/fs/splice.c index 399442179d89..b30311ba8af6 100644 --- a/fs/splice.c +++ b/fs/splice.c | |||
@@ -772,7 +772,7 @@ generic_file_splice_write_nolock(struct pipe_inode_info *pipe, struct file *out, | |||
772 | ssize_t ret; | 772 | ssize_t ret; |
773 | int err; | 773 | int err; |
774 | 774 | ||
775 | err = remove_suid(out->f_path.dentry); | 775 | err = file_remove_suid(out); |
776 | if (unlikely(err)) | 776 | if (unlikely(err)) |
777 | return err; | 777 | return err; |
778 | 778 | ||
@@ -830,7 +830,7 @@ generic_file_splice_write(struct pipe_inode_info *pipe, struct file *out, | |||
830 | ssize_t ret; | 830 | ssize_t ret; |
831 | 831 | ||
832 | inode_double_lock(inode, pipe->inode); | 832 | inode_double_lock(inode, pipe->inode); |
833 | ret = remove_suid(out->f_path.dentry); | 833 | ret = file_remove_suid(out); |
834 | if (likely(!ret)) | 834 | if (likely(!ret)) |
835 | ret = __splice_from_pipe(pipe, &sd, pipe_to_file); | 835 | ret = __splice_from_pipe(pipe, &sd, pipe_to_file); |
836 | inode_double_unlock(inode, pipe->inode); | 836 | inode_double_unlock(inode, pipe->inode); |
@@ -1161,36 +1161,6 @@ static long do_splice(struct file *in, loff_t __user *off_in, | |||
1161 | } | 1161 | } |
1162 | 1162 | ||
1163 | /* | 1163 | /* |
1164 | * Do a copy-from-user while holding the mmap_semaphore for reading, in a | ||
1165 | * manner safe from deadlocking with simultaneous mmap() (grabbing mmap_sem | ||
1166 | * for writing) and page faulting on the user memory pointed to by src. | ||
1167 | * This assumes that we will very rarely hit the partial != 0 path, or this | ||
1168 | * will not be a win. | ||
1169 | */ | ||
1170 | static int copy_from_user_mmap_sem(void *dst, const void __user *src, size_t n) | ||
1171 | { | ||
1172 | int partial; | ||
1173 | |||
1174 | if (!access_ok(VERIFY_READ, src, n)) | ||
1175 | return -EFAULT; | ||
1176 | |||
1177 | pagefault_disable(); | ||
1178 | partial = __copy_from_user_inatomic(dst, src, n); | ||
1179 | pagefault_enable(); | ||
1180 | |||
1181 | /* | ||
1182 | * Didn't copy everything, drop the mmap_sem and do a faulting copy | ||
1183 | */ | ||
1184 | if (unlikely(partial)) { | ||
1185 | up_read(¤t->mm->mmap_sem); | ||
1186 | partial = copy_from_user(dst, src, n); | ||
1187 | down_read(¤t->mm->mmap_sem); | ||
1188 | } | ||
1189 | |||
1190 | return partial; | ||
1191 | } | ||
1192 | |||
1193 | /* | ||
1194 | * Map an iov into an array of pages and offset/length tupples. With the | 1164 | * Map an iov into an array of pages and offset/length tupples. With the |
1195 | * partial_page structure, we can map several non-contiguous ranges into | 1165 | * partial_page structure, we can map several non-contiguous ranges into |
1196 | * our ones pages[] map instead of splitting that operation into pieces. | 1166 | * our ones pages[] map instead of splitting that operation into pieces. |
@@ -1203,8 +1173,6 @@ static int get_iovec_page_array(const struct iovec __user *iov, | |||
1203 | { | 1173 | { |
1204 | int buffers = 0, error = 0; | 1174 | int buffers = 0, error = 0; |
1205 | 1175 | ||
1206 | down_read(¤t->mm->mmap_sem); | ||
1207 | |||
1208 | while (nr_vecs) { | 1176 | while (nr_vecs) { |
1209 | unsigned long off, npages; | 1177 | unsigned long off, npages; |
1210 | struct iovec entry; | 1178 | struct iovec entry; |
@@ -1213,7 +1181,7 @@ static int get_iovec_page_array(const struct iovec __user *iov, | |||
1213 | int i; | 1181 | int i; |
1214 | 1182 | ||
1215 | error = -EFAULT; | 1183 | error = -EFAULT; |
1216 | if (copy_from_user_mmap_sem(&entry, iov, sizeof(entry))) | 1184 | if (copy_from_user(&entry, iov, sizeof(entry))) |
1217 | break; | 1185 | break; |
1218 | 1186 | ||
1219 | base = entry.iov_base; | 1187 | base = entry.iov_base; |
@@ -1247,9 +1215,8 @@ static int get_iovec_page_array(const struct iovec __user *iov, | |||
1247 | if (npages > PIPE_BUFFERS - buffers) | 1215 | if (npages > PIPE_BUFFERS - buffers) |
1248 | npages = PIPE_BUFFERS - buffers; | 1216 | npages = PIPE_BUFFERS - buffers; |
1249 | 1217 | ||
1250 | error = get_user_pages(current, current->mm, | 1218 | error = get_user_pages_fast((unsigned long)base, npages, |
1251 | (unsigned long) base, npages, 0, 0, | 1219 | 0, &pages[buffers]); |
1252 | &pages[buffers], NULL); | ||
1253 | 1220 | ||
1254 | if (unlikely(error <= 0)) | 1221 | if (unlikely(error <= 0)) |
1255 | break; | 1222 | break; |
@@ -1288,8 +1255,6 @@ static int get_iovec_page_array(const struct iovec __user *iov, | |||
1288 | iov++; | 1255 | iov++; |
1289 | } | 1256 | } |
1290 | 1257 | ||
1291 | up_read(¤t->mm->mmap_sem); | ||
1292 | |||
1293 | if (buffers) | 1258 | if (buffers) |
1294 | return buffers; | 1259 | return buffers; |
1295 | 1260 | ||
@@ -57,13 +57,13 @@ EXPORT_SYMBOL(vfs_getattr); | |||
57 | 57 | ||
58 | int vfs_stat_fd(int dfd, char __user *name, struct kstat *stat) | 58 | int vfs_stat_fd(int dfd, char __user *name, struct kstat *stat) |
59 | { | 59 | { |
60 | struct nameidata nd; | 60 | struct path path; |
61 | int error; | 61 | int error; |
62 | 62 | ||
63 | error = __user_walk_fd(dfd, name, LOOKUP_FOLLOW, &nd); | 63 | error = user_path_at(dfd, name, LOOKUP_FOLLOW, &path); |
64 | if (!error) { | 64 | if (!error) { |
65 | error = vfs_getattr(nd.path.mnt, nd.path.dentry, stat); | 65 | error = vfs_getattr(path.mnt, path.dentry, stat); |
66 | path_put(&nd.path); | 66 | path_put(&path); |
67 | } | 67 | } |
68 | return error; | 68 | return error; |
69 | } | 69 | } |
@@ -77,13 +77,13 @@ EXPORT_SYMBOL(vfs_stat); | |||
77 | 77 | ||
78 | int vfs_lstat_fd(int dfd, char __user *name, struct kstat *stat) | 78 | int vfs_lstat_fd(int dfd, char __user *name, struct kstat *stat) |
79 | { | 79 | { |
80 | struct nameidata nd; | 80 | struct path path; |
81 | int error; | 81 | int error; |
82 | 82 | ||
83 | error = __user_walk_fd(dfd, name, 0, &nd); | 83 | error = user_path_at(dfd, name, 0, &path); |
84 | if (!error) { | 84 | if (!error) { |
85 | error = vfs_getattr(nd.path.mnt, nd.path.dentry, stat); | 85 | error = vfs_getattr(path.mnt, path.dentry, stat); |
86 | path_put(&nd.path); | 86 | path_put(&path); |
87 | } | 87 | } |
88 | return error; | 88 | return error; |
89 | } | 89 | } |
@@ -291,29 +291,29 @@ asmlinkage long sys_newfstat(unsigned int fd, struct stat __user *statbuf) | |||
291 | return error; | 291 | return error; |
292 | } | 292 | } |
293 | 293 | ||
294 | asmlinkage long sys_readlinkat(int dfd, const char __user *path, | 294 | asmlinkage long sys_readlinkat(int dfd, const char __user *pathname, |
295 | char __user *buf, int bufsiz) | 295 | char __user *buf, int bufsiz) |
296 | { | 296 | { |
297 | struct nameidata nd; | 297 | struct path path; |
298 | int error; | 298 | int error; |
299 | 299 | ||
300 | if (bufsiz <= 0) | 300 | if (bufsiz <= 0) |
301 | return -EINVAL; | 301 | return -EINVAL; |
302 | 302 | ||
303 | error = __user_walk_fd(dfd, path, 0, &nd); | 303 | error = user_path_at(dfd, pathname, 0, &path); |
304 | if (!error) { | 304 | if (!error) { |
305 | struct inode *inode = nd.path.dentry->d_inode; | 305 | struct inode *inode = path.dentry->d_inode; |
306 | 306 | ||
307 | error = -EINVAL; | 307 | error = -EINVAL; |
308 | if (inode->i_op && inode->i_op->readlink) { | 308 | if (inode->i_op && inode->i_op->readlink) { |
309 | error = security_inode_readlink(nd.path.dentry); | 309 | error = security_inode_readlink(path.dentry); |
310 | if (!error) { | 310 | if (!error) { |
311 | touch_atime(nd.path.mnt, nd.path.dentry); | 311 | touch_atime(path.mnt, path.dentry); |
312 | error = inode->i_op->readlink(nd.path.dentry, | 312 | error = inode->i_op->readlink(path.dentry, |
313 | buf, bufsiz); | 313 | buf, bufsiz); |
314 | } | 314 | } |
315 | } | 315 | } |
316 | path_put(&nd.path); | 316 | path_put(&path); |
317 | } | 317 | } |
318 | return error; | 318 | return error; |
319 | } | 319 | } |
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index c1a7efb310bf..aedaeba82ae5 100644 --- a/fs/sysfs/dir.c +++ b/fs/sysfs/dir.c | |||
@@ -459,11 +459,8 @@ int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd) | |||
459 | int ret; | 459 | int ret; |
460 | 460 | ||
461 | ret = __sysfs_add_one(acxt, sd); | 461 | ret = __sysfs_add_one(acxt, sd); |
462 | if (ret == -EEXIST) { | 462 | WARN(ret == -EEXIST, KERN_WARNING "sysfs: duplicate filename '%s' " |
463 | printk(KERN_WARNING "sysfs: duplicate filename '%s' " | ||
464 | "can not be created\n", sd->s_name); | 463 | "can not be created\n", sd->s_name); |
465 | WARN_ON(1); | ||
466 | } | ||
467 | return ret; | 464 | return ret; |
468 | } | 465 | } |
469 | 466 | ||
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index 3f07893ff896..c9e4e5091da1 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c | |||
@@ -337,9 +337,8 @@ static int sysfs_open_file(struct inode *inode, struct file *file) | |||
337 | if (kobj->ktype && kobj->ktype->sysfs_ops) | 337 | if (kobj->ktype && kobj->ktype->sysfs_ops) |
338 | ops = kobj->ktype->sysfs_ops; | 338 | ops = kobj->ktype->sysfs_ops; |
339 | else { | 339 | else { |
340 | printk(KERN_ERR "missing sysfs attribute operations for " | 340 | WARN(1, KERN_ERR "missing sysfs attribute operations for " |
341 | "kobject: %s\n", kobject_name(kobj)); | 341 | "kobject: %s\n", kobject_name(kobj)); |
342 | WARN_ON(1); | ||
343 | goto err_out; | 342 | goto err_out; |
344 | } | 343 | } |
345 | 344 | ||
diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c index eeba38417b1d..fe611949a7f7 100644 --- a/fs/sysfs/group.c +++ b/fs/sysfs/group.c | |||
@@ -134,9 +134,8 @@ void sysfs_remove_group(struct kobject * kobj, | |||
134 | if (grp->name) { | 134 | if (grp->name) { |
135 | sd = sysfs_get_dirent(dir_sd, grp->name); | 135 | sd = sysfs_get_dirent(dir_sd, grp->name); |
136 | if (!sd) { | 136 | if (!sd) { |
137 | printk(KERN_WARNING "sysfs group %p not found for " | 137 | WARN(!sd, KERN_WARNING "sysfs group %p not found for " |
138 | "kobject '%s'\n", grp, kobject_name(kobj)); | 138 | "kobject '%s'\n", grp, kobject_name(kobj)); |
139 | WARN_ON(!sd); | ||
140 | return; | 139 | return; |
141 | } | 140 | } |
142 | } else | 141 | } else |
diff --git a/fs/sysv/inode.c b/fs/sysv/inode.c index c5d60de0658f..df0d435baa48 100644 --- a/fs/sysv/inode.c +++ b/fs/sysv/inode.c | |||
@@ -326,7 +326,7 @@ static void sysv_destroy_inode(struct inode *inode) | |||
326 | kmem_cache_free(sysv_inode_cachep, SYSV_I(inode)); | 326 | kmem_cache_free(sysv_inode_cachep, SYSV_I(inode)); |
327 | } | 327 | } |
328 | 328 | ||
329 | static void init_once(struct kmem_cache *cachep, void *p) | 329 | static void init_once(void *p) |
330 | { | 330 | { |
331 | struct sysv_inode_info *si = (struct sysv_inode_info *)p; | 331 | struct sysv_inode_info *si = (struct sysv_inode_info *)p; |
332 | 332 | ||
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c index 005a3b854d96..8565e586e533 100644 --- a/fs/ubifs/file.c +++ b/fs/ubifs/file.c | |||
@@ -53,6 +53,7 @@ | |||
53 | 53 | ||
54 | #include "ubifs.h" | 54 | #include "ubifs.h" |
55 | #include <linux/mount.h> | 55 | #include <linux/mount.h> |
56 | #include <linux/namei.h> | ||
56 | 57 | ||
57 | static int read_block(struct inode *inode, void *addr, unsigned int block, | 58 | static int read_block(struct inode *inode, void *addr, unsigned int block, |
58 | struct ubifs_data_node *dn) | 59 | struct ubifs_data_node *dn) |
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 00eb9c68ad03..ca1e2d4e03cc 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c | |||
@@ -1841,7 +1841,7 @@ static struct file_system_type ubifs_fs_type = { | |||
1841 | /* | 1841 | /* |
1842 | * Inode slab cache constructor. | 1842 | * Inode slab cache constructor. |
1843 | */ | 1843 | */ |
1844 | static void inode_slab_ctor(struct kmem_cache *cachep, void *obj) | 1844 | static void inode_slab_ctor(void *obj) |
1845 | { | 1845 | { |
1846 | struct ubifs_inode *ui = obj; | 1846 | struct ubifs_inode *ui = obj; |
1847 | inode_init_once(&ui->vfs_inode); | 1847 | inode_init_once(&ui->vfs_inode); |
diff --git a/fs/udf/super.c b/fs/udf/super.c index 44cc702f96cc..5698bbf83bbf 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c | |||
@@ -148,7 +148,7 @@ static void udf_destroy_inode(struct inode *inode) | |||
148 | kmem_cache_free(udf_inode_cachep, UDF_I(inode)); | 148 | kmem_cache_free(udf_inode_cachep, UDF_I(inode)); |
149 | } | 149 | } |
150 | 150 | ||
151 | static void init_once(struct kmem_cache *cachep, void *foo) | 151 | static void init_once(void *foo) |
152 | { | 152 | { |
153 | struct udf_inode_info *ei = (struct udf_inode_info *)foo; | 153 | struct udf_inode_info *ei = (struct udf_inode_info *)foo; |
154 | 154 | ||
diff --git a/fs/ufs/super.c b/fs/ufs/super.c index 227c9d700040..3e30e40aa24d 100644 --- a/fs/ufs/super.c +++ b/fs/ufs/super.c | |||
@@ -1302,7 +1302,7 @@ static void ufs_destroy_inode(struct inode *inode) | |||
1302 | kmem_cache_free(ufs_inode_cachep, UFS_I(inode)); | 1302 | kmem_cache_free(ufs_inode_cachep, UFS_I(inode)); |
1303 | } | 1303 | } |
1304 | 1304 | ||
1305 | static void init_once(struct kmem_cache * cachep, void *foo) | 1305 | static void init_once(void *foo) |
1306 | { | 1306 | { |
1307 | struct ufs_inode_info *ei = (struct ufs_inode_info *) foo; | 1307 | struct ufs_inode_info *ei = (struct ufs_inode_info *) foo; |
1308 | 1308 | ||
diff --git a/fs/utimes.c b/fs/utimes.c index b6b664e7145e..6929e3e91d05 100644 --- a/fs/utimes.c +++ b/fs/utimes.c | |||
@@ -48,66 +48,22 @@ static bool nsec_valid(long nsec) | |||
48 | return nsec >= 0 && nsec <= 999999999; | 48 | return nsec >= 0 && nsec <= 999999999; |
49 | } | 49 | } |
50 | 50 | ||
51 | /* If times==NULL, set access and modification to current time, | 51 | static int utimes_common(struct path *path, struct timespec *times) |
52 | * must be owner or have write permission. | ||
53 | * Else, update from *times, must be owner or super user. | ||
54 | */ | ||
55 | long do_utimes(int dfd, char __user *filename, struct timespec *times, int flags) | ||
56 | { | 52 | { |
57 | int error; | 53 | int error; |
58 | struct nameidata nd; | ||
59 | struct dentry *dentry; | ||
60 | struct inode *inode; | ||
61 | struct iattr newattrs; | 54 | struct iattr newattrs; |
62 | struct file *f = NULL; | 55 | struct inode *inode = path->dentry->d_inode; |
63 | struct vfsmount *mnt; | ||
64 | |||
65 | error = -EINVAL; | ||
66 | if (times && (!nsec_valid(times[0].tv_nsec) || | ||
67 | !nsec_valid(times[1].tv_nsec))) { | ||
68 | goto out; | ||
69 | } | ||
70 | |||
71 | if (flags & ~AT_SYMLINK_NOFOLLOW) | ||
72 | goto out; | ||
73 | |||
74 | if (filename == NULL && dfd != AT_FDCWD) { | ||
75 | error = -EINVAL; | ||
76 | if (flags & AT_SYMLINK_NOFOLLOW) | ||
77 | goto out; | ||
78 | 56 | ||
79 | error = -EBADF; | 57 | error = mnt_want_write(path->mnt); |
80 | f = fget(dfd); | ||
81 | if (!f) | ||
82 | goto out; | ||
83 | dentry = f->f_path.dentry; | ||
84 | mnt = f->f_path.mnt; | ||
85 | } else { | ||
86 | error = __user_walk_fd(dfd, filename, (flags & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW, &nd); | ||
87 | if (error) | ||
88 | goto out; | ||
89 | |||
90 | dentry = nd.path.dentry; | ||
91 | mnt = nd.path.mnt; | ||
92 | } | ||
93 | |||
94 | inode = dentry->d_inode; | ||
95 | |||
96 | error = mnt_want_write(mnt); | ||
97 | if (error) | 58 | if (error) |
98 | goto dput_and_out; | 59 | goto out; |
99 | 60 | ||
100 | if (times && times[0].tv_nsec == UTIME_NOW && | 61 | if (times && times[0].tv_nsec == UTIME_NOW && |
101 | times[1].tv_nsec == UTIME_NOW) | 62 | times[1].tv_nsec == UTIME_NOW) |
102 | times = NULL; | 63 | times = NULL; |
103 | 64 | ||
104 | /* In most cases, the checks are done in inode_change_ok() */ | ||
105 | newattrs.ia_valid = ATTR_CTIME | ATTR_MTIME | ATTR_ATIME; | 65 | newattrs.ia_valid = ATTR_CTIME | ATTR_MTIME | ATTR_ATIME; |
106 | if (times) { | 66 | if (times) { |
107 | error = -EPERM; | ||
108 | if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) | ||
109 | goto mnt_drop_write_and_out; | ||
110 | |||
111 | if (times[0].tv_nsec == UTIME_OMIT) | 67 | if (times[0].tv_nsec == UTIME_OMIT) |
112 | newattrs.ia_valid &= ~ATTR_ATIME; | 68 | newattrs.ia_valid &= ~ATTR_ATIME; |
113 | else if (times[0].tv_nsec != UTIME_NOW) { | 69 | else if (times[0].tv_nsec != UTIME_NOW) { |
@@ -123,21 +79,13 @@ long do_utimes(int dfd, char __user *filename, struct timespec *times, int flags | |||
123 | newattrs.ia_mtime.tv_nsec = times[1].tv_nsec; | 79 | newattrs.ia_mtime.tv_nsec = times[1].tv_nsec; |
124 | newattrs.ia_valid |= ATTR_MTIME_SET; | 80 | newattrs.ia_valid |= ATTR_MTIME_SET; |
125 | } | 81 | } |
126 | |||
127 | /* | 82 | /* |
128 | * For the UTIME_OMIT/UTIME_NOW and UTIME_NOW/UTIME_OMIT | 83 | * Tell inode_change_ok(), that this is an explicit time |
129 | * cases, we need to make an extra check that is not done by | 84 | * update, even if neither ATTR_ATIME_SET nor ATTR_MTIME_SET |
130 | * inode_change_ok(). | 85 | * were used. |
131 | */ | 86 | */ |
132 | if (((times[0].tv_nsec == UTIME_NOW && | 87 | newattrs.ia_valid |= ATTR_TIMES_SET; |
133 | times[1].tv_nsec == UTIME_OMIT) | ||
134 | || | ||
135 | (times[0].tv_nsec == UTIME_OMIT && | ||
136 | times[1].tv_nsec == UTIME_NOW)) | ||
137 | && !is_owner_or_cap(inode)) | ||
138 | goto mnt_drop_write_and_out; | ||
139 | } else { | 88 | } else { |
140 | |||
141 | /* | 89 | /* |
142 | * If times is NULL (or both times are UTIME_NOW), | 90 | * If times is NULL (or both times are UTIME_NOW), |
143 | * then we need to check permissions, because | 91 | * then we need to check permissions, because |
@@ -148,21 +96,76 @@ long do_utimes(int dfd, char __user *filename, struct timespec *times, int flags | |||
148 | goto mnt_drop_write_and_out; | 96 | goto mnt_drop_write_and_out; |
149 | 97 | ||
150 | if (!is_owner_or_cap(inode)) { | 98 | if (!is_owner_or_cap(inode)) { |
151 | error = permission(inode, MAY_WRITE, NULL); | 99 | error = inode_permission(inode, MAY_WRITE); |
152 | if (error) | 100 | if (error) |
153 | goto mnt_drop_write_and_out; | 101 | goto mnt_drop_write_and_out; |
154 | } | 102 | } |
155 | } | 103 | } |
156 | mutex_lock(&inode->i_mutex); | 104 | mutex_lock(&inode->i_mutex); |
157 | error = notify_change(dentry, &newattrs); | 105 | error = notify_change(path->dentry, &newattrs); |
158 | mutex_unlock(&inode->i_mutex); | 106 | mutex_unlock(&inode->i_mutex); |
107 | |||
159 | mnt_drop_write_and_out: | 108 | mnt_drop_write_and_out: |
160 | mnt_drop_write(mnt); | 109 | mnt_drop_write(path->mnt); |
161 | dput_and_out: | 110 | out: |
162 | if (f) | 111 | return error; |
163 | fput(f); | 112 | } |
164 | else | 113 | |
165 | path_put(&nd.path); | 114 | /* |
115 | * do_utimes - change times on filename or file descriptor | ||
116 | * @dfd: open file descriptor, -1 or AT_FDCWD | ||
117 | * @filename: path name or NULL | ||
118 | * @times: new times or NULL | ||
119 | * @flags: zero or more flags (only AT_SYMLINK_NOFOLLOW for the moment) | ||
120 | * | ||
121 | * If filename is NULL and dfd refers to an open file, then operate on | ||
122 | * the file. Otherwise look up filename, possibly using dfd as a | ||
123 | * starting point. | ||
124 | * | ||
125 | * If times==NULL, set access and modification to current time, | ||
126 | * must be owner or have write permission. | ||
127 | * Else, update from *times, must be owner or super user. | ||
128 | */ | ||
129 | long do_utimes(int dfd, char __user *filename, struct timespec *times, int flags) | ||
130 | { | ||
131 | int error = -EINVAL; | ||
132 | |||
133 | if (times && (!nsec_valid(times[0].tv_nsec) || | ||
134 | !nsec_valid(times[1].tv_nsec))) { | ||
135 | goto out; | ||
136 | } | ||
137 | |||
138 | if (flags & ~AT_SYMLINK_NOFOLLOW) | ||
139 | goto out; | ||
140 | |||
141 | if (filename == NULL && dfd != AT_FDCWD) { | ||
142 | struct file *file; | ||
143 | |||
144 | if (flags & AT_SYMLINK_NOFOLLOW) | ||
145 | goto out; | ||
146 | |||
147 | file = fget(dfd); | ||
148 | error = -EBADF; | ||
149 | if (!file) | ||
150 | goto out; | ||
151 | |||
152 | error = utimes_common(&file->f_path, times); | ||
153 | fput(file); | ||
154 | } else { | ||
155 | struct path path; | ||
156 | int lookup_flags = 0; | ||
157 | |||
158 | if (!(flags & AT_SYMLINK_NOFOLLOW)) | ||
159 | lookup_flags |= LOOKUP_FOLLOW; | ||
160 | |||
161 | error = user_path_at(dfd, filename, lookup_flags, &path); | ||
162 | if (error) | ||
163 | goto out; | ||
164 | |||
165 | error = utimes_common(&path, times); | ||
166 | path_put(&path); | ||
167 | } | ||
168 | |||
166 | out: | 169 | out: |
167 | return error; | 170 | return error; |
168 | } | 171 | } |
diff --git a/fs/xattr.c b/fs/xattr.c index 4706a8b1f495..468377e66531 100644 --- a/fs/xattr.c +++ b/fs/xattr.c | |||
@@ -63,7 +63,7 @@ xattr_permission(struct inode *inode, const char *name, int mask) | |||
63 | return -EPERM; | 63 | return -EPERM; |
64 | } | 64 | } |
65 | 65 | ||
66 | return permission(inode, mask, NULL); | 66 | return inode_permission(inode, mask); |
67 | } | 67 | } |
68 | 68 | ||
69 | int | 69 | int |
@@ -252,40 +252,40 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value, | |||
252 | } | 252 | } |
253 | 253 | ||
254 | asmlinkage long | 254 | asmlinkage long |
255 | sys_setxattr(const char __user *path, const char __user *name, | 255 | sys_setxattr(const char __user *pathname, const char __user *name, |
256 | const void __user *value, size_t size, int flags) | 256 | const void __user *value, size_t size, int flags) |
257 | { | 257 | { |
258 | struct nameidata nd; | 258 | struct path path; |
259 | int error; | 259 | int error; |
260 | 260 | ||
261 | error = user_path_walk(path, &nd); | 261 | error = user_path(pathname, &path); |
262 | if (error) | 262 | if (error) |
263 | return error; | 263 | return error; |
264 | error = mnt_want_write(nd.path.mnt); | 264 | error = mnt_want_write(path.mnt); |
265 | if (!error) { | 265 | if (!error) { |
266 | error = setxattr(nd.path.dentry, name, value, size, flags); | 266 | error = setxattr(path.dentry, name, value, size, flags); |
267 | mnt_drop_write(nd.path.mnt); | 267 | mnt_drop_write(path.mnt); |
268 | } | 268 | } |
269 | path_put(&nd.path); | 269 | path_put(&path); |
270 | return error; | 270 | return error; |
271 | } | 271 | } |
272 | 272 | ||
273 | asmlinkage long | 273 | asmlinkage long |
274 | sys_lsetxattr(const char __user *path, const char __user *name, | 274 | sys_lsetxattr(const char __user *pathname, const char __user *name, |
275 | const void __user *value, size_t size, int flags) | 275 | const void __user *value, size_t size, int flags) |
276 | { | 276 | { |
277 | struct nameidata nd; | 277 | struct path path; |
278 | int error; | 278 | int error; |
279 | 279 | ||
280 | error = user_path_walk_link(path, &nd); | 280 | error = user_lpath(pathname, &path); |
281 | if (error) | 281 | if (error) |
282 | return error; | 282 | return error; |
283 | error = mnt_want_write(nd.path.mnt); | 283 | error = mnt_want_write(path.mnt); |
284 | if (!error) { | 284 | if (!error) { |
285 | error = setxattr(nd.path.dentry, name, value, size, flags); | 285 | error = setxattr(path.dentry, name, value, size, flags); |
286 | mnt_drop_write(nd.path.mnt); | 286 | mnt_drop_write(path.mnt); |
287 | } | 287 | } |
288 | path_put(&nd.path); | 288 | path_put(&path); |
289 | return error; | 289 | return error; |
290 | } | 290 | } |
291 | 291 | ||
@@ -350,32 +350,32 @@ getxattr(struct dentry *d, const char __user *name, void __user *value, | |||
350 | } | 350 | } |
351 | 351 | ||
352 | asmlinkage ssize_t | 352 | asmlinkage ssize_t |
353 | sys_getxattr(const char __user *path, const char __user *name, | 353 | sys_getxattr(const char __user *pathname, const char __user *name, |
354 | void __user *value, size_t size) | 354 | void __user *value, size_t size) |
355 | { | 355 | { |
356 | struct nameidata nd; | 356 | struct path path; |
357 | ssize_t error; | 357 | ssize_t error; |
358 | 358 | ||
359 | error = user_path_walk(path, &nd); | 359 | error = user_path(pathname, &path); |
360 | if (error) | 360 | if (error) |
361 | return error; | 361 | return error; |
362 | error = getxattr(nd.path.dentry, name, value, size); | 362 | error = getxattr(path.dentry, name, value, size); |
363 | path_put(&nd.path); | 363 | path_put(&path); |
364 | return error; | 364 | return error; |
365 | } | 365 | } |
366 | 366 | ||
367 | asmlinkage ssize_t | 367 | asmlinkage ssize_t |
368 | sys_lgetxattr(const char __user *path, const char __user *name, void __user *value, | 368 | sys_lgetxattr(const char __user *pathname, const char __user *name, void __user *value, |
369 | size_t size) | 369 | size_t size) |
370 | { | 370 | { |
371 | struct nameidata nd; | 371 | struct path path; |
372 | ssize_t error; | 372 | ssize_t error; |
373 | 373 | ||
374 | error = user_path_walk_link(path, &nd); | 374 | error = user_lpath(pathname, &path); |
375 | if (error) | 375 | if (error) |
376 | return error; | 376 | return error; |
377 | error = getxattr(nd.path.dentry, name, value, size); | 377 | error = getxattr(path.dentry, name, value, size); |
378 | path_put(&nd.path); | 378 | path_put(&path); |
379 | return error; | 379 | return error; |
380 | } | 380 | } |
381 | 381 | ||
@@ -425,30 +425,30 @@ listxattr(struct dentry *d, char __user *list, size_t size) | |||
425 | } | 425 | } |
426 | 426 | ||
427 | asmlinkage ssize_t | 427 | asmlinkage ssize_t |
428 | sys_listxattr(const char __user *path, char __user *list, size_t size) | 428 | sys_listxattr(const char __user *pathname, char __user *list, size_t size) |
429 | { | 429 | { |
430 | struct nameidata nd; | 430 | struct path path; |
431 | ssize_t error; | 431 | ssize_t error; |
432 | 432 | ||
433 | error = user_path_walk(path, &nd); | 433 | error = user_path(pathname, &path); |
434 | if (error) | 434 | if (error) |
435 | return error; | 435 | return error; |
436 | error = listxattr(nd.path.dentry, list, size); | 436 | error = listxattr(path.dentry, list, size); |
437 | path_put(&nd.path); | 437 | path_put(&path); |
438 | return error; | 438 | return error; |
439 | } | 439 | } |
440 | 440 | ||
441 | asmlinkage ssize_t | 441 | asmlinkage ssize_t |
442 | sys_llistxattr(const char __user *path, char __user *list, size_t size) | 442 | sys_llistxattr(const char __user *pathname, char __user *list, size_t size) |
443 | { | 443 | { |
444 | struct nameidata nd; | 444 | struct path path; |
445 | ssize_t error; | 445 | ssize_t error; |
446 | 446 | ||
447 | error = user_path_walk_link(path, &nd); | 447 | error = user_lpath(pathname, &path); |
448 | if (error) | 448 | if (error) |
449 | return error; | 449 | return error; |
450 | error = listxattr(nd.path.dentry, list, size); | 450 | error = listxattr(path.dentry, list, size); |
451 | path_put(&nd.path); | 451 | path_put(&path); |
452 | return error; | 452 | return error; |
453 | } | 453 | } |
454 | 454 | ||
@@ -486,38 +486,38 @@ removexattr(struct dentry *d, const char __user *name) | |||
486 | } | 486 | } |
487 | 487 | ||
488 | asmlinkage long | 488 | asmlinkage long |
489 | sys_removexattr(const char __user *path, const char __user *name) | 489 | sys_removexattr(const char __user *pathname, const char __user *name) |
490 | { | 490 | { |
491 | struct nameidata nd; | 491 | struct path path; |
492 | int error; | 492 | int error; |
493 | 493 | ||
494 | error = user_path_walk(path, &nd); | 494 | error = user_path(pathname, &path); |
495 | if (error) | 495 | if (error) |
496 | return error; | 496 | return error; |
497 | error = mnt_want_write(nd.path.mnt); | 497 | error = mnt_want_write(path.mnt); |
498 | if (!error) { | 498 | if (!error) { |
499 | error = removexattr(nd.path.dentry, name); | 499 | error = removexattr(path.dentry, name); |
500 | mnt_drop_write(nd.path.mnt); | 500 | mnt_drop_write(path.mnt); |
501 | } | 501 | } |
502 | path_put(&nd.path); | 502 | path_put(&path); |
503 | return error; | 503 | return error; |
504 | } | 504 | } |
505 | 505 | ||
506 | asmlinkage long | 506 | asmlinkage long |
507 | sys_lremovexattr(const char __user *path, const char __user *name) | 507 | sys_lremovexattr(const char __user *pathname, const char __user *name) |
508 | { | 508 | { |
509 | struct nameidata nd; | 509 | struct path path; |
510 | int error; | 510 | int error; |
511 | 511 | ||
512 | error = user_path_walk_link(path, &nd); | 512 | error = user_lpath(pathname, &path); |
513 | if (error) | 513 | if (error) |
514 | return error; | 514 | return error; |
515 | error = mnt_want_write(nd.path.mnt); | 515 | error = mnt_want_write(path.mnt); |
516 | if (!error) { | 516 | if (!error) { |
517 | error = removexattr(nd.path.dentry, name); | 517 | error = removexattr(path.dentry, name); |
518 | mnt_drop_write(nd.path.mnt); | 518 | mnt_drop_write(path.mnt); |
519 | } | 519 | } |
520 | path_put(&nd.path); | 520 | path_put(&path); |
521 | return error; | 521 | return error; |
522 | } | 522 | } |
523 | 523 | ||
diff --git a/fs/xfs/linux-2.6/kmem.h b/fs/xfs/linux-2.6/kmem.h index 5e9564902976..a20683cf74dd 100644 --- a/fs/xfs/linux-2.6/kmem.h +++ b/fs/xfs/linux-2.6/kmem.h | |||
@@ -79,7 +79,7 @@ kmem_zone_init(int size, char *zone_name) | |||
79 | 79 | ||
80 | static inline kmem_zone_t * | 80 | static inline kmem_zone_t * |
81 | kmem_zone_init_flags(int size, char *zone_name, unsigned long flags, | 81 | kmem_zone_init_flags(int size, char *zone_name, unsigned long flags, |
82 | void (*construct)(kmem_zone_t *, void *)) | 82 | void (*construct)(void *)) |
83 | { | 83 | { |
84 | return kmem_cache_create(zone_name, size, 0, flags, construct); | 84 | return kmem_cache_create(zone_name, size, 0, flags, construct); |
85 | } | 85 | } |
diff --git a/fs/xfs/linux-2.6/xfs_ioctl.c b/fs/xfs/linux-2.6/xfs_ioctl.c index a42ba9d71156..01939ba2d8de 100644 --- a/fs/xfs/linux-2.6/xfs_ioctl.c +++ b/fs/xfs/linux-2.6/xfs_ioctl.c | |||
@@ -84,17 +84,15 @@ xfs_find_handle( | |||
84 | switch (cmd) { | 84 | switch (cmd) { |
85 | case XFS_IOC_PATH_TO_FSHANDLE: | 85 | case XFS_IOC_PATH_TO_FSHANDLE: |
86 | case XFS_IOC_PATH_TO_HANDLE: { | 86 | case XFS_IOC_PATH_TO_HANDLE: { |
87 | struct nameidata nd; | 87 | struct path path; |
88 | int error; | 88 | int error = user_lpath((const char __user *)hreq.path, &path); |
89 | |||
90 | error = user_path_walk_link((const char __user *)hreq.path, &nd); | ||
91 | if (error) | 89 | if (error) |
92 | return error; | 90 | return error; |
93 | 91 | ||
94 | ASSERT(nd.path.dentry); | 92 | ASSERT(path.dentry); |
95 | ASSERT(nd.path.dentry->d_inode); | 93 | ASSERT(path.dentry->d_inode); |
96 | inode = igrab(nd.path.dentry->d_inode); | 94 | inode = igrab(path.dentry->d_inode); |
97 | path_put(&nd.path); | 95 | path_put(&path); |
98 | break; | 96 | break; |
99 | } | 97 | } |
100 | 98 | ||
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c index 2bf287ef5489..5fc61c824bb9 100644 --- a/fs/xfs/linux-2.6/xfs_iops.c +++ b/fs/xfs/linux-2.6/xfs_iops.c | |||
@@ -589,8 +589,7 @@ xfs_check_acl( | |||
589 | STATIC int | 589 | STATIC int |
590 | xfs_vn_permission( | 590 | xfs_vn_permission( |
591 | struct inode *inode, | 591 | struct inode *inode, |
592 | int mask, | 592 | int mask) |
593 | struct nameidata *nd) | ||
594 | { | 593 | { |
595 | return generic_permission(inode, mask, xfs_check_acl); | 594 | return generic_permission(inode, mask, xfs_check_acl); |
596 | } | 595 | } |
diff --git a/fs/xfs/linux-2.6/xfs_lrw.c b/fs/xfs/linux-2.6/xfs_lrw.c index 5e3b57516ec7..82333b3e118e 100644 --- a/fs/xfs/linux-2.6/xfs_lrw.c +++ b/fs/xfs/linux-2.6/xfs_lrw.c | |||
@@ -711,7 +711,7 @@ start: | |||
711 | !capable(CAP_FSETID)) { | 711 | !capable(CAP_FSETID)) { |
712 | error = xfs_write_clear_setuid(xip); | 712 | error = xfs_write_clear_setuid(xip); |
713 | if (likely(!error)) | 713 | if (likely(!error)) |
714 | error = -remove_suid(file->f_path.dentry); | 714 | error = -file_remove_suid(file); |
715 | if (unlikely(error)) { | 715 | if (unlikely(error)) { |
716 | goto out_unlock_internal; | 716 | goto out_unlock_internal; |
717 | } | 717 | } |
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c index 742b2c7852c1..943381284e2e 100644 --- a/fs/xfs/linux-2.6/xfs_super.c +++ b/fs/xfs/linux-2.6/xfs_super.c | |||
@@ -843,7 +843,6 @@ xfs_fs_destroy_inode( | |||
843 | 843 | ||
844 | STATIC void | 844 | STATIC void |
845 | xfs_fs_inode_init_once( | 845 | xfs_fs_inode_init_once( |
846 | kmem_zone_t *zonep, | ||
847 | void *vnode) | 846 | void *vnode) |
848 | { | 847 | { |
849 | inode_init_once(vn_to_inode((bhv_vnode_t *)vnode)); | 848 | inode_init_once(vn_to_inode((bhv_vnode_t *)vnode)); |