1 /* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */
3 /* Key manipulations. */
10 #include <linux/types.h> /* for __u?? */
12 /* Minimal possible key: all components are zero. It is presumed that this is
13 independent of key scheme. */
14 static const reiser4_key MINIMAL_KEY
= {
23 /* Maximal possible key: all components are ~0. It is presumed that this is
24 independent of key scheme. */
25 static const reiser4_key MAXIMAL_KEY
= {
27 __constant_cpu_to_le64(~0ull),
28 ON_LARGE_KEY(__constant_cpu_to_le64(~0ull),)
29 __constant_cpu_to_le64(~0ull),
30 __constant_cpu_to_le64(~0ull)
35 void reiser4_key_init(reiser4_key
* key
/* key to init */ )
37 assert("nikita-1169", key
!= NULL
);
38 memset(key
, 0, sizeof *key
);
41 /* minimal possible key in the tree. Return pointer to the static storage. */
42 const reiser4_key
*reiser4_min_key(void)
47 /* maximum possible key in the tree. Return pointer to the static storage. */
48 const reiser4_key
*reiser4_max_key(void)
54 /* debugging aid: print symbolic name of key type */
55 static const char *type_name(unsigned int key_type
/* key type */ )
58 case KEY_FILE_NAME_MINOR
:
62 case KEY_ATTR_NAME_MINOR
:
64 case KEY_ATTR_BODY_MINOR
:
73 /* debugging aid: print human readable information about key */
74 void reiser4_print_key(const char *prefix
/* prefix to print */ ,
75 const reiser4_key
* key
/* key to print */ )
78 /* printf ("\033[1m"); */
80 printk("%s: null key\n", prefix
);
82 if (REISER4_LARGE_KEY
)
83 printk("%s: (%Lx:%x:%Lx:%Lx:%Lx:%Lx)", prefix
,
84 get_key_locality(key
),
86 get_key_ordering(key
),
88 get_key_objectid(key
), get_key_offset(key
));
90 printk("%s: (%Lx:%x:%Lx:%Lx:%Lx)", prefix
,
91 get_key_locality(key
),
94 get_key_objectid(key
), get_key_offset(key
));
96 * if this is a key of directory entry, try to decode part of
97 * a name stored in the key, and output it.
99 if (get_key_type(key
) == KEY_FILE_NAME_MINOR
) {
100 char buf
[DE_NAME_BUF_LEN
];
104 c
= reiser4_unpack_string(get_key_ordering(key
), c
);
105 reiser4_unpack_string(get_key_fulloid(key
), c
);
107 if (is_longname_key(key
))
109 * only part of the name is stored in the key.
114 * whole name is stored in the key.
116 reiser4_unpack_string(get_key_offset(key
), buf
);
117 printk("%s]\n", buf
);
120 printk("[%s]\n", type_name(get_key_type(key
)));
124 /* printf ("\033[m\017"); */
131 c-indentation-style: "K&R"