Re: [PATCH v2] hfsplus: add HFSX subfolder count support

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

 



On Fri,  7 Feb 2014 20:35:59 +0100 Sergei Antonov <saproj@xxxxxxxxx> wrote:

> This patch adds support for HFSX 'HasFolderCount' flag and a corresponding
> 'folderCount' field in folder records. (For reference see HFS_FOLDERCOUNT
> and kHFSHasFolderCountBit/kHFSHasFolderCountMask in Apple's source code.)
> 
> Ignoring subfolder count leads to fs errors found by Mac:
> ...
> Checking catalog hierarchy.
> HasFolderCount flag needs to be set (id = 105)
> (It should be 0x10 instead of 0)
> Incorrect folder count in a directory (id = 2)
> (It should be 7 instead of 6)
> ...
> 
> Steps to reproduce:
>  Format with "newfs_hfs -s /dev/diskXXX".
>  Mount in Linux.
>  Create a new directory in root.
>  Unmount.
>  Run "fsck_hfs /dev/diskXXX".
> 
> The patch handles directory creation, deletion, and rename.
> 
> @@ -203,6 +205,36 @@ int hfsplus_find_cat(struct super_block *sb, u32 cnid,
>  	return hfs_brec_find(fd, hfs_find_rec_by_key);
>  }
>  
> +static void hfsplus_subfolders_inc(struct inode *dir)
> +{
> +	struct hfsplus_sb_info *sbi = HFSPLUS_SB(dir->i_sb);
> +
> +	if (test_bit(HFSPLUS_SB_HFSX, &sbi->flags)) {
> +		/*
> +		 * Increment subfolder count. Note, the value is only meaningful
> +		 * for folders with HFSPLUS_HAS_FOLDER_COUNT flag set.
> +		 */
> +		HFSPLUS_I(dir)->subfolders++;
> +	}
> +}
> +
> +static void hfsplus_subfolders_dec(struct inode *dir)
> +{
> +	struct hfsplus_sb_info *sbi = HFSPLUS_SB(dir->i_sb);
> +
> +	if (test_bit(HFSPLUS_SB_HFSX, &sbi->flags)) {
> +		/*
> +		 * Decrement subfolder count. Note, the value is only meaningful
> +		 * for folders with HFSPLUS_HAS_FOLDER_COUNT flag set.
> +		 *
> +		 * Check for zero. Some subfolders may have been created
> +		 * by an implementation ignorant of this counter.
> +		 */
> +		if (HFSPLUS_I(dir)->subfolders)
> +			HFSPLUS_I(dir)->subfolders--;
> +	}
> +}
> +

Two of hfsplus_rename_cat()'s callers hold vh_mutex, hfsplus_rename()
does not.  Which lock is preventing the obvious races here?

--
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