summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorian <ian@FreeBSD.org>2014-02-22 22:03:26 +0000
committerian <ian@FreeBSD.org>2014-02-22 22:03:26 +0000
commitf462797a7d2b0afc9492194e33457e4887fcee49 (patch)
tree1ec255766dc52457cbda3322d6a06feba1ddcaf7
parentfc6685cd75dceda6659773d1b991a614236555ab (diff)
downloadFreeBSD-src-f462797a7d2b0afc9492194e33457e4887fcee49.zip
FreeBSD-src-f462797a7d2b0afc9492194e33457e4887fcee49.tar.gz
Change file_loadraw() from static to public. Change the order of its
arguments from type,filename to filename,type to be consistant with other public file_whatever() functions, and change it to return a pointer to the preloaded_file struct describing the file. Adjust existing callers.
-rw-r--r--sys/boot/common/bootstrap.h1
-rw-r--r--sys/boot/common/module.c19
2 files changed, 10 insertions, 10 deletions
diff --git a/sys/boot/common/bootstrap.h b/sys/boot/common/bootstrap.h
index 516b8a5..c9bcc52 100644
--- a/sys/boot/common/bootstrap.h
+++ b/sys/boot/common/bootstrap.h
@@ -233,6 +233,7 @@ int mod_loadkld(const char *name, int argc, char *argv[]);
struct preloaded_file *file_alloc(void);
struct preloaded_file *file_findfile(char *name, char *type);
struct file_metadata *file_findmetadata(struct preloaded_file *fp, int type);
+struct preloaded_file *file_loadraw(char *name, char *type);
void file_discard(struct preloaded_file *fp);
void file_addmetadata(struct preloaded_file *fp, int type, size_t size, void *p);
int file_addmodule(struct preloaded_file *fp, char *modname, int version,
diff --git a/sys/boot/common/module.c b/sys/boot/common/module.c
index e450fbd..cea01c0 100644
--- a/sys/boot/common/module.c
+++ b/sys/boot/common/module.c
@@ -52,7 +52,6 @@ struct moduledir {
};
static int file_load(char *filename, vm_offset_t dest, struct preloaded_file **result);
-static int file_loadraw(char *type, char *name);
static int file_load_dependencies(struct preloaded_file *base_mod);
static char * file_search(const char *name, char **extlist);
static struct kernel_module * file_findmodule(struct preloaded_file *fp, char *modname, struct mod_depend *verinfo);
@@ -134,7 +133,7 @@ command_load(int argc, char *argv[])
command_errmsg = "invalid load type";
return(CMD_ERROR);
}
- return(file_loadraw(typestr, argv[1]));
+ return(file_loadraw(argv[1], typestr) ? CMD_OK : CMD_ERROR);
}
/*
* Do we have explicit KLD load ?
@@ -189,7 +188,7 @@ command_load_geli(int argc, char *argv[])
argv += (optind - 1);
argc -= (optind - 1);
sprintf(typestr, "%s:geli_keyfile%d", argv[1], num);
- return(file_loadraw(typestr, argv[2]));
+ return(file_loadraw(argv[2], typestr) ? CMD_OK : CMD_ERROR);
}
COMMAND_SET(unload, "unload", "unload all modules", command_unload);
@@ -357,8 +356,8 @@ file_load_dependencies(struct preloaded_file *base_file)
* We've been asked to load (name) as (type), so just suck it in,
* no arguments or anything.
*/
-int
-file_loadraw(char *type, char *name)
+struct preloaded_file *
+file_loadraw(char *name, char *type)
{
struct preloaded_file *fp;
char *cp;
@@ -368,21 +367,21 @@ file_loadraw(char *type, char *name)
/* We can't load first */
if ((file_findfile(NULL, NULL)) == NULL) {
command_errmsg = "can't load file before kernel";
- return(CMD_ERROR);
+ return(NULL);
}
/* locate the file on the load path */
cp = file_search(name, NULL);
if (cp == NULL) {
sprintf(command_errbuf, "can't find '%s'", name);
- return(CMD_ERROR);
+ return(NULL);
}
name = cp;
if ((fd = open(name, O_RDONLY)) < 0) {
sprintf(command_errbuf, "can't open '%s': %s", name, strerror(errno));
free(name);
- return(CMD_ERROR);
+ return(NULL);
}
if (archsw.arch_loadaddr != NULL)
@@ -398,7 +397,7 @@ file_loadraw(char *type, char *name)
sprintf(command_errbuf, "error reading '%s': %s", name, strerror(errno));
free(name);
close(fd);
- return(CMD_ERROR);
+ return(NULL);
}
laddr += got;
}
@@ -419,7 +418,7 @@ file_loadraw(char *type, char *name)
/* Add to the list of loaded files */
file_insert_tail(fp);
close(fd);
- return(CMD_OK);
+ return(fp);
}
/*
OpenPOWER on IntegriCloud