Whamcloud - gitweb
libcom_err: deal with the fact that the Hurd error messages are not zero-based
authorTheodore Ts'o <tytso@mit.edu>
Wed, 8 Jan 2020 15:59:37 +0000 (10:59 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 8 Jan 2020 20:59:01 +0000 (15:59 -0500)
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
debian/changelog
lib/et/error_message.c

index d26f8db..bf82d15 100644 (file)
@@ -1,3 +1,12 @@
+e2fsprogs (1.45.5-2) unstable; urgency=medium
+
+  * Fix com_err support on Hurd, which has POSIX E* error code starting at
+    0x40000000.  Otherwise the regression tests will fail since the
+    expected output for various error cases will not have the correct
+    error text.
+
+ -- Theodore Y. Ts'o <tytso@mit.edu>  Wed, 08 Jan 2020 15:58:44 -0500
+
 e2fsprogs (1.45.5-1) unstable; urgency=medium
 
   * New upstream feature
index bd18be7..cd9f57f 100644 (file)
@@ -113,6 +113,11 @@ gettextf set_com_err_gettext(gettextf new_proc)
     return x;
 }
 
+#ifdef __GNU__
+#define SYS_ERR_BASE 0x40000000
+#else
+#define SYS_ERR_BASE 0
+#endif
 
 const char * error_message (errcode_t code)
 {
@@ -124,14 +129,14 @@ const char * error_message (errcode_t code)
 
     offset = (int) (code & ((1<<ERRCODE_RANGE)-1));
     table_num = code - offset;
-    if (!table_num) {
+    if (table_num == SYS_ERR_BASE) {
 #ifdef HAS_SYS_ERRLIST
-       if (offset < sys_nerr)
-           return(sys_errlist[offset]);
+       if (code < sys_nerr)
+           return(sys_errlist[code]);
        else
            goto oops;
 #else
-       cp = strerror(offset);
+       cp = strerror(code);
        if (cp)
            return(cp);
        else