diff options
author | Guillaume Cottenceau <gc@mandriva.com> | 2001-01-02 23:38:22 +0000 |
---|---|---|
committer | Guillaume Cottenceau <gc@mandriva.com> | 2001-01-02 23:38:22 +0000 |
commit | 9302affdabc003d034c338a6ed3ef266df93ade5 (patch) | |
tree | 19b1babf7665cadf426de3aae66d3ef9f8b05cb7 | |
parent | 206de487dc1dda8cf884101947b0cd1ac5c0e40c (diff) | |
download | drakx-backup-do-not-use-9302affdabc003d034c338a6ed3ef266df93ade5.tar drakx-backup-do-not-use-9302affdabc003d034c338a6ed3ef266df93ade5.tar.gz drakx-backup-do-not-use-9302affdabc003d034c338a6ed3ef266df93ade5.tar.bz2 drakx-backup-do-not-use-9302affdabc003d034c338a6ed3ef266df93ade5.tar.xz drakx-backup-do-not-use-9302affdabc003d034c338a6ed3ef266df93ade5.zip |
vacances:
- be consistent so that every error messages do not end up with a newline. smaller code + consistency.
- support insmod calls with parameters given to the kernel (ISA boards and so on..)
-rw-r--r-- | mdk-stage1/insmod-busybox/insmod.c | 106 | ||||
-rw-r--r-- | mdk-stage1/insmod-busybox/utility.c | 6 |
2 files changed, 63 insertions, 49 deletions
diff --git a/mdk-stage1/insmod-busybox/insmod.c b/mdk-stage1/insmod-busybox/insmod.c index 2f95f8198..ac5f191fb 100644 --- a/mdk-stage1/insmod-busybox/insmod.c +++ b/mdk-stage1/insmod-busybox/insmod.c @@ -1045,7 +1045,7 @@ struct obj_symbol *obj_add_symbol(struct obj_file *f, const char *name, /* Don't report an error if the symbol is coming from the kernel or some external module. */ if (secidx <= SHN_HIRESERVE) - errorMsg("%s multiply defined\n", name); + errorMsg("%s multiply defined", name); return sym; } } @@ -1308,7 +1308,7 @@ old_process_module_arguments(struct obj_file *f, int argc, char **argv) /* Also check that the parameter was not resolved from the kernel. */ if (sym == NULL || sym->secidx > SHN_HIRESERVE) { - errorMsg("symbol for parameter %s not found\n", p); + errorMsg("symbol for parameter %s not found", p); return 0; } @@ -1321,7 +1321,7 @@ old_process_module_arguments(struct obj_file *f, int argc, char **argv) str = alloca(strlen(q)); for (r = str, q++; *q != '"'; ++q, ++r) { if (*q == '\0') { - errorMsg("improperly terminated string argument for %s\n", p); + errorMsg("improperly terminated string argument for %s", p); return 0; } else if (*q == '\\') switch (*++q) { @@ -1450,7 +1450,7 @@ static int old_get_kernel_symbols(const char *m_name) nks = get_kernel_syms(NULL); if (nks < 0) { - errorMsg("get_kernel_syms: %s: %s\n", m_name, strerror(errno)); + errorMsg("get_kernel_syms: %s: %s", m_name, strerror(errno)); return 0; } @@ -1631,7 +1631,7 @@ old_init_module(const char *m_name, struct obj_file *f, m_size | (flag_autoclean ? OLD_MOD_AUTOCLEAN : 0), &routines, symtab); if (ret) - errorMsg("init_module: %s: %s\n", m_name, strerror(errno)); + errorMsg("init_module: %s: %s", m_name, strerror(errno)); free(image); free(symtab); @@ -1674,7 +1674,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv) p = get_modinfo_value(f, key); key += 5; if (p == NULL) { - errorMsg("invalid parameter %s\n", key); + errorMsg("invalid parameter %s", key); return 0; } @@ -1682,7 +1682,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv) /* Also check that the parameter was not resolved from the kernel. */ if (sym == NULL || sym->secidx > SHN_HIRESERVE) { - errorMsg("symbol for parameter %s not found\n", key); + errorMsg("symbol for parameter %s not found", key); return 0; } @@ -1710,7 +1710,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv) str = alloca(strlen(q)); for (r = str, q++; *q != '"'; ++q, ++r) { if (*q == '\0') { - errorMsg("improperly terminated string argument for %s\n", + errorMsg("improperly terminated string argument for %s", key); return 0; } else if (*q == '\\') @@ -1805,14 +1805,14 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv) /* Probably we should do that outside the loop ? */ if (!isdigit(*(p + 1))) { errorMsg("parameter type 'c' for %s must be followed by" - " the maximum size\n", key); + " the maximum size", key); return 0; } charssize = strtoul(p + 1, (char **) NULL, 10); /* Check length */ if (strlen(str) >= charssize) { - errorMsg("string too long for %s (max %ld)\n", key, + errorMsg("string too long for %s (max %ld)", key, charssize - 1); return 0; } @@ -1841,7 +1841,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv) break; default: - errorMsg("unknown parameter type '%c' for %s\n", *p, key); + errorMsg("unknown parameter type '%c' for %s", *p, key); return 0; } } @@ -1860,21 +1860,21 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv) case ',': if (++n > max) { - errorMsg("too many values for %s (max %d)\n", key, max); + errorMsg("too many values for %s (max %d)", key, max); return 0; } ++q; break; default: - errorMsg("invalid argument syntax for %s\n", key); + errorMsg("invalid argument syntax for %s", key); return 0; } } end_of_arg: if (n < min) { - errorMsg("too few values for %s (min %d)\n", key, min); + errorMsg("too few values for %s (min %d)", key, min); return 0; } @@ -1943,7 +1943,7 @@ static int new_get_kernel_symbols(void) module_names = xrealloc(module_names, bufsize = ret); goto retry_modules_load; } - errorMsg("QM_MODULES: %s\n", strerror(errno)); + errorMsg("QM_MODULES: %s", strerror(errno)); return 0; } @@ -1962,7 +1962,7 @@ static int new_get_kernel_symbols(void) /* The module was removed out from underneath us. */ continue; } - errorMsg("query_module: QM_INFO: %s: %s\n", mn, strerror(errno)); + errorMsg("query_module: QM_INFO: %s: %s", mn, strerror(errno)); return 0; } @@ -1977,7 +1977,7 @@ static int new_get_kernel_symbols(void) /* The module was removed out from underneath us. */ continue; default: - errorMsg("query_module: QM_SYMBOLS: %s: %s\n", mn, strerror(errno)); + errorMsg("query_module: QM_SYMBOLS: %s: %s", mn, strerror(errno)); return 0; } } @@ -2002,7 +2002,7 @@ static int new_get_kernel_symbols(void) syms = xrealloc(syms, bufsize = ret); goto retry_kern_sym_load; } - errorMsg("kernel: QM_SYMBOLS: %s\n", strerror(errno)); + errorMsg("kernel: QM_SYMBOLS: %s", strerror(errno)); return 0; } nksyms = nsyms = ret; @@ -2183,7 +2183,7 @@ new_init_module(const char *m_name, struct obj_file *f, ret = new_sys_init_module(m_name, (struct new_module *) image); if (ret) - errorMsg("init_module: %s: %s\n", m_name, strerror(errno)); + errorMsg("init_module: %s: %s", m_name, strerror(errno)); free(image); @@ -2259,7 +2259,7 @@ int obj_check_undefineds(struct obj_file *f) sym->secidx = SHN_ABS; sym->value = 0; } else { - errorMsg("unresolved symbol %s\n", sym->name); + errorMsg("unresolved symbol %s", sym->name); ret = 0; } } @@ -2482,11 +2482,11 @@ int obj_relocate(struct obj_file *f, ElfW(Addr) base) errmsg = "Unhandled relocation"; bad_reloc: if (extsym) { - errorMsg("%s of type %ld for %s\n", errmsg, + errorMsg("%s of type %ld for %s", errmsg, (long) ELFW(R_TYPE) (rel->r_info), strtab + extsym->st_name); } else { - errorMsg("%s of type %ld\n", errmsg, + errorMsg("%s of type %ld", errmsg, (long) ELFW(R_TYPE) (rel->r_info)); } ret = 0; @@ -2563,7 +2563,7 @@ struct obj_file *obj_load(FILE * fp) fseek(fp, 0, SEEK_SET); if (fread(&f->header, sizeof(f->header), 1, fp) != 1) { - errorMsg("error reading ELF header: %s\n", strerror(errno)); + errorMsg("error reading ELF header: %s", strerror(errno)); return NULL; } @@ -2571,25 +2571,25 @@ struct obj_file *obj_load(FILE * fp) || f->header.e_ident[EI_MAG1] != ELFMAG1 || f->header.e_ident[EI_MAG2] != ELFMAG2 || f->header.e_ident[EI_MAG3] != ELFMAG3) { - errorMsg("not an ELF file\n"); + errorMsg("not an ELF file"); return NULL; } if (f->header.e_ident[EI_CLASS] != ELFCLASSM || f->header.e_ident[EI_DATA] != ELFDATAM || f->header.e_ident[EI_VERSION] != EV_CURRENT || !MATCH_MACHINE(f->header.e_machine)) { - errorMsg("ELF file not for this architecture\n"); + errorMsg("ELF file not for this architecture"); return NULL; } if (f->header.e_type != ET_REL) { - errorMsg("ELF file not a relocatable object\n"); + errorMsg("ELF file not a relocatable object"); return NULL; } /* Read the section headers. */ if (f->header.e_shentsize != sizeof(ElfW(Shdr))) { - errorMsg("section header size mismatch: %lu != %lu\n", + errorMsg("section header size mismatch: %lu != %lu", (unsigned long) f->header.e_shentsize, (unsigned long) sizeof(ElfW(Shdr))); return NULL; @@ -2602,7 +2602,7 @@ struct obj_file *obj_load(FILE * fp) section_headers = alloca(sizeof(ElfW(Shdr)) * shnum); fseek(fp, f->header.e_shoff, SEEK_SET); if (fread(section_headers, sizeof(ElfW(Shdr)), shnum, fp) != shnum) { - errorMsg("error reading ELF section headers: %s\n", strerror(errno)); + errorMsg("error reading ELF section headers: %s", strerror(errno)); return NULL; } @@ -2632,7 +2632,7 @@ struct obj_file *obj_load(FILE * fp) sec->contents = xmalloc(sec->header.sh_size); fseek(fp, sec->header.sh_offset, SEEK_SET); if (fread(sec->contents, sec->header.sh_size, 1, fp) != 1) { - errorMsg("error reading ELF section data: %s\n", strerror(errno)); + errorMsg("error reading ELF section data: %s", strerror(errno)); return NULL; } } else { @@ -2642,11 +2642,11 @@ struct obj_file *obj_load(FILE * fp) #if SHT_RELM == SHT_REL case SHT_RELA: - errorMsg("RELA relocations not supported on this architecture\n"); + errorMsg("RELA relocations not supported on this architecture"); return NULL; #else case SHT_REL: - errorMsg("REL relocations not supported on this architecture\n"); + errorMsg("REL relocations not supported on this architecture"); return NULL; #endif @@ -2659,7 +2659,7 @@ struct obj_file *obj_load(FILE * fp) break; } - errorMsg("can't handle sections of type %ld\n", + errorMsg("can't handle sections of type %ld", (long) sec->header.sh_type); return NULL; } @@ -2688,7 +2688,7 @@ struct obj_file *obj_load(FILE * fp) ElfW(Sym) * sym; if (sec->header.sh_entsize != sizeof(ElfW(Sym))) { - errorMsg("symbol size mismatch: %lu != %lu\n", + errorMsg("symbol size mismatch: %lu != %lu", (unsigned long) sec->header.sh_entsize, (unsigned long) sizeof(ElfW(Sym))); return NULL; @@ -2720,7 +2720,7 @@ struct obj_file *obj_load(FILE * fp) case SHT_RELM: if (sec->header.sh_entsize != sizeof(ElfW(RelM))) { - errorMsg("relocation entry size mismatch: %lu != %lu\n", + errorMsg("relocation entry size mismatch: %lu != %lu", (unsigned long) sec->header.sh_entsize, (unsigned long) sizeof(ElfW(RelM))); return NULL; @@ -2753,7 +2753,7 @@ static void hide_special_symbols(struct obj_file *f) void my_usage(void) { - printf("Usage.\n"); + printf("Usage."); exit(0); } @@ -2826,11 +2826,11 @@ extern int insmod_main( int argc, char **argv) if (m_filename[0] == '\0' || ((fp = fopen(m_filename, "r")) == NULL)) { - errorMsg("No module named '%s' found in '%s'\n", m_fullName, _PATH_MODULES); + errorMsg("No module named '%s' found in '%s'", m_fullName, _PATH_MODULES); return -1; } } else - fatalError("No module named '%s' found in '%s'\n", m_fullName, _PATH_MODULES); + fatalError("No module named '%s' found in '%s'", m_fullName, _PATH_MODULES); } else memcpy(m_filename, *argv, strlen(*argv)); @@ -2855,7 +2855,7 @@ extern int insmod_main( int argc, char **argv) m_version = old_get_module_version(f, m_strversion); if (m_version == -1) { errorMsg("couldn't find the kernel version the module was " - "compiled for\n"); + "compiled for"); goto out; } } @@ -2864,12 +2864,12 @@ extern int insmod_main( int argc, char **argv) if (flag_force_load) { errorMsg("Warning: kernel-module version mismatch\n" "\t%s was compiled for kernel version %s\n" - "\twhile this kernel is version %s\n", + "\twhile this kernel is version %s", m_filename, m_strversion, k_strversion); } else { errorMsg("kernel-module version mismatch\n" "\t%s was compiled for kernel version %s\n" - "\twhile this kernel is version %s.\n", + "\twhile this kernel is version %s.", m_filename, m_strversion, k_strversion); goto out; } @@ -2885,7 +2885,7 @@ extern int insmod_main( int argc, char **argv) goto out; k_crcs = new_is_kernel_checksummed(); #else - errorMsg("Not configured to support new kernels\n"); + errorMsg("Not configured to support new kernels"); goto out; #endif } else { @@ -2894,7 +2894,7 @@ extern int insmod_main( int argc, char **argv) goto out; k_crcs = old_is_kernel_checksummed(); #else - errorMsg("Not configured to support old kernels\n"); + errorMsg("Not configured to support old kernels"); goto out; #endif } @@ -2951,16 +2951,16 @@ extern int insmod_main( int argc, char **argv) case 0: break; case EEXIST: - errorMsg("A module named %s already exists\n", m_name); + errorMsg("A module named %s already exists", m_name); /* Considered as a success in stage1 */ fclose(fp); return(TRUE); case ENOMEM: - errorMsg("Can't allocate kernel memory for module; needed %lu bytes\n", + errorMsg("Can't allocate kernel memory for module; needed %lu bytes", m_size); goto out; default: - errorMsg("create_module: %s: %s\n", m_name, strerror(errno)); + errorMsg("create_module: %s: %s", m_name, strerror(errno)); goto out; } @@ -2985,11 +2985,23 @@ out: } -int insmod_call(char * full_filename) +int insmod_call(char * full_filename, char * params) { int argc = 2; - char *argv[2]; + char *argv[50]; + char * ptr = params; argv[0] = "stage1"; argv[1] = full_filename; + + while (ptr != NULL) { + argv[argc] = ptr; + argc++; + ptr = strchr(ptr, ' '); + if (ptr) { + ptr[0] = '\0'; + ptr++; + } + } + return insmod_main(argc, argv); } diff --git a/mdk-stage1/insmod-busybox/utility.c b/mdk-stage1/insmod-busybox/utility.c index 35c169538..c5f26b8d9 100644 --- a/mdk-stage1/insmod-busybox/utility.c +++ b/mdk-stage1/insmod-busybox/utility.c @@ -86,6 +86,7 @@ extern void errorMsg(const char *s, ...) fflush(stdout); fprintf(stderr, "busybox: "); vfprintf(stderr, s, p); + fprintf(stderr, "\n"); va_end(p); fflush(stderr); } @@ -98,6 +99,7 @@ extern void fatalError(const char *s, ...) fflush(stdout); fprintf(stderr, "busybox: "); vfprintf(stderr, s, p); + fprintf(stderr, "\n"); va_end(p); fflush(stderr); exit(FALSE); @@ -109,7 +111,7 @@ extern void errorMsg(const char *s, ...) va_list p; va_start(p, s); - vlog_message_nobs(s, p); + vlog_message(s, p); va_end(p); } @@ -118,7 +120,7 @@ extern void fatalError(const char *s, ...) va_list p; va_start(p, s); - vlog_message_nobs(s, p); + vlog_message(s, p); va_end(p); while (1); } |