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