Re: [PATCH] hfsplus: disable rename of directory hardlinks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2011-05-03, at 8:26 AM, Gustav Munkby <grddev@xxxxxxxxx> wrote:
> Signed-off-by: Gustav Munkby <grddev@xxxxxxxxx>
> ---
> fs/hfsplus/dir.c |    9 ++++++++-
> 1 files changed, 8 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
> index 4df5059..3c35296 100644
> --- a/fs/hfsplus/dir.c
> +++ b/fs/hfsplus/dir.c
> @@ -108,7 +108,7 @@ again:
>    inode = hfsplus_iget(dir->i_sb, cnid);
>    if (IS_ERR(inode))
>        return ERR_CAST(inode);
> -    if (S_ISREG(inode->i_mode))
> +    if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode))
>        HFSPLUS_I(inode)->linkid = linkid;
> out:
>    d_add(dentry, inode);
> @@ -465,6 +465,13 @@ static int hfsplus_rename(struct inode *old_dir, struct dentry *old_dentry,
> {
>    int res;
> 
> +    /* Renaming directory hardlinks to could create loops.
> +     * Conservatively prevent any hardlink renaming.
> +     */

It should also be safe to rename a directory hard link if the source and target parent directories are the same. 

This would allow the case of changing the directory name without moving it to another location.  

> +    if (S_ISDIR(old_dentry->d_inode->i_mode) &&
> +            HFSPLUS_I(old_dentry->d_inode)->linkid)
> +        return -EPERM;
> +
>    /* Unlink destination if it already exists */
>    if (new_dentry->d_inode) {
>        if (S_ISDIR(new_dentry->d_inode->i_mode))
> -- 
> 1.7.5
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux