xattr.c (b05f30bcf71b8060d4a32b11353aaa2c5b0a8e3d) xattr.c (9e382914617c5cab89a01a223b8d00bbd43ad3b3)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Copyright (C) 2017-2018 HUAWEI, Inc.
4 * https://www.huawei.com/
5 * Copyright (C) 2021-2022, Alibaba Cloud
6 */
7#include <linux/security.h>
8#include "xattr.h"

--- 596 unchanged lines hidden (view full) ---

605
606 ret = inline_listxattr(&it);
607 if (ret >= 0 || ret == -ENOATTR)
608 ret = shared_listxattr(&it);
609 erofs_put_metabuf(&it.it.buf);
610 return ret;
611}
612
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Copyright (C) 2017-2018 HUAWEI, Inc.
4 * https://www.huawei.com/
5 * Copyright (C) 2021-2022, Alibaba Cloud
6 */
7#include <linux/security.h>
8#include "xattr.h"

--- 596 unchanged lines hidden (view full) ---

605
606 ret = inline_listxattr(&it);
607 if (ret >= 0 || ret == -ENOATTR)
608 ret = shared_listxattr(&it);
609 erofs_put_metabuf(&it.it.buf);
610 return ret;
611}
612
613void erofs_xattr_prefixes_cleanup(struct super_block *sb)
614{
615 struct erofs_sb_info *sbi = EROFS_SB(sb);
616 int i;
617
618 if (sbi->xattr_prefixes) {
619 for (i = 0; i < sbi->xattr_prefix_count; i++)
620 kfree(sbi->xattr_prefixes[i].prefix);
621 kfree(sbi->xattr_prefixes);
622 sbi->xattr_prefixes = NULL;
623 }
624}
625
626int erofs_xattr_prefixes_init(struct super_block *sb)
627{
628 struct erofs_sb_info *sbi = EROFS_SB(sb);
629 struct erofs_buf buf = __EROFS_BUF_INITIALIZER;
630 erofs_off_t pos = (erofs_off_t)sbi->xattr_prefix_start << 2;
631 struct erofs_xattr_prefix_item *pfs;
632 int ret = 0, i, len;
633
634 if (!sbi->xattr_prefix_count)
635 return 0;
636
637 pfs = kzalloc(sbi->xattr_prefix_count * sizeof(*pfs), GFP_KERNEL);
638 if (!pfs)
639 return -ENOMEM;
640
641 if (erofs_sb_has_fragments(sbi))
642 buf.inode = sbi->packed_inode;
643 else
644 erofs_init_metabuf(&buf, sb);
645
646 for (i = 0; i < sbi->xattr_prefix_count; i++) {
647 void *ptr = erofs_read_metadata(sb, &buf, &pos, &len);
648
649 if (IS_ERR(ptr)) {
650 ret = PTR_ERR(ptr);
651 break;
652 } else if (len < sizeof(*pfs->prefix) ||
653 len > EROFS_NAME_LEN + sizeof(*pfs->prefix)) {
654 kfree(ptr);
655 ret = -EFSCORRUPTED;
656 break;
657 }
658 pfs[i].prefix = ptr;
659 pfs[i].infix_len = len - sizeof(struct erofs_xattr_long_prefix);
660 }
661
662 erofs_put_metabuf(&buf);
663 sbi->xattr_prefixes = pfs;
664 if (ret)
665 erofs_xattr_prefixes_cleanup(sb);
666 return ret;
667}
668
613#ifdef CONFIG_EROFS_FS_POSIX_ACL
614struct posix_acl *erofs_get_acl(struct inode *inode, int type, bool rcu)
615{
616 struct posix_acl *acl;
617 int prefix, rc;
618 char *value = NULL;
619
620 if (rcu)

--- 31 unchanged lines hidden ---
669#ifdef CONFIG_EROFS_FS_POSIX_ACL
670struct posix_acl *erofs_get_acl(struct inode *inode, int type, bool rcu)
671{
672 struct posix_acl *acl;
673 int prefix, rc;
674 char *value = NULL;
675
676 if (rcu)

--- 31 unchanged lines hidden ---