fed up with those stupid warnings
[mmotm.git] / fs / reiser4 / key.c
blob0efd51832d1a137b4a9066db1535e0c5f5d89d16
1 /* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by
2 * reiser4/README */
4 /* Key manipulations. */
6 #include "debug.h"
7 #include "key.h"
8 #include "super.h"
9 #include "reiser4.h"
11 #include <linux/types.h> /* for __u?? */
13 /* Minimal possible key: all components are zero. It is presumed that this is
14 independent of key scheme. */
15 static const reiser4_key MINIMAL_KEY = {
16 .el = {
17 0ull,
18 ON_LARGE_KEY(0ull,)
19 0ull,
20 0ull
24 /* Maximal possible key: all components are ~0. It is presumed that this is
25 independent of key scheme. */
26 static const reiser4_key MAXIMAL_KEY = {
27 .el = {
28 __constant_cpu_to_le64(~0ull),
29 ON_LARGE_KEY(__constant_cpu_to_le64(~0ull),)
30 __constant_cpu_to_le64(~0ull),
31 __constant_cpu_to_le64(~0ull)
35 /* Initialize key. */
36 void reiser4_key_init(reiser4_key * key/* key to init */)
38 assert("nikita-1169", key != NULL);
39 memset(key, 0, sizeof *key);
42 /* minimal possible key in the tree. Return pointer to the static storage. */
43 const reiser4_key * reiser4_min_key(void)
45 return &MINIMAL_KEY;
48 /* maximum possible key in the tree. Return pointer to the static storage. */
49 const reiser4_key * reiser4_max_key(void)
51 return &MAXIMAL_KEY;
54 #if REISER4_DEBUG
55 /* debugging aid: print symbolic name of key type */
56 static const char *type_name(unsigned int key_type/* key type */)
58 switch (key_type) {
59 case KEY_FILE_NAME_MINOR:
60 return "file name";
61 case KEY_SD_MINOR:
62 return "stat data";
63 case KEY_ATTR_NAME_MINOR:
64 return "attr name";
65 case KEY_ATTR_BODY_MINOR:
66 return "attr body";
67 case KEY_BODY_MINOR:
68 return "file body";
69 default:
70 return "unknown";
74 /* debugging aid: print human readable information about key */
75 void reiser4_print_key(const char *prefix /* prefix to print */ ,
76 const reiser4_key * key/* key to print */)
78 /* turn bold on */
79 /* printf ("\033[1m"); */
80 if (key == NULL)
81 printk("%s: null key\n", prefix);
82 else {
83 if (REISER4_LARGE_KEY)
84 printk("%s: (%Lx:%x:%Lx:%Lx:%Lx:%Lx)", prefix,
85 get_key_locality(key),
86 get_key_type(key),
87 get_key_ordering(key),
88 get_key_band(key),
89 get_key_objectid(key), get_key_offset(key));
90 else
91 printk("%s: (%Lx:%x:%Lx:%Lx:%Lx)", prefix,
92 get_key_locality(key),
93 get_key_type(key),
94 get_key_band(key),
95 get_key_objectid(key), get_key_offset(key));
97 * if this is a key of directory entry, try to decode part of
98 * a name stored in the key, and output it.
100 if (get_key_type(key) == KEY_FILE_NAME_MINOR) {
101 char buf[DE_NAME_BUF_LEN];
102 char *c;
104 c = buf;
105 c = reiser4_unpack_string(get_key_ordering(key), c);
106 reiser4_unpack_string(get_key_fulloid(key), c);
107 printk("[%s", buf);
108 if (is_longname_key(key))
110 * only part of the name is stored in the key.
112 printk("...]\n");
113 else {
115 * whole name is stored in the key.
117 reiser4_unpack_string(get_key_offset(key), buf);
118 printk("%s]\n", buf);
120 } else {
121 printk("[%s]\n", type_name(get_key_type(key)));
124 /* turn bold off */
125 /* printf ("\033[m\017"); */
128 #endif
130 /* Make Linus happy.
131 Local variables:
132 c-indentation-style: "K&R"
133 mode-name: "LC"
134 c-basic-offset: 8
135 tab-width: 8
136 fill-column: 120
137 End: