1 /* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by
4 /* Key manipulations. */
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
= {
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
= {
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)
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)
48 /* maximum possible key in the tree. Return pointer to the static storage. */
49 const reiser4_key
* reiser4_max_key(void)
55 /* debugging aid: print symbolic name of key type */
56 static const char *type_name(unsigned int key_type
/* key type */)
59 case KEY_FILE_NAME_MINOR
:
63 case KEY_ATTR_NAME_MINOR
:
65 case KEY_ATTR_BODY_MINOR
:
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 */)
79 /* printf ("\033[1m"); */
81 printk("%s: null key\n", prefix
);
83 if (REISER4_LARGE_KEY
)
84 printk("%s: (%Lx:%x:%Lx:%Lx:%Lx:%Lx)", prefix
,
85 get_key_locality(key
),
87 get_key_ordering(key
),
89 get_key_objectid(key
), get_key_offset(key
));
91 printk("%s: (%Lx:%x:%Lx:%Lx:%Lx)", prefix
,
92 get_key_locality(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
];
105 c
= reiser4_unpack_string(get_key_ordering(key
), c
);
106 reiser4_unpack_string(get_key_fulloid(key
), c
);
108 if (is_longname_key(key
))
110 * only part of the name is stored in the key.
115 * whole name is stored in the key.
117 reiser4_unpack_string(get_key_offset(key
), buf
);
118 printk("%s]\n", buf
);
121 printk("[%s]\n", type_name(get_key_type(key
)));
125 /* printf ("\033[m\017"); */
132 c-indentation-style: "K&R"