diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-21 16:36:41 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-21 16:36:41 -0400 |
commit | e2a0883e4071237d09b604a342c28b96b44a04b3 (patch) | |
tree | aa56f4d376b5eb1c32358c19c2669c2a94e0e1fd /fs/namei.c | |
parent | 3a990a52f9f25f45469e272017a31e7a3fda60ed (diff) | |
parent | 07c0c5d8b8c122b2f2df9ee574ac3083daefc981 (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs pile 1 from Al Viro:
"This is _not_ all; in particular, Miklos' and Jan's stuff is not there
yet."
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (64 commits)
ext4: initialization of ext4_li_mtx needs to be done earlier
debugfs-related mode_t whack-a-mole
hfsplus: add an ioctl to bless files
hfsplus: change finder_info to u32
hfsplus: initialise userflags
qnx4: new helper - try_extent()
qnx4: get rid of qnx4_bread/qnx4_getblk
take removal of PF_FORKNOEXEC to flush_old_exec()
trim includes in inode.c
um: uml_dup_mmap() relies on ->mmap_sem being held, but activate_mm() doesn't hold it
um: embed ->stub_pages[] into mmu_context
gadgetfs: list_for_each_safe() misuse
ocfs2: fix leaks on failure exits in module_init
ecryptfs: make register_filesystem() the last potential failure exit
ntfs: forgets to unregister sysctls on register_filesystem() failure
logfs: missing cleanup on register_filesystem() failure
jfs: mising cleanup on register_filesystem() failure
make configfs_pin_fs() return root dentry on success
configfs: configfs_create_dir() has parent dentry in dentry->d_parent
configfs: sanitize configfs_create()
...
Diffstat (limited to 'fs/namei.c')
-rw-r--r-- | fs/namei.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/fs/namei.c b/fs/namei.c index 20a4fcf001ec..13e6a1f191a9 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -642,7 +642,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p) | |||
642 | cond_resched(); | 642 | cond_resched(); |
643 | current->total_link_count++; | 643 | current->total_link_count++; |
644 | 644 | ||
645 | touch_atime(link->mnt, dentry); | 645 | touch_atime(link); |
646 | nd_set_link(nd, NULL); | 646 | nd_set_link(nd, NULL); |
647 | 647 | ||
648 | error = security_inode_follow_link(link->dentry, nd); | 648 | error = security_inode_follow_link(link->dentry, nd); |
@@ -2691,6 +2691,7 @@ SYSCALL_DEFINE3(mknod, const char __user *, filename, umode_t, mode, unsigned, d | |||
2691 | int vfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) | 2691 | int vfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) |
2692 | { | 2692 | { |
2693 | int error = may_create(dir, dentry); | 2693 | int error = may_create(dir, dentry); |
2694 | unsigned max_links = dir->i_sb->s_max_links; | ||
2694 | 2695 | ||
2695 | if (error) | 2696 | if (error) |
2696 | return error; | 2697 | return error; |
@@ -2703,6 +2704,9 @@ int vfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) | |||
2703 | if (error) | 2704 | if (error) |
2704 | return error; | 2705 | return error; |
2705 | 2706 | ||
2707 | if (max_links && dir->i_nlink >= max_links) | ||
2708 | return -EMLINK; | ||
2709 | |||
2706 | error = dir->i_op->mkdir(dir, dentry, mode); | 2710 | error = dir->i_op->mkdir(dir, dentry, mode); |
2707 | if (!error) | 2711 | if (!error) |
2708 | fsnotify_mkdir(dir, dentry); | 2712 | fsnotify_mkdir(dir, dentry); |
@@ -3033,6 +3037,7 @@ SYSCALL_DEFINE2(symlink, const char __user *, oldname, const char __user *, newn | |||
3033 | int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry) | 3037 | int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry) |
3034 | { | 3038 | { |
3035 | struct inode *inode = old_dentry->d_inode; | 3039 | struct inode *inode = old_dentry->d_inode; |
3040 | unsigned max_links = dir->i_sb->s_max_links; | ||
3036 | int error; | 3041 | int error; |
3037 | 3042 | ||
3038 | if (!inode) | 3043 | if (!inode) |
@@ -3063,6 +3068,8 @@ int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_de | |||
3063 | /* Make sure we don't allow creating hardlink to an unlinked file */ | 3068 | /* Make sure we don't allow creating hardlink to an unlinked file */ |
3064 | if (inode->i_nlink == 0) | 3069 | if (inode->i_nlink == 0) |
3065 | error = -ENOENT; | 3070 | error = -ENOENT; |
3071 | else if (max_links && inode->i_nlink >= max_links) | ||
3072 | error = -EMLINK; | ||
3066 | else | 3073 | else |
3067 | error = dir->i_op->link(old_dentry, dir, new_dentry); | 3074 | error = dir->i_op->link(old_dentry, dir, new_dentry); |
3068 | mutex_unlock(&inode->i_mutex); | 3075 | mutex_unlock(&inode->i_mutex); |
@@ -3172,6 +3179,7 @@ static int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry, | |||
3172 | { | 3179 | { |
3173 | int error = 0; | 3180 | int error = 0; |
3174 | struct inode *target = new_dentry->d_inode; | 3181 | struct inode *target = new_dentry->d_inode; |
3182 | unsigned max_links = new_dir->i_sb->s_max_links; | ||
3175 | 3183 | ||
3176 | /* | 3184 | /* |
3177 | * If we are going to change the parent - check write permissions, | 3185 | * If we are going to change the parent - check write permissions, |
@@ -3195,6 +3203,11 @@ static int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry, | |||
3195 | if (d_mountpoint(old_dentry) || d_mountpoint(new_dentry)) | 3203 | if (d_mountpoint(old_dentry) || d_mountpoint(new_dentry)) |
3196 | goto out; | 3204 | goto out; |
3197 | 3205 | ||
3206 | error = -EMLINK; | ||
3207 | if (max_links && !target && new_dir != old_dir && | ||
3208 | new_dir->i_nlink >= max_links) | ||
3209 | goto out; | ||
3210 | |||
3198 | if (target) | 3211 | if (target) |
3199 | shrink_dcache_parent(new_dentry); | 3212 | shrink_dcache_parent(new_dentry); |
3200 | error = old_dir->i_op->rename(old_dir, old_dentry, new_dir, new_dentry); | 3213 | error = old_dir->i_op->rename(old_dir, old_dentry, new_dir, new_dentry); |