udf: Preserve link count of system files

commit fc8033a34a3ca7d23353e645e6dde5d364ac5f12 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Jan Kara
2023-01-03 09:56:56 +01:00
committed by Greg Kroah-Hartman
parent eb2133900c
commit 63478c3ce2
3 changed files with 10 additions and 3 deletions

View File

@@ -1385,6 +1385,7 @@ reread:
ret = -EIO;
goto out;
}
iinfo->i_hidden = hidden_inode;
iinfo->i_unique = 0;
iinfo->i_lenEAttr = 0;
iinfo->i_lenExtents = 0;
@@ -1720,8 +1721,12 @@ static int udf_update_inode(struct inode *inode, int do_sync)
if (S_ISDIR(inode->i_mode) && inode->i_nlink > 0)
fe->fileLinkCount = cpu_to_le16(inode->i_nlink - 1);
else
fe->fileLinkCount = cpu_to_le16(inode->i_nlink);
else {
if (iinfo->i_hidden)
fe->fileLinkCount = cpu_to_le16(0);
else
fe->fileLinkCount = cpu_to_le16(inode->i_nlink);
}
fe->informationLength = cpu_to_le64(inode->i_size);