[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190815044155.88483-7-gaoxiang25@huawei.com>
Date: Thu, 15 Aug 2019 12:41:37 +0800
From: Gao Xiang <gaoxiang25@...wei.com>
To: <linux-fsdevel@...r.kernel.org>, <devel@...verdev.osuosl.org>,
"Alexander Viro" <viro@...iv.linux.org.uk>
CC: LKML <linux-kernel@...r.kernel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Stephen Rothwell <sfr@...b.auug.org.au>,
Theodore Ts'o <tytso@....edu>, "Pavel Machek" <pavel@...x.de>,
David Sterba <dsterba@...e.cz>,
Amir Goldstein <amir73il@...il.com>,
Christoph Hellwig <hch@...radead.org>,
"Darrick J . Wong" <darrick.wong@...cle.com>,
Dave Chinner <david@...morbit.com>,
"Jaegeuk Kim" <jaegeuk@...nel.org>, Jan Kara <jack@...e.cz>,
Richard Weinberger <richard@....at>,
Linus Torvalds <torvalds@...ux-foundation.org>,
<linux-erofs@...ts.ozlabs.org>, Chao Yu <yuchao0@...wei.com>,
Miao Xie <miaoxie@...wei.com>,
Li Guifu <bluce.liguifu@...wei.com>,
Fang Wei <fangwei1@...wei.com>,
Gao Xiang <gaoxiang25@...wei.com>
Subject: [PATCH v8 06/24] erofs: support special inode
This patch adds to support special inode, such as
block dev, char, socket, pipe inode.
Signed-off-by: Gao Xiang <gaoxiang25@...wei.com>
---
fs/erofs/inode.c | 32 ++++++++++++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
index 9960edaf6f7a..f55193856359 100644
--- a/fs/erofs/inode.c
+++ b/fs/erofs/inode.c
@@ -34,7 +34,16 @@ static int read_inode(struct inode *inode, void *data)
vi->xattr_isize = ondisk_xattr_ibody_size(v2->i_xattr_icount);
inode->i_mode = le16_to_cpu(v2->i_mode);
- vi->raw_blkaddr = le32_to_cpu(v2->i_u.raw_blkaddr);
+ if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
+ S_ISLNK(inode->i_mode))
+ vi->raw_blkaddr = le32_to_cpu(v2->i_u.raw_blkaddr);
+ else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
+ inode->i_rdev =
+ new_decode_dev(le32_to_cpu(v2->i_u.rdev));
+ else if (S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode))
+ inode->i_rdev = 0;
+ else
+ goto bogusimode;
i_uid_write(inode, le32_to_cpu(v2->i_uid));
i_gid_write(inode, le32_to_cpu(v2->i_gid));
@@ -58,7 +67,16 @@ static int read_inode(struct inode *inode, void *data)
vi->xattr_isize = ondisk_xattr_ibody_size(v1->i_xattr_icount);
inode->i_mode = le16_to_cpu(v1->i_mode);
- vi->raw_blkaddr = le32_to_cpu(v1->i_u.raw_blkaddr);
+ if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
+ S_ISLNK(inode->i_mode))
+ vi->raw_blkaddr = le32_to_cpu(v1->i_u.raw_blkaddr);
+ else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
+ inode->i_rdev =
+ new_decode_dev(le32_to_cpu(v1->i_u.rdev));
+ else if (S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode))
+ inode->i_rdev = 0;
+ else
+ goto bogusimode;
i_uid_write(inode, le16_to_cpu(v1->i_uid));
i_gid_write(inode, le16_to_cpu(v1->i_gid));
@@ -86,6 +104,11 @@ static int read_inode(struct inode *inode, void *data)
else
inode->i_blocks = nblks << LOG_SECTORS_PER_BLOCK;
return 0;
+
+bogusimode:
+ errln("bogus i_mode (%o) @ nid %llu", inode->i_mode, vi->nid);
+ DBG_BUGON(1);
+ return -EFSCORRUPTED;
}
/*
@@ -178,6 +201,11 @@ static int fill_inode(struct inode *inode, int isdir)
/* by default, page_get_link is used for symlink */
inode->i_op = &erofs_symlink_iops;
inode_nohighmem(inode);
+ } else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) ||
+ S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) {
+ inode->i_op = &erofs_generic_iops;
+ init_special_inode(inode, inode->i_mode, inode->i_rdev);
+ goto out_unlock;
} else {
err = -EFSCORRUPTED;
goto out_unlock;
--
2.17.1
Powered by blists - more mailing lists