Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^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) #include <linux/reiserfs_xattr.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #include <linux/rwsem.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #include <linux/xattr.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) struct inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) struct dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) struct iattr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) struct super_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) int reiserfs_xattr_register_handlers(void) __init;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) void reiserfs_xattr_unregister_handlers(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) int reiserfs_xattr_init(struct super_block *sb, int mount_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) int reiserfs_lookup_privroot(struct super_block *sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) int reiserfs_delete_xattrs(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) int reiserfs_permission(struct inode *inode, int mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #ifdef CONFIG_REISERFS_FS_XATTR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #define has_xattr_dir(inode) (REISERFS_I(inode)->i_flags & i_has_xattr_dir)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) ssize_t reiserfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) int reiserfs_xattr_get(struct inode *, const char *, void *, size_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) int reiserfs_xattr_set(struct inode *, const char *, const void *, size_t, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) int reiserfs_xattr_set_handle(struct reiserfs_transaction_handle *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 			      struct inode *, const char *, const void *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 			      size_t, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) extern const struct xattr_handler reiserfs_xattr_user_handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) extern const struct xattr_handler reiserfs_xattr_trusted_handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) extern const struct xattr_handler reiserfs_xattr_security_handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #ifdef CONFIG_REISERFS_FS_SECURITY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) int reiserfs_security_init(struct inode *dir, struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 			   const struct qstr *qstr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 			   struct reiserfs_security_handle *sec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) int reiserfs_security_write(struct reiserfs_transaction_handle *th,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 			    struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 			    struct reiserfs_security_handle *sec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) void reiserfs_security_free(struct reiserfs_security_handle *sec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) static inline int reiserfs_xattrs_initialized(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	return REISERFS_SB(sb)->priv_root && REISERFS_SB(sb)->xattr_root;
^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) #define xattr_size(size) ((size) + sizeof(struct reiserfs_xattr_header))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) static inline loff_t reiserfs_xattr_nblocks(struct inode *inode, loff_t size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	loff_t ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	if (reiserfs_file_data_log(inode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		ret = _ROUND_UP(xattr_size(size), inode->i_sb->s_blocksize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 		ret >>= inode->i_sb->s_blocksize_bits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	return ret;
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61)  * We may have to create up to 3 objects: xattr root, xattr dir, xattr file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62)  * Let's try to be smart about it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63)  * xattr root: We cache it. If it's not cached, we may need to create it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64)  * xattr dir: If anything has been loaded for this inode, we can set a flag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65)  *            saying so.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66)  * xattr file: Since we don't cache xattrs, we can't tell. We always include
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67)  *             blocks for it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)  * However, since root and dir can be created between calls - YOU MUST SAVE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  * THIS VALUE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) static inline size_t reiserfs_xattr_jcreate_nblocks(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	size_t nblocks = JOURNAL_BLOCKS_PER_OBJECT(inode->i_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	if ((REISERFS_I(inode)->i_flags & i_has_xattr_dir) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		nblocks += JOURNAL_BLOCKS_PER_OBJECT(inode->i_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 		if (d_really_is_negative(REISERFS_SB(inode->i_sb)->xattr_root))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 			nblocks += JOURNAL_BLOCKS_PER_OBJECT(inode->i_sb);
^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) 	return nblocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) static inline void reiserfs_init_xattr_rwsem(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	init_rwsem(&REISERFS_I(inode)->i_xattr_sem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) #define reiserfs_listxattr NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) static inline void reiserfs_init_xattr_rwsem(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) #endif  /*  CONFIG_REISERFS_FS_XATTR  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) #ifndef CONFIG_REISERFS_FS_SECURITY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) static inline int reiserfs_security_init(struct inode *dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 					 struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 					 const struct qstr *qstr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 					 struct reiserfs_security_handle *sec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) static inline int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) reiserfs_security_write(struct reiserfs_transaction_handle *th,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 			struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 			struct reiserfs_security_handle *sec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) static inline void reiserfs_security_free(struct reiserfs_security_handle *sec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) #endif