cmd_fs.c 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.
  3. *
  4. * Inspired by cmd_ext_common.c, cmd_fat.c.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms and conditions of the GNU General Public License,
  8. * version 2, as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include <common.h>
  19. #include <command.h>
  20. #include <fs.h>
  21. static int do_size_wrapper(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  22. {
  23. return do_size(cmdtp, flag, argc, argv, FS_TYPE_ANY);
  24. }
  25. U_BOOT_CMD(
  26. size, 4, 0, do_size_wrapper,
  27. "determine a file's size",
  28. "<interface> <dev[:part]> <filename>\n"
  29. " - Find file 'filename' from 'dev' on 'interface'\n"
  30. " and determine its size."
  31. );
  32. static int do_load_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
  33. char * const argv[])
  34. {
  35. return do_load(cmdtp, flag, argc, argv, FS_TYPE_ANY);
  36. }
  37. U_BOOT_CMD(
  38. load, 7, 0, do_load_wrapper,
  39. "load binary file from a filesystem",
  40. "<interface> [<dev[:part]> [<addr> [<filename> [bytes [pos]]]]]\n"
  41. " - Load binary file 'filename' from partition 'part' on device\n"
  42. " type 'interface' instance 'dev' to address 'addr' in memory.\n"
  43. " 'bytes' gives the size to load in bytes.\n"
  44. " If 'bytes' is 0 or omitted, the file is read until the end.\n"
  45. " 'pos' gives the file byte position to start reading from.\n"
  46. " If 'pos' is 0 or omitted, the file is read from the start."
  47. )
  48. static int do_save_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
  49. char * const argv[])
  50. {
  51. return do_save(cmdtp, flag, argc, argv, FS_TYPE_ANY);
  52. }
  53. U_BOOT_CMD(
  54. save, 7, 0, do_save_wrapper,
  55. "save file to a filesystem",
  56. "<interface> <dev[:part]> <addr> <filename> bytes [pos]\n"
  57. " - Save binary file 'filename' to partition 'part' on device\n"
  58. " type 'interface' instance 'dev' from addr 'addr' in memory.\n"
  59. " 'bytes' gives the size to save in bytes and is mandatory.\n"
  60. " 'pos' gives the file byte position to start writing to.\n"
  61. " If 'pos' is 0 or omitted, the file is written from the start."
  62. )
  63. static int do_ls_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
  64. char * const argv[])
  65. {
  66. return do_ls(cmdtp, flag, argc, argv, FS_TYPE_ANY);
  67. }
  68. U_BOOT_CMD(
  69. ls, 4, 1, do_ls_wrapper,
  70. "list files in a directory (default /)",
  71. "<interface> [<dev[:part]> [directory]]\n"
  72. " - List files in directory 'directory' of partition 'part' on\n"
  73. " device type 'interface' instance 'dev'."
  74. )
  75. static int do_fstype_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
  76. char * const argv[])
  77. {
  78. return do_fs_type(cmdtp, flag, argc, argv);
  79. }
  80. U_BOOT_CMD(
  81. fstype, 4, 1, do_fstype_wrapper,
  82. "Look up a filesystem type",
  83. "<interface> <dev>:<part>\n"
  84. "- print filesystem type\n"
  85. "fstype <interface> <dev>:<part> <varname>\n"
  86. "- set environment variable to filesystem type\n"
  87. );