aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namei.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c15
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
2691int vfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) 2691int 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
3033int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry) 3037int 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);