cpio_be.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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), 2))
  21. #define MAGIC "\x71\xc7"
  22. struct head
  23. {
  24. grub_uint16_t magic[1];
  25. grub_uint16_t dev;
  26. grub_uint16_t ino;
  27. grub_uint16_t mode[1];
  28. grub_uint16_t uid;
  29. grub_uint16_t gid;
  30. grub_uint16_t nlink;
  31. grub_uint16_t rdev;
  32. grub_uint16_t mtime[2];
  33. grub_uint16_t namesize[1];
  34. grub_uint16_t filesize[2];
  35. } GRUB_PACKED;
  36. static inline unsigned long long
  37. read_number (const grub_uint16_t *arr, grub_size_t size)
  38. {
  39. long long ret = 0;
  40. while (size--)
  41. ret = (ret << 16) | grub_be_to_cpu16 (*arr++);
  42. return ret;
  43. }
  44. #define FSNAME "cpiofs_be"
  45. #include "cpio_common.c"
  46. GRUB_MOD_INIT (cpio_be)
  47. {
  48. grub_cpio_fs.mod = mod;
  49. grub_fs_register (&grub_cpio_fs);
  50. }
  51. GRUB_MOD_FINI (cpio_be)
  52. {
  53. grub_fs_unregister (&grub_cpio_fs);
  54. }