Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2000,2002-2003,2005 Silicon Graphics, Inc. |
| 4 | * All Rights Reserved. |
| 5 | */ |
| 6 | #ifndef __XFS_ATTR_H__ |
| 7 | #define __XFS_ATTR_H__ |
| 8 | |
| 9 | struct xfs_inode; |
| 10 | struct xfs_da_args; |
| 11 | struct xfs_attr_list_context; |
| 12 | |
| 13 | /* |
| 14 | * Large attribute lists are structured around Btrees where all the data |
| 15 | * elements are in the leaf nodes. Attribute names are hashed into an int, |
| 16 | * then that int is used as the index into the Btree. Since the hashval |
| 17 | * of an attribute name may not be unique, we may have duplicate keys. |
| 18 | * The internal links in the Btree are logical block offsets into the file. |
| 19 | * |
| 20 | * Small attribute lists use a different format and are packed as tightly |
| 21 | * as possible so as to fit into the literal area of the inode. |
| 22 | */ |
| 23 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 24 | /* |
| 25 | * The maximum size (into the kernel or returned from the kernel) of an |
| 26 | * attribute value or the buffer used for an attr_list() call. Larger |
| 27 | * sizes will result in an ERANGE return code. |
| 28 | */ |
| 29 | #define ATTR_MAX_VALUELEN (64*1024) /* max length of a value */ |
| 30 | |
| 31 | /* |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 32 | * Kernel-internal version of the attrlist cursor. |
| 33 | */ |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 34 | struct xfs_attrlist_cursor_kern { |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 35 | __u32 hashval; /* hash value of next entry to add */ |
| 36 | __u32 blkno; /* block containing entry (suggestion) */ |
| 37 | __u32 offset; /* offset in list of equal-hashvals */ |
| 38 | __u16 pad1; /* padding to match user-level */ |
| 39 | __u8 pad2; /* padding to match user-level */ |
| 40 | __u8 initted; /* T/F: cursor has been initialized */ |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 41 | }; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 42 | |
| 43 | |
| 44 | /*======================================================================== |
| 45 | * Structure used to pass context around among the routines. |
| 46 | *========================================================================*/ |
| 47 | |
| 48 | |
| 49 | /* void; state communicated via *context */ |
| 50 | typedef void (*put_listent_func_t)(struct xfs_attr_list_context *, int, |
| 51 | unsigned char *, int, int); |
| 52 | |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 53 | struct xfs_attr_list_context { |
| 54 | struct xfs_trans *tp; |
| 55 | struct xfs_inode *dp; /* inode */ |
| 56 | struct xfs_attrlist_cursor_kern cursor; /* position in list */ |
| 57 | void *buffer; /* output buffer */ |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 58 | |
| 59 | /* |
| 60 | * Abort attribute list iteration if non-zero. Can be used to pass |
| 61 | * error values to the xfs_attr_list caller. |
| 62 | */ |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 63 | int seen_enough; |
| 64 | bool allow_incomplete; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 65 | |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 66 | ssize_t count; /* num used entries */ |
| 67 | int dupcnt; /* count dup hashvals seen */ |
| 68 | int bufsize; /* total buffer size */ |
| 69 | int firstu; /* first used byte in buffer */ |
| 70 | unsigned int attr_filter; /* XFS_ATTR_{ROOT,SECURE} */ |
| 71 | int resynch; /* T/F: resynch with cursor */ |
| 72 | put_listent_func_t put_listent; /* list output fmt function */ |
| 73 | int index; /* index into output buffer */ |
| 74 | }; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 75 | |
| 76 | |
| 77 | /*======================================================================== |
| 78 | * Function prototypes for the kernel. |
| 79 | *========================================================================*/ |
| 80 | |
| 81 | /* |
| 82 | * Overall external interface routines. |
| 83 | */ |
| 84 | int xfs_attr_inactive(struct xfs_inode *dp); |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 85 | int xfs_attr_list_ilocked(struct xfs_attr_list_context *); |
| 86 | int xfs_attr_list(struct xfs_attr_list_context *); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 87 | int xfs_inode_hasattr(struct xfs_inode *ip); |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 88 | int xfs_attr_get_ilocked(struct xfs_da_args *args); |
| 89 | int xfs_attr_get(struct xfs_da_args *args); |
| 90 | int xfs_attr_set(struct xfs_da_args *args); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 91 | int xfs_attr_set_args(struct xfs_da_args *args); |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 92 | int xfs_has_attr(struct xfs_da_args *args); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 93 | int xfs_attr_remove_args(struct xfs_da_args *args); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 94 | bool xfs_attr_namecheck(const void *name, size_t length); |
| 95 | |
| 96 | #endif /* __XFS_ATTR_H__ */ |