1 /*-------------------------------------------------------------------------*
2 * File: fs/jffs2/xattr.c
3 * XATTR support on JFFS2 FileSystem
5 * Implemented by KaiGai Kohei <kaigai@ak.jp.nec.com>
6 * Copyright (C) 2006 NEC Corporation
8 * For licensing information, see the file 'LICENCE' in the jffs2 directory.
9 *-------------------------------------------------------------------------*/
11 #ifndef _JFFS2_FS_XATTR_H_
12 #define _JFFS2_FS_XATTR_H_
14 #include <linux/xattr.h>
16 #define JFFS2_XFLAGS_HOT (0x01) /* This datum is HOT */
17 #define JFFS2_XFLAGS_BIND (0x02) /* This datum is not reclaimed */
19 struct jffs2_xattr_datum
24 u16 xprefix; /* see JFFS2_XATTR_PREFIX_* */
26 struct jffs2_raw_node_ref *node;
27 struct list_head xindex; /* chained from c->xattrindex[n] */
28 uint32_t refcnt; /* # of xattr_ref refers this */
34 char *xname; /* XATTR name without prefix */
35 uint32_t name_len; /* length of xname */
36 char *xvalue; /* XATTR value */
37 uint32_t value_len; /* length of xvalue */
40 struct jffs2_inode_cache; /* forward refence */
41 struct jffs2_xattr_ref
45 u8 flags; /* Currently unused */
48 struct jffs2_raw_node_ref *node;
50 struct jffs2_inode_cache *ic; /* reference to jffs2_inode_cache */
51 uint32_t ino; /* only used in scanning/building */
54 struct jffs2_xattr_datum *xd; /* reference to jffs2_xattr_datum */
55 uint32_t xid; /* only used in sccanning/building */
57 struct jffs2_xattr_ref *next; /* chained from ic->xref_list */
60 #ifdef CONFIG_JFFS2_FS_XATTR
62 extern void jffs2_init_xattr_subsystem(struct jffs2_sb_info *c);
63 extern void jffs2_build_xattr_subsystem(struct jffs2_sb_info *c);
64 extern void jffs2_clear_xattr_subsystem(struct jffs2_sb_info *c);
66 extern struct jffs2_xattr_datum *jffs2_setup_xattr_datum(struct jffs2_sb_info *c,
67 uint32_t xid, uint32_t version);
69 extern void jffs2_xattr_delete_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic);
70 extern void jffs2_xattr_free_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic);
72 extern int jffs2_garbage_collect_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd);
73 extern int jffs2_garbage_collect_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref);
74 extern int jffs2_verify_xattr(struct jffs2_sb_info *c);
76 extern int do_jffs2_getxattr(struct inode *inode, int xprefix, const char *xname,
77 char *buffer, size_t size);
78 extern int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname,
79 const char *buffer, size_t size, int flags);
81 extern struct xattr_handler *jffs2_xattr_handlers[];
82 extern struct xattr_handler jffs2_user_xattr_handler;
83 extern struct xattr_handler jffs2_trusted_xattr_handler;
85 extern ssize_t jffs2_listxattr(struct dentry *, char *, size_t);
86 #define jffs2_getxattr generic_getxattr
87 #define jffs2_setxattr generic_setxattr
88 #define jffs2_removexattr generic_removexattr
92 #define jffs2_init_xattr_subsystem(c)
93 #define jffs2_build_xattr_subsystem(c)
94 #define jffs2_clear_xattr_subsystem(c)
96 #define jffs2_xattr_delete_inode(c, ic)
97 #define jffs2_xattr_free_inode(c, ic)
98 #define jffs2_verify_xattr(c) (1)
100 #define jffs2_xattr_handlers NULL
101 #define jffs2_listxattr NULL
102 #define jffs2_getxattr NULL
103 #define jffs2_setxattr NULL
104 #define jffs2_removexattr NULL
106 #endif /* CONFIG_JFFS2_FS_XATTR */
108 #ifdef CONFIG_JFFS2_FS_SECURITY
109 extern int jffs2_init_security(struct inode *inode, struct inode *dir);
110 extern struct xattr_handler jffs2_security_xattr_handler;
112 #define jffs2_init_security(inode,dir) (0)
113 #endif /* CONFIG_JFFS2_FS_SECURITY */
115 #endif /* _JFFS2_FS_XATTR_H_ */