Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp383479imm; Thu, 26 Jul 2018 05:26:57 -0700 (PDT) X-Google-Smtp-Source: AAOMgpccHNCvG+81hsToEuthAxCJ8+lzq8CMjJz6JtdAgs5bi+nXupL/TUT4uRlp1ybCSc5XRnxw X-Received: by 2002:a63:f18:: with SMTP id e24-v6mr1783145pgl.320.1532608017780; Thu, 26 Jul 2018 05:26:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532608017; cv=none; d=google.com; s=arc-20160816; b=pscxn5ONgGoiPmmxThOvKiCS0ODNxRZT4YK5swjuah0X5XrK0Y1bOw68n7G1CqBz4n zkB0prO+3pybLwJAhVDougeFP05Ohk47I6ELsWlfZl0Zd6SU7WO4V/bLG/da5kV3ICkX eFbMa+gg1iJB4dVzbiOneDdJsql4m6e13/+g6vtxXlEF1zHFJC5kqX61h03WaLn/nO57 GvEboRLzndUjRIi+AyFlhNFm4uchd9+W7etM8L1fSYsRNXjwTqDc8Eo2gML86+s0VDc4 hDHdlyTiCLOntXyxx/piTd9AlpF2Pi2P1Si1XKEFhnNt+bYjkIw585atLfjgG+xtSwex MlWQ== 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:arc-authentication-results; bh=lELZHzvyt8/LyVKpdaaUhMIC55o0KJ+Jq6QiCMFog3w=; b=AoOpNFtNxLJN7tX1ebfXXTqeGsm6n0JW2ag8Iv7iovba5pEMHmtWDZ//wVenfLEyQa J0XTnhUXxp7viQXkExL3HUPEoAPlH5qccyYc6Qht9UmZ6IwLSIkmhu2Q8r3TLcQAuYxu c9NS1KWJrBXP1w5vkNvBGx3gTVOJLzxYp1HXnRT5vDyLAMNfrTzMlvlkRakvG6bRpApV rWoqF48pYphNGfy35hxH3BkwrHuUDlWGTO2f83sr22pqxdjndMW9lTqNLxaXqP1VrINT /Chg0idE1Sj9nZDjH1TZEZSdWL3fyZJGuwifrY37+VPFXR0NIRHzmRw7qHEOsKOzyWUV EZVQ== 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 z68-v6si1265928pfz.163.2018.07.26.05.26.43; Thu, 26 Jul 2018 05:26:57 -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 S1731157AbeGZNmS (ORCPT + 99 others); Thu, 26 Jul 2018 09:42:18 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:9725 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730599AbeGZNmR (ORCPT ); Thu, 26 Jul 2018 09:42:17 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 6FD2DA1C47EC8; Thu, 26 Jul 2018 20:25:35 +0800 (CST) Received: from szvp000100637.huawei.com (10.162.55.131) by smtp.huawei.com (10.3.19.208) with Microsoft SMTP Server (TLS) id 14.3.382.0; Thu, 26 Jul 2018 20:25:28 +0800 From: Gao Xiang To: Greg Kroah-Hartman , CC: , , , , , , , Subject: [PATCH 10/25] staging: erofs: support special inode Date: Thu, 26 Jul 2018 20:21:53 +0800 Message-ID: <1532607728-103372-11-git-send-email-gaoxiang25@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1532607728-103372-1-git-send-email-gaoxiang25@huawei.com> References: <1527764767-22190-1-git-send-email-gaoxiang25@huawei.com> <1532607728-103372-1-git-send-email-gaoxiang25@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.162.55.131] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chao Yu This patch adds to support special inode, such as block dev, char, socket, pipe inode. Reviewed-by: Gao Xiang Signed-off-by: Chao Yu --- drivers/staging/erofs/inode.c | 36 ++++++++++++++++++++++++++++++++++-- drivers/staging/erofs/internal.h | 1 + 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/drivers/staging/erofs/inode.c b/drivers/staging/erofs/inode.c index 15ed919..c011811 100644 --- a/drivers/staging/erofs/inode.c +++ b/drivers/staging/erofs/inode.c @@ -34,8 +34,18 @@ static int read_inode(struct inode *inode, void *data) vi->inode_isize = sizeof(struct erofs_inode_v2); vi->xattr_isize = ondisk_xattr_ibody_size(v2->i_xattr_icount); - vi->raw_blkaddr = le32_to_cpu(v2->i_u.raw_blkaddr); inode->i_mode = le16_to_cpu(v2->i_mode); + 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)); @@ -54,8 +64,18 @@ static int read_inode(struct inode *inode, void *data) vi->inode_isize = sizeof(struct erofs_inode_v1); vi->xattr_isize = ondisk_xattr_ibody_size(v1->i_xattr_icount); - vi->raw_blkaddr = le32_to_cpu(v1->i_u.raw_blkaddr); inode->i_mode = le16_to_cpu(v1->i_mode); + 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)); @@ -173,6 +193,12 @@ static int fill_inode(struct inode *inode, int isdir) &page_symlink_inode_operations; #endif 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)) { +#ifdef CONFIG_EROFS_FS_XATTR + inode->i_op = &erofs_special_inode_operations; +#endif + init_special_inode(inode, inode->i_mode, inode->i_rdev); } else { err = -EIO; goto out_unlock; @@ -232,6 +258,12 @@ struct inode *erofs_iget(struct super_block *sb, }; #endif +const struct inode_operations erofs_special_inode_operations = { +#ifdef CONFIG_EROFS_FS_XATTR + .listxattr = erofs_listxattr, +#endif +}; + #ifdef CONFIG_EROFS_FS_XATTR const struct inode_operations erofs_fast_symlink_xattr_iops = { .get_link = simple_get_link, diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h index 8a8caf0..5862705 100644 --- a/drivers/staging/erofs/internal.h +++ b/drivers/staging/erofs/internal.h @@ -252,6 +252,7 @@ int erofs_namei(struct inode *dir, struct qstr *name, #ifdef CONFIG_EROFS_FS_XATTR extern const struct inode_operations erofs_symlink_xattr_iops; extern const struct inode_operations erofs_fast_symlink_xattr_iops; +extern const struct inode_operations erofs_special_inode_operations; #endif static inline void set_inode_fast_symlink(struct inode *inode) -- 1.9.1