ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / um / kernel / initrd_user.c
1 /*
2  * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com)
3  * Licensed under the GPL
4  */
5
6 #include <unistd.h>
7 #include <sys/types.h>
8 #include <sys/stat.h>
9 #include <fcntl.h>
10 #include <errno.h>
11
12 #include "user_util.h"
13 #include "kern_util.h"
14 #include "user.h"
15 #include "initrd.h"
16 #include "os.h"
17
18 int load_initrd(char *filename, void *buf, int size)
19 {
20         int fd, n;
21
22         if((fd = os_open_file(filename, of_read(OPENFLAGS()), 0)) < 0){
23                 printk("Opening '%s' failed - errno = %d\n", filename, errno);
24                 return(-1);
25         }
26         if((n = read(fd, buf, size)) != size){
27                 printk("Read of %d bytes from '%s' returned %d, errno = %d\n",
28                        size, filename, n, errno);
29                 return(-1);
30         }
31         return(0);
32 }
33
34 /*
35  * Overrides for Emacs so that we follow Linus's tabbing style.
36  * Emacs will notice this stuff at the end of the file and automatically
37  * adjust the settings for this buffer only.  This must remain at the end
38  * of the file.
39  * ---------------------------------------------------------------------------
40  * Local variables:
41  * c-file-style: "linux"
42  * End:
43  */