aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext2
diff options
context:
space:
mode:
authorAnton Altaparmakov <aia21@cantab.net>2006-01-19 11:39:33 -0500
committerAnton Altaparmakov <aia21@cantab.net>2006-01-19 11:39:33 -0500
commit944d79559d154c12becde0dab327016cf438f46c (patch)
tree50c101806f4d3b6585222dda060559eb4f3e005a /fs/ext2
parentd087e4bdd24ebe3ae3d0b265b6573ec901af4b4b (diff)
parent0f36b018b2e314d45af86449f1a97facb1fbe300 (diff)
Merge branch 'master' of /usr/src/ntfs-2.6/
Diffstat (limited to 'fs/ext2')
-rw-r--r--fs/ext2/acl.c11
-rw-r--r--fs/ext2/balloc.c1
-rw-r--r--fs/ext2/bitmap.c7
-rw-r--r--fs/ext2/dir.c2
-rw-r--r--fs/ext2/ext2.h2
-rw-r--r--fs/ext2/ioctl.c1
-rw-r--r--fs/ext2/namei.c5
-rw-r--r--fs/ext2/super.c4
-rw-r--r--fs/ext2/xattr.c6
-rw-r--r--fs/ext2/xattr_trusted.c5
-rw-r--r--fs/ext2/xattr_user.c14
11 files changed, 22 insertions, 36 deletions
diff --git a/fs/ext2/acl.c b/fs/ext2/acl.c
index 6af2f4130290..35acc43b897f 100644
--- a/fs/ext2/acl.c
+++ b/fs/ext2/acl.c
@@ -4,6 +4,7 @@
4 * Copyright (C) 2001-2003 Andreas Gruenbacher, <agruen@suse.de> 4 * Copyright (C) 2001-2003 Andreas Gruenbacher, <agruen@suse.de>
5 */ 5 */
6 6
7#include <linux/capability.h>
7#include <linux/init.h> 8#include <linux/init.h>
8#include <linux/sched.h> 9#include <linux/sched.h>
9#include <linux/slab.h> 10#include <linux/slab.h>
@@ -149,7 +150,7 @@ ext2_iset_acl(struct inode *inode, struct posix_acl **i_acl,
149} 150}
150 151
151/* 152/*
152 * inode->i_sem: don't care 153 * inode->i_mutex: don't care
153 */ 154 */
154static struct posix_acl * 155static struct posix_acl *
155ext2_get_acl(struct inode *inode, int type) 156ext2_get_acl(struct inode *inode, int type)
@@ -211,7 +212,7 @@ ext2_get_acl(struct inode *inode, int type)
211} 212}
212 213
213/* 214/*
214 * inode->i_sem: down 215 * inode->i_mutex: down
215 */ 216 */
216static int 217static int
217ext2_set_acl(struct inode *inode, int type, struct posix_acl *acl) 218ext2_set_acl(struct inode *inode, int type, struct posix_acl *acl)
@@ -301,8 +302,8 @@ ext2_permission(struct inode *inode, int mask, struct nameidata *nd)
301/* 302/*
302 * Initialize the ACLs of a new inode. Called from ext2_new_inode. 303 * Initialize the ACLs of a new inode. Called from ext2_new_inode.
303 * 304 *
304 * dir->i_sem: down 305 * dir->i_mutex: down
305 * inode->i_sem: up (access to inode is still exclusive) 306 * inode->i_mutex: up (access to inode is still exclusive)
306 */ 307 */
307int 308int
308ext2_init_acl(struct inode *inode, struct inode *dir) 309ext2_init_acl(struct inode *inode, struct inode *dir)
@@ -361,7 +362,7 @@ cleanup:
361 * for directories) are added. There are no more bits available in the 362 * for directories) are added. There are no more bits available in the
362 * file mode. 363 * file mode.
363 * 364 *
364 * inode->i_sem: down 365 * inode->i_mutex: down
365 */ 366 */
366int 367int
367ext2_acl_chmod(struct inode *inode) 368ext2_acl_chmod(struct inode *inode)
diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
index bb6908066494..2c00953d4b0b 100644
--- a/fs/ext2/balloc.c
+++ b/fs/ext2/balloc.c
@@ -16,6 +16,7 @@
16#include <linux/quotaops.h> 16#include <linux/quotaops.h>
17#include <linux/sched.h> 17#include <linux/sched.h>
18#include <linux/buffer_head.h> 18#include <linux/buffer_head.h>
19#include <linux/capability.h>
19 20
20/* 21/*
21 * balloc.c contains the blocks allocation and deallocation routines 22 * balloc.c contains the blocks allocation and deallocation routines
diff --git a/fs/ext2/bitmap.c b/fs/ext2/bitmap.c
index 20145b74623f..e9983a0dd396 100644
--- a/fs/ext2/bitmap.c
+++ b/fs/ext2/bitmap.c
@@ -7,8 +7,12 @@
7 * Universite Pierre et Marie Curie (Paris VI) 7 * Universite Pierre et Marie Curie (Paris VI)
8 */ 8 */
9 9
10#ifdef EXT2FS_DEBUG
11
10#include <linux/buffer_head.h> 12#include <linux/buffer_head.h>
11 13
14#include "ext2.h"
15
12static int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0}; 16static int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0};
13 17
14unsigned long ext2_count_free (struct buffer_head * map, unsigned int numchars) 18unsigned long ext2_count_free (struct buffer_head * map, unsigned int numchars)
@@ -23,3 +27,6 @@ unsigned long ext2_count_free (struct buffer_head * map, unsigned int numchars)
23 nibblemap[(map->b_data[i] >> 4) & 0xf]; 27 nibblemap[(map->b_data[i] >> 4) & 0xf];
24 return (sum); 28 return (sum);
25} 29}
30
31#endif /* EXT2FS_DEBUG */
32
diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c
index 5b5f52876b42..7442bdd1267a 100644
--- a/fs/ext2/dir.c
+++ b/fs/ext2/dir.c
@@ -592,7 +592,7 @@ int ext2_make_empty(struct inode *inode, struct inode *parent)
592 goto fail; 592 goto fail;
593 } 593 }
594 kaddr = kmap_atomic(page, KM_USER0); 594 kaddr = kmap_atomic(page, KM_USER0);
595 memset(kaddr, 0, chunk_size); 595 memset(kaddr, 0, chunk_size);
596 de = (struct ext2_dir_entry_2 *)kaddr; 596 de = (struct ext2_dir_entry_2 *)kaddr;
597 de->name_len = 1; 597 de->name_len = 1;
598 de->rec_len = cpu_to_le16(EXT2_DIR_REC_LEN(1)); 598 de->rec_len = cpu_to_le16(EXT2_DIR_REC_LEN(1));
diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
index e977f8566d14..00de0a7312a2 100644
--- a/fs/ext2/ext2.h
+++ b/fs/ext2/ext2.h
@@ -53,7 +53,7 @@ struct ext2_inode_info {
53#ifdef CONFIG_EXT2_FS_XATTR 53#ifdef CONFIG_EXT2_FS_XATTR
54 /* 54 /*
55 * Extended attributes can be read independently of the main file 55 * Extended attributes can be read independently of the main file
56 * data. Taking i_sem even when reading would cause contention 56 * data. Taking i_mutex even when reading would cause contention
57 * between readers of EAs and writers of regular file data, so 57 * between readers of EAs and writers of regular file data, so
58 * instead we synchronize on xattr_sem when reading or changing 58 * instead we synchronize on xattr_sem when reading or changing
59 * EAs. 59 * EAs.
diff --git a/fs/ext2/ioctl.c b/fs/ext2/ioctl.c
index 709d8676b962..3ca9afdf713d 100644
--- a/fs/ext2/ioctl.c
+++ b/fs/ext2/ioctl.c
@@ -8,6 +8,7 @@
8 */ 8 */
9 9
10#include "ext2.h" 10#include "ext2.h"
11#include <linux/capability.h>
11#include <linux/time.h> 12#include <linux/time.h>
12#include <linux/sched.h> 13#include <linux/sched.h>
13#include <asm/current.h> 14#include <asm/current.h>
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
index c5513953c825..ad1432a2a62e 100644
--- a/fs/ext2/namei.c
+++ b/fs/ext2/namei.c
@@ -83,10 +83,7 @@ static struct dentry *ext2_lookup(struct inode * dir, struct dentry *dentry, str
83 if (!inode) 83 if (!inode)
84 return ERR_PTR(-EACCES); 84 return ERR_PTR(-EACCES);
85 } 85 }
86 if (inode) 86 return d_splice_alias(inode, dentry);
87 return d_splice_alias(inode, dentry);
88 d_add(dentry, inode);
89 return NULL;
90} 87}
91 88
92struct dentry *ext2_get_parent(struct dentry *child) 89struct dentry *ext2_get_parent(struct dentry *child)
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 522fa70dd8ea..8d6819846fc9 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -1152,7 +1152,7 @@ static ssize_t ext2_quota_write(struct super_block *sb, int type,
1152 struct buffer_head tmp_bh; 1152 struct buffer_head tmp_bh;
1153 struct buffer_head *bh; 1153 struct buffer_head *bh;
1154 1154
1155 down(&inode->i_sem); 1155 mutex_lock(&inode->i_mutex);
1156 while (towrite > 0) { 1156 while (towrite > 0) {
1157 tocopy = sb->s_blocksize - offset < towrite ? 1157 tocopy = sb->s_blocksize - offset < towrite ?
1158 sb->s_blocksize - offset : towrite; 1158 sb->s_blocksize - offset : towrite;
@@ -1189,7 +1189,7 @@ out:
1189 inode->i_version++; 1189 inode->i_version++;
1190 inode->i_mtime = inode->i_ctime = CURRENT_TIME; 1190 inode->i_mtime = inode->i_ctime = CURRENT_TIME;
1191 mark_inode_dirty(inode); 1191 mark_inode_dirty(inode);
1192 up(&inode->i_sem); 1192 mutex_unlock(&inode->i_mutex);
1193 return len - towrite; 1193 return len - towrite;
1194} 1194}
1195 1195
diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
index 0099462d4271..a2ca3107d475 100644
--- a/fs/ext2/xattr.c
+++ b/fs/ext2/xattr.c
@@ -325,7 +325,7 @@ cleanup:
325/* 325/*
326 * Inode operation listxattr() 326 * Inode operation listxattr()
327 * 327 *
328 * dentry->d_inode->i_sem: don't care 328 * dentry->d_inode->i_mutex: don't care
329 */ 329 */
330ssize_t 330ssize_t
331ext2_listxattr(struct dentry *dentry, char *buffer, size_t size) 331ext2_listxattr(struct dentry *dentry, char *buffer, size_t size)
@@ -389,10 +389,6 @@ ext2_xattr_set(struct inode *inode, int name_index, const char *name,
389 ea_idebug(inode, "name=%d.%s, value=%p, value_len=%ld", 389 ea_idebug(inode, "name=%d.%s, value=%p, value_len=%ld",
390 name_index, name, value, (long)value_len); 390 name_index, name, value, (long)value_len);
391 391
392 if (IS_RDONLY(inode))
393 return -EROFS;
394 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
395 return -EPERM;
396 if (value == NULL) 392 if (value == NULL)
397 value_len = 0; 393 value_len = 0;
398 if (name == NULL) 394 if (name == NULL)
diff --git a/fs/ext2/xattr_trusted.c b/fs/ext2/xattr_trusted.c
index 52b30ee6a25f..f28a6a499c96 100644
--- a/fs/ext2/xattr_trusted.c
+++ b/fs/ext2/xattr_trusted.c
@@ -7,6 +7,7 @@
7 7
8#include <linux/module.h> 8#include <linux/module.h>
9#include <linux/string.h> 9#include <linux/string.h>
10#include <linux/capability.h>
10#include <linux/fs.h> 11#include <linux/fs.h>
11#include <linux/smp_lock.h> 12#include <linux/smp_lock.h>
12#include <linux/ext2_fs.h> 13#include <linux/ext2_fs.h>
@@ -38,8 +39,6 @@ ext2_xattr_trusted_get(struct inode *inode, const char *name,
38{ 39{
39 if (strcmp(name, "") == 0) 40 if (strcmp(name, "") == 0)
40 return -EINVAL; 41 return -EINVAL;
41 if (!capable(CAP_SYS_ADMIN))
42 return -EPERM;
43 return ext2_xattr_get(inode, EXT2_XATTR_INDEX_TRUSTED, name, 42 return ext2_xattr_get(inode, EXT2_XATTR_INDEX_TRUSTED, name,
44 buffer, size); 43 buffer, size);
45} 44}
@@ -50,8 +49,6 @@ ext2_xattr_trusted_set(struct inode *inode, const char *name,
50{ 49{
51 if (strcmp(name, "") == 0) 50 if (strcmp(name, "") == 0)
52 return -EINVAL; 51 return -EINVAL;
53 if (!capable(CAP_SYS_ADMIN))
54 return -EPERM;
55 return ext2_xattr_set(inode, EXT2_XATTR_INDEX_TRUSTED, name, 52 return ext2_xattr_set(inode, EXT2_XATTR_INDEX_TRUSTED, name,
56 value, size, flags); 53 value, size, flags);
57} 54}
diff --git a/fs/ext2/xattr_user.c b/fs/ext2/xattr_user.c
index 0c03ea131a94..f383e7c3a7b5 100644
--- a/fs/ext2/xattr_user.c
+++ b/fs/ext2/xattr_user.c
@@ -35,16 +35,10 @@ static int
35ext2_xattr_user_get(struct inode *inode, const char *name, 35ext2_xattr_user_get(struct inode *inode, const char *name,
36 void *buffer, size_t size) 36 void *buffer, size_t size)
37{ 37{
38 int error;
39
40 if (strcmp(name, "") == 0) 38 if (strcmp(name, "") == 0)
41 return -EINVAL; 39 return -EINVAL;
42 if (!test_opt(inode->i_sb, XATTR_USER)) 40 if (!test_opt(inode->i_sb, XATTR_USER))
43 return -EOPNOTSUPP; 41 return -EOPNOTSUPP;
44 error = permission(inode, MAY_READ, NULL);
45 if (error)
46 return error;
47
48 return ext2_xattr_get(inode, EXT2_XATTR_INDEX_USER, name, buffer, size); 42 return ext2_xattr_get(inode, EXT2_XATTR_INDEX_USER, name, buffer, size);
49} 43}
50 44
@@ -52,18 +46,10 @@ static int
52ext2_xattr_user_set(struct inode *inode, const char *name, 46ext2_xattr_user_set(struct inode *inode, const char *name,
53 const void *value, size_t size, int flags) 47 const void *value, size_t size, int flags)
54{ 48{
55 int error;
56
57 if (strcmp(name, "") == 0) 49 if (strcmp(name, "") == 0)
58 return -EINVAL; 50 return -EINVAL;
59 if (!test_opt(inode->i_sb, XATTR_USER)) 51 if (!test_opt(inode->i_sb, XATTR_USER))
60 return -EOPNOTSUPP; 52 return -EOPNOTSUPP;
61 if ( !S_ISREG(inode->i_mode) &&
62 (!S_ISDIR(inode->i_mode) || inode->i_mode & S_ISVTX))
63 return -EPERM;
64 error = permission(inode, MAY_WRITE, NULL);
65 if (error)
66 return error;
67 53
68 return ext2_xattr_set(inode, EXT2_XATTR_INDEX_USER, name, 54 return ext2_xattr_set(inode, EXT2_XATTR_INDEX_USER, name,
69 value, size, flags); 55 value, size, flags);