newc.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* cpio.c - cpio and tar filesystem. */
  2. /*
  3. * GRUB -- GRand Unified Bootloader
  4. * Copyright (C) 2007,2008,2009,2013 Free Software Foundation, Inc.
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include <grub/misc.h>
  20. #define ALIGN_CPIO(x) (ALIGN_UP ((x), 4))
  21. #define MAGIC "070701"
  22. #define MAGIC2 "070702"
  23. struct head
  24. {
  25. char magic[6];
  26. char ino[8];
  27. char mode[8];
  28. char uid[8];
  29. char gid[8];
  30. char nlink[8];
  31. char mtime[8];
  32. char filesize[8];
  33. char devmajor[8];
  34. char devminor[8];
  35. char rdevmajor[8];
  36. char rdevminor[8];
  37. char namesize[8];
  38. char check[8];
  39. } GRUB_PACKED;
  40. static inline unsigned long long
  41. read_number (const char *str, grub_size_t size)
  42. {
  43. unsigned long long ret = 0;
  44. while (size-- && grub_isxdigit (*str))
  45. {
  46. char dig = *str++;
  47. if (dig >= '0' && dig <= '9')
  48. dig &= 0xf;
  49. else if (dig >= 'a' && dig <= 'f')
  50. dig -= 'a' - 10;
  51. else
  52. dig -= 'A' - 10;
  53. ret = (ret << 4) | (dig);
  54. }
  55. return ret;
  56. }
  57. #define FSNAME "newc"
  58. #include "cpio_common.c"
  59. GRUB_MOD_INIT (newc)
  60. {
  61. grub_fs_register (&grub_cpio_fs);
  62. }
  63. GRUB_MOD_FINI (newc)
  64. {
  65. grub_fs_unregister (&grub_cpio_fs);
  66. }