[NETFILTER]: conntrack: fix {nf,ip}_ct_iterate_cleanup endless loops
[linux-2.6/sactl.git] / scripts / mod / file2alias.c
blobb2f73ffb40bde5e790c2a93fb68b9d215bbcf86a
1 /* Simple code to turn various tables in an ELF file into alias definitions.
2 * This deals with kernel datastructures where they should be
3 * dealt with: in the kernel source.
5 * Copyright 2002-2003 Rusty Russell, IBM Corporation
6 * 2003 Kai Germaschewski
9 * This software may be used and distributed according to the terms
10 * of the GNU General Public License, incorporated herein by reference.
13 #include "modpost.h"
15 /* We use the ELF typedefs for kernel_ulong_t but bite the bullet and
16 * use either stdint.h or inttypes.h for the rest. */
17 #if KERNEL_ELFCLASS == ELFCLASS32
18 typedef Elf32_Addr kernel_ulong_t;
19 #define BITS_PER_LONG 32
20 #else
21 typedef Elf64_Addr kernel_ulong_t;
22 #define BITS_PER_LONG 64
23 #endif
24 #ifdef __sun__
25 #include <inttypes.h>
26 #else
27 #include <stdint.h>
28 #endif
30 #include <ctype.h>
32 typedef uint32_t __u32;
33 typedef uint16_t __u16;
34 typedef unsigned char __u8;
36 /* Big exception to the "don't include kernel headers into userspace, which
37 * even potentially has different endianness and word sizes, since
38 * we handle those differences explicitly below */
39 #include "../../include/linux/mod_devicetable.h"
40 #include "../../include/linux/input.h"
42 #define ADD(str, sep, cond, field) \
43 do { \
44 strcat(str, sep); \
45 if (cond) \
46 sprintf(str + strlen(str), \
47 sizeof(field) == 1 ? "%02X" : \
48 sizeof(field) == 2 ? "%04X" : \
49 sizeof(field) == 4 ? "%08X" : "", \
50 field); \
51 else \
52 sprintf(str + strlen(str), "*"); \
53 } while(0)
55 /**
56 * Check that sizeof(device_id type) are consistent with size of section
57 * in .o file. If in-consistent then userspace and kernel does not agree
58 * on actual size which is a bug.
59 **/
60 static void device_id_size_check(const char *modname, const char *device_id,
61 unsigned long size, unsigned long id_size)
63 if (size % id_size || size < id_size) {
64 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
65 "of the size of section __mod_%s_device_table=%lu.\n"
66 "Fix definition of struct %s_device_id "
67 "in mod_devicetable.h\n",
68 modname, device_id, id_size, device_id, size, device_id);
72 /* USB is special because the bcdDevice can be matched against a numeric range */
73 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipN" */
74 static void do_usb_entry(struct usb_device_id *id,
75 unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
76 unsigned char range_lo, unsigned char range_hi,
77 struct module *mod)
79 char alias[500];
80 strcpy(alias, "usb:");
81 ADD(alias, "v", id->match_flags&USB_DEVICE_ID_MATCH_VENDOR,
82 id->idVendor);
83 ADD(alias, "p", id->match_flags&USB_DEVICE_ID_MATCH_PRODUCT,
84 id->idProduct);
86 strcat(alias, "d");
87 if (bcdDevice_initial_digits)
88 sprintf(alias + strlen(alias), "%0*X",
89 bcdDevice_initial_digits, bcdDevice_initial);
90 if (range_lo == range_hi)
91 sprintf(alias + strlen(alias), "%u", range_lo);
92 else if (range_lo > 0 || range_hi < 9)
93 sprintf(alias + strlen(alias), "[%u-%u]", range_lo, range_hi);
94 if (bcdDevice_initial_digits < (sizeof(id->bcdDevice_lo) * 2 - 1))
95 strcat(alias, "*");
97 ADD(alias, "dc", id->match_flags&USB_DEVICE_ID_MATCH_DEV_CLASS,
98 id->bDeviceClass);
99 ADD(alias, "dsc",
100 id->match_flags&USB_DEVICE_ID_MATCH_DEV_SUBCLASS,
101 id->bDeviceSubClass);
102 ADD(alias, "dp",
103 id->match_flags&USB_DEVICE_ID_MATCH_DEV_PROTOCOL,
104 id->bDeviceProtocol);
105 ADD(alias, "ic",
106 id->match_flags&USB_DEVICE_ID_MATCH_INT_CLASS,
107 id->bInterfaceClass);
108 ADD(alias, "isc",
109 id->match_flags&USB_DEVICE_ID_MATCH_INT_SUBCLASS,
110 id->bInterfaceSubClass);
111 ADD(alias, "ip",
112 id->match_flags&USB_DEVICE_ID_MATCH_INT_PROTOCOL,
113 id->bInterfaceProtocol);
115 /* Always end in a wildcard, for future extension */
116 if (alias[strlen(alias)-1] != '*')
117 strcat(alias, "*");
118 buf_printf(&mod->dev_table_buf,
119 "MODULE_ALIAS(\"%s\");\n", alias);
122 static void do_usb_entry_multi(struct usb_device_id *id, struct module *mod)
124 unsigned int devlo, devhi;
125 unsigned char chi, clo;
126 int ndigits;
128 id->match_flags = TO_NATIVE(id->match_flags);
129 id->idVendor = TO_NATIVE(id->idVendor);
130 id->idProduct = TO_NATIVE(id->idProduct);
132 devlo = id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO ?
133 TO_NATIVE(id->bcdDevice_lo) : 0x0U;
134 devhi = id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI ?
135 TO_NATIVE(id->bcdDevice_hi) : ~0x0U;
138 * Some modules (visor) have empty slots as placeholder for
139 * run-time specification that results in catch-all alias
141 if (!(id->idVendor | id->bDeviceClass | id->bInterfaceClass))
142 return;
144 /* Convert numeric bcdDevice range into fnmatch-able pattern(s) */
145 for (ndigits = sizeof(id->bcdDevice_lo) * 2 - 1; devlo <= devhi; ndigits--) {
146 clo = devlo & 0xf;
147 chi = devhi & 0xf;
148 if (chi > 9) /* it's bcd not hex */
149 chi = 9;
150 devlo >>= 4;
151 devhi >>= 4;
153 if (devlo == devhi || !ndigits) {
154 do_usb_entry(id, devlo, ndigits, clo, chi, mod);
155 break;
158 if (clo > 0)
159 do_usb_entry(id, devlo++, ndigits, clo, 9, mod);
161 if (chi < 9)
162 do_usb_entry(id, devhi--, ndigits, 0, chi, mod);
166 static void do_usb_table(void *symval, unsigned long size,
167 struct module *mod)
169 unsigned int i;
170 const unsigned long id_size = sizeof(struct usb_device_id);
172 device_id_size_check(mod->name, "usb", size, id_size);
174 /* Leave last one: it's the terminator. */
175 size -= id_size;
177 for (i = 0; i < size; i += id_size)
178 do_usb_entry_multi(symval + i, mod);
181 /* Looks like: ieee1394:venNmoNspNverN */
182 static int do_ieee1394_entry(const char *filename,
183 struct ieee1394_device_id *id, char *alias)
185 id->match_flags = TO_NATIVE(id->match_flags);
186 id->vendor_id = TO_NATIVE(id->vendor_id);
187 id->model_id = TO_NATIVE(id->model_id);
188 id->specifier_id = TO_NATIVE(id->specifier_id);
189 id->version = TO_NATIVE(id->version);
191 strcpy(alias, "ieee1394:");
192 ADD(alias, "ven", id->match_flags & IEEE1394_MATCH_VENDOR_ID,
193 id->vendor_id);
194 ADD(alias, "mo", id->match_flags & IEEE1394_MATCH_MODEL_ID,
195 id->model_id);
196 ADD(alias, "sp", id->match_flags & IEEE1394_MATCH_SPECIFIER_ID,
197 id->specifier_id);
198 ADD(alias, "ver", id->match_flags & IEEE1394_MATCH_VERSION,
199 id->version);
201 return 1;
204 /* Looks like: pci:vNdNsvNsdNbcNscNiN. */
205 static int do_pci_entry(const char *filename,
206 struct pci_device_id *id, char *alias)
208 /* Class field can be divided into these three. */
209 unsigned char baseclass, subclass, interface,
210 baseclass_mask, subclass_mask, interface_mask;
212 id->vendor = TO_NATIVE(id->vendor);
213 id->device = TO_NATIVE(id->device);
214 id->subvendor = TO_NATIVE(id->subvendor);
215 id->subdevice = TO_NATIVE(id->subdevice);
216 id->class = TO_NATIVE(id->class);
217 id->class_mask = TO_NATIVE(id->class_mask);
219 strcpy(alias, "pci:");
220 ADD(alias, "v", id->vendor != PCI_ANY_ID, id->vendor);
221 ADD(alias, "d", id->device != PCI_ANY_ID, id->device);
222 ADD(alias, "sv", id->subvendor != PCI_ANY_ID, id->subvendor);
223 ADD(alias, "sd", id->subdevice != PCI_ANY_ID, id->subdevice);
225 baseclass = (id->class) >> 16;
226 baseclass_mask = (id->class_mask) >> 16;
227 subclass = (id->class) >> 8;
228 subclass_mask = (id->class_mask) >> 8;
229 interface = id->class;
230 interface_mask = id->class_mask;
232 if ((baseclass_mask != 0 && baseclass_mask != 0xFF)
233 || (subclass_mask != 0 && subclass_mask != 0xFF)
234 || (interface_mask != 0 && interface_mask != 0xFF)) {
235 warn("Can't handle masks in %s:%04X\n",
236 filename, id->class_mask);
237 return 0;
240 ADD(alias, "bc", baseclass_mask == 0xFF, baseclass);
241 ADD(alias, "sc", subclass_mask == 0xFF, subclass);
242 ADD(alias, "i", interface_mask == 0xFF, interface);
243 return 1;
246 /* looks like: "ccw:tNmNdtNdmN" */
247 static int do_ccw_entry(const char *filename,
248 struct ccw_device_id *id, char *alias)
250 id->match_flags = TO_NATIVE(id->match_flags);
251 id->cu_type = TO_NATIVE(id->cu_type);
252 id->cu_model = TO_NATIVE(id->cu_model);
253 id->dev_type = TO_NATIVE(id->dev_type);
254 id->dev_model = TO_NATIVE(id->dev_model);
256 strcpy(alias, "ccw:");
257 ADD(alias, "t", id->match_flags&CCW_DEVICE_ID_MATCH_CU_TYPE,
258 id->cu_type);
259 ADD(alias, "m", id->match_flags&CCW_DEVICE_ID_MATCH_CU_MODEL,
260 id->cu_model);
261 ADD(alias, "dt", id->match_flags&CCW_DEVICE_ID_MATCH_DEVICE_TYPE,
262 id->dev_type);
263 ADD(alias, "dm", id->match_flags&CCW_DEVICE_ID_MATCH_DEVICE_MODEL,
264 id->dev_model);
265 return 1;
268 /* looks like: "ap:tN" */
269 static int do_ap_entry(const char *filename,
270 struct ap_device_id *id, char *alias)
272 sprintf(alias, "ap:t%02X", id->dev_type);
273 return 1;
276 /* Looks like: "serio:tyNprNidNexN" */
277 static int do_serio_entry(const char *filename,
278 struct serio_device_id *id, char *alias)
280 id->type = TO_NATIVE(id->type);
281 id->proto = TO_NATIVE(id->proto);
282 id->id = TO_NATIVE(id->id);
283 id->extra = TO_NATIVE(id->extra);
285 strcpy(alias, "serio:");
286 ADD(alias, "ty", id->type != SERIO_ANY, id->type);
287 ADD(alias, "pr", id->proto != SERIO_ANY, id->proto);
288 ADD(alias, "id", id->id != SERIO_ANY, id->id);
289 ADD(alias, "ex", id->extra != SERIO_ANY, id->extra);
291 return 1;
294 /* looks like: "pnp:dD" */
295 static int do_pnp_entry(const char *filename,
296 struct pnp_device_id *id, char *alias)
298 sprintf(alias, "pnp:d%s", id->id);
299 return 1;
302 /* looks like: "pnp:cCdD..." */
303 static int do_pnp_card_entry(const char *filename,
304 struct pnp_card_device_id *id, char *alias)
306 int i;
308 sprintf(alias, "pnp:c%s", id->id);
309 for (i = 0; i < PNP_MAX_DEVICES; i++) {
310 if (! *id->devs[i].id)
311 break;
312 sprintf(alias + strlen(alias), "d%s", id->devs[i].id);
314 return 1;
317 /* Looks like: pcmcia:mNcNfNfnNpfnNvaNvbNvcNvdN. */
318 static int do_pcmcia_entry(const char *filename,
319 struct pcmcia_device_id *id, char *alias)
321 unsigned int i;
323 id->match_flags = TO_NATIVE(id->match_flags);
324 id->manf_id = TO_NATIVE(id->manf_id);
325 id->card_id = TO_NATIVE(id->card_id);
326 id->func_id = TO_NATIVE(id->func_id);
327 id->function = TO_NATIVE(id->function);
328 id->device_no = TO_NATIVE(id->device_no);
330 for (i=0; i<4; i++) {
331 id->prod_id_hash[i] = TO_NATIVE(id->prod_id_hash[i]);
334 strcpy(alias, "pcmcia:");
335 ADD(alias, "m", id->match_flags & PCMCIA_DEV_ID_MATCH_MANF_ID,
336 id->manf_id);
337 ADD(alias, "c", id->match_flags & PCMCIA_DEV_ID_MATCH_CARD_ID,
338 id->card_id);
339 ADD(alias, "f", id->match_flags & PCMCIA_DEV_ID_MATCH_FUNC_ID,
340 id->func_id);
341 ADD(alias, "fn", id->match_flags & PCMCIA_DEV_ID_MATCH_FUNCTION,
342 id->function);
343 ADD(alias, "pfn", id->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO,
344 id->device_no);
345 ADD(alias, "pa", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID1, id->prod_id_hash[0]);
346 ADD(alias, "pb", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID2, id->prod_id_hash[1]);
347 ADD(alias, "pc", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID3, id->prod_id_hash[2]);
348 ADD(alias, "pd", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID4, id->prod_id_hash[3]);
350 return 1;
355 static int do_of_entry (const char *filename, struct of_device_id *of, char *alias)
357 char *tmp;
358 sprintf (alias, "of:N%sT%sC%s",
359 of->name[0] ? of->name : "*",
360 of->type[0] ? of->type : "*",
361 of->compatible[0] ? of->compatible : "*");
363 /* Replace all whitespace with underscores */
364 for (tmp = alias; tmp && *tmp; tmp++)
365 if (isspace (*tmp))
366 *tmp = '_';
368 return 1;
371 static int do_vio_entry(const char *filename, struct vio_device_id *vio,
372 char *alias)
374 char *tmp;
376 sprintf(alias, "vio:T%sS%s", vio->type[0] ? vio->type : "*",
377 vio->compat[0] ? vio->compat : "*");
379 /* Replace all whitespace with underscores */
380 for (tmp = alias; tmp && *tmp; tmp++)
381 if (isspace (*tmp))
382 *tmp = '_';
384 return 1;
387 static int do_i2c_entry(const char *filename, struct i2c_device_id *i2c, char *alias)
389 strcpy(alias, "i2c:");
390 ADD(alias, "id", 1, i2c->id);
391 return 1;
394 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
396 static void do_input(char *alias,
397 kernel_ulong_t *arr, unsigned int min, unsigned int max)
399 unsigned int i;
401 for (i = min; i < max; i++)
402 if (arr[i / BITS_PER_LONG] & (1L << (i%BITS_PER_LONG)))
403 sprintf(alias + strlen(alias), "%X,*", i);
406 /* input:b0v0p0e0-eXkXrXaXmXlXsXfXwX where X is comma-separated %02X. */
407 static int do_input_entry(const char *filename, struct input_device_id *id,
408 char *alias)
410 sprintf(alias, "input:");
412 ADD(alias, "b", id->flags & INPUT_DEVICE_ID_MATCH_BUS, id->bustype);
413 ADD(alias, "v", id->flags & INPUT_DEVICE_ID_MATCH_VENDOR, id->vendor);
414 ADD(alias, "p", id->flags & INPUT_DEVICE_ID_MATCH_PRODUCT, id->product);
415 ADD(alias, "e", id->flags & INPUT_DEVICE_ID_MATCH_VERSION, id->version);
417 sprintf(alias + strlen(alias), "-e*");
418 if (id->flags & INPUT_DEVICE_ID_MATCH_EVBIT)
419 do_input(alias, id->evbit, 0, EV_MAX);
420 sprintf(alias + strlen(alias), "k*");
421 if (id->flags & INPUT_DEVICE_ID_MATCH_KEYBIT)
422 do_input(alias, id->keybit, KEY_MIN_INTERESTING, KEY_MAX);
423 sprintf(alias + strlen(alias), "r*");
424 if (id->flags & INPUT_DEVICE_ID_MATCH_RELBIT)
425 do_input(alias, id->relbit, 0, REL_MAX);
426 sprintf(alias + strlen(alias), "a*");
427 if (id->flags & INPUT_DEVICE_ID_MATCH_ABSBIT)
428 do_input(alias, id->absbit, 0, ABS_MAX);
429 sprintf(alias + strlen(alias), "m*");
430 if (id->flags & INPUT_DEVICE_ID_MATCH_MSCIT)
431 do_input(alias, id->mscbit, 0, MSC_MAX);
432 sprintf(alias + strlen(alias), "l*");
433 if (id->flags & INPUT_DEVICE_ID_MATCH_LEDBIT)
434 do_input(alias, id->ledbit, 0, LED_MAX);
435 sprintf(alias + strlen(alias), "s*");
436 if (id->flags & INPUT_DEVICE_ID_MATCH_SNDBIT)
437 do_input(alias, id->sndbit, 0, SND_MAX);
438 sprintf(alias + strlen(alias), "f*");
439 if (id->flags & INPUT_DEVICE_ID_MATCH_FFBIT)
440 do_input(alias, id->ffbit, 0, FF_MAX);
441 sprintf(alias + strlen(alias), "w*");
442 if (id->flags & INPUT_DEVICE_ID_MATCH_SWBIT)
443 do_input(alias, id->swbit, 0, SW_MAX);
444 return 1;
447 static int do_eisa_entry(const char *filename, struct eisa_device_id *eisa,
448 char *alias)
450 if (eisa->sig[0])
451 sprintf(alias, EISA_DEVICE_MODALIAS_FMT "*", eisa->sig);
452 return 1;
455 /* Looks like: parisc:tNhvNrevNsvN */
456 static int do_parisc_entry(const char *filename, struct parisc_device_id *id,
457 char *alias)
459 id->hw_type = TO_NATIVE(id->hw_type);
460 id->hversion = TO_NATIVE(id->hversion);
461 id->hversion_rev = TO_NATIVE(id->hversion_rev);
462 id->sversion = TO_NATIVE(id->sversion);
464 strcpy(alias, "parisc:");
465 ADD(alias, "t", id->hw_type != PA_HWTYPE_ANY_ID, id->hw_type);
466 ADD(alias, "hv", id->hversion != PA_HVERSION_ANY_ID, id->hversion);
467 ADD(alias, "rev", id->hversion_rev != PA_HVERSION_REV_ANY_ID, id->hversion_rev);
468 ADD(alias, "sv", id->sversion != PA_SVERSION_ANY_ID, id->sversion);
470 return 1;
473 /* Ignore any prefix, eg. v850 prepends _ */
474 static inline int sym_is(const char *symbol, const char *name)
476 const char *match;
478 match = strstr(symbol, name);
479 if (!match)
480 return 0;
481 return match[strlen(symbol)] == '\0';
484 static void do_table(void *symval, unsigned long size,
485 unsigned long id_size,
486 const char *device_id,
487 void *function,
488 struct module *mod)
490 unsigned int i;
491 char alias[500];
492 int (*do_entry)(const char *, void *entry, char *alias) = function;
494 device_id_size_check(mod->name, device_id, size, id_size);
495 /* Leave last one: it's the terminator. */
496 size -= id_size;
498 for (i = 0; i < size; i += id_size) {
499 if (do_entry(mod->name, symval+i, alias)) {
500 /* Always end in a wildcard, for future extension */
501 if (alias[strlen(alias)-1] != '*')
502 strcat(alias, "*");
503 buf_printf(&mod->dev_table_buf,
504 "MODULE_ALIAS(\"%s\");\n", alias);
509 /* Create MODULE_ALIAS() statements.
510 * At this time, we cannot write the actual output C source yet,
511 * so we write into the mod->dev_table_buf buffer. */
512 void handle_moddevtable(struct module *mod, struct elf_info *info,
513 Elf_Sym *sym, const char *symname)
515 void *symval;
517 /* We're looking for a section relative symbol */
518 if (!sym->st_shndx || sym->st_shndx >= info->hdr->e_shnum)
519 return;
521 symval = (void *)info->hdr
522 + info->sechdrs[sym->st_shndx].sh_offset
523 + sym->st_value;
525 if (sym_is(symname, "__mod_pci_device_table"))
526 do_table(symval, sym->st_size,
527 sizeof(struct pci_device_id), "pci",
528 do_pci_entry, mod);
529 else if (sym_is(symname, "__mod_usb_device_table"))
530 /* special case to handle bcdDevice ranges */
531 do_usb_table(symval, sym->st_size, mod);
532 else if (sym_is(symname, "__mod_ieee1394_device_table"))
533 do_table(symval, sym->st_size,
534 sizeof(struct ieee1394_device_id), "ieee1394",
535 do_ieee1394_entry, mod);
536 else if (sym_is(symname, "__mod_ccw_device_table"))
537 do_table(symval, sym->st_size,
538 sizeof(struct ccw_device_id), "ccw",
539 do_ccw_entry, mod);
540 else if (sym_is(symname, "__mod_ap_device_table"))
541 do_table(symval, sym->st_size,
542 sizeof(struct ap_device_id), "ap",
543 do_ap_entry, mod);
544 else if (sym_is(symname, "__mod_serio_device_table"))
545 do_table(symval, sym->st_size,
546 sizeof(struct serio_device_id), "serio",
547 do_serio_entry, mod);
548 else if (sym_is(symname, "__mod_pnp_device_table"))
549 do_table(symval, sym->st_size,
550 sizeof(struct pnp_device_id), "pnp",
551 do_pnp_entry, mod);
552 else if (sym_is(symname, "__mod_pnp_card_device_table"))
553 do_table(symval, sym->st_size,
554 sizeof(struct pnp_card_device_id), "pnp_card",
555 do_pnp_card_entry, mod);
556 else if (sym_is(symname, "__mod_pcmcia_device_table"))
557 do_table(symval, sym->st_size,
558 sizeof(struct pcmcia_device_id), "pcmcia",
559 do_pcmcia_entry, mod);
560 else if (sym_is(symname, "__mod_of_device_table"))
561 do_table(symval, sym->st_size,
562 sizeof(struct of_device_id), "of",
563 do_of_entry, mod);
564 else if (sym_is(symname, "__mod_vio_device_table"))
565 do_table(symval, sym->st_size,
566 sizeof(struct vio_device_id), "vio",
567 do_vio_entry, mod);
568 else if (sym_is(symname, "__mod_i2c_device_table"))
569 do_table(symval, sym->st_size,
570 sizeof(struct i2c_device_id), "i2c",
571 do_i2c_entry, mod);
572 else if (sym_is(symname, "__mod_input_device_table"))
573 do_table(symval, sym->st_size,
574 sizeof(struct input_device_id), "input",
575 do_input_entry, mod);
576 else if (sym_is(symname, "__mod_eisa_device_table"))
577 do_table(symval, sym->st_size,
578 sizeof(struct eisa_device_id), "eisa",
579 do_eisa_entry, mod);
580 else if (sym_is(symname, "__mod_parisc_device_table"))
581 do_table(symval, sym->st_size,
582 sizeof(struct parisc_device_id), "parisc",
583 do_parisc_entry, mod);
586 /* Now add out buffered information to the generated C source */
587 void add_moddevtable(struct buffer *buf, struct module *mod)
589 buf_printf(buf, "\n");
590 buf_write(buf, mod->dev_table_buf.p, mod->dev_table_buf.pos);
591 free(mod->dev_table_buf.p);