|
|
|
@ -1,13 +1,5 @@
|
|
|
|
|
--- reiserfscore/prints.c 2013-08-26 22:55:43.000000000 +0200
|
|
|
|
|
+++ reiserfscore/prints.c 2015-09-10 19:22:02.791317465 +0200
|
|
|
|
|
@@ -1,5 +1,5 @@
|
|
|
|
|
-/*
|
|
|
|
|
- * Copyright 1996-2004 by Hans Reiser, licensing governed by
|
|
|
|
|
+/*
|
|
|
|
|
+ * Copyright 1996-2004 by Hans Reiser, licensing governed by
|
|
|
|
|
* reiserfsprogs/README
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
--- reiserfscore/prints.c
|
|
|
|
|
+++ reiserfscore/prints.c
|
|
|
|
|
@@ -7,8 +7,11 @@
|
|
|
|
|
|
|
|
|
|
#include "includes.h"
|
|
|
|
@ -20,7 +12,7 @@
|
|
|
|
|
#include <limits.h>
|
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
|
|
@@ -16,6 +19,37 @@
|
|
|
|
|
@@ -16,6 +19,38 @@
|
|
|
|
|
# include <uuid/uuid.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
@ -28,19 +20,19 @@
|
|
|
|
|
+char ftypelet (mode_t mode)
|
|
|
|
|
+{
|
|
|
|
|
+ if (S_ISBLK (mode))
|
|
|
|
|
+ return 'b';
|
|
|
|
|
+ return 'b';
|
|
|
|
|
+ if (S_ISCHR (mode))
|
|
|
|
|
+ return 'c';
|
|
|
|
|
+ return 'c';
|
|
|
|
|
+ if (S_ISDIR (mode))
|
|
|
|
|
+ return 'd';
|
|
|
|
|
+ return 'd';
|
|
|
|
|
+ if (S_ISREG (mode))
|
|
|
|
|
+ return '-';
|
|
|
|
|
+ return '-';
|
|
|
|
|
+ if (S_ISFIFO (mode))
|
|
|
|
|
+ return 'p';
|
|
|
|
|
+ return 'p';
|
|
|
|
|
+ if (S_ISLNK (mode))
|
|
|
|
|
+ return 'l';
|
|
|
|
|
+ return 'l';
|
|
|
|
|
+ if (S_ISSOCK (mode))
|
|
|
|
|
+ return 's';
|
|
|
|
|
+ return 's';
|
|
|
|
|
+ return '?';
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
@ -48,536 +40,189 @@
|
|
|
|
|
+static int rwx (FILE * stream, mode_t mode)
|
|
|
|
|
+{
|
|
|
|
|
+ return fprintf (stream, "%c%c%c",
|
|
|
|
|
+ (mode & S_IRUSR) ? 'r' : '-',
|
|
|
|
|
+ (mode & S_IWUSR) ? 'w' : '-',
|
|
|
|
|
+ (mode & S_IXUSR) ? 'x' : '-');
|
|
|
|
|
+ (mode & S_IRUSR) ? 'r' : '-',
|
|
|
|
|
+ (mode & S_IWUSR) ? 'w' : '-',
|
|
|
|
|
+ (mode & S_IXUSR) ? 'x' : '-');
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+#if defined(__GLIBC__)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
#ifndef HAVE_REGISTER_PRINTF_SPECIFIER
|
|
|
|
|
#define register_printf_specifier(x, y, z) register_printf_function(x, y, z)
|
|
|
|
|
static int arginfo_ptr (const struct printf_info *info, size_t n,
|
|
|
|
|
@@ -86,7 +120,7 @@
|
|
|
|
|
int len;
|
|
|
|
|
|
|
|
|
|
key = *((const struct key **)(args[0]));
|
|
|
|
|
- len = asprintf (&buffer, "[%u %u 0x%Lx %s (%d)]",
|
|
|
|
|
+ len = asprintf (&buffer, "[%u %u 0x%Lx %s (%d)]",
|
|
|
|
|
get_key_dirid (key), get_key_objectid (key),
|
|
|
|
|
(unsigned long long)get_offset (key), key_of_what (key), get_type (key));
|
|
|
|
|
FPRINTF;
|
|
|
|
|
@@ -109,7 +143,7 @@
|
|
|
|
|
(unsigned long long)get_offset (&ih->ih_key), key_of_what (&ih->ih_key),
|
|
|
|
|
get_type (&ih->ih_key), get_ih_item_len (ih), get_ih_location (ih),
|
|
|
|
|
get_ih_entry_count (ih), get_ih_flags (ih),
|
|
|
|
|
- get_ih_key_format (ih) == KEY_FORMAT_2 ? "new" :
|
|
|
|
|
+ get_ih_key_format (ih) == KEY_FORMAT_2 ? "new" :
|
|
|
|
|
((get_ih_key_format (ih) == KEY_FORMAT_1) ? "old" : "BAD"));
|
|
|
|
|
FPRINTF;
|
|
|
|
|
}
|
|
|
|
|
@@ -130,35 +164,6 @@
|
|
|
|
|
static int arginfo_ptr(const struct printf_info *info, size_t n, int *argtypes)
|
|
|
|
|
@@ -129,33 +164,6 @@ static int print_disk_child(FILE * stream,
|
|
|
|
|
FPRINTF;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-char ftypelet (mode_t mode)
|
|
|
|
|
-char ftypelet(mode_t mode)
|
|
|
|
|
-{
|
|
|
|
|
- if (S_ISBLK (mode))
|
|
|
|
|
- return 'b';
|
|
|
|
|
- if (S_ISCHR (mode))
|
|
|
|
|
- return 'c';
|
|
|
|
|
- if (S_ISDIR (mode))
|
|
|
|
|
- return 'd';
|
|
|
|
|
- if (S_ISREG (mode))
|
|
|
|
|
- return '-';
|
|
|
|
|
- if (S_ISFIFO (mode))
|
|
|
|
|
- return 'p';
|
|
|
|
|
- if (S_ISLNK (mode))
|
|
|
|
|
- return 'l';
|
|
|
|
|
- if (S_ISSOCK (mode))
|
|
|
|
|
- return 's';
|
|
|
|
|
- return '?';
|
|
|
|
|
- if (S_ISBLK(mode))
|
|
|
|
|
- return 'b';
|
|
|
|
|
- if (S_ISCHR(mode))
|
|
|
|
|
- return 'c';
|
|
|
|
|
- if (S_ISDIR(mode))
|
|
|
|
|
- return 'd';
|
|
|
|
|
- if (S_ISREG(mode))
|
|
|
|
|
- return '-';
|
|
|
|
|
- if (S_ISFIFO(mode))
|
|
|
|
|
- return 'p';
|
|
|
|
|
- if (S_ISLNK(mode))
|
|
|
|
|
- return 'l';
|
|
|
|
|
- if (S_ISSOCK(mode))
|
|
|
|
|
- return 's';
|
|
|
|
|
- return '?';
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-static int rwx (FILE * stream, mode_t mode)
|
|
|
|
|
-static int rwx(FILE * stream, mode_t mode)
|
|
|
|
|
-{
|
|
|
|
|
- return fprintf (stream, "%c%c%c",
|
|
|
|
|
- (mode & S_IRUSR) ? 'r' : '-',
|
|
|
|
|
- (mode & S_IWUSR) ? 'w' : '-',
|
|
|
|
|
- (mode & S_IXUSR) ? 'x' : '-');
|
|
|
|
|
- return fprintf(stream, "%c%c%c",
|
|
|
|
|
- (mode & S_IRUSR) ? 'r' : '-',
|
|
|
|
|
- (mode & S_IWUSR) ? 'w' : '-',
|
|
|
|
|
- (mode & S_IXUSR) ? 'x' : '-');
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
/* %M */
|
|
|
|
|
static int print_sd_mode (FILE * stream,
|
|
|
|
|
const struct printf_info *info,
|
|
|
|
|
@@ -192,14 +197,14 @@
|
|
|
|
|
#endif
|
|
|
|
|
static int print_sd_mode(FILE * stream,
|
|
|
|
|
const struct printf_info *info,
|
|
|
|
|
@@ -211,6 +219,140 @@ void reiserfs_warning(FILE * fp, const char *fmt, ...)
|
|
|
|
|
va_end(args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-void reiserfs_warning (FILE * fp, const char * fmt, ...)
|
|
|
|
|
+void reiserfs_warning (FILE * fp, const char * fmt, ...)
|
|
|
|
|
{
|
|
|
|
|
static int registered = 0;
|
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
|
|
if (!registered) {
|
|
|
|
|
registered = 1;
|
|
|
|
|
-
|
|
|
|
|
+
|
|
|
|
|
register_printf_specifier ('K', print_short_key, arginfo_ptr);
|
|
|
|
|
register_printf_specifier ('k', print_key, arginfo_ptr);
|
|
|
|
|
register_printf_specifier ('H', print_item_head, arginfo_ptr);
|
|
|
|
|
@@ -214,6 +219,140 @@
|
|
|
|
|
va_end (args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+#else /* defined(__GLIBC__) */
|
|
|
|
|
+#else /* defined(__GLIBC__) */
|
|
|
|
|
+
|
|
|
|
|
+typedef void* void_ptr;
|
|
|
|
|
+
|
|
|
|
|
+void reiserfs_warning (FILE * fp, const char * fmt, ...)
|
|
|
|
|
+{
|
|
|
|
|
+ char * buffer;
|
|
|
|
|
+ int len;
|
|
|
|
|
+ char format_buf[32];
|
|
|
|
|
+ char* dst = format_buf;
|
|
|
|
|
+ char* end = &dst[30];
|
|
|
|
|
+ const struct buffer_head * bh;
|
|
|
|
|
+ const struct item_head * ih;
|
|
|
|
|
+ const struct disk_child * dc;
|
|
|
|
|
+ const struct key * key;
|
|
|
|
|
+ uint16_t mode;
|
|
|
|
|
+ char * buffer;
|
|
|
|
|
+ int len;
|
|
|
|
|
+ char format_buf[32];
|
|
|
|
|
+ char* dst = format_buf;
|
|
|
|
|
+ char* end = &dst[30];
|
|
|
|
|
+ const struct buffer_head * bh;
|
|
|
|
|
+ const struct item_head * ih;
|
|
|
|
|
+ const struct disk_child * dc;
|
|
|
|
|
+ const struct reiserfs_key * key;
|
|
|
|
|
+ uint16_t mode;
|
|
|
|
|
+#if defined(HAVE_LIBUUID) && defined(HAVE_UUID_UUID_H)
|
|
|
|
|
+ const unsigned char *uuid;
|
|
|
|
|
+ char uuid_buf[37];
|
|
|
|
|
+ const unsigned char *uuid;
|
|
|
|
|
+ char uuid_buf[37];
|
|
|
|
|
+#endif
|
|
|
|
|
+ va_list args;
|
|
|
|
|
+ int esc = 0;
|
|
|
|
|
+ va_list args;
|
|
|
|
|
+ int esc = 0;
|
|
|
|
|
+
|
|
|
|
|
+ va_start (args, fmt);
|
|
|
|
|
+ while (*fmt) {
|
|
|
|
|
+ int ch = *fmt++;
|
|
|
|
|
+ if (esc) {
|
|
|
|
|
+ switch (ch) {
|
|
|
|
|
+ case '%':
|
|
|
|
|
+ fputc(ch, fp);
|
|
|
|
|
+ esc = 0;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'b': // block head
|
|
|
|
|
+ bh = (const struct buffer_head *) va_arg(args, void_ptr);
|
|
|
|
|
+ len = asprintf(&buffer, "level=%d, nr_items=%d, free_space=%d rdkey",
|
|
|
|
|
+ B_LEVEL (bh), B_NR_ITEMS (bh), B_FREE_SPACE (bh));
|
|
|
|
|
+ *dst++ = 's';
|
|
|
|
|
+ *dst = '\0';
|
|
|
|
|
+ fprintf(fp, format_buf, buffer);
|
|
|
|
|
+ esc = 0;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'K': // short key
|
|
|
|
|
+ key = (const struct key *) va_arg(args, void_ptr);
|
|
|
|
|
+ len = asprintf(&buffer, "[%u %u]", get_key_dirid (key),
|
|
|
|
|
+ get_key_objectid (key));
|
|
|
|
|
+ *dst++ = 's';
|
|
|
|
|
+ *dst = '\0';
|
|
|
|
|
+ fprintf(fp, format_buf, buffer);
|
|
|
|
|
+ esc = 0;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'k': // key
|
|
|
|
|
+ key = (const struct key *) va_arg(args, void_ptr);
|
|
|
|
|
+ len = asprintf(&buffer, "[%u %u 0x%Lx %s (%d)]",
|
|
|
|
|
+ get_key_dirid (key), get_key_objectid (key),
|
|
|
|
|
+ (unsigned long long)get_offset (key), key_of_what (key), get_type (key));
|
|
|
|
|
+ *dst++ = 's';
|
|
|
|
|
+ *dst = '\0';
|
|
|
|
|
+ fprintf(fp, format_buf, buffer);
|
|
|
|
|
+ esc = 0;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'H': // item head
|
|
|
|
|
+ ih = (const struct item_head *) va_arg(args, void_ptr);
|
|
|
|
|
+ len = asprintf(&buffer, "%u %u 0x%Lx %s (%d), "
|
|
|
|
|
+ "len %u, location %u entry count %u, fsck need %u, format %s",
|
|
|
|
|
+ get_key_dirid (&ih->ih_key), get_key_objectid (&ih->ih_key),
|
|
|
|
|
+ (unsigned long long)get_offset (&ih->ih_key), key_of_what (&ih->ih_key),
|
|
|
|
|
+ get_type (&ih->ih_key), get_ih_item_len (ih), get_ih_location (ih),
|
|
|
|
|
+ get_ih_entry_count (ih), get_ih_flags (ih),
|
|
|
|
|
+ get_ih_key_format (ih) == KEY_FORMAT_2 ?
|
|
|
|
|
+ "new" :
|
|
|
|
|
+ ((get_ih_key_format (ih) == KEY_FORMAT_1) ? "old" : "BAD"));
|
|
|
|
|
+ *dst++ = 's';
|
|
|
|
|
+ *dst = '\0';
|
|
|
|
|
+ fprintf(fp, format_buf, buffer);
|
|
|
|
|
+ esc = 0;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'y': // disk child
|
|
|
|
|
+ dc = (const struct disk_child *) va_arg(args, void_ptr);
|
|
|
|
|
+ len = asprintf(&buffer, "[dc_number=%u, dc_size=%u]", get_dc_child_blocknr (dc),
|
|
|
|
|
+ get_dc_child_size (dc));
|
|
|
|
|
+ *dst++ = 's';
|
|
|
|
|
+ *dst = '\0';
|
|
|
|
|
+ fprintf(fp, format_buf, buffer);
|
|
|
|
|
+ esc = 0;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'M': // sd mode
|
|
|
|
|
+ mode = (mode_t) va_arg(args, void_ptr);
|
|
|
|
|
+ fputc(ftypelet (mode), fp);
|
|
|
|
|
+ rwx (fp, (mode & 0700) << 0);
|
|
|
|
|
+ rwx (fp, (mode & 0070) << 3);
|
|
|
|
|
+ rwx (fp, (mode & 0007) << 6);
|
|
|
|
|
+ esc = 0;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'U': // UUID
|
|
|
|
|
+ va_start (args, fmt);
|
|
|
|
|
+ while (*fmt) {
|
|
|
|
|
+ int ch = *fmt++;
|
|
|
|
|
+ if (esc) {
|
|
|
|
|
+ switch (ch) {
|
|
|
|
|
+ case '%':
|
|
|
|
|
+ fputc(ch, fp);
|
|
|
|
|
+ esc = 0;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'b': // block head
|
|
|
|
|
+ bh = (const struct buffer_head *) va_arg(args, void_ptr);
|
|
|
|
|
+ len = asprintf(&buffer, "level=%d, nr_items=%d, free_space=%d rdkey",
|
|
|
|
|
+ B_LEVEL (bh), B_NR_ITEMS (bh), B_FREE_SPACE (bh));
|
|
|
|
|
+ *dst++ = 's';
|
|
|
|
|
+ *dst = '\0';
|
|
|
|
|
+ fprintf(fp, format_buf, buffer);
|
|
|
|
|
+ esc = 0;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'K': // short key
|
|
|
|
|
+ key = (const struct reiserfs_key *) va_arg(args, void_ptr);
|
|
|
|
|
+ len = asprintf(&buffer, "[%u %u]", get_key_dirid (key),
|
|
|
|
|
+ get_key_objectid (key));
|
|
|
|
|
+ *dst++ = 's';
|
|
|
|
|
+ *dst = '\0';
|
|
|
|
|
+ fprintf(fp, format_buf, buffer);
|
|
|
|
|
+ esc = 0;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'k': // key
|
|
|
|
|
+ key = (const struct reiserfs_key *) va_arg(args, void_ptr);
|
|
|
|
|
+ len = asprintf(&buffer, "[%u %u 0x%Lx %s (%d)]",
|
|
|
|
|
+ get_key_dirid (key), get_key_objectid (key),
|
|
|
|
|
+ (unsigned long long)get_offset (key), key_of_what (key), get_type (key));
|
|
|
|
|
+ *dst++ = 's';
|
|
|
|
|
+ *dst = '\0';
|
|
|
|
|
+ fprintf(fp, format_buf, buffer);
|
|
|
|
|
+ esc = 0;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'H': // item head
|
|
|
|
|
+ ih = (const struct item_head *) va_arg(args, void_ptr);
|
|
|
|
|
+ len = asprintf(&buffer, "%u %u 0x%Lx %s (%d), "
|
|
|
|
|
+ "len %u, location %u entry count %u, fsck need %u, format %s",
|
|
|
|
|
+ get_key_dirid (&ih->ih_key), get_key_objectid (&ih->ih_key),
|
|
|
|
|
+ (unsigned long long)get_offset (&ih->ih_key), key_of_what (&ih->ih_key),
|
|
|
|
|
+ get_type (&ih->ih_key), get_ih_item_len (ih), get_ih_location (ih),
|
|
|
|
|
+ get_ih_entry_count (ih), get_ih_flags (ih),
|
|
|
|
|
+ get_ih_key_format (ih) == KEY_FORMAT_2 ?
|
|
|
|
|
+ "new" :
|
|
|
|
|
+ ((get_ih_key_format (ih) == KEY_FORMAT_1) ? "old" : "BAD"));
|
|
|
|
|
+ *dst++ = 's';
|
|
|
|
|
+ *dst = '\0';
|
|
|
|
|
+ fprintf(fp, format_buf, buffer);
|
|
|
|
|
+ esc = 0;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'y': // disk child
|
|
|
|
|
+ dc = (const struct disk_child *) va_arg(args, void_ptr);
|
|
|
|
|
+ len = asprintf(&buffer, "[dc_number=%u, dc_size=%u]", get_dc_child_blocknr (dc),
|
|
|
|
|
+ get_dc_child_size (dc));
|
|
|
|
|
+ *dst++ = 's';
|
|
|
|
|
+ *dst = '\0';
|
|
|
|
|
+ fprintf(fp, format_buf, buffer);
|
|
|
|
|
+ esc = 0;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'M': // sd mode
|
|
|
|
|
+ mode = (mode_t) va_arg(args, void_ptr);
|
|
|
|
|
+ fputc(ftypelet (mode), fp);
|
|
|
|
|
+ rwx (fp, (mode & 0700) << 0);
|
|
|
|
|
+ rwx (fp, (mode & 0070) << 3);
|
|
|
|
|
+ rwx (fp, (mode & 0007) << 6);
|
|
|
|
|
+ esc = 0;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'U': // UUID
|
|
|
|
|
+#if defined(HAVE_LIBUUID) && defined(HAVE_UUID_UUID_H)
|
|
|
|
|
+ uuid = (const unsigned char *) va_arg(args, void_ptr);
|
|
|
|
|
+ uuid_buf[36] = '\0';
|
|
|
|
|
+ uuid_unparse(uuid, uuid_buf);
|
|
|
|
|
+ fprintf(fp, "%s", uuid_buf);
|
|
|
|
|
+ uuid = (const unsigned char *) va_arg(args, void_ptr);
|
|
|
|
|
+ uuid_buf[36] = '\0';
|
|
|
|
|
+ uuid_unparse(uuid, uuid_buf);
|
|
|
|
|
+ fprintf(fp, "%s", uuid_buf);
|
|
|
|
|
+#else
|
|
|
|
|
+ fprintf(fp, "<no libuuid installed>");
|
|
|
|
|
+ fprintf(fp, "<no libuuid installed>");
|
|
|
|
|
+#endif
|
|
|
|
|
+ esc = 0;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case '-': case '+': case '#': case '.':
|
|
|
|
|
+ case '0': case '1': case '2': case '3': case '4':
|
|
|
|
|
+ case '5': case '6': case '7': case '8': case '9':
|
|
|
|
|
+ case 'l': case 'L': case 'h':
|
|
|
|
|
+ // non-terminal format modifiers
|
|
|
|
|
+ if (dst < end)
|
|
|
|
|
+ *dst++ = ch;
|
|
|
|
|
+ break;
|
|
|
|
|
+ default:
|
|
|
|
|
+ *dst++ = ch;
|
|
|
|
|
+ *dst = '\0';
|
|
|
|
|
+ fprintf(fp, format_buf, va_arg(args, void_ptr));
|
|
|
|
|
+ esc = 0;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (ch == '%') {
|
|
|
|
|
+ esc = 1;
|
|
|
|
|
+ dst = format_buf;
|
|
|
|
|
+ end = &dst[30]; // leave room for final "s\0"
|
|
|
|
|
+ *dst++ = ch;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ fputc(ch, fp);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ esc = 0;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case '-': case '+': case '#': case '.':
|
|
|
|
|
+ case '0': case '1': case '2': case '3': case '4':
|
|
|
|
|
+ case '5': case '6': case '7': case '8': case '9':
|
|
|
|
|
+ case 'l': case 'L': case 'h':
|
|
|
|
|
+ // non-terminal format modifiers
|
|
|
|
|
+ if (dst < end)
|
|
|
|
|
+ *dst++ = ch;
|
|
|
|
|
+ break;
|
|
|
|
|
+ default:
|
|
|
|
|
+ *dst++ = ch;
|
|
|
|
|
+ *dst = '\0';
|
|
|
|
|
+ fprintf(fp, format_buf, va_arg(args, void_ptr));
|
|
|
|
|
+ esc = 0;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (ch == '%') {
|
|
|
|
|
+ esc = 1;
|
|
|
|
|
+ dst = format_buf;
|
|
|
|
|
+ end = &dst[30]; // leave room for final "s\0"
|
|
|
|
|
+ *dst++ = ch;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ fputc(ch, fp);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ va_end (args);
|
|
|
|
|
+ va_end (args);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+#endif /* !defined(__GLIBC__) */
|
|
|
|
|
+#endif /* !defined(__GLIBC__) */
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
static char * vi_type (struct virtual_item * vi)
|
|
|
|
|
static void print_directory_item(FILE *fp, reiserfs_filsys_t fs,
|
|
|
|
|
struct buffer_head *bh, struct item_head *ih)
|
|
|
|
|
{
|
|
|
|
|
@@ -236,10 +374,10 @@
|
|
|
|
|
void print_virtual_node (struct virtual_node * vn)
|
|
|
|
|
{
|
|
|
|
|
int i, j;
|
|
|
|
|
-
|
|
|
|
|
+
|
|
|
|
|
printf ("VIRTUAL NODE CONTAINS %d items, has size %d,%s,%s, ITEM_POS=%d POS_IN_ITEM=%d MODE=\'%c\'\n",
|
|
|
|
|
vn->vn_nr_item, vn->vn_size,
|
|
|
|
|
- (vn->vn_vi[0].vi_type & VI_TYPE_LEFT_MERGEABLE )? "left mergeable" : "",
|
|
|
|
|
+ (vn->vn_vi[0].vi_type & VI_TYPE_LEFT_MERGEABLE )? "left mergeable" : "",
|
|
|
|
|
(vn->vn_vi[vn->vn_nr_item - 1].vi_type & VI_TYPE_RIGHT_MERGEABLE) ? "right mergeable" : "",
|
|
|
|
|
vn->vn_affected_item_num, vn->vn_pos_in_item, vn->vn_mode);
|
|
|
|
|
|
|
|
|
|
@@ -265,10 +403,10 @@
|
|
|
|
|
printf ("Offset Bh (b_blocknr, b_count) Position Nr_item\n");
|
|
|
|
|
while ( offset > ILLEGAL_PATH_ELEMENT_OFFSET ) {
|
|
|
|
|
bh = PATH_OFFSET_PBUFFER (path, offset);
|
|
|
|
|
- printf ("%6d %10p (%9lu, %7d) %8d %7d\n", offset,
|
|
|
|
|
+ printf ("%6d %10p (%9lu, %7d) %8d %7d\n", offset,
|
|
|
|
|
bh, bh ? bh->b_blocknr : 0, bh ? bh->b_count : 0,
|
|
|
|
|
PATH_OFFSET_POSITION (path, offset), bh ? B_NR_ITEMS (bh) : -1);
|
|
|
|
|
-
|
|
|
|
|
+
|
|
|
|
|
offset --;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -298,13 +436,13 @@
|
|
|
|
|
}
|
|
|
|
|
if (i && dir_entry_bad_location (deh - 1, ih, ((i - 1) == 0) ? 1 : 0))
|
|
|
|
|
/* previous entry has bad location so we can not calculate entry
|
|
|
|
|
- length */
|
|
|
|
|
+ length */
|
|
|
|
|
namelen = 25;
|
|
|
|
|
else
|
|
|
|
|
namelen = name_in_entry_length (ih, deh, i);
|
|
|
|
|
|
|
|
|
|
name = name_in_entry (deh, i);
|
|
|
|
|
- reiserfs_warning (fp, "%3d: \"%-25.*s\"(%3d)%20K%12d%5d, loc %u, state %x %s\n",
|
|
|
|
|
+ reiserfs_warning (fp, "%3d: \"%-25.*s\"(%3d)%20K%12d%5d, loc %u, state %x %s\n",
|
|
|
|
|
i, namelen, name, namelen,
|
|
|
|
|
(struct key *)&(deh->deh2_dir_id),
|
|
|
|
|
GET_HASH_VALUE (get_deh_offset (deh)),
|
|
|
|
|
@@ -366,10 +504,10 @@
|
|
|
|
|
unp = (__u32 *)B_I_PITEM (bh, ih);
|
|
|
|
|
|
|
|
|
|
if (get_ih_item_len (ih) % UNFM_P_SIZE)
|
|
|
|
|
- reiserfs_warning (fp, "print_indirect_item: invalid item len");
|
|
|
|
|
+ reiserfs_warning (fp, "print_indirect_item: invalid item len");
|
|
|
|
|
|
|
|
|
|
reiserfs_warning (fp, "%d pointer%s\n[", I_UNFM_NUM (ih),
|
|
|
|
|
- I_UNFM_NUM (ih) != 1 ? "s" : "" );
|
|
|
|
|
+ I_UNFM_NUM (ih) != 1 ? "s" : "" );
|
|
|
|
|
for (j = 0; j < I_UNFM_NUM (ih); j ++) {
|
|
|
|
|
if (sequence_finished (prev, &num, d32_get(unp, j))) {
|
|
|
|
|
print_sequence (fp, prev, num);
|
|
|
|
|
@@ -392,29 +530,29 @@
|
|
|
|
|
static int print_stat_data (FILE * fp, struct buffer_head * bh, struct item_head * ih, int alltimes)
|
|
|
|
|
{
|
|
|
|
|
int retval;
|
|
|
|
|
-
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
/* we cannot figure out if it is new stat data or old by key_format
|
|
|
|
|
macro. Stat data's key looks identical in both formats */
|
|
|
|
|
if (get_ih_key_format (ih) == KEY_FORMAT_1) {
|
|
|
|
|
- struct stat_data_v1 * sd_v1 = (struct stat_data_v1 *)B_I_PITEM (bh, ih);
|
|
|
|
|
+ struct stat_data_v1 * sd_v1 = (struct stat_data_v1 *)B_I_PITEM (bh, ih);
|
|
|
|
|
reiserfs_warning (fp, "(OLD SD), mode %M, size %u, nlink %u, uid %u, FDB %u, mtime %s blocks %u",
|
|
|
|
|
sd_v1_mode(sd_v1), sd_v1_size(sd_v1), sd_v1_nlink(sd_v1),
|
|
|
|
|
- sd_v1_uid(sd_v1), sd_v1_first_direct_byte(sd_v1), timestamp
|
|
|
|
|
- (sd_v1_mtime(sd_v1)), sd_v1_blocks(sd_v1));
|
|
|
|
|
+ sd_v1_uid(sd_v1), sd_v1_first_direct_byte(sd_v1), timestamp
|
|
|
|
|
+ (sd_v1_mtime(sd_v1)), sd_v1_blocks(sd_v1));
|
|
|
|
|
retval = (S_ISLNK (sd_v1_mode(sd_v1))) ? 1 : 0;
|
|
|
|
|
- if (alltimes)
|
|
|
|
|
- reiserfs_warning (fp, "%s %s\n", timestamp (sd_v1_ctime(sd_v1)),
|
|
|
|
|
- timestamp (sd_v1_atime(sd_v1)));
|
|
|
|
|
+ if (alltimes)
|
|
|
|
|
+ reiserfs_warning (fp, "%s %s\n", timestamp (sd_v1_ctime(sd_v1)),
|
|
|
|
|
+ timestamp (sd_v1_atime(sd_v1)));
|
|
|
|
|
} else {
|
|
|
|
|
- struct stat_data * sd = (struct stat_data *)B_I_PITEM (bh, ih);
|
|
|
|
|
+ struct stat_data * sd = (struct stat_data *)B_I_PITEM (bh, ih);
|
|
|
|
|
reiserfs_warning (fp, "(NEW SD), mode %M, size %Lu, nlink %u, mtime %s blocks %u, uid %u",
|
|
|
|
|
sd_v2_mode(sd), sd_v2_size(sd), sd_v2_nlink(sd),
|
|
|
|
|
timestamp (sd_v2_mtime(sd)), sd_v2_blocks(sd), sd_v2_uid(sd));
|
|
|
|
|
retval = (S_ISLNK (sd_v2_mode(sd))) ? 1 : 0;
|
|
|
|
|
- if (alltimes)
|
|
|
|
|
- reiserfs_warning (fp, "%s %s\n", timestamp (sd_v2_ctime(sd)),
|
|
|
|
|
- timestamp (sd_v2_atime(sd)));
|
|
|
|
|
+ if (alltimes)
|
|
|
|
|
+ reiserfs_warning (fp, "%s %s\n", timestamp (sd_v2_ctime(sd)),
|
|
|
|
|
+ timestamp (sd_v2_atime(sd)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
reiserfs_warning (fp, "\n");
|
|
|
|
|
@@ -442,7 +580,7 @@
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- print_directory_item (fp, 0, bh, ih);
|
|
|
|
|
+ print_directory_item (fp, 0, bh, ih);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -494,7 +632,7 @@
|
|
|
|
|
|
|
|
|
|
if (!is_tree_node (bh, DISK_LEAF_NODE_LEVEL))
|
|
|
|
|
return 1;
|
|
|
|
|
-
|
|
|
|
|
+
|
|
|
|
|
ih = B_N_PITEM_HEAD (bh,0);
|
|
|
|
|
real_nr = leaf_count_ih(bh->b_data, bh->b_size);
|
|
|
|
|
nr = get_blkh_nr_items((struct block_head *)bh->b_data);
|
|
|
|
|
@@ -510,9 +648,9 @@
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- if (first < 0 || first > real_nr - 1)
|
|
|
|
|
+ if (first < 0 || first > real_nr - 1)
|
|
|
|
|
from = 0;
|
|
|
|
|
- else
|
|
|
|
|
+ else
|
|
|
|
|
from = first;
|
|
|
|
|
|
|
|
|
|
if (last < 0 || last > real_nr)
|
|
|
|
|
@@ -601,11 +739,11 @@
|
|
|
|
|
switch (get_reiserfs_format (sb)) {
|
|
|
|
|
case REISERFS_FORMAT_3_5:
|
|
|
|
|
reiserfs_warning (fp, "format 3.5 with ");
|
|
|
|
|
- format = 1;
|
|
|
|
|
+ format = 1;
|
|
|
|
|
break;
|
|
|
|
|
case REISERFS_FORMAT_3_6:
|
|
|
|
|
reiserfs_warning (fp, "format 3.6 with ");
|
|
|
|
|
- format = 2;
|
|
|
|
|
+ format = 2;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
reiserfs_warning (fp, "unknown format with ");
|
|
|
|
|
@@ -631,7 +769,7 @@
|
|
|
|
|
(get_sb_umount_state (sb) == FS_CLEANLY_UMOUNTED) ? "" : "NOT ");
|
|
|
|
|
|
|
|
|
|
if (short_print)
|
|
|
|
|
- return 0;
|
|
|
|
|
+ return 0;
|
|
|
|
|
reiserfs_warning (fp, "Tree height: %d\n", get_sb_tree_height (sb));
|
|
|
|
|
reiserfs_warning (fp, "Hash function used to sort names: %s\n",
|
|
|
|
|
code2name (get_sb_hash_code (sb)));
|
|
|
|
|
@@ -652,10 +790,10 @@
|
|
|
|
|
|
|
|
|
|
reiserfs_warning (fp, "sb_version: %u\n", get_sb_version (sb));
|
|
|
|
|
if (format == 2) {
|
|
|
|
|
- reiserfs_warning (fp, "inode generation number: %u\n", get_sb_v2_inode_generation (sb));
|
|
|
|
|
- reiserfs_warning (fp, "UUID: %U\n", sb->s_uuid);
|
|
|
|
|
- reiserfs_warning (fp, "LABEL: %.16s\n", sb->s_label);
|
|
|
|
|
- reiserfs_warning (fp, "Set flags in SB:\n");
|
|
|
|
|
+ reiserfs_warning (fp, "inode generation number: %u\n", get_sb_v2_inode_generation (sb));
|
|
|
|
|
+ reiserfs_warning (fp, "UUID: %U\n", sb->s_uuid);
|
|
|
|
|
+ reiserfs_warning (fp, "LABEL: %.16s\n", sb->s_label);
|
|
|
|
|
+ reiserfs_warning (fp, "Set flags in SB:\n");
|
|
|
|
|
if ((get_sb_v2_flag (sb, reiserfs_attrs_cleared)))
|
|
|
|
|
reiserfs_warning (fp, "\tATTRIBUTES CLEAN\n");
|
|
|
|
|
reiserfs_warning(fp, "Mount count: %u\n",
|
|
|
|
|
@@ -713,7 +851,7 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-void print_block (FILE * fp, reiserfs_filsys_t * fs,
|
|
|
|
|
+void print_block (FILE * fp, reiserfs_filsys_t * fs,
|
|
|
|
|
struct buffer_head * bh, ...)//int print_mode, int first, int last)
|
|
|
|
|
{
|
|
|
|
|
va_list args;
|
|
|
|
|
@@ -732,7 +870,7 @@
|
|
|
|
|
last = va_arg (args, int);
|
|
|
|
|
file_name = (fs) ? fs->fs_file_name : NULL ;
|
|
|
|
|
if (print_desc_block (fp, bh))
|
|
|
|
|
- if (print_super_block (fp, fs, file_name, bh, 0))
|
|
|
|
|
+ if (print_super_block (fp, fs, file_name, bh, 0))
|
|
|
|
|
if (print_leaf (fp, fs, bh, mode, first, last))
|
|
|
|
|
if (print_internal (fp, bh, first, last))
|
|
|
|
|
reiserfs_warning (fp, "Block %lu contains unformatted data\n", bh->b_blocknr);
|
|
|
|
|
@@ -758,21 +896,21 @@
|
|
|
|
|
1 2 3 4 5 6 7 8
|
|
|
|
|
printk ("*********************************************************************\n");
|
|
|
|
|
*/
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
for (h = 0; h < sizeof(tb->insert_size) / sizeof (tb->insert_size[0]); h ++) {
|
|
|
|
|
- if (PATH_H_PATH_OFFSET (tb->tb_path, h) <= tb->tb_path->path_length &&
|
|
|
|
|
+ if (PATH_H_PATH_OFFSET (tb->tb_path, h) <= tb->tb_path->path_length &&
|
|
|
|
|
PATH_H_PATH_OFFSET (tb->tb_path, h) > ILLEGAL_PATH_ELEMENT_OFFSET) {
|
|
|
|
|
tbSh = PATH_H_PBUFFER (tb->tb_path, h);
|
|
|
|
|
tbFh = PATH_H_PPARENT (tb->tb_path, h);
|
|
|
|
|
} else {
|
|
|
|
|
- /* printk ("print_tb: h=%d, PATH_H_PATH_OFFSET=%d, path_length=%d\n",
|
|
|
|
|
+ /* printk ("print_tb: h=%d, PATH_H_PATH_OFFSET=%d, path_length=%d\n",
|
|
|
|
|
h, PATH_H_PATH_OFFSET (tb->tb_path, h), tb->tb_path->path_length);*/
|
|
|
|
|
tbSh = 0;
|
|
|
|
|
tbFh = 0;
|
|
|
|
|
}
|
|
|
|
|
printf ("* %u * %3lu(%2lu) * %3lu(%2lu) * %3lu(%2lu) * %5lu * %5lu * %5lu * %5lu * %5lu *\n",
|
|
|
|
|
- h,
|
|
|
|
|
+ h,
|
|
|
|
|
tbSh ? tbSh->b_blocknr : ~0ul,
|
|
|
|
|
tbSh ? tbSh->b_count : ~0ul,
|
|
|
|
|
tb->L[h] ? tb->L[h]->b_blocknr : ~0ul,
|
|
|
|
|
@@ -793,7 +931,7 @@
|
|
|
|
|
h = 0;
|
|
|
|
|
printf ("* h * size * ln * lb * rn * rb * blkn * s0 * s1 * s1b * s2 * s2b * curb * lk * rk *\n");
|
|
|
|
|
printf ("* %d * %4d * %2d * %2d * %2d * %2d * %4d * %2d * %2d * %3d * %2d * %3d * %4d * %2d * %2d *\n",
|
|
|
|
|
- h, tb->insert_size[h], tb->lnum[h], tb->lbytes, tb->rnum[h],tb->rbytes, tb->blknum[h],
|
|
|
|
|
+ h, tb->insert_size[h], tb->lnum[h], tb->lbytes, tb->rnum[h],tb->rbytes, tb->blknum[h],
|
|
|
|
|
tb->s0num, tb->s1num,tb->s1bytes, tb->s2num, tb->s2bytes, tb->cur_blknum, tb->lkey[h], tb->rkey[h]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -822,7 +960,7 @@
|
|
|
|
|
int j, k;
|
|
|
|
|
int bits = blocksize * 8;
|
|
|
|
|
int zeros = 0, ones = 0;
|
|
|
|
|
-
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
reiserfs_warning (fp, "#%d: block %lu: ", i, block);
|
|
|
|
|
|
|
|
|
|
@@ -882,7 +1020,7 @@
|
|
|
|
|
zeros += k;
|
|
|
|
|
if (!silent)
|
|
|
|
|
reiserfs_warning (fp, "%d) Busy(%d-", j - 1 + i * bits, j + i * bits);
|
|
|
|
|
-
|
|
|
|
|
+
|
|
|
|
|
k = 0;
|
|
|
|
|
while (misc_test_bit (j, map)) {
|
|
|
|
|
ones ++;
|
|
|
|
|
@@ -897,7 +1035,7 @@
|
|
|
|
|
ones += k;
|
|
|
|
|
if (!silent)
|
|
|
|
|
reiserfs_warning (fp, "%d) Free(%d-", j - 1 + i * bits, j + i * bits);
|
|
|
|
|
-
|
|
|
|
|
+
|
|
|
|
|
j --;
|
|
|
|
|
end2:
|
|
|
|
|
/* to make gcc 3.2 do not sware here */;
|
|
|
|
|
@@ -943,7 +1081,7 @@
|
|
|
|
|
block = (block / (fs->fs_blocksize * 8) + 1) * (fs->fs_blocksize * 8);
|
|
|
|
|
else
|
|
|
|
|
block ++;
|
|
|
|
|
-
|
|
|
|
|
+
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -965,26 +1103,26 @@
|
|
|
|
|
reiserfs_warning (fp, "print_objectid_map: proper signature is not found\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
-
|
|
|
|
|
+
|
|
|
|
|
reiserfs_warning (fp, "Map of objectids (super block size %d)\n",
|
|
|
|
|
(char *)omap - (char *)sb);
|
|
|
|
|
-
|
|
|
|
|
+
|
|
|
|
|
for (i = 0; i < get_sb_oid_cursize (sb); i ++) {
|
|
|
|
|
if (i % 2 == 0) {
|
|
|
|
|
reiserfs_warning(fp, "busy(%u-%u) ", le32_to_cpu (omap[i]),
|
|
|
|
|
- le32_to_cpu (omap[i+1]) - 1);
|
|
|
|
|
+ le32_to_cpu (omap[i+1]) - 1);
|
|
|
|
|
} else {
|
|
|
|
|
reiserfs_warning(fp, "free(%u-%u) ", le32_to_cpu (omap[i]),
|
|
|
|
|
- ((i+1) == get_sb_oid_cursize (sb)) ?
|
|
|
|
|
+ ((i+1) == get_sb_oid_cursize (sb)) ?
|
|
|
|
|
~(__u32)0 : (le32_to_cpu (omap[i+1]) - 1));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- reiserfs_warning (fp, "\nObject id array has size %d (max %d):",
|
|
|
|
|
+ reiserfs_warning (fp, "\nObject id array has size %d (max %d):",
|
|
|
|
|
get_sb_oid_cursize (sb), get_sb_oid_maxsize (sb));
|
|
|
|
|
-
|
|
|
|
|
+
|
|
|
|
|
for (i = 0; i < get_sb_oid_cursize (sb); i ++)
|
|
|
|
|
- reiserfs_warning (fp, "%s%u ", i % 2 ? "" : "*", le32_to_cpu (omap[i]));
|
|
|
|
|
+ reiserfs_warning (fp, "%s%u ", i % 2 ? "" : "*", le32_to_cpu (omap[i]));
|
|
|
|
|
reiserfs_warning (fp, "\n");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@@ -999,7 +1137,7 @@
|
|
|
|
|
reiserfs_warning (stdout, "Journal header (block #%lu of %s):\n"
|
|
|
|
|
"\tj_last_flush_trans_id %ld\n"
|
|
|
|
|
"\tj_first_unflushed_offset %ld\n"
|
|
|
|
|
- "\tj_mount_id %ld\n",
|
|
|
|
|
+ "\tj_mount_id %ld\n",
|
|
|
|
|
fs->fs_jh_bh->b_blocknr, fs->fs_j_file_name,
|
|
|
|
|
get_jh_last_flushed (j_head),
|
|
|
|
|
get_jh_replay_start_offset (j_head),
|
|
|
|
|
@@ -1009,7 +1147,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void print_trans_element (reiserfs_filsys_t * fs, reiserfs_trans_t * trans,
|
|
|
|
|
- unsigned int index, unsigned long in_journal,
|
|
|
|
|
+ unsigned int index, unsigned long in_journal,
|
|
|
|
|
unsigned long in_place)
|
|
|
|
|
{
|
|
|
|
|
if (index % 8 == 0)
|
|
|
|
|
@@ -1043,4 +1181,3 @@
|
|
|
|
|
|
|
|
|
|
for_each_transaction (fs, print_one_transaction);
|
|
|
|
|
}
|
|
|
|
|
-
|
|
|
|
|