2008-01-17 22:46:25 +01:00
|
|
|
Index: e2fsprogs-1.40.4/lib/et/com_err.pc.in
|
2007-03-30 16:29:23 +02:00
|
|
|
===================================================================
|
2008-01-17 22:46:25 +01:00
|
|
|
--- e2fsprogs-1.40.4.orig/lib/et/com_err.pc.in
|
|
|
|
+++ e2fsprogs-1.40.4/lib/et/com_err.pc.in
|
2007-03-30 16:29:23 +02:00
|
|
|
@@ -7,5 +7,5 @@ Name: com_err
|
2006-12-19 00:15:45 +01:00
|
|
|
Description: Common error description library
|
|
|
|
Version: @E2FSPROGS_VERSION@
|
|
|
|
Requires:
|
|
|
|
-Cflags: -I${includedir}
|
|
|
|
-Libs: -L${libdir} -lcom_err
|
|
|
|
+Cflags: -I${includedir} -pthread
|
|
|
|
+Libs: -L${libdir} -lcom_err -pthread
|
2008-01-17 22:46:25 +01:00
|
|
|
Index: e2fsprogs-1.40.4/lib/et/error_message.c
|
2007-03-30 16:29:23 +02:00
|
|
|
===================================================================
|
2008-01-17 22:46:25 +01:00
|
|
|
--- e2fsprogs-1.40.4.orig/lib/et/error_message.c
|
|
|
|
+++ e2fsprogs-1.40.4/lib/et/error_message.c
|
2006-12-19 00:15:45 +01:00
|
|
|
@@ -20,6 +20,7 @@
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
+#include <pthread.h>
|
2007-03-30 16:29:23 +02:00
|
|
|
#ifdef HAVE_SYS_PRCTL_H
|
|
|
|
#include <sys/prctl.h>
|
|
|
|
#else
|
2008-01-17 22:46:25 +01:00
|
|
|
@@ -41,6 +42,17 @@
|
2006-12-19 00:15:45 +01:00
|
|
|
struct et_list * _et_list = (struct et_list *) NULL;
|
|
|
|
struct et_list * _et_dynamic_list = (struct et_list *) NULL;
|
|
|
|
|
|
|
|
+static pthread_mutex_t _et_lock = PTHREAD_MUTEX_INITIALIZER;
|
|
|
|
+
|
|
|
|
+int et_list_lock()
|
|
|
|
+{
|
|
|
|
+ return pthread_mutex_lock(&_et_lock);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+int et_list_unlock()
|
|
|
|
+{
|
|
|
|
+ return pthread_mutex_unlock(&_et_lock);
|
|
|
|
+}
|
|
|
|
|
|
|
|
const char * error_message (errcode_t code)
|
|
|
|
{
|
2008-01-17 22:46:25 +01:00
|
|
|
@@ -66,22 +78,32 @@ const char * error_message (errcode_t co
|
2006-12-19 00:15:45 +01:00
|
|
|
goto oops;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
+ et_list_lock();
|
|
|
|
for (et = _et_list; et; et = et->next) {
|
2008-01-17 22:46:25 +01:00
|
|
|
if ((et->table->base & 0xffffffL) == (table_num & 0xffffffL)) {
|
2006-12-19 00:15:45 +01:00
|
|
|
/* This is the right table */
|
|
|
|
- if (et->table->n_msgs <= offset)
|
|
|
|
- goto oops;
|
|
|
|
- return(et->table->msgs[offset]);
|
|
|
|
+ if (et->table->n_msgs <= offset) {
|
|
|
|
+ break;
|
|
|
|
+ } else {
|
|
|
|
+ const char *msg = et->table->msgs[offset];
|
|
|
|
+ et_list_unlock();
|
|
|
|
+ return(msg);
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (et = _et_dynamic_list; et; et = et->next) {
|
2008-01-17 22:46:25 +01:00
|
|
|
if ((et->table->base & 0xffffffL) == (table_num & 0xffffffL)) {
|
2006-12-19 00:15:45 +01:00
|
|
|
/* This is the right table */
|
|
|
|
- if (et->table->n_msgs <= offset)
|
|
|
|
- goto oops;
|
|
|
|
- return(et->table->msgs[offset]);
|
|
|
|
+ if (et->table->n_msgs <= offset) {
|
|
|
|
+ break;
|
|
|
|
+ } else {
|
|
|
|
+ const char *msg = et->table->msgs[offset];
|
|
|
|
+ et_list_unlock();
|
|
|
|
+ return(msg);
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+ et_list_unlock();
|
|
|
|
oops:
|
|
|
|
return "Unknown code";
|
|
|
|
}
|
2008-01-17 22:46:25 +01:00
|
|
|
@@ -150,6 +172,9 @@ errcode_t add_error_table(const struct e
|
2006-12-19 00:15:45 +01:00
|
|
|
if (!(el = (struct et_list *) malloc(sizeof(struct et_list))))
|
|
|
|
return ENOMEM;
|
|
|
|
|
|
|
|
+ if( 0 != et_list_lock())
|
|
|
|
+ return errno;
|
|
|
|
+
|
|
|
|
el->table = et;
|
|
|
|
el->next = _et_dynamic_list;
|
|
|
|
_et_dynamic_list = el;
|
2008-01-17 22:46:25 +01:00
|
|
|
@@ -160,6 +185,7 @@ errcode_t add_error_table(const struct e
|
2007-03-30 16:29:23 +02:00
|
|
|
error_table_name(et->base),
|
|
|
|
(const void *) et);
|
2006-12-19 00:15:45 +01:00
|
|
|
|
|
|
|
+ et_list_unlock();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-01-17 22:46:25 +01:00
|
|
|
@@ -168,9 +194,13 @@ errcode_t add_error_table(const struct e
|
2006-12-19 00:15:45 +01:00
|
|
|
*/
|
|
|
|
errcode_t remove_error_table(const struct error_table * et)
|
|
|
|
{
|
|
|
|
- struct et_list *el = _et_dynamic_list;
|
|
|
|
+ struct et_list *el;
|
|
|
|
struct et_list *el2 = 0;
|
|
|
|
|
|
|
|
+ if( 0 != et_list_lock())
|
|
|
|
+ return ENOENT;
|
|
|
|
+
|
|
|
|
+ el = _et_dynamic_list;
|
2007-03-30 16:29:23 +02:00
|
|
|
init_debug();
|
2006-12-19 00:15:45 +01:00
|
|
|
while (el) {
|
|
|
|
if (el->table->base == et->base) {
|
2008-01-17 22:46:25 +01:00
|
|
|
@@ -184,6 +214,7 @@ errcode_t remove_error_table(const struc
|
2007-03-30 16:29:23 +02:00
|
|
|
"remove_error_table: %s (0x%p)\n",
|
|
|
|
error_table_name(et->base),
|
|
|
|
(const void *) et);
|
2006-12-19 00:15:45 +01:00
|
|
|
+ et_list_unlock();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
el2 = el;
|
2008-01-17 22:46:25 +01:00
|
|
|
@@ -193,6 +224,7 @@ errcode_t remove_error_table(const struc
|
2007-03-30 16:29:23 +02:00
|
|
|
fprintf(debug_f, "remove_error_table FAILED: %s (0x%p)\n",
|
|
|
|
error_table_name(et->base),
|
|
|
|
(const void *) et);
|
2006-12-19 00:15:45 +01:00
|
|
|
+ et_list_unlock();
|
|
|
|
return ENOENT;
|
|
|
|
}
|
|
|
|
|
2008-01-17 22:46:25 +01:00
|
|
|
Index: e2fsprogs-1.40.4/lib/et/error_table.h
|
2007-03-30 16:29:23 +02:00
|
|
|
===================================================================
|
2008-01-17 22:46:25 +01:00
|
|
|
--- e2fsprogs-1.40.4.orig/lib/et/error_table.h
|
|
|
|
+++ e2fsprogs-1.40.4/lib/et/error_table.h
|
2007-03-30 16:29:23 +02:00
|
|
|
@@ -19,6 +19,8 @@ struct et_list {
|
2006-12-19 00:15:45 +01:00
|
|
|
const struct error_table *table;
|
|
|
|
};
|
|
|
|
extern struct et_list * _et_list;
|
|
|
|
+extern int et_list_lock(void);
|
|
|
|
+extern int et_list_unlock(void);
|
|
|
|
|
|
|
|
#define ERRCODE_RANGE 8 /* # of bits to shift table number */
|
|
|
|
#define BITS_PER_CHAR 6 /* # bits to shift per character in name */
|
2008-01-17 22:46:25 +01:00
|
|
|
Index: e2fsprogs-1.40.4/lib/et/et_c.awk
|
2007-03-30 16:29:23 +02:00
|
|
|
===================================================================
|
2008-01-17 22:46:25 +01:00
|
|
|
--- e2fsprogs-1.40.4.orig/lib/et/et_c.awk
|
|
|
|
+++ e2fsprogs-1.40.4/lib/et/et_c.awk
|
2007-03-30 16:29:23 +02:00
|
|
|
@@ -225,6 +225,8 @@ END {
|
2006-12-19 00:15:45 +01:00
|
|
|
print " const struct error_table * table;" > outfile
|
|
|
|
print "};" > outfile
|
|
|
|
print "extern struct et_list *_et_list;" > outfile
|
|
|
|
+ print "extern int et_list_lock();" > outfile
|
|
|
|
+ print "extern int et_list_unlock();" > outfile
|
|
|
|
print "" > outfile
|
|
|
|
if (tab_base_high == 0) {
|
|
|
|
print "const struct error_table et_" table_name "_error_table = { text, " \
|
2007-03-30 16:29:23 +02:00
|
|
|
@@ -242,7 +244,22 @@ END {
|
2006-12-19 00:15:45 +01:00
|
|
|
print "void initialize_" table_name "_error_table(void);" > outfile
|
|
|
|
print "" > outfile
|
|
|
|
print "void initialize_" table_name "_error_table(void) {" > outfile
|
|
|
|
- print " initialize_" table_name "_error_table_r(&_et_list);" > outfile
|
|
|
|
+ print " if(0 == et_list_lock()) {" > outfile
|
|
|
|
+ print " if ( !link.table) {" > outfile
|
|
|
|
+ print " struct et_list *el = _et_list;" > outfile
|
|
|
|
+ print " while (el) {" > outfile
|
|
|
|
+ print " if (el->table->base == et_" table_name "_error_table.base) {" > outfile
|
|
|
|
+ print " et_list_unlock();" > outfile
|
|
|
|
+ print " return;" > outfile
|
|
|
|
+ print " }" > outfile
|
|
|
|
+ print " el = el->next;" > outfile
|
|
|
|
+ print " }" > outfile
|
|
|
|
+ print " link.next = _et_list;" > outfile
|
|
|
|
+ print " link.table = &et_" table_name "_error_table;" > outfile
|
|
|
|
+ print " _et_list = &link;" > outfile
|
|
|
|
+ print " }" > outfile
|
|
|
|
+ print " et_list_unlock();" > outfile
|
|
|
|
+ print " }" > outfile
|
|
|
|
print "}" > outfile
|
|
|
|
print "" > outfile
|
|
|
|
print "/* For Heimdal compatibility */" > outfile
|
2007-03-30 16:29:23 +02:00
|
|
|
@@ -255,9 +272,6 @@ END {
|
2006-12-19 00:15:45 +01:00
|
|
|
print " return;" > outfile
|
|
|
|
print " et = malloc(sizeof(struct et_list));" > outfile
|
|
|
|
print " if (et == 0) {" > outfile
|
|
|
|
- print " if (!link.table)" > outfile
|
|
|
|
- print " et = &link;" > outfile
|
|
|
|
- print " else" > outfile
|
|
|
|
print " return;" > outfile
|
|
|
|
print " }" > outfile
|
|
|
|
print " et->table = &et_" table_name "_error_table;" > outfile
|