Contributors: 4
Author |
Tokens |
Token Proportion |
Commits |
Commit Proportion |
Jeff Dike |
121 |
49.59% |
3 |
33.33% |
Vincent Whitchurch |
108 |
44.26% |
1 |
11.11% |
Mike Rapoport |
13 |
5.33% |
4 |
44.44% |
Alex Dewar |
2 |
0.82% |
1 |
11.11% |
Total |
244 |
|
9 |
|
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
*/
#include <linux/memblock.h>
#include <os.h>
#include "um_arch.h"
static int __init __uml_load_file(const char *filename, void *buf, int size)
{
int fd, n;
fd = os_open_file(filename, of_read(OPENFLAGS()), 0);
if (fd < 0) {
printk(KERN_ERR "Opening '%s' failed - err = %d\n", filename,
-fd);
return -1;
}
n = os_read_file(fd, buf, size);
if (n != size) {
printk(KERN_ERR "Read of %d bytes from '%s' failed, "
"err = %d\n", size,
filename, -n);
return -1;
}
os_close_file(fd);
return 0;
}
void *uml_load_file(const char *filename, unsigned long long *size)
{
void *area;
int err;
*size = 0;
if (!filename)
return NULL;
err = os_file_size(filename, size);
if (err)
return NULL;
if (*size == 0) {
printk(KERN_ERR "\"%s\" is empty\n", filename);
return NULL;
}
area = memblock_alloc(*size, SMP_CACHE_BYTES);
if (!area)
panic("%s: Failed to allocate %llu bytes\n", __func__, *size);
if (__uml_load_file(filename, area, *size)) {
memblock_free(area, *size);
return NULL;
}
return area;
}