^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * JFFS2 -- Journalling Flash File System, Version 2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright © 2006 NEC Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Created by KaiGai Kohei <kaigai@ak.jp.nec.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * For licensing information, see the file 'LICENCE' in this directory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #ifndef _JFFS2_FS_XATTR_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #define _JFFS2_FS_XATTR_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/xattr.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #define JFFS2_XFLAGS_HOT (0x01) /* This datum is HOT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #define JFFS2_XFLAGS_BIND (0x02) /* This datum is not reclaimed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #define JFFS2_XFLAGS_DEAD (0x40) /* This datum is already dead */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #define JFFS2_XFLAGS_INVALID (0x80) /* This datum contains crc error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) struct jffs2_xattr_datum
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) void *always_null;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) struct jffs2_raw_node_ref *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) uint8_t class;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) uint8_t flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) uint16_t xprefix; /* see JFFS2_XATTR_PREFIX_* */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) struct list_head xindex; /* chained from c->xattrindex[n] */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) atomic_t refcnt; /* # of xattr_ref refers this */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) uint32_t xid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) uint32_t version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) uint32_t data_crc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) uint32_t hashkey;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) char *xname; /* XATTR name without prefix */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) uint32_t name_len; /* length of xname */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) char *xvalue; /* XATTR value */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) uint32_t value_len; /* length of xvalue */
^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) struct jffs2_inode_cache;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) struct jffs2_xattr_ref
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) void *always_null;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) struct jffs2_raw_node_ref *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) uint8_t class;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) uint8_t flags; /* Currently unused */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) u16 unused;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) uint32_t xseqno;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) struct jffs2_inode_cache *ic; /* reference to jffs2_inode_cache */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) uint32_t ino; /* only used in scanning/building */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) struct jffs2_xattr_datum *xd; /* reference to jffs2_xattr_datum */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) uint32_t xid; /* only used in sccanning/building */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) struct jffs2_xattr_ref *next; /* chained from ic->xref_list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) #define XREF_DELETE_MARKER (0x00000001)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) static inline int is_xattr_ref_dead(struct jffs2_xattr_ref *ref)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) return ((ref->xseqno & XREF_DELETE_MARKER) != 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) #ifdef CONFIG_JFFS2_FS_XATTR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) extern void jffs2_init_xattr_subsystem(struct jffs2_sb_info *c);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) extern void jffs2_build_xattr_subsystem(struct jffs2_sb_info *c);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) extern void jffs2_clear_xattr_subsystem(struct jffs2_sb_info *c);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) extern struct jffs2_xattr_datum *jffs2_setup_xattr_datum(struct jffs2_sb_info *c,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) uint32_t xid, uint32_t version);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) extern void jffs2_xattr_do_crccheck_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) extern void jffs2_xattr_delete_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) extern void jffs2_xattr_free_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) extern int jffs2_garbage_collect_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) struct jffs2_raw_node_ref *raw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) extern int jffs2_garbage_collect_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) struct jffs2_raw_node_ref *raw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) extern int jffs2_verify_xattr(struct jffs2_sb_info *c);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) extern void jffs2_release_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) extern void jffs2_release_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) extern int do_jffs2_getxattr(struct inode *inode, int xprefix, const char *xname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) char *buffer, size_t size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) extern int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) const char *buffer, size_t size, int flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) extern const struct xattr_handler *jffs2_xattr_handlers[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) extern const struct xattr_handler jffs2_user_xattr_handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) extern const struct xattr_handler jffs2_trusted_xattr_handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) extern ssize_t jffs2_listxattr(struct dentry *, char *, size_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) #define jffs2_init_xattr_subsystem(c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) #define jffs2_build_xattr_subsystem(c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) #define jffs2_clear_xattr_subsystem(c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) #define jffs2_xattr_do_crccheck_inode(c, ic)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) #define jffs2_xattr_delete_inode(c, ic)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) #define jffs2_xattr_free_inode(c, ic)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) #define jffs2_verify_xattr(c) (1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) #define jffs2_xattr_handlers NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) #define jffs2_listxattr NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) #endif /* CONFIG_JFFS2_FS_XATTR */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) #ifdef CONFIG_JFFS2_FS_SECURITY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) extern int jffs2_init_security(struct inode *inode, struct inode *dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) const struct qstr *qstr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) extern const struct xattr_handler jffs2_security_xattr_handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) #define jffs2_init_security(inode,dir,qstr) (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) #endif /* CONFIG_JFFS2_FS_SECURITY */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) #endif /* _JFFS2_FS_XATTR_H_ */