Lines Matching +full:entry +full:- +full:name

1 // SPDX-License-Identifier: GPL-2.0
10 * Copyright (C) 2001-2003 Andreas Gruenbacher <agruen@suse.de>
28 if (likely(size == sbi->inline_xattr_slab_size)) { in xattr_alloc()
30 return f2fs_kmem_cache_alloc(sbi->inline_xattr_slab, in xattr_alloc()
41 kmem_cache_free(sbi->inline_xattr_slab, xattr_addr); in xattr_free()
48 const char *name, void *buffer, size_t size) in f2fs_xattr_generic_get() argument
50 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); in f2fs_xattr_generic_get()
52 switch (handler->flags) { in f2fs_xattr_generic_get()
55 return -EOPNOTSUPP; in f2fs_xattr_generic_get()
61 return -EINVAL; in f2fs_xattr_generic_get()
63 return f2fs_getxattr(inode, handler->flags, name, in f2fs_xattr_generic_get()
70 const char *name, const void *value, in f2fs_xattr_generic_set() argument
73 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); in f2fs_xattr_generic_set()
75 switch (handler->flags) { in f2fs_xattr_generic_set()
78 return -EOPNOTSUPP; in f2fs_xattr_generic_set()
84 return -EINVAL; in f2fs_xattr_generic_set()
86 return f2fs_setxattr(inode, handler->flags, name, in f2fs_xattr_generic_set()
92 struct f2fs_sb_info *sbi = F2FS_SB(dentry->d_sb); in f2fs_xattr_user_list()
104 const char *name, void *buffer, size_t size) in f2fs_xattr_advise_get() argument
107 *((char *)buffer) = F2FS_I(inode)->i_advise; in f2fs_xattr_advise_get()
114 const char *name, const void *value, in f2fs_xattr_advise_set() argument
117 unsigned char old_advise = F2FS_I(inode)->i_advise; in f2fs_xattr_advise_set()
121 return -EPERM; in f2fs_xattr_advise_set()
123 return -EINVAL; in f2fs_xattr_advise_set()
127 return -EINVAL; in f2fs_xattr_advise_set()
132 F2FS_I(inode)->i_advise = new_advise; in f2fs_xattr_advise_set()
144 for (xattr = xattr_array; xattr->name != NULL; xattr++) { in f2fs_initxattrs()
146 xattr->name, xattr->value, in f2fs_initxattrs()
147 xattr->value_len, (struct page *)page, 0); in f2fs_initxattrs()
179 .name = F2FS_SYSTEM_ADVISE_NAME,
230 int index, size_t len, const char *name) in __find_xattr() argument
232 struct f2fs_xattr_entry *entry; in __find_xattr() local
234 list_for_each_xattr(entry, base_addr) { in __find_xattr()
235 if ((void *)(entry) + sizeof(__u32) > last_base_addr || in __find_xattr()
236 (void *)XATTR_NEXT_ENTRY(entry) > last_base_addr) { in __find_xattr()
238 *last_addr = entry; in __find_xattr()
242 if (entry->e_name_index != index) in __find_xattr()
244 if (entry->e_name_len != len) in __find_xattr()
246 if (!memcmp(entry->e_name, name, len)) in __find_xattr()
249 return entry; in __find_xattr()
254 size_t len, const char *name) in __find_inline_xattr() argument
256 struct f2fs_xattr_entry *entry; in __find_inline_xattr() local
260 entry = __find_xattr(base_addr, max_addr, last_addr, index, len, name); in __find_inline_xattr()
261 if (!entry) in __find_inline_xattr()
264 /* inline xattr header or entry across max inline xattr size */ in __find_inline_xattr()
265 if (IS_XATTR_LAST_ENTRY(entry) && in __find_inline_xattr()
266 (void *)entry + sizeof(__u32) > max_addr) { in __find_inline_xattr()
267 *last_addr = entry; in __find_inline_xattr()
270 return entry; in __find_inline_xattr()
284 page = f2fs_get_node_page(sbi, inode->i_ino); in read_inline_xattr()
299 nid_t xnid = F2FS_I(inode)->i_xattr_nid; in read_xattr_block()
318 const char *name, struct f2fs_xattr_entry **xe, in lookup_all_xattrs() argument
324 nid_t xnid = F2FS_I(inode)->i_xattr_nid; in lookup_all_xattrs()
329 return -ENODATA; in lookup_all_xattrs()
334 return -ENOMEM; in lookup_all_xattrs()
345 index, len, name); in lookup_all_xattrs()
360 cur_addr = XATTR_HDR(last_addr) - 1; in lookup_all_xattrs()
364 *xe = __find_xattr(cur_addr, last_txattr_addr, NULL, index, len, name); in lookup_all_xattrs()
367 inode->i_ino); in lookup_all_xattrs()
369 err = -EFSCORRUPTED; in lookup_all_xattrs()
376 err = -ENODATA; in lookup_all_xattrs()
391 nid_t xnid = F2FS_I(inode)->i_xattr_nid; in read_all_xattrs()
400 return -ENOMEM; in read_all_xattrs()
419 if (le32_to_cpu(header->h_magic) != F2FS_XATTR_MAGIC) { in read_all_xattrs()
420 header->h_magic = cpu_to_le32(F2FS_XATTR_MAGIC); in read_all_xattrs()
421 header->h_refcount = cpu_to_le32(1); in read_all_xattrs()
442 if (hsize > inline_size && !F2FS_I(inode)->i_xattr_nid) in write_all_xattrs()
444 return -ENOSPC; in write_all_xattrs()
451 in_page = f2fs_get_node_page(sbi, inode->i_ino); in write_all_xattrs()
476 if (F2FS_I(inode)->i_xattr_nid) { in write_all_xattrs()
477 xpage = f2fs_get_node_page(sbi, F2FS_I(inode)->i_xattr_nid); in write_all_xattrs()
513 int f2fs_getxattr(struct inode *inode, int index, const char *name, in f2fs_getxattr() argument
516 struct f2fs_xattr_entry *entry = NULL; in f2fs_getxattr() local
523 if (name == NULL) in f2fs_getxattr()
524 return -EINVAL; in f2fs_getxattr()
526 len = strlen(name); in f2fs_getxattr()
528 return -ERANGE; in f2fs_getxattr()
530 f2fs_down_read(&F2FS_I(inode)->i_xattr_sem); in f2fs_getxattr()
531 error = lookup_all_xattrs(inode, ipage, index, len, name, in f2fs_getxattr()
532 &entry, &base_addr, &base_size, &is_inline); in f2fs_getxattr()
533 f2fs_up_read(&F2FS_I(inode)->i_xattr_sem); in f2fs_getxattr()
537 size = le16_to_cpu(entry->e_value_size); in f2fs_getxattr()
540 error = -ERANGE; in f2fs_getxattr()
545 char *pval = entry->e_name + entry->e_name_len; in f2fs_getxattr()
547 if (base_size - (pval - (char *)base_addr) < size) { in f2fs_getxattr()
548 error = -ERANGE; in f2fs_getxattr()
562 struct f2fs_xattr_entry *entry; in f2fs_listxattr() local
567 f2fs_down_read(&F2FS_I(inode)->i_xattr_sem); in f2fs_listxattr()
569 f2fs_up_read(&F2FS_I(inode)->i_xattr_sem); in f2fs_listxattr()
575 list_for_each_xattr(entry, base_addr) { in f2fs_listxattr()
577 f2fs_xattr_handler(entry->e_name_index); in f2fs_listxattr()
582 if ((void *)(entry) + sizeof(__u32) > last_base_addr || in f2fs_listxattr()
583 (void *)XATTR_NEXT_ENTRY(entry) > last_base_addr) { in f2fs_listxattr()
585 inode->i_ino); in f2fs_listxattr()
587 error = -EFSCORRUPTED; in f2fs_listxattr()
593 if (!handler || (handler->list && !handler->list(dentry))) in f2fs_listxattr()
598 size = prefix_len + entry->e_name_len + 1; in f2fs_listxattr()
601 error = -ERANGE; in f2fs_listxattr()
606 memcpy(buffer, entry->e_name, entry->e_name_len); in f2fs_listxattr()
607 buffer += entry->e_name_len; in f2fs_listxattr()
610 rest -= size; in f2fs_listxattr()
612 error = buffer_size - rest; in f2fs_listxattr()
618 static bool f2fs_xattr_value_same(struct f2fs_xattr_entry *entry, in f2fs_xattr_value_same() argument
621 void *pval = entry->e_name + entry->e_name_len; in f2fs_xattr_value_same()
623 return (le16_to_cpu(entry->e_value_size) == size) && in f2fs_xattr_value_same()
628 const char *name, const void *value, size_t size, in __f2fs_setxattr() argument
638 if (name == NULL) in __f2fs_setxattr()
639 return -EINVAL; in __f2fs_setxattr()
644 len = strlen(name); in __f2fs_setxattr()
647 return -ERANGE; in __f2fs_setxattr()
650 return -E2BIG; in __f2fs_setxattr()
658 /* find entry with wanted name. */ in __f2fs_setxattr()
659 here = __find_xattr(base_addr, last_base_addr, NULL, index, len, name); in __f2fs_setxattr()
662 inode->i_ino); in __f2fs_setxattr()
664 error = -EFSCORRUPTED; in __f2fs_setxattr()
674 error = -EEXIST; in __f2fs_setxattr()
681 error = -ENODATA; in __f2fs_setxattr()
689 f2fs_err(F2FS_I_SB(inode), "inode (%lu) has invalid last xattr entry, entry_size: %zu", in __f2fs_setxattr()
690 inode->i_ino, ENTRY_SIZE(last)); in __f2fs_setxattr()
692 error = -EFSCORRUPTED; in __f2fs_setxattr()
709 free = MIN_OFFSET(inode) - ((char *)last - (char *)base_addr); in __f2fs_setxattr()
714 error = -E2BIG; in __f2fs_setxattr()
719 /* 2. Remove old entry */ in __f2fs_setxattr()
722 * If entry is found, remove old entry. in __f2fs_setxattr()
728 memmove(here, next, (char *)last - (char *)next); in __f2fs_setxattr()
729 last = (struct f2fs_xattr_entry *)((char *)last - oldsize); in __f2fs_setxattr()
733 new_hsize = (char *)last - (char *)base_addr; in __f2fs_setxattr()
735 /* 3. Write new entry */ in __f2fs_setxattr()
739 * Before we come here, old entry is removed. in __f2fs_setxattr()
740 * We just write new entry. in __f2fs_setxattr()
742 last->e_name_index = index; in __f2fs_setxattr()
743 last->e_name_len = len; in __f2fs_setxattr()
744 memcpy(last->e_name, name, len); in __f2fs_setxattr()
745 pval = last->e_name + len; in __f2fs_setxattr()
747 last->e_value_size = cpu_to_le16(size); in __f2fs_setxattr()
756 !strcmp(name, F2FS_XATTR_NAME_ENCRYPTION_CONTEXT)) in __f2fs_setxattr()
759 if (!error && S_ISDIR(inode->i_mode)) in __f2fs_setxattr()
764 inode->i_mode = F2FS_I(inode)->i_acl_mode; in __f2fs_setxattr()
765 inode->i_ctime = current_time(inode); in __f2fs_setxattr()
774 int f2fs_setxattr(struct inode *inode, int index, const char *name, in f2fs_setxattr() argument
782 return -EIO; in f2fs_setxattr()
784 return -ENOSPC; in f2fs_setxattr()
792 return __f2fs_setxattr(inode, index, name, value, in f2fs_setxattr()
797 f2fs_down_write(&F2FS_I(inode)->i_xattr_sem); in f2fs_setxattr()
798 err = __f2fs_setxattr(inode, index, name, value, size, ipage, flags); in f2fs_setxattr()
799 f2fs_up_write(&F2FS_I(inode)->i_xattr_sem); in f2fs_setxattr()
808 dev_t dev = sbi->sb->s_bdev->bd_dev; in f2fs_init_xattr_caches()
811 sprintf(slab_name, "f2fs_xattr_entry-%u:%u", MAJOR(dev), MINOR(dev)); in f2fs_init_xattr_caches()
813 sbi->inline_xattr_slab_size = F2FS_OPTION(sbi).inline_xattr_size * in f2fs_init_xattr_caches()
816 sbi->inline_xattr_slab = f2fs_kmem_cache_create(slab_name, in f2fs_init_xattr_caches()
817 sbi->inline_xattr_slab_size); in f2fs_init_xattr_caches()
818 if (!sbi->inline_xattr_slab) in f2fs_init_xattr_caches()
819 return -ENOMEM; in f2fs_init_xattr_caches()
826 kmem_cache_destroy(sbi->inline_xattr_slab); in f2fs_destroy_xattr_caches()