Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

udf: Preserve link count of system files

System files in UDF filesystem have link count 0. To not confuse VFS we
fudge the link count to be 1 when reading such inodes however we forget
to restore the link count of 0 when writing such inodes. Fix that.

CC: stable@vger.kernel.org
Signed-off-by: Jan Kara <jack@suse.cz>

Jan Kara fc8033a3 256fe416

+10 -3
+7 -2
fs/udf/inode.c
··· 1301 1301 ret = -EIO; 1302 1302 goto out; 1303 1303 } 1304 + iinfo->i_hidden = hidden_inode; 1304 1305 iinfo->i_unique = 0; 1305 1306 iinfo->i_lenEAttr = 0; 1306 1307 iinfo->i_lenExtents = 0; ··· 1637 1636 1638 1637 if (S_ISDIR(inode->i_mode) && inode->i_nlink > 0) 1639 1638 fe->fileLinkCount = cpu_to_le16(inode->i_nlink - 1); 1640 - else 1641 - fe->fileLinkCount = cpu_to_le16(inode->i_nlink); 1639 + else { 1640 + if (iinfo->i_hidden) 1641 + fe->fileLinkCount = cpu_to_le16(0); 1642 + else 1643 + fe->fileLinkCount = cpu_to_le16(inode->i_nlink); 1644 + } 1642 1645 1643 1646 fe->informationLength = cpu_to_le64(inode->i_size); 1644 1647
+1
fs/udf/super.c
··· 147 147 ei->i_next_alloc_goal = 0; 148 148 ei->i_strat4096 = 0; 149 149 ei->i_streamdir = 0; 150 + ei->i_hidden = 0; 150 151 init_rwsem(&ei->i_data_sem); 151 152 ei->cached_extent.lstart = -1; 152 153 spin_lock_init(&ei->i_extent_cache_lock);
+2 -1
fs/udf/udf_i.h
··· 44 44 unsigned i_use : 1; /* unallocSpaceEntry */ 45 45 unsigned i_strat4096 : 1; 46 46 unsigned i_streamdir : 1; 47 - unsigned reserved : 25; 47 + unsigned i_hidden : 1; /* hidden system inode */ 48 + unsigned reserved : 24; 48 49 __u8 *i_data; 49 50 struct kernel_lb_addr i_locStreamdir; 50 51 __u64 i_lenStreams;