|
Line
Link Here
|
|
-- e2fsprogs-1.38/lib/et/com_err.pc.in |
|
|
|
Lines 7-11
Name: com_err
Link Here
|
| 7 |
Description: Common error description library |
7 |
Description: Common error description library |
| 8 |
Version: @E2FSPROGS_VERSION@ |
8 |
Version: @E2FSPROGS_VERSION@ |
| 9 |
Requires: |
9 |
Requires: |
| 10 |
Cflags: -I${includedir} |
10 |
Cflags: -I${includedir} -pthread |
| 11 |
Libs: -L${libdir} -lcom_err |
11 |
Libs: -L${libdir} -lcom_err -pthread |
| 12 |
-- e2fsprogs-1.38/lib/et/error_message.c |
|
|
|
Lines 20-25
Link Here
|
| 20 |
#include <stdlib.h> |
20 |
#include <stdlib.h> |
| 21 |
#include <string.h> |
21 |
#include <string.h> |
| 22 |
#include <errno.h> |
22 |
#include <errno.h> |
|
|
23 |
#include <pthread.h> |
| 23 |
#include "com_err.h" |
24 |
#include "com_err.h" |
| 24 |
#include "error_table.h" |
25 |
#include "error_table.h" |
| 25 |
#include "internal.h" |
26 |
#include "internal.h" |
|
Lines 27-32
Link Here
|
| 27 |
struct et_list * _et_list = (struct et_list *) NULL; |
28 |
struct et_list * _et_list = (struct et_list *) NULL; |
| 28 |
struct et_list * _et_dynamic_list = (struct et_list *) NULL; |
29 |
struct et_list * _et_dynamic_list = (struct et_list *) NULL; |
| 29 |
|
30 |
|
|
|
31 |
static pthread_mutex_t _et_lock = PTHREAD_MUTEX_INITIALIZER; |
| 32 |
|
| 33 |
int et_list_lock() |
| 34 |
{ |
| 35 |
return pthread_mutex_lock(&_et_lock); |
| 36 |
} |
| 37 |
|
| 38 |
int et_list_unlock() |
| 39 |
{ |
| 40 |
return pthread_mutex_unlock(&_et_lock); |
| 41 |
} |
| 30 |
|
42 |
|
| 31 |
const char * error_message (errcode_t code) |
43 |
const char * error_message (errcode_t code) |
| 32 |
{ |
44 |
{ |
|
Lines 52-73
const char * error_message (errcode_t co
Link Here
|
| 52 |
goto oops; |
64 |
goto oops; |
| 53 |
#endif |
65 |
#endif |
| 54 |
} |
66 |
} |
|
|
67 |
et_list_lock(); |
| 55 |
for (et = _et_list; et; et = et->next) { |
68 |
for (et = _et_list; et; et = et->next) { |
| 56 |
if (et->table->base == table_num) { |
69 |
if (et->table->base == table_num) { |
| 57 |
/* This is the right table */ |
70 |
/* This is the right table */ |
| 58 |
if (et->table->n_msgs <= offset) |
71 |
if (et->table->n_msgs <= offset) { |
| 59 |
goto oops; |
72 |
break; |
| 60 |
return(et->table->msgs[offset]); |
73 |
} else { |
|
|
74 |
const char *msg = et->table->msgs[offset]; |
| 75 |
et_list_unlock(); |
| 76 |
return(msg); |
| 77 |
} |
| 61 |
} |
78 |
} |
| 62 |
} |
79 |
} |
| 63 |
for (et = _et_dynamic_list; et; et = et->next) { |
80 |
for (et = _et_dynamic_list; et; et = et->next) { |
| 64 |
if (et->table->base == table_num) { |
81 |
if (et->table->base == table_num) { |
| 65 |
/* This is the right table */ |
82 |
/* This is the right table */ |
| 66 |
if (et->table->n_msgs <= offset) |
83 |
if (et->table->n_msgs <= offset) { |
| 67 |
goto oops; |
84 |
break; |
| 68 |
return(et->table->msgs[offset]); |
85 |
} else { |
|
|
86 |
const char *msg = et->table->msgs[offset]; |
| 87 |
et_list_unlock(); |
| 88 |
return(msg); |
| 89 |
} |
| 69 |
} |
90 |
} |
| 70 |
} |
91 |
} |
|
|
92 |
et_list_unlock(); |
| 71 |
oops: |
93 |
oops: |
| 72 |
return "Unknown code"; |
94 |
return "Unknown code"; |
| 73 |
} |
95 |
} |
|
Lines 82-91
errcode_t add_error_table(const struct e
Link Here
|
| 82 |
if (!(el = (struct et_list *) malloc(sizeof(struct et_list)))) |
104 |
if (!(el = (struct et_list *) malloc(sizeof(struct et_list)))) |
| 83 |
return ENOMEM; |
105 |
return ENOMEM; |
| 84 |
|
106 |
|
|
|
107 |
if( 0 != et_list_lock()) |
| 108 |
return errno; |
| 109 |
|
| 85 |
el->table = et; |
110 |
el->table = et; |
| 86 |
el->next = _et_dynamic_list; |
111 |
el->next = _et_dynamic_list; |
| 87 |
_et_dynamic_list = el; |
112 |
_et_dynamic_list = el; |
| 88 |
|
113 |
|
|
|
114 |
et_list_unlock(); |
| 89 |
return 0; |
115 |
return 0; |
| 90 |
} |
116 |
} |
| 91 |
|
117 |
|
|
Lines 94-102
errcode_t add_error_table(const struct e
Link Here
|
| 94 |
*/ |
120 |
*/ |
| 95 |
errcode_t remove_error_table(const struct error_table * et) |
121 |
errcode_t remove_error_table(const struct error_table * et) |
| 96 |
{ |
122 |
{ |
| 97 |
struct et_list *el = _et_dynamic_list; |
123 |
struct et_list *el; |
| 98 |
struct et_list *el2 = 0; |
124 |
struct et_list *el2 = 0; |
| 99 |
|
125 |
|
|
|
126 |
if( 0 != et_list_lock()) |
| 127 |
return ENOENT; |
| 128 |
|
| 129 |
el = _et_dynamic_list; |
| 100 |
while (el) { |
130 |
while (el) { |
| 101 |
if (el->table->base == et->base) { |
131 |
if (el->table->base == et->base) { |
| 102 |
if (el2) /* Not the beginning of the list */ |
132 |
if (el2) /* Not the beginning of the list */ |
|
Lines 104-114
errcode_t remove_error_table(const struc
Link Here
|
| 104 |
else |
134 |
else |
| 105 |
_et_dynamic_list = el->next; |
135 |
_et_dynamic_list = el->next; |
| 106 |
(void) free(el); |
136 |
(void) free(el); |
|
|
137 |
et_list_unlock(); |
| 107 |
return 0; |
138 |
return 0; |
| 108 |
} |
139 |
} |
| 109 |
el2 = el; |
140 |
el2 = el; |
| 110 |
el = el->next; |
141 |
el = el->next; |
| 111 |
} |
142 |
} |
|
|
143 |
et_list_unlock(); |
| 112 |
return ENOENT; |
144 |
return ENOENT; |
| 113 |
} |
145 |
} |
| 114 |
|
146 |
|
| 115 |
-- e2fsprogs-1.38/lib/et/error_table.h |
|
|
|
Lines 19-24
struct et_list {
Link Here
|
| 19 |
const struct error_table *table; |
19 |
const struct error_table *table; |
| 20 |
}; |
20 |
}; |
| 21 |
extern struct et_list * _et_list; |
21 |
extern struct et_list * _et_list; |
|
|
22 |
extern int et_list_lock(void); |
| 23 |
extern int et_list_unlock(void); |
| 22 |
|
24 |
|
| 23 |
#define ERRCODE_RANGE 8 /* # of bits to shift table number */ |
25 |
#define ERRCODE_RANGE 8 /* # of bits to shift table number */ |
| 24 |
#define BITS_PER_CHAR 6 /* # bits to shift per character in name */ |
26 |
#define BITS_PER_CHAR 6 /* # bits to shift per character in name */ |
| 25 |
-- e2fsprogs-1.38/lib/et/et_c.awk |
|
|
|
Lines 224-229
END {
Link Here
|
| 224 |
print " const struct error_table * table;" > outfile |
224 |
print " const struct error_table * table;" > outfile |
| 225 |
print "};" > outfile |
225 |
print "};" > outfile |
| 226 |
print "extern struct et_list *_et_list;" > outfile |
226 |
print "extern struct et_list *_et_list;" > outfile |
|
|
227 |
print "extern int et_list_lock();" > outfile |
| 228 |
print "extern int et_list_unlock();" > outfile |
| 227 |
print "" > outfile |
229 |
print "" > outfile |
| 228 |
if (tab_base_high == 0) { |
230 |
if (tab_base_high == 0) { |
| 229 |
print "const struct error_table et_" table_name "_error_table = { text, " \ |
231 |
print "const struct error_table et_" table_name "_error_table = { text, " \ |
|
Lines 241-247
END {
Link Here
|
| 241 |
print "void initialize_" table_name "_error_table(void);" > outfile |
243 |
print "void initialize_" table_name "_error_table(void);" > outfile |
| 242 |
print "" > outfile |
244 |
print "" > outfile |
| 243 |
print "void initialize_" table_name "_error_table(void) {" > outfile |
245 |
print "void initialize_" table_name "_error_table(void) {" > outfile |
| 244 |
print " initialize_" table_name "_error_table_r(&_et_list);" > outfile |
246 |
print " et_list_lock();" > outfile |
|
|
247 |
print " if ( !link.table) {" > outfile |
| 248 |
print " struct et_list *el = _et_list;" > outfile |
| 249 |
print " while (el) {" > outfile |
| 250 |
print " if (el->table->base == et_" table_name "_error_table.base) {" > outfile |
| 251 |
print " et_list_unlock();" > outfile |
| 252 |
print " return;" > outfile |
| 253 |
print " }" > outfile |
| 254 |
print " el = el->next;" > outfile |
| 255 |
print " }" > outfile |
| 256 |
print " link.next = _et_list;" > outfile |
| 257 |
print " link.table = &et_" table_name "_error_table;" > outfile |
| 258 |
print " _et_list = &link;" > outfile |
| 259 |
print " }" > outfile |
| 260 |
print " et_list_unlock();" > outfile |
| 245 |
print "}" > outfile |
261 |
print "}" > outfile |
| 246 |
print "" > outfile |
262 |
print "" > outfile |
| 247 |
print "/* For Heimdal compatibility */" > outfile |
263 |
print "/* For Heimdal compatibility */" > outfile |
|
Lines 254-262
END {
Link Here
|
| 254 |
print " return;" > outfile |
270 |
print " return;" > outfile |
| 255 |
print " et = malloc(sizeof(struct et_list));" > outfile |
271 |
print " et = malloc(sizeof(struct et_list));" > outfile |
| 256 |
print " if (et == 0) {" > outfile |
272 |
print " if (et == 0) {" > outfile |
| 257 |
print " if (!link.table)" > outfile |
|
|
| 258 |
print " et = &link;" > outfile |
| 259 |
print " else" > outfile |
| 260 |
print " return;" > outfile |
273 |
print " return;" > outfile |
| 261 |
print " }" > outfile |
274 |
print " }" > outfile |
| 262 |
print " et->table = &et_" table_name "_error_table;" > outfile |
275 |
print " et->table = &et_" table_name "_error_table;" > outfile |