162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * JFFS2 -- Journalling Flash File System, Version 2. 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * Copyright © 2006 NEC Corporation 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * Created by KaiGai Kohei <kaigai@ak.jp.nec.com> 762306a36Sopenharmony_ci * 862306a36Sopenharmony_ci * For licensing information, see the file 'LICENCE' in this directory. 962306a36Sopenharmony_ci * 1062306a36Sopenharmony_ci */ 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci#ifndef _JFFS2_FS_XATTR_H_ 1362306a36Sopenharmony_ci#define _JFFS2_FS_XATTR_H_ 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ci#include <linux/xattr.h> 1662306a36Sopenharmony_ci#include <linux/list.h> 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci#define JFFS2_XFLAGS_HOT (0x01) /* This datum is HOT */ 1962306a36Sopenharmony_ci#define JFFS2_XFLAGS_BIND (0x02) /* This datum is not reclaimed */ 2062306a36Sopenharmony_ci#define JFFS2_XFLAGS_DEAD (0x40) /* This datum is already dead */ 2162306a36Sopenharmony_ci#define JFFS2_XFLAGS_INVALID (0x80) /* This datum contains crc error */ 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_cistruct jffs2_xattr_datum 2462306a36Sopenharmony_ci{ 2562306a36Sopenharmony_ci void *always_null; 2662306a36Sopenharmony_ci struct jffs2_raw_node_ref *node; 2762306a36Sopenharmony_ci uint8_t class; 2862306a36Sopenharmony_ci uint8_t flags; 2962306a36Sopenharmony_ci uint16_t xprefix; /* see JFFS2_XATTR_PREFIX_* */ 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ci struct list_head xindex; /* chained from c->xattrindex[n] */ 3262306a36Sopenharmony_ci atomic_t refcnt; /* # of xattr_ref refers this */ 3362306a36Sopenharmony_ci uint32_t xid; 3462306a36Sopenharmony_ci uint32_t version; 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ci uint32_t data_crc; 3762306a36Sopenharmony_ci uint32_t hashkey; 3862306a36Sopenharmony_ci char *xname; /* XATTR name without prefix */ 3962306a36Sopenharmony_ci uint32_t name_len; /* length of xname */ 4062306a36Sopenharmony_ci char *xvalue; /* XATTR value */ 4162306a36Sopenharmony_ci uint32_t value_len; /* length of xvalue */ 4262306a36Sopenharmony_ci}; 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_cistruct jffs2_inode_cache; 4562306a36Sopenharmony_cistruct jffs2_xattr_ref 4662306a36Sopenharmony_ci{ 4762306a36Sopenharmony_ci void *always_null; 4862306a36Sopenharmony_ci struct jffs2_raw_node_ref *node; 4962306a36Sopenharmony_ci uint8_t class; 5062306a36Sopenharmony_ci uint8_t flags; /* Currently unused */ 5162306a36Sopenharmony_ci u16 unused; 5262306a36Sopenharmony_ci 5362306a36Sopenharmony_ci uint32_t xseqno; 5462306a36Sopenharmony_ci union { 5562306a36Sopenharmony_ci struct jffs2_inode_cache *ic; /* reference to jffs2_inode_cache */ 5662306a36Sopenharmony_ci uint32_t ino; /* only used in scanning/building */ 5762306a36Sopenharmony_ci }; 5862306a36Sopenharmony_ci union { 5962306a36Sopenharmony_ci struct jffs2_xattr_datum *xd; /* reference to jffs2_xattr_datum */ 6062306a36Sopenharmony_ci uint32_t xid; /* only used in sccanning/building */ 6162306a36Sopenharmony_ci }; 6262306a36Sopenharmony_ci struct jffs2_xattr_ref *next; /* chained from ic->xref_list */ 6362306a36Sopenharmony_ci}; 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_ci#define XREF_DELETE_MARKER (0x00000001) 6662306a36Sopenharmony_cistatic inline int is_xattr_ref_dead(struct jffs2_xattr_ref *ref) 6762306a36Sopenharmony_ci{ 6862306a36Sopenharmony_ci return ((ref->xseqno & XREF_DELETE_MARKER) != 0); 6962306a36Sopenharmony_ci} 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_ci#ifdef CONFIG_JFFS2_FS_XATTR 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ciextern void jffs2_init_xattr_subsystem(struct jffs2_sb_info *c); 7462306a36Sopenharmony_ciextern int jffs2_build_xattr_subsystem(struct jffs2_sb_info *c); 7562306a36Sopenharmony_ciextern void jffs2_clear_xattr_subsystem(struct jffs2_sb_info *c); 7662306a36Sopenharmony_ci 7762306a36Sopenharmony_ciextern struct jffs2_xattr_datum *jffs2_setup_xattr_datum(struct jffs2_sb_info *c, 7862306a36Sopenharmony_ci uint32_t xid, uint32_t version); 7962306a36Sopenharmony_ci 8062306a36Sopenharmony_ciextern void jffs2_xattr_do_crccheck_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic); 8162306a36Sopenharmony_ciextern void jffs2_xattr_delete_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic); 8262306a36Sopenharmony_ciextern void jffs2_xattr_free_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic); 8362306a36Sopenharmony_ci 8462306a36Sopenharmony_ciextern int jffs2_garbage_collect_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd, 8562306a36Sopenharmony_ci struct jffs2_raw_node_ref *raw); 8662306a36Sopenharmony_ciextern int jffs2_garbage_collect_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref, 8762306a36Sopenharmony_ci struct jffs2_raw_node_ref *raw); 8862306a36Sopenharmony_ciextern int jffs2_verify_xattr(struct jffs2_sb_info *c); 8962306a36Sopenharmony_ciextern void jffs2_release_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd); 9062306a36Sopenharmony_ciextern void jffs2_release_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref); 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_ciextern int do_jffs2_getxattr(struct inode *inode, int xprefix, const char *xname, 9362306a36Sopenharmony_ci char *buffer, size_t size); 9462306a36Sopenharmony_ciextern int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname, 9562306a36Sopenharmony_ci const char *buffer, size_t size, int flags); 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_ciextern const struct xattr_handler *jffs2_xattr_handlers[]; 9862306a36Sopenharmony_ciextern const struct xattr_handler jffs2_user_xattr_handler; 9962306a36Sopenharmony_ciextern const struct xattr_handler jffs2_trusted_xattr_handler; 10062306a36Sopenharmony_ci 10162306a36Sopenharmony_ciextern ssize_t jffs2_listxattr(struct dentry *, char *, size_t); 10262306a36Sopenharmony_ci 10362306a36Sopenharmony_ci#else 10462306a36Sopenharmony_ci 10562306a36Sopenharmony_ci#define jffs2_init_xattr_subsystem(c) 10662306a36Sopenharmony_ci#define jffs2_build_xattr_subsystem(c) (0) 10762306a36Sopenharmony_ci#define jffs2_clear_xattr_subsystem(c) 10862306a36Sopenharmony_ci 10962306a36Sopenharmony_ci#define jffs2_xattr_do_crccheck_inode(c, ic) 11062306a36Sopenharmony_ci#define jffs2_xattr_delete_inode(c, ic) 11162306a36Sopenharmony_ci#define jffs2_xattr_free_inode(c, ic) 11262306a36Sopenharmony_ci#define jffs2_verify_xattr(c) (1) 11362306a36Sopenharmony_ci 11462306a36Sopenharmony_ci#define jffs2_xattr_handlers NULL 11562306a36Sopenharmony_ci#define jffs2_listxattr NULL 11662306a36Sopenharmony_ci 11762306a36Sopenharmony_ci#endif /* CONFIG_JFFS2_FS_XATTR */ 11862306a36Sopenharmony_ci 11962306a36Sopenharmony_ci#ifdef CONFIG_JFFS2_FS_SECURITY 12062306a36Sopenharmony_ciextern int jffs2_init_security(struct inode *inode, struct inode *dir, 12162306a36Sopenharmony_ci const struct qstr *qstr); 12262306a36Sopenharmony_ciextern const struct xattr_handler jffs2_security_xattr_handler; 12362306a36Sopenharmony_ci#else 12462306a36Sopenharmony_ci#define jffs2_init_security(inode,dir,qstr) (0) 12562306a36Sopenharmony_ci#endif /* CONFIG_JFFS2_FS_SECURITY */ 12662306a36Sopenharmony_ci 12762306a36Sopenharmony_ci#endif /* _JFFS2_FS_XATTR_H_ */ 128