From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-113.freemail.mail.aliyun.com (out30-113.freemail.mail.aliyun.com [115.124.30.113]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CEFA01FB1 for ; Mon, 29 Dec 2025 09:30:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.113 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767000609; cv=none; b=Kp20/eKIgqDzePKIE5nrtXSQoDzhX3B3XTowsFbDfw8l4cyUyeEKNZMwIfZaLd0PMPlL2jalr9X1ZJPjIra7vSuoCKmjtTbGA8watn5LPhUMHlHLjzYyYEUQAf8xtVApRNcWEz6L7ajxY54/lEP341MOZvMFeWUMsWtcTT+m8Zw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767000609; c=relaxed/simple; bh=EYDC5kiFIov4/QwVdRQUM+IbRg3lU235SACZ+WH1sPM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Hu/C05MqTB/gdQ1jDTkWbKhNrDdEMwYofLSG3Ek3AF2LR6+npJJC+/h8SMHwSrS7UuitQdt1MMzkHi05xf2yJlAAhulcTkGfd0BZAczCzSsoN16lvWZ60qFSjwygVv3hESb0JuBGYSnF4e7QjEypiXaSLPacqm8uomkq6uFSisg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=Bpy9QKzH; arc=none smtp.client-ip=115.124.30.113 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="Bpy9QKzH" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1767000595; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=JCzITJuRjeKFtm3K6ox8VTBVlLhqGgUOp9rwEBGomNU=; b=Bpy9QKzHl7kOGdr+9TWwSQ5unRZilwsfob1fMkCFuanua033oShMpgpxD5cvk3E59f5mWR8VhBdCUSjUTCDUFsoeZIllC99NXzLRfJljNIypeyU+zlPWRS6XqyjN2WIIDkt20fctxRdg0VdwhNcM3+kGBrkoXdGx/SUC6BxZS7w= Received: from x31i01179.sqa.na131.tbsite.net(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0Wvqzdsy_1767000594 cluster:ay36) by smtp.aliyun-inc.com; Mon, 29 Dec 2025 17:29:55 +0800 From: Gao Xiang To: linux-erofs@lists.ozlabs.org Cc: LKML , Gao Xiang Subject: [PATCH 3/4] erofs: unexport erofs_getxattr() Date: Mon, 29 Dec 2025 17:29:48 +0800 Message-ID: <20251229092949.2316075-3-hsiangkao@linux.alibaba.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20251229092949.2316075-1-hsiangkao@linux.alibaba.com> References: <20251229092949.2316075-1-hsiangkao@linux.alibaba.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit No external users other than those in xattr.c. Signed-off-by: Gao Xiang --- fs/erofs/xattr.c | 108 +++++++++++++++++++++++------------------------ fs/erofs/xattr.h | 7 --- 2 files changed, 54 insertions(+), 61 deletions(-) diff --git a/fs/erofs/xattr.c b/fs/erofs/xattr.c index 396536d9a862..972941ecb71c 100644 --- a/fs/erofs/xattr.c +++ b/fs/erofs/xattr.c @@ -125,58 +125,6 @@ static int erofs_init_inode_xattrs(struct inode *inode) return ret; } -static bool erofs_xattr_user_list(struct dentry *dentry) -{ - return test_opt(&EROFS_SB(dentry->d_sb)->opt, XATTR_USER); -} - -static bool erofs_xattr_trusted_list(struct dentry *dentry) -{ - return capable(CAP_SYS_ADMIN); -} - -static int erofs_xattr_generic_get(const struct xattr_handler *handler, - struct dentry *unused, struct inode *inode, - const char *name, void *buffer, size_t size) -{ - if (handler->flags == EROFS_XATTR_INDEX_USER && - !test_opt(&EROFS_I_SB(inode)->opt, XATTR_USER)) - return -EOPNOTSUPP; - - return erofs_getxattr(inode, handler->flags, name, buffer, size); -} - -const struct xattr_handler erofs_xattr_user_handler = { - .prefix = XATTR_USER_PREFIX, - .flags = EROFS_XATTR_INDEX_USER, - .list = erofs_xattr_user_list, - .get = erofs_xattr_generic_get, -}; - -const struct xattr_handler erofs_xattr_trusted_handler = { - .prefix = XATTR_TRUSTED_PREFIX, - .flags = EROFS_XATTR_INDEX_TRUSTED, - .list = erofs_xattr_trusted_list, - .get = erofs_xattr_generic_get, -}; - -#ifdef CONFIG_EROFS_FS_SECURITY -const struct xattr_handler __maybe_unused erofs_xattr_security_handler = { - .prefix = XATTR_SECURITY_PREFIX, - .flags = EROFS_XATTR_INDEX_SECURITY, - .get = erofs_xattr_generic_get, -}; -#endif - -const struct xattr_handler * const erofs_xattr_handlers[] = { - &erofs_xattr_user_handler, - &erofs_xattr_trusted_handler, -#ifdef CONFIG_EROFS_FS_SECURITY - &erofs_xattr_security_handler, -#endif - NULL, -}; - static int erofs_xattr_copy_to_buffer(struct erofs_xattr_iter *it, unsigned int len) { @@ -391,8 +339,8 @@ static int erofs_xattr_iter_shared(struct erofs_xattr_iter *it, return i ? ret : -ENODATA; } -int erofs_getxattr(struct inode *inode, int index, const char *name, - void *buffer, size_t buffer_size) +static int erofs_getxattr(struct inode *inode, int index, const char *name, + void *buffer, size_t buffer_size) { int ret; unsigned int hashbit; @@ -462,6 +410,58 @@ ssize_t erofs_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size) return ret ? ret : it.buffer_ofs; } +static bool erofs_xattr_user_list(struct dentry *dentry) +{ + return test_opt(&EROFS_SB(dentry->d_sb)->opt, XATTR_USER); +} + +static bool erofs_xattr_trusted_list(struct dentry *dentry) +{ + return capable(CAP_SYS_ADMIN); +} + +static int erofs_xattr_generic_get(const struct xattr_handler *handler, + struct dentry *unused, struct inode *inode, + const char *name, void *buffer, size_t size) +{ + if (handler->flags == EROFS_XATTR_INDEX_USER && + !test_opt(&EROFS_I_SB(inode)->opt, XATTR_USER)) + return -EOPNOTSUPP; + + return erofs_getxattr(inode, handler->flags, name, buffer, size); +} + +const struct xattr_handler erofs_xattr_user_handler = { + .prefix = XATTR_USER_PREFIX, + .flags = EROFS_XATTR_INDEX_USER, + .list = erofs_xattr_user_list, + .get = erofs_xattr_generic_get, +}; + +const struct xattr_handler erofs_xattr_trusted_handler = { + .prefix = XATTR_TRUSTED_PREFIX, + .flags = EROFS_XATTR_INDEX_TRUSTED, + .list = erofs_xattr_trusted_list, + .get = erofs_xattr_generic_get, +}; + +#ifdef CONFIG_EROFS_FS_SECURITY +const struct xattr_handler __maybe_unused erofs_xattr_security_handler = { + .prefix = XATTR_SECURITY_PREFIX, + .flags = EROFS_XATTR_INDEX_SECURITY, + .get = erofs_xattr_generic_get, +}; +#endif + +const struct xattr_handler * const erofs_xattr_handlers[] = { + &erofs_xattr_user_handler, + &erofs_xattr_trusted_handler, +#ifdef CONFIG_EROFS_FS_SECURITY + &erofs_xattr_security_handler, +#endif + NULL, +}; + void erofs_xattr_prefixes_cleanup(struct super_block *sb) { struct erofs_sb_info *sbi = EROFS_SB(sb); diff --git a/fs/erofs/xattr.h b/fs/erofs/xattr.h index 6317caa8413e..ee1d8c310d97 100644 --- a/fs/erofs/xattr.h +++ b/fs/erofs/xattr.h @@ -45,17 +45,10 @@ extern const struct xattr_handler * const erofs_xattr_handlers[]; int erofs_xattr_prefixes_init(struct super_block *sb); void erofs_xattr_prefixes_cleanup(struct super_block *sb); -int erofs_getxattr(struct inode *, int, const char *, void *, size_t); ssize_t erofs_listxattr(struct dentry *, char *, size_t); #else static inline int erofs_xattr_prefixes_init(struct super_block *sb) { return 0; } static inline void erofs_xattr_prefixes_cleanup(struct super_block *sb) {} -static inline int erofs_getxattr(struct inode *inode, int index, - const char *name, void *buffer, - size_t buffer_size) -{ - return -EOPNOTSUPP; -} #define erofs_listxattr (NULL) #define erofs_xattr_handlers (NULL) -- 2.43.5