1
2
3
4
5
6
7
8
9
10
11
12#ifndef _JFFS2_FS_XATTR_H_
13#define _JFFS2_FS_XATTR_H_
14
15#include <linux/xattr.h>
16#include <linux/list.h>
17
18#define JFFS2_XFLAGS_HOT (0x01)
19#define JFFS2_XFLAGS_BIND (0x02)
20#define JFFS2_XFLAGS_DEAD (0x40)
21#define JFFS2_XFLAGS_INVALID (0x80)
22
23struct jffs2_xattr_datum
24{
25 void *always_null;
26 struct jffs2_raw_node_ref *node;
27 uint8_t class;
28 uint8_t flags;
29 uint16_t xprefix;
30
31 struct list_head xindex;
32 atomic_t refcnt;
33 uint32_t xid;
34 uint32_t version;
35
36 uint32_t data_crc;
37 uint32_t hashkey;
38 char *xname;
39 uint32_t name_len;
40 char *xvalue;
41 uint32_t value_len;
42};
43
44struct jffs2_inode_cache;
45struct jffs2_xattr_ref
46{
47 void *always_null;
48 struct jffs2_raw_node_ref *node;
49 uint8_t class;
50 uint8_t flags;
51 u16 unused;
52
53 uint32_t xseqno;
54 union {
55 struct jffs2_inode_cache *ic;
56 uint32_t ino;
57 };
58 union {
59 struct jffs2_xattr_datum *xd;
60 uint32_t xid;
61 };
62 struct jffs2_xattr_ref *next;
63};
64
65#define XREF_DELETE_MARKER (0x00000001)
66static inline int is_xattr_ref_dead(struct jffs2_xattr_ref *ref)
67{
68 return ((ref->xseqno & XREF_DELETE_MARKER) != 0);
69}
70
71#ifdef CONFIG_JFFS2_FS_XATTR
72
73extern void jffs2_init_xattr_subsystem(struct jffs2_sb_info *c);
74extern void jffs2_build_xattr_subsystem(struct jffs2_sb_info *c);
75extern void jffs2_clear_xattr_subsystem(struct jffs2_sb_info *c);
76
77extern struct jffs2_xattr_datum *jffs2_setup_xattr_datum(struct jffs2_sb_info *c,
78 uint32_t xid, uint32_t version);
79
80extern void jffs2_xattr_do_crccheck_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic);
81extern void jffs2_xattr_delete_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic);
82extern void jffs2_xattr_free_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic);
83
84extern int jffs2_garbage_collect_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd,
85 struct jffs2_raw_node_ref *raw);
86extern int jffs2_garbage_collect_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref,
87 struct jffs2_raw_node_ref *raw);
88extern int jffs2_verify_xattr(struct jffs2_sb_info *c);
89extern void jffs2_release_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd);
90extern void jffs2_release_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref);
91
92extern int do_jffs2_getxattr(struct inode *inode, int xprefix, const char *xname,
93 char *buffer, size_t size);
94extern int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname,
95 const char *buffer, size_t size, int flags);
96
97extern const struct xattr_handler *jffs2_xattr_handlers[];
98extern const struct xattr_handler jffs2_user_xattr_handler;
99extern const struct xattr_handler jffs2_trusted_xattr_handler;
100
101extern ssize_t jffs2_listxattr(struct dentry *, char *, size_t);
102
103#else
104
105#define jffs2_init_xattr_subsystem(c)
106#define jffs2_build_xattr_subsystem(c)
107#define jffs2_clear_xattr_subsystem(c)
108
109#define jffs2_xattr_do_crccheck_inode(c, ic)
110#define jffs2_xattr_delete_inode(c, ic)
111#define jffs2_xattr_free_inode(c, ic)
112#define jffs2_verify_xattr(c) (1)
113
114#define jffs2_xattr_handlers NULL
115#define jffs2_listxattr NULL
116
117#endif
118
119#ifdef CONFIG_JFFS2_FS_SECURITY
120extern int jffs2_init_security(struct inode *inode, struct inode *dir,
121 const struct qstr *qstr);
122extern const struct xattr_handler jffs2_security_xattr_handler;
123#else
124#define jffs2_init_security(inode,dir,qstr) (0)
125#endif
126
127#endif
128