revert-mm-fix-blkdev-size-calculation-in-generic_write_checks
[linux-2.6/linux-trees-mm.git] / fs / reiser4 / plugin / dir / hashed_dir.c
blob0f34824dbae4b711ece6784d67ba425fdd23d8a8
1 /* Copyright 2001, 2002, 2003, 2004 by Hans Reiser, licensing governed by
2 * reiser4/README */
4 /* Directory plugin using hashes (see fs/reiser4/plugin/hash.c) to map file
5 names to the files. */
7 /*
8 * Hashed directory logically consists of persistent directory
9 * entries. Directory entry is a pair of a file name and a key of stat-data of
10 * a file that has this name in the given directory.
12 * Directory entries are stored in the tree in the form of directory
13 * items. Directory item should implement dir_entry_ops portion of item plugin
14 * interface (see plugin/item/item.h). Hashed directory interacts with
15 * directory item plugin exclusively through dir_entry_ops operations.
17 * Currently there are two implementations of directory items: "simple
18 * directory item" (plugin/item/sde.[ch]), and "compound directory item"
19 * (plugin/item/cde.[ch]) with the latter being the default.
21 * There is, however some delicate way through which directory code interferes
22 * with item plugin: key assignment policy. A key for a directory item is
23 * chosen by directory code, and as described in kassign.c, this key contains
24 * a portion of file name. Directory item uses this knowledge to avoid storing
25 * this portion of file name twice: in the key and in the directory item body.
29 #include "../../inode.h"
31 void complete_entry_key(const struct inode *, const char *name,
32 int len, reiser4_key * result);
34 /* this is implementation of build_entry_key method of dir
35 plugin for HASHED_DIR_PLUGIN_ID
37 void build_entry_key_hashed(const struct inode *dir, /* directory where entry is
38 * (or will be) in.*/
39 const struct qstr *qname, /* name of file referenced
40 * by this entry */
41 reiser4_key * result /* resulting key of directory
42 * entry */ )
44 const char *name;
45 int len;
47 assert("nikita-1139", dir != NULL);
48 assert("nikita-1140", qname != NULL);
49 assert("nikita-1141", qname->name != NULL);
50 assert("nikita-1142", result != NULL);
52 name = qname->name;
53 len = qname->len;
55 assert("nikita-2867", strlen(name) == len);
57 reiser4_key_init(result);
58 /* locality of directory entry's key is objectid of parent
59 directory */
60 set_key_locality(result, get_inode_oid(dir));
61 /* minor packing locality is constant */
62 set_key_type(result, KEY_FILE_NAME_MINOR);
63 /* dot is special case---we always want it to be first entry in
64 a directory. Actually, we just want to have smallest
65 directory entry.
67 if (len == 1 && name[0] == '.')
68 return;
70 /* initialize part of entry key which depends on file name */
71 complete_entry_key(dir, name, len, result);
74 /* Local variables:
75 c-indentation-style: "K&R"
76 mode-name: "LC"
77 c-basic-offset: 8
78 tab-width: 8
79 fill-column: 120
80 End: