191 lines
6.3 KiB
Diff
191 lines
6.3 KiB
Diff
Index: e2fsprogs-1.39+1.40_WIP_20061114+PATCH20070329/lib/et/com_err.pc.in
|
|
===================================================================
|
|
--- e2fsprogs-1.39+1.40_WIP_20061114+PATCH20070329.orig/lib/et/com_err.pc.in
|
|
+++ e2fsprogs-1.39+1.40_WIP_20061114+PATCH20070329/lib/et/com_err.pc.in
|
|
@@ -7,5 +7,5 @@ Name: com_err
|
|
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
|
|
Index: e2fsprogs-1.39+1.40_WIP_20061114+PATCH20070329/lib/et/error_message.c
|
|
===================================================================
|
|
--- e2fsprogs-1.39+1.40_WIP_20061114+PATCH20070329.orig/lib/et/error_message.c
|
|
+++ e2fsprogs-1.39+1.40_WIP_20061114+PATCH20070329/lib/et/error_message.c
|
|
@@ -20,6 +20,7 @@
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <errno.h>
|
|
+#include <pthread.h>
|
|
#ifdef HAVE_SYS_PRCTL_H
|
|
#include <sys/prctl.h>
|
|
#else
|
|
@@ -35,6 +36,17 @@
|
|
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)
|
|
{
|
|
@@ -59,22 +71,32 @@ const char * error_message (errcode_t co
|
|
goto oops;
|
|
#endif
|
|
}
|
|
+ et_list_lock();
|
|
for (et = _et_list; et; et = et->next) {
|
|
if (et->table->base == table_num) {
|
|
/* 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) {
|
|
if (et->table->base == table_num) {
|
|
/* 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";
|
|
}
|
|
@@ -143,6 +165,9 @@ errcode_t add_error_table(const struct e
|
|
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;
|
|
@@ -153,6 +178,7 @@ errcode_t add_error_table(const struct e
|
|
error_table_name(et->base),
|
|
(const void *) et);
|
|
|
|
+ et_list_unlock();
|
|
return 0;
|
|
}
|
|
|
|
@@ -161,9 +187,13 @@ errcode_t add_error_table(const struct e
|
|
*/
|
|
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;
|
|
init_debug();
|
|
while (el) {
|
|
if (el->table->base == et->base) {
|
|
@@ -177,6 +207,7 @@ errcode_t remove_error_table(const struc
|
|
"remove_error_table: %s (0x%p)\n",
|
|
error_table_name(et->base),
|
|
(const void *) et);
|
|
+ et_list_unlock();
|
|
return 0;
|
|
}
|
|
el2 = el;
|
|
@@ -186,6 +217,7 @@ errcode_t remove_error_table(const struc
|
|
fprintf(debug_f, "remove_error_table FAILED: %s (0x%p)\n",
|
|
error_table_name(et->base),
|
|
(const void *) et);
|
|
+ et_list_unlock();
|
|
return ENOENT;
|
|
}
|
|
|
|
Index: e2fsprogs-1.39+1.40_WIP_20061114+PATCH20070329/lib/et/error_table.h
|
|
===================================================================
|
|
--- e2fsprogs-1.39+1.40_WIP_20061114+PATCH20070329.orig/lib/et/error_table.h
|
|
+++ e2fsprogs-1.39+1.40_WIP_20061114+PATCH20070329/lib/et/error_table.h
|
|
@@ -19,6 +19,8 @@ struct et_list {
|
|
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 */
|
|
Index: e2fsprogs-1.39+1.40_WIP_20061114+PATCH20070329/lib/et/et_c.awk
|
|
===================================================================
|
|
--- e2fsprogs-1.39+1.40_WIP_20061114+PATCH20070329.orig/lib/et/et_c.awk
|
|
+++ e2fsprogs-1.39+1.40_WIP_20061114+PATCH20070329/lib/et/et_c.awk
|
|
@@ -225,6 +225,8 @@ END {
|
|
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, " \
|
|
@@ -242,7 +244,22 @@ END {
|
|
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
|
|
@@ -255,9 +272,6 @@ END {
|
|
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
|