Merge tag 'v3.10.59' into update
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / fs / jffs2 / xattr.h
CommitLineData
652ecc20
KK
1/*
2 * JFFS2 -- Journalling Flash File System, Version 2.
aa98d7cf 3 *
c00c310e 4 * Copyright © 2006 NEC Corporation
aa98d7cf 5 *
652ecc20
KK
6 * Created by KaiGai Kohei <kaigai@ak.jp.nec.com>
7 *
8 * For licensing information, see the file 'LICENCE' in this directory.
9 *
10 */
c00c310e 11
aa98d7cf
KK
12#ifndef _JFFS2_FS_XATTR_H_
13#define _JFFS2_FS_XATTR_H_
14
15#include <linux/xattr.h>
4470d040 16#include <linux/list.h>
aa98d7cf
KK
17
18#define JFFS2_XFLAGS_HOT (0x01) /* This datum is HOT */
19#define JFFS2_XFLAGS_BIND (0x02) /* This datum is not reclaimed */
8a13695c 20#define JFFS2_XFLAGS_DEAD (0x40) /* This datum is already dead */
c9f700f8 21#define JFFS2_XFLAGS_INVALID (0x80) /* This datum contains crc error */
aa98d7cf
KK
22
23struct jffs2_xattr_datum
24{
25 void *always_null;
aa98d7cf 26 struct jffs2_raw_node_ref *node;
987d47b7
DW
27 uint8_t class;
28 uint8_t flags;
c9f700f8 29 uint16_t xprefix; /* see JFFS2_XATTR_PREFIX_* */
987d47b7 30
aa98d7cf 31 struct list_head xindex; /* chained from c->xattrindex[n] */
2c887e23 32 atomic_t refcnt; /* # of xattr_ref refers this */
aa98d7cf
KK
33 uint32_t xid;
34 uint32_t version;
35
36 uint32_t data_crc;
37 uint32_t hashkey;
38 char *xname; /* XATTR name without prefix */
39 uint32_t name_len; /* length of xname */
40 char *xvalue; /* XATTR value */
41 uint32_t value_len; /* length of xvalue */
42};
43
ee886b5d 44struct jffs2_inode_cache;
aa98d7cf
KK
45struct jffs2_xattr_ref
46{
47 void *always_null;
987d47b7
DW
48 struct jffs2_raw_node_ref *node;
49 uint8_t class;
50 uint8_t flags; /* Currently unused */
aa98d7cf
KK
51 u16 unused;
52
c9f700f8 53 uint32_t xseqno;
aa98d7cf
KK
54 union {
55 struct jffs2_inode_cache *ic; /* reference to jffs2_inode_cache */
56 uint32_t ino; /* only used in scanning/building */
57 };
58 union {
59 struct jffs2_xattr_datum *xd; /* reference to jffs2_xattr_datum */
60 uint32_t xid; /* only used in sccanning/building */
61 };
8f2b6f49 62 struct jffs2_xattr_ref *next; /* chained from ic->xref_list */
aa98d7cf
KK
63};
64
c9f700f8 65#define XREF_DELETE_MARKER (0x00000001)
c9f700f8
KK
66static inline int is_xattr_ref_dead(struct jffs2_xattr_ref *ref)
67{
68 return ((ref->xseqno & XREF_DELETE_MARKER) != 0);
69}
70
aa98d7cf
KK
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,
ef53cb02 78 uint32_t xid, uint32_t version);
aa98d7cf 79
8c5a0366 80extern void jffs2_xattr_do_crccheck_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic);
aa98d7cf
KK
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
c9f700f8
KK
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);
aa98d7cf 88extern int jffs2_verify_xattr(struct jffs2_sb_info *c);
c9f700f8
KK
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);
aa98d7cf
KK
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
365f0cb9
SH
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;
aa98d7cf
KK
100
101extern ssize_t jffs2_listxattr(struct dentry *, char *, size_t);
102#define jffs2_getxattr generic_getxattr
103#define jffs2_setxattr generic_setxattr
104#define jffs2_removexattr generic_removexattr
105
aa98d7cf
KK
106#else
107
108#define jffs2_init_xattr_subsystem(c)
109#define jffs2_build_xattr_subsystem(c)
110#define jffs2_clear_xattr_subsystem(c)
111
8c5a0366 112#define jffs2_xattr_do_crccheck_inode(c, ic)
aa98d7cf
KK
113#define jffs2_xattr_delete_inode(c, ic)
114#define jffs2_xattr_free_inode(c, ic)
aa98d7cf
KK
115#define jffs2_verify_xattr(c) (1)
116
117#define jffs2_xattr_handlers NULL
118#define jffs2_listxattr NULL
119#define jffs2_getxattr NULL
120#define jffs2_setxattr NULL
121#define jffs2_removexattr NULL
122
aa98d7cf
KK
123#endif /* CONFIG_JFFS2_FS_XATTR */
124
125#ifdef CONFIG_JFFS2_FS_SECURITY
2a7dba39
EP
126extern int jffs2_init_security(struct inode *inode, struct inode *dir,
127 const struct qstr *qstr);
365f0cb9 128extern const struct xattr_handler jffs2_security_xattr_handler;
aa98d7cf 129#else
2a7dba39 130#define jffs2_init_security(inode,dir,qstr) (0)
aa98d7cf
KK
131#endif /* CONFIG_JFFS2_FS_SECURITY */
132
133#endif /* _JFFS2_FS_XATTR_H_ */