blob: cf4f5759b42b407ba614d1c40fd67b9db511e01a [file] [log] [blame]
KaiGai Kohei652ecc22006-05-13 15:18:27 +09001/*
2 * JFFS2 -- Journalling Flash File System, Version 2.
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +09003 *
David Woodhousec00c3102007-04-25 14:16:47 +01004 * Copyright © 2006 NEC Corporation
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +09005 *
KaiGai Kohei652ecc22006-05-13 15:18:27 +09006 * Created by KaiGai Kohei <kaigai@ak.jp.nec.com>
7 *
8 * For licensing information, see the file 'LICENCE' in this directory.
9 *
10 */
David Woodhousec00c3102007-04-25 14:16:47 +010011
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +090012#ifndef _JFFS2_FS_XATTR_H_
13#define _JFFS2_FS_XATTR_H_
14
15#include <linux/xattr.h>
KaiGai Kohei4470d042006-05-13 15:17:11 +090016#include <linux/list.h>
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +090017
18#define JFFS2_XFLAGS_HOT (0x01) /* This datum is HOT */
19#define JFFS2_XFLAGS_BIND (0x02) /* This datum is not reclaimed */
KaiGai Kohei8a136952006-06-24 09:14:13 +090020#define JFFS2_XFLAGS_DEAD (0x40) /* This datum is already dead */
KaiGai Koheic9f700f2006-06-11 10:35:15 +090021#define JFFS2_XFLAGS_INVALID (0x80) /* This datum contains crc error */
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +090022
23struct jffs2_xattr_datum
24{
25 void *always_null;
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +090026 struct jffs2_raw_node_ref *node;
David Woodhouse987d47b2006-05-22 16:32:05 +010027 uint8_t class;
28 uint8_t flags;
KaiGai Koheic9f700f2006-06-11 10:35:15 +090029 uint16_t xprefix; /* see JFFS2_XATTR_PREFIX_* */
David Woodhouse987d47b2006-05-22 16:32:05 +010030
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +090031 struct list_head xindex; /* chained from c->xattrindex[n] */
KaiGai Kohei2c887e22006-06-24 09:16:50 +090032 atomic_t refcnt; /* # of xattr_ref refers this */
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +090033 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
KaiGai Koheiee886b52006-05-13 15:19:03 +090044struct jffs2_inode_cache;
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +090045struct jffs2_xattr_ref
46{
47 void *always_null;
David Woodhouse987d47b2006-05-22 16:32:05 +010048 struct jffs2_raw_node_ref *node;
49 uint8_t class;
50 uint8_t flags; /* Currently unused */
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +090051 u16 unused;
52
KaiGai Koheic9f700f2006-06-11 10:35:15 +090053 uint32_t xseqno;
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +090054 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 };
KaiGai Kohei8f2b6f42006-05-13 15:15:07 +090062 struct jffs2_xattr_ref *next; /* chained from ic->xref_list */
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +090063};
64
KaiGai Koheic9f700f2006-06-11 10:35:15 +090065#define XREF_DELETE_MARKER (0x00000001)
KaiGai Koheic9f700f2006-06-11 10:35:15 +090066static inline int is_xattr_ref_dead(struct jffs2_xattr_ref *ref)
67{
68 return ((ref->xseqno & XREF_DELETE_MARKER) != 0);
69}
70
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +090071#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,
David Woodhouseef53cb02007-07-10 10:01:22 +010078 uint32_t xid, uint32_t version);
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +090079
80extern void jffs2_xattr_delete_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic);
81extern void jffs2_xattr_free_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic);
82
KaiGai Koheic9f700f2006-06-11 10:35:15 +090083extern int jffs2_garbage_collect_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd,
84 struct jffs2_raw_node_ref *raw);
85extern int jffs2_garbage_collect_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref,
86 struct jffs2_raw_node_ref *raw);
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +090087extern int jffs2_verify_xattr(struct jffs2_sb_info *c);
KaiGai Koheic9f700f2006-06-11 10:35:15 +090088extern void jffs2_release_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd);
89extern void jffs2_release_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref);
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +090090
91extern int do_jffs2_getxattr(struct inode *inode, int xprefix, const char *xname,
92 char *buffer, size_t size);
93extern int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname,
94 const char *buffer, size_t size, int flags);
95
Stephen Hemminger365f0cb2010-05-13 17:53:21 -070096extern const struct xattr_handler *jffs2_xattr_handlers[];
97extern const struct xattr_handler jffs2_user_xattr_handler;
98extern const struct xattr_handler jffs2_trusted_xattr_handler;
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +090099
100extern ssize_t jffs2_listxattr(struct dentry *, char *, size_t);
101#define jffs2_getxattr generic_getxattr
102#define jffs2_setxattr generic_setxattr
103#define jffs2_removexattr generic_removexattr
104
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900105#else
106
107#define jffs2_init_xattr_subsystem(c)
108#define jffs2_build_xattr_subsystem(c)
109#define jffs2_clear_xattr_subsystem(c)
110
111#define jffs2_xattr_delete_inode(c, ic)
112#define jffs2_xattr_free_inode(c, ic)
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900113#define jffs2_verify_xattr(c) (1)
114
115#define jffs2_xattr_handlers NULL
116#define jffs2_listxattr NULL
117#define jffs2_getxattr NULL
118#define jffs2_setxattr NULL
119#define jffs2_removexattr NULL
120
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900121#endif /* CONFIG_JFFS2_FS_XATTR */
122
123#ifdef CONFIG_JFFS2_FS_SECURITY
124extern int jffs2_init_security(struct inode *inode, struct inode *dir);
Stephen Hemminger365f0cb2010-05-13 17:53:21 -0700125extern const struct xattr_handler jffs2_security_xattr_handler;
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900126#else
127#define jffs2_init_security(inode,dir) (0)
128#endif /* CONFIG_JFFS2_FS_SECURITY */
129
130#endif /* _JFFS2_FS_XATTR_H_ */