Better error checking in insmod. Remove left over %m's
-Erik
This commit is contained in:
parent
4a971aef59
commit
8a24a6783a
34
insmod.c
34
insmod.c
@ -71,7 +71,7 @@
|
|||||||
#ifndef MODUTILS_MODULE_H
|
#ifndef MODUTILS_MODULE_H
|
||||||
#define MODUTILS_MODULE_H 1
|
#define MODUTILS_MODULE_H 1
|
||||||
|
|
||||||
#ident "$Id: insmod.c,v 1.9 2000/06/19 19:53:30 andersen Exp $"
|
#ident "$Id: insmod.c,v 1.10 2000/06/22 18:19:31 andersen Exp $"
|
||||||
|
|
||||||
/* This file contains the structures used by the 2.0 and 2.1 kernels.
|
/* This file contains the structures used by the 2.0 and 2.1 kernels.
|
||||||
We do not use the kernel headers directly because we do not wish
|
We do not use the kernel headers directly because we do not wish
|
||||||
@ -277,7 +277,7 @@ int delete_module(const char *);
|
|||||||
#ifndef MODUTILS_OBJ_H
|
#ifndef MODUTILS_OBJ_H
|
||||||
#define MODUTILS_OBJ_H 1
|
#define MODUTILS_OBJ_H 1
|
||||||
|
|
||||||
#ident "$Id: insmod.c,v 1.9 2000/06/19 19:53:30 andersen Exp $"
|
#ident "$Id: insmod.c,v 1.10 2000/06/22 18:19:31 andersen Exp $"
|
||||||
|
|
||||||
/* The relocatable object is manipulated using elfin types. */
|
/* The relocatable object is manipulated using elfin types. */
|
||||||
|
|
||||||
@ -1210,9 +1210,7 @@ old_process_module_arguments(struct obj_file *f, int argc, char **argv)
|
|||||||
str = alloca(strlen(q));
|
str = alloca(strlen(q));
|
||||||
for (r = str, q++; *q != '"'; ++q, ++r) {
|
for (r = str, q++; *q != '"'; ++q, ++r) {
|
||||||
if (*q == '\0') {
|
if (*q == '\0') {
|
||||||
fprintf(stderr,
|
fprintf(stderr, "improperly terminated string argument for %s\n", p);
|
||||||
"improperly terminated string argument for %s\n",
|
|
||||||
p);
|
|
||||||
return 0;
|
return 0;
|
||||||
} else if (*q == '\\')
|
} else if (*q == '\\')
|
||||||
switch (*++q) {
|
switch (*++q) {
|
||||||
@ -1341,7 +1339,7 @@ static int old_get_kernel_symbols(void)
|
|||||||
|
|
||||||
nks = get_kernel_syms(NULL);
|
nks = get_kernel_syms(NULL);
|
||||||
if (nks < 0) {
|
if (nks < 0) {
|
||||||
perror("get_kernel_syms: %m");
|
errorMsg("get_kernel_syms: %s: %s", m_name, strerror(errno));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1522,7 +1520,7 @@ old_init_module(const char *m_name, struct obj_file *f,
|
|||||||
m_size | (flag_autoclean ? OLD_MOD_AUTOCLEAN
|
m_size | (flag_autoclean ? OLD_MOD_AUTOCLEAN
|
||||||
: 0), &routines, symtab);
|
: 0), &routines, symtab);
|
||||||
if (ret)
|
if (ret)
|
||||||
perror("init_module: %m");
|
errorMsg("init_module: %s: %s", m_name, strerror(errno));
|
||||||
|
|
||||||
free(image);
|
free(image);
|
||||||
free(symtab);
|
free(symtab);
|
||||||
@ -1837,7 +1835,7 @@ static int new_get_kernel_symbols(void)
|
|||||||
module_names = xrealloc(module_names, bufsize = ret);
|
module_names = xrealloc(module_names, bufsize = ret);
|
||||||
goto retry_modules_load;
|
goto retry_modules_load;
|
||||||
}
|
}
|
||||||
perror("QM_MODULES: %m\n");
|
errorMsg("QM_MODULES: %s", strerror(errno));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1856,7 +1854,7 @@ static int new_get_kernel_symbols(void)
|
|||||||
/* The module was removed out from underneath us. */
|
/* The module was removed out from underneath us. */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
perror("query_module: QM_INFO: %m");
|
errorMsg("query_module: QM_INFO: %s: %s", mn, strerror(errno));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1871,7 +1869,7 @@ static int new_get_kernel_symbols(void)
|
|||||||
/* The module was removed out from underneath us. */
|
/* The module was removed out from underneath us. */
|
||||||
continue;
|
continue;
|
||||||
default:
|
default:
|
||||||
perror("query_module: QM_SYMBOLS: %m");
|
errorMsg("query_module: QM_SYMBOLS: %s: %s", mn, strerror(errno));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1896,7 +1894,7 @@ static int new_get_kernel_symbols(void)
|
|||||||
syms = xrealloc(syms, bufsize = ret);
|
syms = xrealloc(syms, bufsize = ret);
|
||||||
goto retry_kern_sym_load;
|
goto retry_kern_sym_load;
|
||||||
}
|
}
|
||||||
perror("kernel: QM_SYMBOLS: %m");
|
errorMsg("kernel: QM_SYMBOLS: %s", strerror(errno));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
nksyms = nsyms = ret;
|
nksyms = nsyms = ret;
|
||||||
@ -2077,7 +2075,7 @@ new_init_module(const char *m_name, struct obj_file *f,
|
|||||||
|
|
||||||
ret = new_sys_init_module(m_name, (struct new_module *) image);
|
ret = new_sys_init_module(m_name, (struct new_module *) image);
|
||||||
if (ret)
|
if (ret)
|
||||||
perror("init_module: %m");
|
errorMsg("init_module: %s: %s", m_name, strerror(errno));
|
||||||
|
|
||||||
free(image);
|
free(image);
|
||||||
|
|
||||||
@ -2457,7 +2455,7 @@ struct obj_file *obj_load(FILE * fp)
|
|||||||
|
|
||||||
fseek(fp, 0, SEEK_SET);
|
fseek(fp, 0, SEEK_SET);
|
||||||
if (fread(&f->header, sizeof(f->header), 1, fp) != 1) {
|
if (fread(&f->header, sizeof(f->header), 1, fp) != 1) {
|
||||||
perror("error reading ELF header: %m");
|
errorMsg("error reading ELF header: %s", strerror(errno));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2496,7 +2494,7 @@ struct obj_file *obj_load(FILE * fp)
|
|||||||
section_headers = alloca(sizeof(ElfW(Shdr)) * shnum);
|
section_headers = alloca(sizeof(ElfW(Shdr)) * shnum);
|
||||||
fseek(fp, f->header.e_shoff, SEEK_SET);
|
fseek(fp, f->header.e_shoff, SEEK_SET);
|
||||||
if (fread(section_headers, sizeof(ElfW(Shdr)), shnum, fp) != shnum) {
|
if (fread(section_headers, sizeof(ElfW(Shdr)), shnum, fp) != shnum) {
|
||||||
perror("error reading ELF section headers: %m");
|
errorMsg("error reading ELF section headers: %s", strerror(errno));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2526,8 +2524,7 @@ struct obj_file *obj_load(FILE * fp)
|
|||||||
sec->contents = xmalloc(sec->header.sh_size);
|
sec->contents = xmalloc(sec->header.sh_size);
|
||||||
fseek(fp, sec->header.sh_offset, SEEK_SET);
|
fseek(fp, sec->header.sh_offset, SEEK_SET);
|
||||||
if (fread(sec->contents, sec->header.sh_size, 1, fp) != 1) {
|
if (fread(sec->contents, sec->header.sh_size, 1, fp) != 1) {
|
||||||
fprintf(stderr,
|
errorMsg("error reading ELF section data: %s", strerror(errno));
|
||||||
"error reading ELF section data: %m\n");
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -2724,8 +2721,7 @@ extern int insmod_main( int argc, char **argv)
|
|||||||
if (m_filename[0] == '\0'
|
if (m_filename[0] == '\0'
|
||||||
|| ((fp = fopen(m_filename, "r")) == NULL))
|
|| ((fp = fopen(m_filename, "r")) == NULL))
|
||||||
{
|
{
|
||||||
perror("No module by that name found in " _PATH_MODULES
|
errorMsg("No module named '%s' found in '%s'\n", m_fullName, _PATH_MODULES);
|
||||||
"\n");
|
|
||||||
exit(FALSE);
|
exit(FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2857,7 +2853,7 @@ extern int insmod_main( int argc, char **argv)
|
|||||||
m_size);
|
m_size);
|
||||||
goto out;
|
goto out;
|
||||||
default:
|
default:
|
||||||
perror("create_module: %m");
|
errorMsg("create_module: %s: %s", m_name, strerror(errno));
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@
|
|||||||
#ifndef MODUTILS_MODULE_H
|
#ifndef MODUTILS_MODULE_H
|
||||||
#define MODUTILS_MODULE_H 1
|
#define MODUTILS_MODULE_H 1
|
||||||
|
|
||||||
#ident "$Id: insmod.c,v 1.9 2000/06/19 19:53:30 andersen Exp $"
|
#ident "$Id: insmod.c,v 1.10 2000/06/22 18:19:31 andersen Exp $"
|
||||||
|
|
||||||
/* This file contains the structures used by the 2.0 and 2.1 kernels.
|
/* This file contains the structures used by the 2.0 and 2.1 kernels.
|
||||||
We do not use the kernel headers directly because we do not wish
|
We do not use the kernel headers directly because we do not wish
|
||||||
@ -277,7 +277,7 @@ int delete_module(const char *);
|
|||||||
#ifndef MODUTILS_OBJ_H
|
#ifndef MODUTILS_OBJ_H
|
||||||
#define MODUTILS_OBJ_H 1
|
#define MODUTILS_OBJ_H 1
|
||||||
|
|
||||||
#ident "$Id: insmod.c,v 1.9 2000/06/19 19:53:30 andersen Exp $"
|
#ident "$Id: insmod.c,v 1.10 2000/06/22 18:19:31 andersen Exp $"
|
||||||
|
|
||||||
/* The relocatable object is manipulated using elfin types. */
|
/* The relocatable object is manipulated using elfin types. */
|
||||||
|
|
||||||
@ -1210,9 +1210,7 @@ old_process_module_arguments(struct obj_file *f, int argc, char **argv)
|
|||||||
str = alloca(strlen(q));
|
str = alloca(strlen(q));
|
||||||
for (r = str, q++; *q != '"'; ++q, ++r) {
|
for (r = str, q++; *q != '"'; ++q, ++r) {
|
||||||
if (*q == '\0') {
|
if (*q == '\0') {
|
||||||
fprintf(stderr,
|
fprintf(stderr, "improperly terminated string argument for %s\n", p);
|
||||||
"improperly terminated string argument for %s\n",
|
|
||||||
p);
|
|
||||||
return 0;
|
return 0;
|
||||||
} else if (*q == '\\')
|
} else if (*q == '\\')
|
||||||
switch (*++q) {
|
switch (*++q) {
|
||||||
@ -1341,7 +1339,7 @@ static int old_get_kernel_symbols(void)
|
|||||||
|
|
||||||
nks = get_kernel_syms(NULL);
|
nks = get_kernel_syms(NULL);
|
||||||
if (nks < 0) {
|
if (nks < 0) {
|
||||||
perror("get_kernel_syms: %m");
|
errorMsg("get_kernel_syms: %s: %s", m_name, strerror(errno));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1522,7 +1520,7 @@ old_init_module(const char *m_name, struct obj_file *f,
|
|||||||
m_size | (flag_autoclean ? OLD_MOD_AUTOCLEAN
|
m_size | (flag_autoclean ? OLD_MOD_AUTOCLEAN
|
||||||
: 0), &routines, symtab);
|
: 0), &routines, symtab);
|
||||||
if (ret)
|
if (ret)
|
||||||
perror("init_module: %m");
|
errorMsg("init_module: %s: %s", m_name, strerror(errno));
|
||||||
|
|
||||||
free(image);
|
free(image);
|
||||||
free(symtab);
|
free(symtab);
|
||||||
@ -1837,7 +1835,7 @@ static int new_get_kernel_symbols(void)
|
|||||||
module_names = xrealloc(module_names, bufsize = ret);
|
module_names = xrealloc(module_names, bufsize = ret);
|
||||||
goto retry_modules_load;
|
goto retry_modules_load;
|
||||||
}
|
}
|
||||||
perror("QM_MODULES: %m\n");
|
errorMsg("QM_MODULES: %s", strerror(errno));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1856,7 +1854,7 @@ static int new_get_kernel_symbols(void)
|
|||||||
/* The module was removed out from underneath us. */
|
/* The module was removed out from underneath us. */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
perror("query_module: QM_INFO: %m");
|
errorMsg("query_module: QM_INFO: %s: %s", mn, strerror(errno));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1871,7 +1869,7 @@ static int new_get_kernel_symbols(void)
|
|||||||
/* The module was removed out from underneath us. */
|
/* The module was removed out from underneath us. */
|
||||||
continue;
|
continue;
|
||||||
default:
|
default:
|
||||||
perror("query_module: QM_SYMBOLS: %m");
|
errorMsg("query_module: QM_SYMBOLS: %s: %s", mn, strerror(errno));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1896,7 +1894,7 @@ static int new_get_kernel_symbols(void)
|
|||||||
syms = xrealloc(syms, bufsize = ret);
|
syms = xrealloc(syms, bufsize = ret);
|
||||||
goto retry_kern_sym_load;
|
goto retry_kern_sym_load;
|
||||||
}
|
}
|
||||||
perror("kernel: QM_SYMBOLS: %m");
|
errorMsg("kernel: QM_SYMBOLS: %s", strerror(errno));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
nksyms = nsyms = ret;
|
nksyms = nsyms = ret;
|
||||||
@ -2077,7 +2075,7 @@ new_init_module(const char *m_name, struct obj_file *f,
|
|||||||
|
|
||||||
ret = new_sys_init_module(m_name, (struct new_module *) image);
|
ret = new_sys_init_module(m_name, (struct new_module *) image);
|
||||||
if (ret)
|
if (ret)
|
||||||
perror("init_module: %m");
|
errorMsg("init_module: %s: %s", m_name, strerror(errno));
|
||||||
|
|
||||||
free(image);
|
free(image);
|
||||||
|
|
||||||
@ -2457,7 +2455,7 @@ struct obj_file *obj_load(FILE * fp)
|
|||||||
|
|
||||||
fseek(fp, 0, SEEK_SET);
|
fseek(fp, 0, SEEK_SET);
|
||||||
if (fread(&f->header, sizeof(f->header), 1, fp) != 1) {
|
if (fread(&f->header, sizeof(f->header), 1, fp) != 1) {
|
||||||
perror("error reading ELF header: %m");
|
errorMsg("error reading ELF header: %s", strerror(errno));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2496,7 +2494,7 @@ struct obj_file *obj_load(FILE * fp)
|
|||||||
section_headers = alloca(sizeof(ElfW(Shdr)) * shnum);
|
section_headers = alloca(sizeof(ElfW(Shdr)) * shnum);
|
||||||
fseek(fp, f->header.e_shoff, SEEK_SET);
|
fseek(fp, f->header.e_shoff, SEEK_SET);
|
||||||
if (fread(section_headers, sizeof(ElfW(Shdr)), shnum, fp) != shnum) {
|
if (fread(section_headers, sizeof(ElfW(Shdr)), shnum, fp) != shnum) {
|
||||||
perror("error reading ELF section headers: %m");
|
errorMsg("error reading ELF section headers: %s", strerror(errno));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2526,8 +2524,7 @@ struct obj_file *obj_load(FILE * fp)
|
|||||||
sec->contents = xmalloc(sec->header.sh_size);
|
sec->contents = xmalloc(sec->header.sh_size);
|
||||||
fseek(fp, sec->header.sh_offset, SEEK_SET);
|
fseek(fp, sec->header.sh_offset, SEEK_SET);
|
||||||
if (fread(sec->contents, sec->header.sh_size, 1, fp) != 1) {
|
if (fread(sec->contents, sec->header.sh_size, 1, fp) != 1) {
|
||||||
fprintf(stderr,
|
errorMsg("error reading ELF section data: %s", strerror(errno));
|
||||||
"error reading ELF section data: %m\n");
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -2724,8 +2721,7 @@ extern int insmod_main( int argc, char **argv)
|
|||||||
if (m_filename[0] == '\0'
|
if (m_filename[0] == '\0'
|
||||||
|| ((fp = fopen(m_filename, "r")) == NULL))
|
|| ((fp = fopen(m_filename, "r")) == NULL))
|
||||||
{
|
{
|
||||||
perror("No module by that name found in " _PATH_MODULES
|
errorMsg("No module named '%s' found in '%s'\n", m_fullName, _PATH_MODULES);
|
||||||
"\n");
|
|
||||||
exit(FALSE);
|
exit(FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2857,7 +2853,7 @@ extern int insmod_main( int argc, char **argv)
|
|||||||
m_size);
|
m_size);
|
||||||
goto out;
|
goto out;
|
||||||
default:
|
default:
|
||||||
perror("create_module: %m");
|
errorMsg("create_module: %s: %s", m_name, strerror(errno));
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user