Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2089282ybl; Thu, 29 Aug 2019 03:26:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqyThM9gpw/6F2BQzv/rjuaQlTvO/ARMLigDlhHx662L/l53b5+eMTRlXNok94dH9qIepeUd X-Received: by 2002:a63:c442:: with SMTP id m2mr7827355pgg.286.1567074394285; Thu, 29 Aug 2019 03:26:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567074394; cv=none; d=google.com; s=arc-20160816; b=u0C+0G4GbfIILryJkF4FKBjlCVVu6HfweyUuyKDHUDZlEeJejNXFFy9cR2dmb6NTSy VUH/oXJfygtdV52U0e6DIeiXp/Uyu/g8thgpCdi3r1GAOgmB5YSROHsW7ekKIf44V8ey 18oL1NhHV+/S/oJp+SxYL0RAKVAi+WOKvoOqD/1zNBFic17rW3nJjFvrCrvKojPz33f2 2NkwjYOqC+qP6dmjshux6N5nYJRE6eiKy9yRToq028q3Q3FrJOVtmPm9APCSVBa/b513 pO7CG0X7VqBIA+qtwSxp5NhWc/JY8WuLEczxqAmfmW6CvWQc891pn8j3EVznNJZiePY6 nsWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=2+CihOn1ngbaXeMiWDZKT9pHBOLXEG5xdssh2kdm+FU=; b=CdXPa+fItm5e8PVrnJcceN2xi09j2sDlW1iwXD3sDQs26bo6Q9Ymk7s+hLp5AQ4sTI 3aojxA8MVCG1CQikctG3MGb+n4I29cG4hKdCTTBmytAj8HbkfYXSSUMT7itnCYeUk4pv unJ/DrJ0VAfQ7gA848OLdUcXRqZGqLoVGD5mY/MH/V3sHfJ9bticYZtzeND+S2frzs1M qIosOe3GLJtl05BBZ510hj9l0JYJt69aEUfKhS/HlW/epiPmgY339drt6lCiQc2IIa5d kaFNgPh2UR3mQh3MmRV4/Fuv17RSNX22emc5pV1p5pgeRrSUFVj3p8SGAXeyuxQTqAjK ssHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=bOFsHPhy; 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 u14si1799774pjn.61.2019.08.29.03.26.17; Thu, 29 Aug 2019 03:26:34 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=bOFsHPhy; 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 S1727392AbfH2KZM (ORCPT + 99 others); Thu, 29 Aug 2019 06:25:12 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:55928 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726379AbfH2KZM (ORCPT ); Thu, 29 Aug 2019 06:25:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=2+CihOn1ngbaXeMiWDZKT9pHBOLXEG5xdssh2kdm+FU=; b=bOFsHPhysKyAq5Gk7Q+fYHwPG iIQh3sbehCzj0y6PhFfTvp0pxAies6r61lOhRpVgZFqpYU0tVuks3QRfD3w/P1ReFRdy1NHICjQIl H9PIKfxeTt0owWTegVbv7eKZ+k9+pxGOkVmcXB9mj7Y7obaXREYDY6tBtNOGDF2QWGC5PV4nOivWW RLNyP7iov5cz6Y6dr9AnnWUuYsVyZtHyfqKXb5daSGwhX8UeLoqHFtwAkA20OkYz2kuExCC/qZl9T 9fxqPbUktLqeJ9dyGSAeIrQexg3y6XhSrvysYYtUg0IE1It6mQxA/aqGEQXz8csfXdYWu1ijAOe09 2U5M+blcg==; Received: from hch by bombadil.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1i3Hbz-0007WE-RG; Thu, 29 Aug 2019 10:25:03 +0000 Date: Thu, 29 Aug 2019 03:25:03 -0700 From: Christoph Hellwig To: Gao Xiang Cc: 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 , linux-fsdevel@vger.kernel.org, devel@driverdev.osuosl.org, LKML , linux-erofs@lists.ozlabs.org, Chao Yu , Miao Xie , Li Guifu , Fang Wei Subject: Re: [PATCH v6 06/24] erofs: support special inode Message-ID: <20190829102503.GF20598@infradead.org> References: <20190802125347.166018-1-gaoxiang25@huawei.com> <20190802125347.166018-7-gaoxiang25@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190802125347.166018-7-gaoxiang25@huawei.com> User-Agent: Mutt/1.11.4 (2019-03-13) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 02, 2019 at 08:53:29PM +0800, Gao Xiang wrote: > 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; Please use a switch statement when dealing with the file modes to make everything easier to read.