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 | * |
KaiGai Kohei | 652ecc2 | 2006-05-13 15:18:27 +0900 | [diff] [blame] | 4 | * Copyright (C) 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 | */ |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 11 | #ifndef _JFFS2_FS_XATTR_H_ |
| 12 | #define _JFFS2_FS_XATTR_H_ |
| 13 | |
| 14 | #include <linux/xattr.h> |
KaiGai Kohei | 4470d04 | 2006-05-13 15:17:11 +0900 | [diff] [blame] | 15 | #include <linux/list.h> |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 16 | |
| 17 | #define JFFS2_XFLAGS_HOT (0x01) /* This datum is HOT */ |
| 18 | #define JFFS2_XFLAGS_BIND (0x02) /* This datum is not reclaimed */ |
| 19 | |
| 20 | struct jffs2_xattr_datum |
| 21 | { |
| 22 | void *always_null; |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 23 | struct jffs2_raw_node_ref *node; |
David Woodhouse | 987d47b | 2006-05-22 16:32:05 +0100 | [diff] [blame] | 24 | uint8_t class; |
| 25 | uint8_t flags; |
| 26 | uint16_t xprefix; /* see JFFS2_XATTR_PREFIX_* */ |
| 27 | |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 28 | struct list_head xindex; /* chained from c->xattrindex[n] */ |
| 29 | uint32_t refcnt; /* # of xattr_ref refers this */ |
| 30 | uint32_t xid; |
| 31 | uint32_t version; |
| 32 | |
| 33 | uint32_t data_crc; |
| 34 | uint32_t hashkey; |
| 35 | char *xname; /* XATTR name without prefix */ |
| 36 | uint32_t name_len; /* length of xname */ |
| 37 | char *xvalue; /* XATTR value */ |
| 38 | uint32_t value_len; /* length of xvalue */ |
| 39 | }; |
| 40 | |
KaiGai Kohei | ee886b5 | 2006-05-13 15:19:03 +0900 | [diff] [blame] | 41 | struct jffs2_inode_cache; |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 42 | struct jffs2_xattr_ref |
| 43 | { |
| 44 | void *always_null; |
David Woodhouse | 987d47b | 2006-05-22 16:32:05 +0100 | [diff] [blame] | 45 | struct jffs2_raw_node_ref *node; |
| 46 | uint8_t class; |
| 47 | uint8_t flags; /* Currently unused */ |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 48 | u16 unused; |
| 49 | |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 50 | union { |
| 51 | struct jffs2_inode_cache *ic; /* reference to jffs2_inode_cache */ |
| 52 | uint32_t ino; /* only used in scanning/building */ |
| 53 | }; |
| 54 | union { |
| 55 | struct jffs2_xattr_datum *xd; /* reference to jffs2_xattr_datum */ |
| 56 | uint32_t xid; /* only used in sccanning/building */ |
| 57 | }; |
KaiGai Kohei | 8f2b6f4 | 2006-05-13 15:15:07 +0900 | [diff] [blame] | 58 | struct jffs2_xattr_ref *next; /* chained from ic->xref_list */ |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | #ifdef CONFIG_JFFS2_FS_XATTR |
| 62 | |
| 63 | extern void jffs2_init_xattr_subsystem(struct jffs2_sb_info *c); |
| 64 | extern void jffs2_build_xattr_subsystem(struct jffs2_sb_info *c); |
| 65 | extern void jffs2_clear_xattr_subsystem(struct jffs2_sb_info *c); |
| 66 | |
| 67 | extern struct jffs2_xattr_datum *jffs2_setup_xattr_datum(struct jffs2_sb_info *c, |
| 68 | uint32_t xid, uint32_t version); |
| 69 | |
| 70 | extern void jffs2_xattr_delete_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic); |
| 71 | extern void jffs2_xattr_free_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic); |
| 72 | |
KaiGai Kohei | 084702e | 2006-05-13 15:16:13 +0900 | [diff] [blame] | 73 | extern int jffs2_garbage_collect_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd); |
| 74 | extern int jffs2_garbage_collect_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref); |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 75 | extern int jffs2_verify_xattr(struct jffs2_sb_info *c); |
| 76 | |
| 77 | extern int do_jffs2_getxattr(struct inode *inode, int xprefix, const char *xname, |
| 78 | char *buffer, size_t size); |
| 79 | extern int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname, |
| 80 | const char *buffer, size_t size, int flags); |
| 81 | |
| 82 | extern struct xattr_handler *jffs2_xattr_handlers[]; |
| 83 | extern struct xattr_handler jffs2_user_xattr_handler; |
| 84 | extern struct xattr_handler jffs2_trusted_xattr_handler; |
| 85 | |
| 86 | extern ssize_t jffs2_listxattr(struct dentry *, char *, size_t); |
| 87 | #define jffs2_getxattr generic_getxattr |
| 88 | #define jffs2_setxattr generic_setxattr |
| 89 | #define jffs2_removexattr generic_removexattr |
| 90 | |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 91 | #else |
| 92 | |
| 93 | #define jffs2_init_xattr_subsystem(c) |
| 94 | #define jffs2_build_xattr_subsystem(c) |
| 95 | #define jffs2_clear_xattr_subsystem(c) |
| 96 | |
| 97 | #define jffs2_xattr_delete_inode(c, ic) |
| 98 | #define jffs2_xattr_free_inode(c, ic) |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 99 | #define jffs2_verify_xattr(c) (1) |
| 100 | |
| 101 | #define jffs2_xattr_handlers NULL |
| 102 | #define jffs2_listxattr NULL |
| 103 | #define jffs2_getxattr NULL |
| 104 | #define jffs2_setxattr NULL |
| 105 | #define jffs2_removexattr NULL |
| 106 | |
KaiGai Kohei | aa98d7c | 2006-05-13 15:09:47 +0900 | [diff] [blame] | 107 | #endif /* CONFIG_JFFS2_FS_XATTR */ |
| 108 | |
| 109 | #ifdef CONFIG_JFFS2_FS_SECURITY |
| 110 | extern int jffs2_init_security(struct inode *inode, struct inode *dir); |
| 111 | extern struct xattr_handler jffs2_security_xattr_handler; |
| 112 | #else |
| 113 | #define jffs2_init_security(inode,dir) (0) |
| 114 | #endif /* CONFIG_JFFS2_FS_SECURITY */ |
| 115 | |
| 116 | #endif /* _JFFS2_FS_XATTR_H_ */ |