initrd_user.c 1.0 KB

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