fs.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  11. {
  12. return do_size(cmdtp, flag, argc, argv, FS_TYPE_ANY);
  13. }
  14. U_BOOT_CMD(
  15. size, 4, 0, do_size_wrapper,
  16. "determine a file's size",
  17. "<interface> <dev[:part]> <filename>\n"
  18. " - Find file 'filename' from 'dev' on 'interface'\n"
  19. " and determine its size."
  20. );
  21. static int do_load_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
  22. char * const argv[])
  23. {
  24. return do_load(cmdtp, flag, argc, argv, FS_TYPE_ANY);
  25. }
  26. U_BOOT_CMD(
  27. load, 7, 0, do_load_wrapper,
  28. "load binary file from a filesystem",
  29. "<interface> [<dev[:part]> [<addr> [<filename> [bytes [pos]]]]]\n"
  30. " - Load binary file 'filename' from partition 'part' on device\n"
  31. " type 'interface' instance 'dev' to address 'addr' in memory.\n"
  32. " 'bytes' gives the size to load in bytes.\n"
  33. " If 'bytes' is 0 or omitted, the file is read until the end.\n"
  34. " 'pos' gives the file byte position to start reading from.\n"
  35. " If 'pos' is 0 or omitted, the file is read from the start."
  36. )
  37. static int do_save_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
  38. char * const argv[])
  39. {
  40. return do_save(cmdtp, flag, argc, argv, FS_TYPE_ANY);
  41. }
  42. U_BOOT_CMD(
  43. save, 7, 0, do_save_wrapper,
  44. "save file to a filesystem",
  45. "<interface> <dev[:part]> <addr> <filename> bytes [pos]\n"
  46. " - Save binary file 'filename' to partition 'part' on device\n"
  47. " type 'interface' instance 'dev' from addr 'addr' in memory.\n"
  48. " 'bytes' gives the size to save in bytes and is mandatory.\n"
  49. " 'pos' gives the file byte position to start writing to.\n"
  50. " If 'pos' is 0 or omitted, the file is written from the start."
  51. )
  52. static int do_ls_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
  53. char * const argv[])
  54. {
  55. return do_ls(cmdtp, flag, argc, argv, FS_TYPE_ANY);
  56. }
  57. U_BOOT_CMD(
  58. ls, 4, 1, do_ls_wrapper,
  59. "list files in a directory (default /)",
  60. "<interface> [<dev[:part]> [directory]]\n"
  61. " - List files in directory 'directory' of partition 'part' on\n"
  62. " device type 'interface' instance 'dev'."
  63. )
  64. static int do_ln_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
  65. char * const argv[])
  66. {
  67. return do_ln(cmdtp, flag, argc, argv, FS_TYPE_ANY);
  68. }
  69. U_BOOT_CMD(
  70. ln, 5, 1, do_ln_wrapper,
  71. "Create a symbolic link",
  72. "<interface> <dev[:part]> target linkname\n"
  73. " - create a symbolic link to 'target' with the name 'linkname' on\n"
  74. " device type 'interface' instance 'dev'."
  75. )
  76. static int do_fstype_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
  77. char * const argv[])
  78. {
  79. return do_fs_type(cmdtp, flag, argc, argv);
  80. }
  81. U_BOOT_CMD(
  82. fstype, 4, 1, do_fstype_wrapper,
  83. "Look up a filesystem type",
  84. "<interface> <dev>:<part>\n"
  85. "- print filesystem type\n"
  86. "fstype <interface> <dev>:<part> <varname>\n"
  87. "- set environment variable to filesystem type\n"
  88. );