fs.c 3.3 KB

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