fs.c 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.
  3. *
  4. * Inspired by cmd_ext_common.c, cmd_fat.c.
  5. *
  6. * SPDX-License-Identifier: GPL-2.0
  7. */
  8. #include <common.h>
  9. #include <command.h>
  10. #include <fs.h>
  11. #include <efi_loader.h>
  12. static int do_size_wrapper(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  13. {
  14. return do_size(cmdtp, flag, argc, argv, FS_TYPE_ANY);
  15. }
  16. U_BOOT_CMD(
  17. size, 4, 0, do_size_wrapper,
  18. "determine a file's size",
  19. "<interface> <dev[:part]> <filename>\n"
  20. " - Find file 'filename' from 'dev' on 'interface'\n"
  21. " and determine its size."
  22. );
  23. static int do_load_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
  24. char * const argv[])
  25. {
  26. efi_set_bootdev(argv[1], (argc > 2) ? argv[2] : "",
  27. (argc > 4) ? argv[4] : "");
  28. return do_load(cmdtp, flag, argc, argv, FS_TYPE_ANY);
  29. }
  30. U_BOOT_CMD(
  31. load, 7, 0, do_load_wrapper,
  32. "load binary file from a filesystem",
  33. "<interface> [<dev[:part]> [<addr> [<filename> [bytes [pos]]]]]\n"
  34. " - Load binary file 'filename' from partition 'part' on device\n"
  35. " type 'interface' instance 'dev' to address 'addr' in memory.\n"
  36. " 'bytes' gives the size to load in bytes.\n"
  37. " If 'bytes' is 0 or omitted, the file is read until the end.\n"
  38. " 'pos' gives the file byte position to start reading from.\n"
  39. " If 'pos' is 0 or omitted, the file is read from the start."
  40. )
  41. static int do_save_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
  42. char * const argv[])
  43. {
  44. return do_save(cmdtp, flag, argc, argv, FS_TYPE_ANY);
  45. }
  46. U_BOOT_CMD(
  47. save, 7, 0, do_save_wrapper,
  48. "save file to a filesystem",
  49. "<interface> <dev[:part]> <addr> <filename> bytes [pos]\n"
  50. " - Save binary file 'filename' to partition 'part' on device\n"
  51. " type 'interface' instance 'dev' from addr 'addr' in memory.\n"
  52. " 'bytes' gives the size to save in bytes and is mandatory.\n"
  53. " 'pos' gives the file byte position to start writing to.\n"
  54. " If 'pos' is 0 or omitted, the file is written from the start."
  55. )
  56. static int do_ls_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
  57. char * const argv[])
  58. {
  59. return do_ls(cmdtp, flag, argc, argv, FS_TYPE_ANY);
  60. }
  61. U_BOOT_CMD(
  62. ls, 4, 1, do_ls_wrapper,
  63. "list files in a directory (default /)",
  64. "<interface> [<dev[:part]> [directory]]\n"
  65. " - List files in directory 'directory' of partition 'part' on\n"
  66. " device type 'interface' instance 'dev'."
  67. )
  68. static int do_fstype_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
  69. char * const argv[])
  70. {
  71. return do_fs_type(cmdtp, flag, argc, argv);
  72. }
  73. U_BOOT_CMD(
  74. fstype, 4, 1, do_fstype_wrapper,
  75. "Look up a filesystem type",
  76. "<interface> <dev>:<part>\n"
  77. "- print filesystem type\n"
  78. "fstype <interface> <dev>:<part> <varname>\n"
  79. "- set environment variable to filesystem type\n"
  80. );