getflags.o getversion.o hashstr.o iod.o ls.o ljs.o mntopts.o \
parse_num.o pe.o pf.o ps.o setflags.o setversion.o uuid.o \
ostype.o percent.o crypto_mode.o fgetproject.o fsetproject.o \
- encoding.o
+ encoding.o errcode.o
SRCS= $(srcdir)/feature.c $(srcdir)/fgetflags.c \
$(srcdir)/fsetflags.c $(srcdir)/fgetversion.c \
$(srcdir)/fsetversion.c $(srcdir)/getflags.c \
$(srcdir)/getversion.c $(srcdir)/hashstr.c $(srcdir)/iod.c \
- $(srcdir)/ls.c $(srcdir)/ljs.c $(srcdir)/mntopts.c $(srcdir)/parse_num.c \
- $(srcdir)/pe.c $(srcdir)/pf.c $(srcdir)/ps.c \
- $(srcdir)/setflags.c $(srcdir)/setversion.c $(srcdir)/uuid.c \
- $(srcdir)/ostype.c $(srcdir)/percent.c $(srcdir)/crypto_mode.c \
- $(srcdir)/fgetproject.c $(srcdir)/fsetproject.c $(srcdir)/encoding.c
+ $(srcdir)/ls.c $(srcdir)/ljs.c $(srcdir)/mntopts.c \
+ $(srcdir)/parse_num.c $(srcdir)/pe.c $(srcdir)/pf.c \
+ $(srcdir)/ps.c $(srcdir)/setflags.c $(srcdir)/setversion.c \
+ $(srcdir)/uuid.c $(srcdir)/ostype.c $(srcdir)/percent.c \
+ $(srcdir)/crypto_mode.c $(srcdir)/fgetproject.c \
+ $(srcdir)/fsetproject.c $(srcdir)/encoding.c \
+ $(srcdir)/errcode.c
+
HFILES= e2p.h
LIBRARY= libe2p
const char *e2p_encoding2str(int encoding);
int e2p_get_encoding_flags(int encoding);
int e2p_str2encoding_flags(int encoding, char *param, __u16 *flags);
+
+const char *e2p_errcode2str(int err);
--- /dev/null
+/*
+ * errcode.c - convert an error code to a string
+ */
+
+#include "config.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static const char *err_string[] = {
+ "",
+ "UNKNOWN", /* 1 */
+ "EIO", /* 2 */
+ "ENOMEM", /* 3 */
+ "EFSBADCRC", /* 4 */
+ "EFSCORRUPTED", /* 5 */
+ "ENOSPC", /* 6 */
+ "ENOKEY", /* 7 */
+ "EROFS", /* 8 */
+ "EFBIG", /* 9 */
+ "EEXIST", /* 10 */
+ "ERANGE", /* 11 */
+ "EOVERFLOW", /* 12 */
+ "EBUSY", /* 13 */
+ "ENOTDIR", /* 14 */
+ "ENOTEMPTY", /* 15 */
+ "ESHUTDOWN", /* 16 */
+ "EFAULT", /* 17 */
+};
+
+#define ARRAY_SIZE(array) \
+ (sizeof(array) / sizeof(array[0]))
+
+/* Return the name of an encoding or NULL */
+const char *e2p_errcode2str(int err)
+{
+ unsigned int i;
+ static char buf[32];
+
+ if (err < ARRAY_SIZE(err_string))
+ return err_string[err];
+
+ sprintf(buf, "UNKNOWN_ERRCODE_%d", err);
+ return buf;
+}
+
+
EXT2_LEN_STR(sb->s_first_error_func));
fprintf(f, "First error line #: %u\n",
sb->s_first_error_line);
- fprintf(f, "First error inode #: %u\n",
- sb->s_first_error_ino);
- fprintf(f, "First error block #: %llu\n",
- sb->s_first_error_block);
+ if (sb->s_first_error_ino)
+ fprintf(f, "First error inode #: %u\n",
+ sb->s_first_error_ino);
+ if (sb->s_first_error_block)
+ fprintf(f, "First error block #: %llu\n",
+ sb->s_first_error_block);
+ if (sb->s_first_error_errcode)
+ fprintf(f, "First error err: %s\n",
+ e2p_errcode2str(sb->s_first_error_errcode));
}
if (sb->s_last_error_time) {
tm = sb->s_last_error_time;
EXT2_LEN_STR(sb->s_last_error_func));
fprintf(f, "Last error line #: %u\n",
sb->s_last_error_line);
- fprintf(f, "Last error inode #: %u\n",
- sb->s_last_error_ino);
- fprintf(f, "Last error block #: %llu\n",
- sb->s_last_error_block);
+ if (sb->s_last_error_ino)
+ fprintf(f, "Last error inode #: %u\n",
+ sb->s_last_error_ino);
+ if (sb->s_last_error_block)
+ fprintf(f, "Last error block #: %llu\n",
+ sb->s_last_error_block);
+ if (sb->s_last_error_errcode)
+ fprintf(f, "Last error err: %s\n",
+ e2p_errcode2str(sb->s_last_error_errcode));
}
if (ext2fs_has_feature_mmp(sb)) {
fprintf(f, "MMP block number: %llu\n",
__u8 s_lastcheck_hi;
__u8 s_first_error_time_hi;
__u8 s_last_error_time_hi;
- __u8 s_pad[2];
+ __u8 s_first_error_errcode;
+ __u8 s_last_error_errcode;
/*27c*/ __le16 s_encoding; /* Filename charset encoding */
__le16 s_encoding_flags; /* Filename charset encoding flags */
__le32 s_reserved[95]; /* Padding to the end of the block */
check_field(s_lastcheck_hi, 1);
check_field(s_first_error_time_hi, 1);
check_field(s_last_error_time_hi, 1);
- check_field(s_pad, 2);
+ check_field(s_first_error_errcode, 1);
+ check_field(s_last_error_errcode, 1);
check_field(s_encoding, 2);
check_field(s_encoding_flags, 2);
check_field(s_reserved, 95 * 4);