Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * JFFS2 -- Journalling Flash File System, Version 2.
0003  *
0004  * Copyright © 2006  NEC Corporation
0005  *
0006  * Created by KaiGai Kohei <kaigai@ak.jp.nec.com>
0007  *
0008  * For licensing information, see the file 'LICENCE' in this directory.
0009  *
0010  */
0011 
0012 #ifndef _JFFS2_FS_XATTR_H_
0013 #define _JFFS2_FS_XATTR_H_
0014 
0015 #include <linux/xattr.h>
0016 #include <linux/list.h>
0017 
0018 #define JFFS2_XFLAGS_HOT    (0x01)  /* This datum is HOT */
0019 #define JFFS2_XFLAGS_BIND   (0x02)  /* This datum is not reclaimed */
0020 #define JFFS2_XFLAGS_DEAD   (0x40)  /* This datum is already dead */
0021 #define JFFS2_XFLAGS_INVALID    (0x80)  /* This datum contains crc error */
0022 
0023 struct jffs2_xattr_datum
0024 {
0025     void *always_null;
0026     struct jffs2_raw_node_ref *node;
0027     uint8_t class;
0028     uint8_t flags;
0029     uint16_t xprefix;       /* see JFFS2_XATTR_PREFIX_* */
0030 
0031     struct list_head xindex;    /* chained from c->xattrindex[n] */
0032     atomic_t refcnt;        /* # of xattr_ref refers this */
0033     uint32_t xid;
0034     uint32_t version;
0035 
0036     uint32_t data_crc;
0037     uint32_t hashkey;
0038     char *xname;        /* XATTR name without prefix */
0039     uint32_t name_len;  /* length of xname */
0040     char *xvalue;       /* XATTR value */
0041     uint32_t value_len; /* length of xvalue */
0042 };
0043 
0044 struct jffs2_inode_cache;
0045 struct jffs2_xattr_ref
0046 {
0047     void *always_null;
0048     struct jffs2_raw_node_ref *node;
0049     uint8_t class;
0050     uint8_t flags;      /* Currently unused */
0051     u16 unused;
0052 
0053     uint32_t xseqno;
0054     union {
0055         struct jffs2_inode_cache *ic;   /* reference to jffs2_inode_cache */
0056         uint32_t ino;           /* only used in scanning/building  */
0057     };
0058     union {
0059         struct jffs2_xattr_datum *xd;   /* reference to jffs2_xattr_datum */
0060         uint32_t xid;           /* only used in sccanning/building */
0061     };
0062     struct jffs2_xattr_ref *next;       /* chained from ic->xref_list */
0063 };
0064 
0065 #define XREF_DELETE_MARKER  (0x00000001)
0066 static inline int is_xattr_ref_dead(struct jffs2_xattr_ref *ref)
0067 {
0068     return ((ref->xseqno & XREF_DELETE_MARKER) != 0);
0069 }
0070 
0071 #ifdef CONFIG_JFFS2_FS_XATTR
0072 
0073 extern void jffs2_init_xattr_subsystem(struct jffs2_sb_info *c);
0074 extern void jffs2_build_xattr_subsystem(struct jffs2_sb_info *c);
0075 extern void jffs2_clear_xattr_subsystem(struct jffs2_sb_info *c);
0076 
0077 extern struct jffs2_xattr_datum *jffs2_setup_xattr_datum(struct jffs2_sb_info *c,
0078                              uint32_t xid, uint32_t version);
0079 
0080 extern void jffs2_xattr_do_crccheck_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic);
0081 extern void jffs2_xattr_delete_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic);
0082 extern void jffs2_xattr_free_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic);
0083 
0084 extern int jffs2_garbage_collect_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd,
0085                          struct jffs2_raw_node_ref *raw);
0086 extern int jffs2_garbage_collect_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref,
0087                        struct jffs2_raw_node_ref *raw);
0088 extern int jffs2_verify_xattr(struct jffs2_sb_info *c);
0089 extern void jffs2_release_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd);
0090 extern void jffs2_release_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref);
0091 
0092 extern int do_jffs2_getxattr(struct inode *inode, int xprefix, const char *xname,
0093                  char *buffer, size_t size);
0094 extern int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname,
0095                  const char *buffer, size_t size, int flags);
0096 
0097 extern const struct xattr_handler *jffs2_xattr_handlers[];
0098 extern const struct xattr_handler jffs2_user_xattr_handler;
0099 extern const struct xattr_handler jffs2_trusted_xattr_handler;
0100 
0101 extern ssize_t jffs2_listxattr(struct dentry *, char *, size_t);
0102 
0103 #else
0104 
0105 #define jffs2_init_xattr_subsystem(c)
0106 #define jffs2_build_xattr_subsystem(c)
0107 #define jffs2_clear_xattr_subsystem(c)
0108 
0109 #define jffs2_xattr_do_crccheck_inode(c, ic)
0110 #define jffs2_xattr_delete_inode(c, ic)
0111 #define jffs2_xattr_free_inode(c, ic)
0112 #define jffs2_verify_xattr(c)           (1)
0113 
0114 #define jffs2_xattr_handlers    NULL
0115 #define jffs2_listxattr     NULL
0116 
0117 #endif /* CONFIG_JFFS2_FS_XATTR */
0118 
0119 #ifdef CONFIG_JFFS2_FS_SECURITY
0120 extern int jffs2_init_security(struct inode *inode, struct inode *dir,
0121                    const struct qstr *qstr);
0122 extern const struct xattr_handler jffs2_security_xattr_handler;
0123 #else
0124 #define jffs2_init_security(inode,dir,qstr) (0)
0125 #endif /* CONFIG_JFFS2_FS_SECURITY */
0126 
0127 #endif /* _JFFS2_FS_XATTR_H_ */