ext4.c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * (C) Copyright 2011 - 2012 Samsung Electronics
  3. * EXT4 filesystem implementation in Uboot by
  4. * Uma Shankar <uma.shankar@samsung.com>
  5. * Manjunatha C Achar <a.manjunatha@samsung.com>
  6. *
  7. * Ext4fs support
  8. * made from existing cmd_ext2.c file of Uboot
  9. *
  10. * (C) Copyright 2004
  11. * esd gmbh <www.esd-electronics.com>
  12. * Reinhard Arlt <reinhard.arlt@esd-electronics.com>
  13. *
  14. * made from cmd_reiserfs by
  15. *
  16. * (C) Copyright 2003 - 2004
  17. * Sysgo Real-Time Solutions, AG <www.elinos.com>
  18. * Pavel Bartusek <pba@sysgo.com>
  19. *
  20. * SPDX-License-Identifier: GPL-2.0+
  21. */
  22. /*
  23. * Changelog:
  24. * 0.1 - Newly created file for ext4fs support. Taken from cmd_ext2.c
  25. * file in uboot. Added ext4fs ls load and write support.
  26. */
  27. #include <common.h>
  28. #include <part.h>
  29. #include <config.h>
  30. #include <command.h>
  31. #include <image.h>
  32. #include <linux/ctype.h>
  33. #include <asm/byteorder.h>
  34. #include <ext4fs.h>
  35. #include <linux/stat.h>
  36. #include <malloc.h>
  37. #include <fs.h>
  38. #if defined(CONFIG_CMD_USB) && defined(CONFIG_USB_STORAGE)
  39. #include <usb.h>
  40. #endif
  41. int do_ext4_size(cmd_tbl_t *cmdtp, int flag, int argc,
  42. char *const argv[])
  43. {
  44. return do_size(cmdtp, flag, argc, argv, FS_TYPE_EXT);
  45. }
  46. int do_ext4_load(cmd_tbl_t *cmdtp, int flag, int argc,
  47. char *const argv[])
  48. {
  49. return do_load(cmdtp, flag, argc, argv, FS_TYPE_EXT);
  50. }
  51. int do_ext4_ls(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
  52. {
  53. return do_ls(cmdtp, flag, argc, argv, FS_TYPE_EXT);
  54. }
  55. #if defined(CONFIG_CMD_EXT4_WRITE)
  56. int do_ext4_write(cmd_tbl_t *cmdtp, int flag, int argc,
  57. char *const argv[])
  58. {
  59. return do_save(cmdtp, flag, argc, argv, FS_TYPE_EXT);
  60. }
  61. U_BOOT_CMD(ext4write, 7, 1, do_ext4_write,
  62. "create a file in the root directory",
  63. "<interface> <dev[:part]> <addr> <absolute filename path>\n"
  64. " [sizebytes] [file offset]\n"
  65. " - create a file in / directory");
  66. #endif
  67. U_BOOT_CMD(
  68. ext4size, 4, 0, do_ext4_size,
  69. "determine a file's size",
  70. "<interface> <dev[:part]> <filename>\n"
  71. " - Find file 'filename' from 'dev' on 'interface'\n"
  72. " and determine its size."
  73. );
  74. U_BOOT_CMD(ext4ls, 4, 1, do_ext4_ls,
  75. "list files in a directory (default /)",
  76. "<interface> <dev[:part]> [directory]\n"
  77. " - list files from 'dev' on 'interface' in a 'directory'");
  78. U_BOOT_CMD(ext4load, 7, 0, do_ext4_load,
  79. "load binary file from a Ext4 filesystem",
  80. "<interface> [<dev[:part]> [addr [filename [bytes [pos]]]]]\n"
  81. " - load binary file 'filename' from 'dev' on 'interface'\n"
  82. " to address 'addr' from ext4 filesystem");