/*
* JFFS2 -- Journalling Flash File System, Version 2.
*
* Copyright (C) 2006 NEC Corporation
*
* Created by KaiGai Kohei <kaigai@ak.jp.nec.com>
*
* For licensing information, see the file 'LICENCE' in this directory.
*
*/
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/fs.h>
#include <linux/time.h>
#include <linux/pagemap.h>
#include <linux/highmem.h>
#include <linux/crc32.h>
#include <linux/jffs2.h>
#include <linux/xattr.h>
#include <linux/mtd/mtd.h>
#include "nodelist.h"
/* -------- xdatum related functions ----------------
* xattr_datum_hashkey(xprefix, xname, xvalue, xsize)
* is used to calcurate xdatum hashkey. The reminder of hashkey into XATTRINDEX_HASHSIZE is
* the index of the xattr name/value pair cache (c->xattrindex).
* is_xattr_datum_unchecked(c, xd)
* returns 1, if xdatum contains any unchecked raw nodes. if all raw nodes are not
* unchecked, it returns 0.
* unload_xattr_datum(c, xd)
* is used to release xattr name/value pair and detach from c->xattrindex.
* reclaim_xattr_datum(c)
* is used to reclaim xattr name/value pairs on the xattr name/value pair cache when
* memory usage by cache is over c->xdatum_mem_threshold. Currentry, this threshold
* is hard coded as 32KiB.
* do_verify_xattr_datum(c, xd)
* is used to load the xdatum informations without name/value pair from the medium.
* It's necessary once, because those informations are not collected during mounting
* process when EBS is enabled.
* 0 will be returned, if success. An negative return value means recoverable error, and
* positive return value means unrecoverable error. Thus, caller must remove this xdatum
* and xref when it returned positive value.
* do_load_xattr_datum(c, xd)
* is used to load name/value pair from the medium.
* The meanings of return value is same as do_verify_xattr_datum().
* load_xattr_datum(c, xd)
* is used to be as a wrapper of do_verify_xattr_datum() and do_load_xattr_datum().
* If xd need to call do_verify_xattr_datum() at first, it's called before calling
* do_load_xattr_datum(). The meanings of return value is same as do_verify_xattr_datum().
* save_xattr_datum(c, xd)
* is used to write xdatum to medium. xd->version will be incremented.
* create_xattr_datum(c, xprefix, xname, xvalue, xsize)
* is used to create new xdatum and write to medium.
* delete_xattr_datum_delay(c, xd)
* is used to delete a xdatum without 'delete marker'. It has a possibility to detect
* orphan xdatum on next mounting.
* delete_xattr_datum(c, xd)
* is used to delete a xdatum with 'delete marker'. Calling jffs2_reserve_space() is
* necessary before this function.
* -------------------------------------------------- */
static uint32_t xattr_datum_hashkey(int xprefix, const char *xname, const char *xvalue, int xsize)
{
int name_len = strlen(xname);
return crc32(xprefix, xname, name_len) ^ crc32(xprefix, xvalue, xsize);
}
static int is_xattr_datum_unchecked(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd)
{
struct jffs2_raw_node_ref *raw;