Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1457500ybi; Fri, 2 Aug 2019 16:22:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqyY+e49fcfuZd/irv28dP/CdWySVKv0H2g91dPXuCot+HpnubIwQDvHJf7sEc7J8nBB3SR9 X-Received: by 2002:a17:902:20c8:: with SMTP id v8mr134206181plg.284.1564788132431; Fri, 02 Aug 2019 16:22:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564788132; cv=none; d=google.com; s=arc-20160816; b=Y+QhHtDuCk3VE/GKY/TQKgdOk6BXCtRLU8K1o9HWVGQef8MTfmheOHV33l2AiaEKIO m8EkHAUiw22L02CtGrHFonVaqZF0BumTEOQaw6kCCIIqfKWMUL8QQRcCUimGmzByGvr8 q5YmNDkkWG1wceAkrSp/Bz0AwOLCpCYHBEIGJ0xPro9mKQvqtiTDxzmm4mj4HNWLfB9K bUtmHB5At6OnPOYnIHtyxgc11J0yVHb9ZA6lLODl6UVAkyu820516Vub3bSKwiX8Ck/j ceuLUGiK1kN88JXRYvYjs2+lu0riIS+YHlW3teGsF2v3MAsdFDKv+5D+J5XCYzoNjlYm Ro7A== 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=xfA6kO52QAxQdQejgOWkGGjV30k3Qzma4An9CtVRZFo=; b=D7X9NhUVwdyOtX2H720XitAJhJX/iDF9oU8emdlz2gizU4z4Z/4ymhFYUND1jZWF9L UsvA3f8i+wv3N+wvLrJXltIMc5CHScPNiDC31qe9jl1I+eBD423ctppsZejVebeo0t4q t7lybPbHuP/woVKxCDj43CyWmg5VFi30RYkYoyaNnBL0+TqODWedRVdkuG32u+Dk4Aml VLuAjwG1PUABgmNkFaeNwpDCKYmwRELy+9D2Cd+wnJ+HMjV1IgRTfLNKJypOFPPJjZjj 3s1kA9o+bg1QW1JBNxBGP3I4Awhb6IxjoGMZFiQhiUe2S7HSdlJJotWFQAzvRxsYWiX/ /OVw== 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 j4si2135076pgq.375.2019.08.02.16.21.57; Fri, 02 Aug 2019 16:22:12 -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 S2392663AbfHBMya (ORCPT + 99 others); Fri, 2 Aug 2019 08:54:30 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:3709 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389526AbfHBMy0 (ORCPT ); Fri, 2 Aug 2019 08:54:26 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id A9AACE570F47F5F04040; Fri, 2 Aug 2019 20:54:22 +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; Fri, 2 Aug 2019 20:54:14 +0800 From: Gao Xiang To: Alexander Viro , Greg Kroah-Hartman , Andrew Morton , Stephen Rothwell , Theodore Ts'o , "Pavel Machek" , David Sterba , Amir Goldstein , Christoph Hellwig , "Darrick J . Wong" , Dave Chinner , "Jaegeuk Kim" , Jan Kara , Linus Torvalds CC: , , LKML , , Chao Yu , Miao Xie , Li Guifu , Fang Wei , Gao Xiang Subject: [PATCH v6 06/24] erofs: support special inode Date: Fri, 2 Aug 2019 20:53:29 +0800 Message-ID: <20190802125347.166018-7-gaoxiang25@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190802125347.166018-1-gaoxiang25@huawei.com> References: <20190802125347.166018-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 b6ea997bc4ae..637bf6e4de44 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