Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6513701ybi; Sun, 21 Jul 2019 19:54:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqxtywlGuNsh20iwn8Cw9KyoSoOu95zdYV6/ENoowhIPqzz+iS+Gd70f2+kj1JWfvSNpOD2U X-Received: by 2002:a63:dd16:: with SMTP id t22mr37702530pgg.140.1563764048920; Sun, 21 Jul 2019 19:54:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563764048; cv=none; d=google.com; s=arc-20160816; b=oSM+sacR5cnwCG9Dv2C87UjjrhSnDqVmQA29s620Z+UC0ssVE+S9EymVdCJbsPOdcQ 4fZLaXoeu8oNPEme7EQjXXLAVaqfuHphzrVsO32axG3GMGM8Xp5ob+G98RsKOtmfbbZa Plu/+PyIYi/ikHtx6yd1/DPeAaEFpw80b2oiET6zyDnR7CMXeX+dWGy0aA0iCf5r9Vma kPpUSpT0yHJQ7rGC8+0oRMPakOMx12mMYuu7qKevzUIiUHTrIhjgd7J26SOAueIKlP0N fnM2uqsJfGrMQbf1fykqZISfyo22Alj7aLd9u1BN+ewedvn5XHDAWeT7SE622DRIX3DD zOzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=jZL36WGl/3+5CcQUCcDJr9Llq8xEJUtbWPFyxV2nZ3M=; b=DMq08WODN2Qdh4lOY9I3c/cn1uFGqxkXvt1mEVqysMoNyJB9O3WIsbHCf2UHpu0T7y 26EjQo0KgEPqAN4lmG4zSQZCXOMbRvc10mBQwuY/fkZ9BN0bOr4uPOZbP2A9Dogwj1z4 uDWtdbEgFV9xlaA6p7LC6+soYuD0wVKJ2G9Gu+dtf1VQ/Pim3568I71nqOmXbeZprTt4 CK2sxtoetrIk2IPiGe0VDte8CeZenQol9rajpGJ1QjR+wurbnr1JJs5rLnCdmqWS7jUI oCX4m7hlELKYSAwIjjLWGET0iG2jlVzjy/QhVe+sVCEYRu9UW/FtYpJlVVPicnZW240z VTbg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a1si10429501pff.73.2019.07.21.19.53.53; Sun, 21 Jul 2019 19:54:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728750AbfGVCwv (ORCPT + 99 others); Sun, 21 Jul 2019 22:52:51 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:38638 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728718AbfGVCvK (ORCPT ); Sun, 21 Jul 2019 22:51:10 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 91C78888231FD268BA03; Mon, 22 Jul 2019 10:51:08 +0800 (CST) Received: from architecture4.huawei.com (10.140.130.215) by smtp.huawei.com (10.3.19.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 22 Jul 2019 10:51:00 +0800 From: Gao Xiang To: Alexander Viro , Greg Kroah-Hartman , Andrew Morton , Stephen Rothwell , Theodore Ts'o , "Linus Torvalds" CC: , , LKML , , Chao Yu , Miao Xie , Li Guifu , Fang Wei , Gao Xiang Subject: [PATCH v3 06/24] erofs: support special inode Date: Mon, 22 Jul 2019 10:50:25 +0800 Message-ID: <20190722025043.166344-7-gaoxiang25@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190722025043.166344-1-gaoxiang25@huawei.com> References: <20190722025043.166344-1-gaoxiang25@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.140.130.215] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds to support special inode, such as block dev, char, socket, pipe inode. Signed-off-by: Gao Xiang --- fs/erofs/inode.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c index 79ef5b38dfa3..5a95cd076fcc 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 + return -EIO; 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 + return -EIO; i_uid_write(inode, le16_to_cpu(v1->i_uid)); i_gid_write(inode, le16_to_cpu(v1->i_gid)); @@ -176,6 +194,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 = -EIO; goto out_unlock; -- 2.17.1