summaryrefslogtreecommitdiffstats
path: root/loader2/modstubs.c
diff options
context:
space:
mode:
authorJeremy Katz <katzj@redhat.com>2003-11-14 22:48:02 +0000
committerJeremy Katz <katzj@redhat.com>2003-11-14 22:48:02 +0000
commit3586c865ffd47fe3d636d134c17a7dbab37868e4 (patch)
tree408dabfe129c94f849089b1160b9e39eaa7ba5a3 /loader2/modstubs.c
parent951493fd9f8b8ea64336d43fa21ac7e2f7b09fb2 (diff)
downloadanaconda-3586c865ffd47fe3d636d134c17a7dbab37868e4.tar.gz
anaconda-3586c865ffd47fe3d636d134c17a7dbab37868e4.tar.xz
anaconda-3586c865ffd47fe3d636d134c17a7dbab37868e4.zip
mmap it and pass the buffer instead of the filename (oops)
Diffstat (limited to 'loader2/modstubs.c')
-rw-r--r--loader2/modstubs.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/loader2/modstubs.c b/loader2/modstubs.c
index 8114897b2..e4ce3c2a9 100644
--- a/loader2/modstubs.c
+++ b/loader2/modstubs.c
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <sys/utsname.h>
#include <sys/wait.h>
+#include <sys/mman.h>
#include "log.h"
#include "modstubs.h"
@@ -84,7 +85,7 @@ int ourInsmodCommand(int argc, char ** argv) {
char * ballPath = NULL;
int version = 1;
int fd;
- char * modbuf = NULL;
+ void * modbuf = NULL;
struct stat sb;
if (argc < 2) {
@@ -124,13 +125,13 @@ int ourInsmodCommand(int argc, char ** argv) {
return 1;
}
- modbuf = malloc(sb.st_size);
- if (read(fd, modbuf, sb.st_size) < sb.st_size) {
+ modbuf = mmap(0, sb.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
+ if (modbuf == NULL) {
logMessage("error reading file %s: %s", file, strerror(errno));
return 1;
}
- rc = init_module(file, sb.st_size, "");
+ rc = init_module(modbuf, sb.st_size, "");
if (rc != 0)
logMessage("failed to insert module (%d)", errno);
return rc;