KaiGai Kohei | 652ecc2 | 2006-05-13 15:18:27 +0900 | [diff] [blame] | 1 | /* |
| 2 | * JFFS2 -- Journalling Flash File System, Version 2. |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 3 | * |
David Woodhouse | c00c310 | 2007-04-25 14:16:47 +0100 | [diff] [blame] | 4 | * Copyright © 2006 NEC Corporation |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 5 | * |
KaiGai Kohei | 652ecc2 | 2006-05-13 15:18:27 +0900 | [diff] [blame] | 6 | * Created by KaiGai Kohei <kaigai@ak.jp.nec.com> |
| 7 | * |
| 8 | * For licensing information, see the file 'LICENCE' in this directory. |
| 9 | * |
| 10 | */ |
David Woodhouse | c00c310 | 2007-04-25 14:16:47 +0100 | [diff] [blame] | 11 | |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 12 | #ifndef _JFFS2_FS_XATTR_H_ |
| 13 | #define _JFFS2_FS_XATTR_H_ |
| 14 | |
| 15 | #include <linux/xattr.h> |
KaiGai Kohei | 4470d04 | 2006-05-13 15:17:11 +0900 | [diff] [blame] | 16 | #include <linux/list.h> |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 17 | |
| 18 | #define JFFS2_XFLAGS_HOT (0x01) /* This datum is HOT */ |
| 19 | #define JFFS2_XFLAGS_BIND (0x02) /* This datum is not reclaimed */ |
KaiGai Kohei | 8a13695 | 2006-06-24 09:14:13 +0900 | [diff] [blame] | 20 | #define JFFS2_XFLAGS_DEAD (0x40) /* This datum is already dead */ |
KaiGai Kohei | c9f700f | 2006-06-11 10:35:15 +0900 | [diff] [blame] | 21 | #define JFFS2_XFLAGS_INVALID (0x80) /* This datum contains crc error */ |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 22 | |
| 23 | struct jffs2_xattr_datum |
| 24 | { |
| 25 | void *always_null; |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 26 | struct jffs2_raw_node_ref *node; |
David Woodhouse | 987d47b | 2006-05-22 16:32:05 +0100 | [diff] [blame] | 27 | uint8_t class; |
| 28 | uint8_t flags; |
KaiGai Kohei | c9f700f | 2006-06-11 10:35:15 +0900 | [diff] [blame] | 29 | uint16_t xprefix; /* see JFFS2_XATTR_PREFIX_* */ |
David Woodhouse | 987d47b | 2006-05-22 16:32:05 +0100 | [diff] [blame] | 30 | |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 31 | struct list_head xindex; /* chained from c->xattrindex[n] */ |
KaiGai Kohei | 2c887e2 | 2006-06-24 09:16:50 +0900 | [diff] [blame] | 32 | atomic_t refcnt; /* # of xattr_ref refers this */ |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 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 | |
KaiGai Kohei | ee886b5 | 2006-05-13 15:19:03 +0900 | [diff] [blame] | 44 | struct jffs2_inode_cache; |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 45 | struct jffs2_xattr_ref |
| 46 | { |
| 47 | void *always_null; |
David Woodhouse | 987d47b | 2006-05-22 16:32:05 +0100 | [diff] [blame] | 48 | struct jffs2_raw_node_ref *node; |
| 49 | uint8_t class; |
| 50 | uint8_t flags; /* Currently unused */ |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 51 | u16 unused; |
| 52 | |
KaiGai Kohei | c9f700f | 2006-06-11 10:35:15 +0900 | [diff] [blame] | 53 | uint32_t xseqno; |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 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 | }; |
KaiGai Kohei | 8f2b6f4 | 2006-05-13 15:15:07 +0900 | [diff] [blame] | 62 | struct jffs2_xattr_ref *next; /* chained from ic->xref_list */ |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 63 | }; |
| 64 | |
KaiGai Kohei | c9f700f | 2006-06-11 10:35:15 +0900 | [diff] [blame] | 65 | #define XREF_DELETE_MARKER (0x00000001) |
KaiGai Kohei | c9f700f | 2006-06-11 10:35:15 +0900 | [diff] [blame] | 66 | static inline int is_xattr_ref_dead(struct jffs2_xattr_ref *ref) |
| 67 | { |
| 68 | return ((ref->xseqno & XREF_DELETE_MARKER) != 0); |
| 69 | } |
| 70 | |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 71 | #ifdef CONFIG_JFFS2_FS_XATTR |
| 72 | |
| 73 | extern void jffs2_init_xattr_subsystem(struct jffs2_sb_info *c); |
| 74 | extern void jffs2_build_xattr_subsystem(struct jffs2_sb_info *c); |
| 75 | extern void jffs2_clear_xattr_subsystem(struct jffs2_sb_info *c); |
| 76 | |
| 77 | extern struct jffs2_xattr_datum *jffs2_setup_xattr_datum(struct jffs2_sb_info *c, |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 78 | uint32_t xid, uint32_t version); |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 79 | |
Jean-Christophe DUBOIS | 8c5a036 | 2012-05-10 17:14:03 +0200 | [diff] [blame] | 80 | extern void jffs2_xattr_do_crccheck_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic); |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 81 | extern void jffs2_xattr_delete_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic); |
| 82 | extern void jffs2_xattr_free_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic); |
| 83 | |
KaiGai Kohei | c9f700f | 2006-06-11 10:35:15 +0900 | [diff] [blame] | 84 | extern int jffs2_garbage_collect_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd, |
| 85 | struct jffs2_raw_node_ref *raw); |
| 86 | extern int jffs2_garbage_collect_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref, |
| 87 | struct jffs2_raw_node_ref *raw); |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 88 | extern int jffs2_verify_xattr(struct jffs2_sb_info *c); |
KaiGai Kohei | c9f700f | 2006-06-11 10:35:15 +0900 | [diff] [blame] | 89 | extern void jffs2_release_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd); |
| 90 | extern void jffs2_release_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref); |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 91 | |
| 92 | extern int do_jffs2_getxattr(struct inode *inode, int xprefix, const char *xname, |
| 93 | char *buffer, size_t size); |
| 94 | extern int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname, |
| 95 | const char *buffer, size_t size, int flags); |
| 96 | |
Stephen Hemminger | 365f0cb | 2010-05-13 17:53:21 -0700 | [diff] [blame] | 97 | extern const struct xattr_handler *jffs2_xattr_handlers[]; |
| 98 | extern const struct xattr_handler jffs2_user_xattr_handler; |
| 99 | extern const struct xattr_handler jffs2_trusted_xattr_handler; |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 100 | |
| 101 | extern ssize_t jffs2_listxattr(struct dentry *, char *, size_t); |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 102 | |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 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 | |
Jean-Christophe DUBOIS | 8c5a036 | 2012-05-10 17:14:03 +0200 | [diff] [blame] | 109 | #define jffs2_xattr_do_crccheck_inode(c, ic) |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 110 | #define jffs2_xattr_delete_inode(c, ic) |
| 111 | #define jffs2_xattr_free_inode(c, ic) |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 112 | #define jffs2_verify_xattr(c) (1) |
| 113 | |
| 114 | #define jffs2_xattr_handlers NULL |
| 115 | #define jffs2_listxattr NULL |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 116 | |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 117 | #endif /* CONFIG_JFFS2_FS_XATTR */ |
| 118 | |
| 119 | #ifdef CONFIG_JFFS2_FS_SECURITY |
Eric Paris | 2a7dba3 | 2011-02-01 11:05:39 -0500 | [diff] [blame] | 120 | extern int jffs2_init_security(struct inode *inode, struct inode *dir, |
| 121 | const struct qstr *qstr); |
Stephen Hemminger | 365f0cb | 2010-05-13 17:53:21 -0700 | [diff] [blame] | 122 | extern const struct xattr_handler jffs2_security_xattr_handler; |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 123 | #else |
Eric Paris | 2a7dba3 | 2011-02-01 11:05:39 -0500 | [diff] [blame] | 124 | #define jffs2_init_security(inode,dir,qstr) (0) |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 125 | #endif /* CONFIG_JFFS2_FS_SECURITY */ |
| 126 | |
| 127 | #endif /* _JFFS2_FS_XATTR_H_ */ |