ext4.c 2.5 KB

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