|
Line
Link Here
|
|
-- e2fsprogs-1.36/lib/et/com_err.pc.in |
|
|
|
Lines 7-11
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.36/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 28-33
Link Here
|
| 28 |
|
29 |
|
| 29 |
struct et_list * _et_list = (struct et_list *) NULL; |
30 |
struct et_list * _et_list = (struct et_list *) NULL; |
| 30 |
|
31 |
|
|
|
32 |
struct et_denv { |
| 33 |
struct et_denv *next; |
| 34 |
struct et_list et_list; |
| 35 |
}; |
| 36 |
static struct et_denv * _et_denv = NULL; |
| 37 |
|
| 38 |
static pthread_mutex_t _et_lock = PTHREAD_MUTEX_INITIALIZER; |
| 39 |
|
| 40 |
int et_list_lock() |
| 41 |
{ |
| 42 |
return pthread_mutex_lock(&_et_lock); |
| 43 |
} |
| 44 |
|
| 45 |
int et_list_unlock() |
| 46 |
{ |
| 47 |
return pthread_mutex_unlock(&_et_lock); |
| 48 |
} |
| 31 |
|
49 |
|
| 32 |
const char * error_message (errcode_t code) |
50 |
const char * error_message (errcode_t code) |
| 33 |
{ |
51 |
{ |
|
Lines 53-66
Link Here
|
| 53 |
goto oops; |
71 |
goto oops; |
| 54 |
#endif |
72 |
#endif |
| 55 |
} |
73 |
} |
|
|
74 |
et_list_lock(); |
| 56 |
for (et = _et_list; et; et = et->next) { |
75 |
for (et = _et_list; et; et = et->next) { |
| 57 |
if (et->table->base == table_num) { |
76 |
if (et->table->base == table_num) { |
| 58 |
/* This is the right table */ |
77 |
/* This is the right table */ |
| 59 |
if (et->table->n_msgs <= offset) |
78 |
if (et->table->n_msgs <= offset) { |
| 60 |
goto oops; |
79 |
break; |
| 61 |
return(et->table->msgs[offset]); |
80 |
} else { |
|
|
81 |
const char *msg = et->table->msgs[offset]; |
| 82 |
et_list_unlock(); |
| 83 |
return(msg); |
| 84 |
} |
| 62 |
} |
85 |
} |
| 63 |
} |
86 |
} |
|
|
87 |
et_list_unlock(); |
| 64 |
oops: |
88 |
oops: |
| 65 |
strcpy (buffer, "Unknown code "); |
89 |
strcpy (buffer, "Unknown code "); |
| 66 |
if (table_num) { |
90 |
if (table_num) { |
|
Lines 88-109
Link Here
|
| 88 |
*/ |
112 |
*/ |
| 89 |
errcode_t add_error_table(const struct error_table * et) |
113 |
errcode_t add_error_table(const struct error_table * et) |
| 90 |
{ |
114 |
{ |
|
|
115 |
if( 0 == et_list_lock()) { |
| 91 |
struct et_list *el = _et_list; |
116 |
struct et_list *el = _et_list; |
|
|
117 |
struct et_denv *ev; |
| 92 |
|
118 |
|
| 93 |
while (el) { |
119 |
while (el) { |
| 94 |
if (el->table->base == et->base) |
120 |
if (el->table->base == et->base) { |
|
|
121 |
et_list_unlock(); |
| 95 |
return EEXIST; |
122 |
return EEXIST; |
|
|
123 |
} |
| 96 |
el = el->next; |
124 |
el = el->next; |
| 97 |
} |
125 |
} |
| 98 |
|
126 |
|
| 99 |
if (!(el = (struct et_list *) malloc(sizeof(struct et_list)))) |
127 |
if (!(ev = (struct et_denv *) malloc(sizeof(struct et_denv)))) { |
|
|
128 |
et_list_unlock(); |
| 100 |
return ENOMEM; |
129 |
return ENOMEM; |
| 101 |
|
130 |
} |
|
|
131 |
ev->next = _et_denv; |
| 132 |
_et_denv = ev; |
| 133 |
el = &ev->et_list; |
| 102 |
el->table = et; |
134 |
el->table = et; |
| 103 |
el->next = _et_list; |
135 |
el->next = _et_list; |
| 104 |
_et_list = el; |
136 |
_et_list = el; |
|
|
137 |
et_list_unlock(); |
| 138 |
} |
| 139 |
return 0; |
| 140 |
} |
| 141 |
|
| 142 |
void |
| 143 |
free_denv_nolock(struct et_list *el) |
| 144 |
{ |
| 145 |
struct et_denv *prev = NULL; |
| 146 |
struct et_denv *curr = _et_denv; |
| 105 |
|
147 |
|
| 106 |
return 0; |
148 |
while( curr) { |
|
|
149 |
if( &curr->et_list == el) { |
| 150 |
if( prev) { |
| 151 |
prev->next = curr->next; |
| 152 |
} else { |
| 153 |
_et_denv = curr->next; |
| 154 |
} |
| 155 |
free(curr); |
| 156 |
return; |
| 157 |
} |
| 158 |
prev = curr; |
| 159 |
curr = curr->next; |
| 160 |
} |
| 107 |
} |
161 |
} |
| 108 |
|
162 |
|
| 109 |
/* |
163 |
/* |
|
Lines 111-116
Link Here
|
| 111 |
*/ |
165 |
*/ |
| 112 |
errcode_t remove_error_table(const struct error_table * et) |
166 |
errcode_t remove_error_table(const struct error_table * et) |
| 113 |
{ |
167 |
{ |
|
|
168 |
if( 0 == et_list_lock()) { |
| 114 |
struct et_list *el = _et_list; |
169 |
struct et_list *el = _et_list; |
| 115 |
struct et_list *el2 = 0; |
170 |
struct et_list *el2 = 0; |
| 116 |
|
171 |
|
|
Lines 120-132
Link Here
|
| 120 |
el2->next = el->next; |
175 |
el2->next = el->next; |
| 121 |
else |
176 |
else |
| 122 |
_et_list = el->next; |
177 |
_et_list = el->next; |
| 123 |
(void) free(el); |
178 |
free_denv_nolock(el); |
|
|
179 |
et_list_unlock(); |
| 124 |
return 0; |
180 |
return 0; |
| 125 |
} |
181 |
} |
| 126 |
el2 = el; |
182 |
el2 = el; |
| 127 |
el = el->next; |
183 |
el = el->next; |
| 128 |
} |
184 |
} |
| 129 |
return ENOENT; |
185 |
et_list_unlock(); |
|
|
186 |
} |
| 187 |
return ENOENT; |
| 130 |
} |
188 |
} |
| 131 |
|
189 |
|
| 132 |
/* |
190 |
/* |
|
Lines 137-139
Link Here
|
| 137 |
{ |
195 |
{ |
| 138 |
add_error_table(new_table->table); |
196 |
add_error_table(new_table->table); |
| 139 |
} |
197 |
} |
| 140 |
-- e2fsprogs-1.36/lib/et/error_table.h |
198 |
|
|
Lines 19-24
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.36/lib/et/et_c.awk |
|
|
|
Lines 221-226
Link Here
|
| 221 |
print " const struct error_table * table;" > outfile |
221 |
print " const struct error_table * table;" > outfile |
| 222 |
print "};" > outfile |
222 |
print "};" > outfile |
| 223 |
print "extern struct et_list *_et_list;" > outfile |
223 |
print "extern struct et_list *_et_list;" > outfile |
|
|
224 |
print "extern int et_list_lock();" > outfile |
| 225 |
print "extern int et_list_unlock();" > outfile |
| 224 |
print "" > outfile |
226 |
print "" > outfile |
| 225 |
if (tab_base_high == 0) { |
227 |
if (tab_base_high == 0) { |
| 226 |
print "const struct error_table et_" table_name "_error_table = { text, " \ |
228 |
print "const struct error_table et_" table_name "_error_table = { text, " \ |
|
Lines 237-247
Link Here
|
| 237 |
print "void initialize_" table_name "_error_table(void);" > outfile |
239 |
print "void initialize_" table_name "_error_table(void);" > outfile |
| 238 |
print "" > outfile |
240 |
print "" > outfile |
| 239 |
print "void initialize_" table_name "_error_table(void) {" > outfile |
241 |
print "void initialize_" table_name "_error_table(void) {" > outfile |
| 240 |
print " if (!link.table) {" > outfile |
242 |
print " et_list_lock();" > outfile |
|
|
243 |
print " if ( !link.table) {" > outfile |
| 244 |
print " struct et_list *el = _et_list;" > outfile |
| 245 |
print " while (el) {" > outfile |
| 246 |
print " if (el->table->base == et_" table_name "_error_table.base) {" > outfile |
| 247 |
print " et_list_unlock();" > outfile |
| 248 |
print " return;" > outfile |
| 249 |
print " }" > outfile |
| 250 |
print " el = el->next;" > outfile |
| 251 |
print " }" > outfile |
| 241 |
print " link.next = _et_list;" > outfile |
252 |
print " link.next = _et_list;" > outfile |
| 242 |
print " link.table = &et_" table_name "_error_table;" > outfile |
253 |
print " link.table = &et_" table_name "_error_table;" > outfile |
| 243 |
print " _et_list = &link;" > outfile |
254 |
print " _et_list = &link;" > outfile |
| 244 |
print " }" > outfile |
255 |
print " }" > outfile |
|
|
256 |
print " et_list_unlock();" > outfile |
| 245 |
print "}" > outfile |
257 |
print "}" > outfile |
| 246 |
print "" > outfile |
258 |
print "" > outfile |
| 247 |
print "/* For Heimdal compatibility */" > outfile |
259 |
print "/* For Heimdal compatibility */" > outfile |