1 /* Copyright 2001, 2002, 2003, 2004 by Hans Reiser, licensing governed by
4 /* Directory plugin using hashes (see fs/reiser4/plugin/hash.c) to map file
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
39 const struct qstr
*qname
, /* name of file referenced
41 reiser4_key
* result
/* resulting key of directory
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
);
55 assert("nikita-2867", strlen(name
) == len
);
57 reiser4_key_init(result
);
58 /* locality of directory entry's key is objectid of parent
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
67 if (len
== 1 && name
[0] == '.')
70 /* initialize part of entry key which depends on file name */
71 complete_entry_key(dir
, name
, len
, result
);
75 c-indentation-style: "K&R"