Blame view

fs/jffs2/xattr.h 4.17 KB
652ecc20d   KaiGai Kohei   [JFFS2][XATTR] Un...
1
2
  /*
   * JFFS2 -- Journalling Flash File System, Version 2.
aa98d7cf5   KaiGai Kohei   [JFFS2][XATTR] XA...
3
   *
c00c310ea   David Woodhouse   [JFFS2] Tidy up l...
4
   * Copyright © 2006  NEC Corporation
aa98d7cf5   KaiGai Kohei   [JFFS2][XATTR] XA...
5
   *
652ecc20d   KaiGai Kohei   [JFFS2][XATTR] Un...
6
7
8
9
10
   * Created by KaiGai Kohei <kaigai@ak.jp.nec.com>
   *
   * For licensing information, see the file 'LICENCE' in this directory.
   *
   */
c00c310ea   David Woodhouse   [JFFS2] Tidy up l...
11

aa98d7cf5   KaiGai Kohei   [JFFS2][XATTR] XA...
12
13
14
15
  #ifndef _JFFS2_FS_XATTR_H_
  #define _JFFS2_FS_XATTR_H_
  
  #include <linux/xattr.h>
4470d0409   KaiGai Kohei   [JFFS2][XATTR] '#...
16
  #include <linux/list.h>
aa98d7cf5   KaiGai Kohei   [JFFS2][XATTR] XA...
17
18
19
  
  #define JFFS2_XFLAGS_HOT	(0x01)	/* This datum is HOT */
  #define JFFS2_XFLAGS_BIND	(0x02)	/* This datum is not reclaimed */
8a13695cb   KaiGai Kohei   [JFFS2][XATTR] ri...
20
  #define JFFS2_XFLAGS_DEAD	(0x40)	/* This datum is already dead */
c9f700f84   KaiGai Kohei   [JFFS2][XATTR] us...
21
  #define JFFS2_XFLAGS_INVALID	(0x80)	/* This datum contains crc error */
aa98d7cf5   KaiGai Kohei   [JFFS2][XATTR] XA...
22
23
24
25
  
  struct jffs2_xattr_datum
  {
  	void *always_null;
aa98d7cf5   KaiGai Kohei   [JFFS2][XATTR] XA...
26
  	struct jffs2_raw_node_ref *node;
987d47b71   David Woodhouse   [JFFS2] Put list ...
27
28
  	uint8_t class;
  	uint8_t flags;
c9f700f84   KaiGai Kohei   [JFFS2][XATTR] us...
29
  	uint16_t xprefix;		/* see JFFS2_XATTR_PREFIX_* */
987d47b71   David Woodhouse   [JFFS2] Put list ...
30

aa98d7cf5   KaiGai Kohei   [JFFS2][XATTR] XA...
31
  	struct list_head xindex;	/* chained from c->xattrindex[n] */
2c887e235   KaiGai Kohei   [JFFS2][XATTR] Re...
32
  	atomic_t refcnt;		/* # of xattr_ref refers this */
aa98d7cf5   KaiGai Kohei   [JFFS2][XATTR] XA...
33
34
35
36
37
38
39
40
41
42
  	uint32_t xid;
  	uint32_t version;
  
  	uint32_t data_crc;
  	uint32_t hashkey;
  	char *xname;		/* XATTR name without prefix */
  	uint32_t name_len;	/* length of xname */
  	char *xvalue;		/* XATTR value */
  	uint32_t value_len;	/* length of xvalue */
  };
ee886b5df   KaiGai Kohei   [JFFS2][XATTR] re...
43
  struct jffs2_inode_cache;
aa98d7cf5   KaiGai Kohei   [JFFS2][XATTR] XA...
44
45
46
  struct jffs2_xattr_ref
  {
  	void *always_null;
987d47b71   David Woodhouse   [JFFS2] Put list ...
47
48
49
  	struct jffs2_raw_node_ref *node;
  	uint8_t class;
  	uint8_t flags;		/* Currently unused */
aa98d7cf5   KaiGai Kohei   [JFFS2][XATTR] XA...
50
  	u16 unused;
c9f700f84   KaiGai Kohei   [JFFS2][XATTR] us...
51
  	uint32_t xseqno;
aa98d7cf5   KaiGai Kohei   [JFFS2][XATTR] XA...
52
53
54
55
56
57
58
59
  	union {
  		struct jffs2_inode_cache *ic;	/* reference to jffs2_inode_cache */
  		uint32_t ino;			/* only used in scanning/building  */
  	};
  	union {
  		struct jffs2_xattr_datum *xd;	/* reference to jffs2_xattr_datum */
  		uint32_t xid;			/* only used in sccanning/building */
  	};
8f2b6f49c   KaiGai Kohei   [JFFS2][XATTR] Re...
60
  	struct jffs2_xattr_ref *next;		/* chained from ic->xref_list */
aa98d7cf5   KaiGai Kohei   [JFFS2][XATTR] XA...
61
  };
c9f700f84   KaiGai Kohei   [JFFS2][XATTR] us...
62
  #define XREF_DELETE_MARKER	(0x00000001)
c9f700f84   KaiGai Kohei   [JFFS2][XATTR] us...
63
64
65
66
  static inline int is_xattr_ref_dead(struct jffs2_xattr_ref *ref)
  {
  	return ((ref->xseqno & XREF_DELETE_MARKER) != 0);
  }
aa98d7cf5   KaiGai Kohei   [JFFS2][XATTR] XA...
67
68
69
70
71
72
73
  #ifdef CONFIG_JFFS2_FS_XATTR
  
  extern void jffs2_init_xattr_subsystem(struct jffs2_sb_info *c);
  extern void jffs2_build_xattr_subsystem(struct jffs2_sb_info *c);
  extern void jffs2_clear_xattr_subsystem(struct jffs2_sb_info *c);
  
  extern struct jffs2_xattr_datum *jffs2_setup_xattr_datum(struct jffs2_sb_info *c,
ef53cb02f   David Woodhouse   [JFFS2] Whitespac...
74
  							 uint32_t xid, uint32_t version);
aa98d7cf5   KaiGai Kohei   [JFFS2][XATTR] XA...
75
76
77
  
  extern void jffs2_xattr_delete_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic);
  extern void jffs2_xattr_free_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic);
c9f700f84   KaiGai Kohei   [JFFS2][XATTR] us...
78
79
80
81
  extern int jffs2_garbage_collect_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd,
  					     struct jffs2_raw_node_ref *raw);
  extern int jffs2_garbage_collect_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref,
  					   struct jffs2_raw_node_ref *raw);
aa98d7cf5   KaiGai Kohei   [JFFS2][XATTR] XA...
82
  extern int jffs2_verify_xattr(struct jffs2_sb_info *c);
c9f700f84   KaiGai Kohei   [JFFS2][XATTR] us...
83
84
  extern void jffs2_release_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd);
  extern void jffs2_release_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref);
aa98d7cf5   KaiGai Kohei   [JFFS2][XATTR] XA...
85
86
87
88
89
  
  extern int do_jffs2_getxattr(struct inode *inode, int xprefix, const char *xname,
  			     char *buffer, size_t size);
  extern int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname,
  			     const char *buffer, size_t size, int flags);
365f0cb9d   Stephen Hemminger   jffs2: constify x...
90
91
92
  extern const struct xattr_handler *jffs2_xattr_handlers[];
  extern const struct xattr_handler jffs2_user_xattr_handler;
  extern const struct xattr_handler jffs2_trusted_xattr_handler;
aa98d7cf5   KaiGai Kohei   [JFFS2][XATTR] XA...
93
94
95
96
97
  
  extern ssize_t jffs2_listxattr(struct dentry *, char *, size_t);
  #define jffs2_getxattr		generic_getxattr
  #define jffs2_setxattr		generic_setxattr
  #define jffs2_removexattr	generic_removexattr
aa98d7cf5   KaiGai Kohei   [JFFS2][XATTR] XA...
98
99
100
101
102
103
104
105
  #else
  
  #define jffs2_init_xattr_subsystem(c)
  #define jffs2_build_xattr_subsystem(c)
  #define jffs2_clear_xattr_subsystem(c)
  
  #define jffs2_xattr_delete_inode(c, ic)
  #define jffs2_xattr_free_inode(c, ic)
aa98d7cf5   KaiGai Kohei   [JFFS2][XATTR] XA...
106
107
108
109
110
111
112
  #define jffs2_verify_xattr(c)			(1)
  
  #define jffs2_xattr_handlers	NULL
  #define jffs2_listxattr		NULL
  #define jffs2_getxattr		NULL
  #define jffs2_setxattr		NULL
  #define jffs2_removexattr	NULL
aa98d7cf5   KaiGai Kohei   [JFFS2][XATTR] XA...
113
114
115
  #endif /* CONFIG_JFFS2_FS_XATTR */
  
  #ifdef CONFIG_JFFS2_FS_SECURITY
2a7dba391   Eric Paris   fs/vfs/security: ...
116
117
  extern int jffs2_init_security(struct inode *inode, struct inode *dir,
  			       const struct qstr *qstr);
365f0cb9d   Stephen Hemminger   jffs2: constify x...
118
  extern const struct xattr_handler jffs2_security_xattr_handler;
aa98d7cf5   KaiGai Kohei   [JFFS2][XATTR] XA...
119
  #else
2a7dba391   Eric Paris   fs/vfs/security: ...
120
  #define jffs2_init_security(inode,dir,qstr)	(0)
aa98d7cf5   KaiGai Kohei   [JFFS2][XATTR] XA...
121
122
123
  #endif /* CONFIG_JFFS2_FS_SECURITY */
  
  #endif /* _JFFS2_FS_XATTR_H_ */