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