revert-mm-fix-blkdev-size-calculation-in-generic_write_checks
[linux-2.6/linux-trees-mm.git] / fs / reiser4 / plugin / dir / seekable_dir.c
blobc1c6c4cc400f3238fbda4998176c0d3c5344d7bf
1 /* Copyright 2005 by Hans Reiser, licensing governed by
2 * reiser4/README */
4 #include "../../inode.h"
6 /* this is implementation of build_entry_key method of dir
7 plugin for SEEKABLE_HASHED_DIR_PLUGIN_ID
8 This is for directories where we want repeatable and restartable readdir()
9 even in case 32bit user level struct dirent (readdir(3)).
11 void
12 build_entry_key_seekable(const struct inode *dir, const struct qstr *name,
13 reiser4_key * result)
15 oid_t objectid;
17 assert("nikita-2283", dir != NULL);
18 assert("nikita-2284", name != NULL);
19 assert("nikita-2285", name->name != NULL);
20 assert("nikita-2286", result != NULL);
22 reiser4_key_init(result);
23 /* locality of directory entry's key is objectid of parent
24 directory */
25 set_key_locality(result, get_inode_oid(dir));
26 /* minor packing locality is constant */
27 set_key_type(result, KEY_FILE_NAME_MINOR);
28 /* dot is special case---we always want it to be first entry in
29 a directory. Actually, we just want to have smallest
30 directory entry.
32 if ((name->len == 1) && (name->name[0] == '.'))
33 return;
35 /* objectid of key is 31 lowest bits of hash. */
36 objectid =
37 inode_hash_plugin(dir)->hash(name->name,
38 (int)name->len) & 0x7fffffff;
40 assert("nikita-2303", !(objectid & ~KEY_OBJECTID_MASK));
41 set_key_objectid(result, objectid);
43 /* offset is always 0. */
44 set_key_offset(result, (__u64) 0);
45 return;