3 * Stäubli Faverges - <www.staubli.com>
6 * SPDX-License-Identifier: GPL-2.0+
17 const char *month [] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
22 /*-----------------------------------------------------------------------------
24 *-----------------------------------------------------------------------------
26 int dos_open(char *name)
32 /* We need to suppress the " char around the name */
33 if (name [0] == '"') {
37 if (name [lg - 1] == '"') {
41 /* Open file system */
42 if (fs_init (&fs) < 0) {
46 /* Init the file descriptor */
50 /* find the subdirectory containing the file */
51 if (open_subdir (&file) < 0) {
55 fname = basename (name);
57 /* if we try to open root directory */
59 file.file = file.subdir;
63 /* find the file in the subdir */
65 if (vfat_lookup (&file.subdir,
71 ACCEPT_DIR | ACCEPT_PLAIN | SINGLE | DO_OPEN,
75 printf ("File not found\n");
82 /*-----------------------------------------------------------------------------
84 *-----------------------------------------------------------------------------
86 int dos_read (ulong addr)
90 /* Try to boot a directory ? */
91 if (file.file.dir.attr & (ATTR_DIRECTORY | ATTR_VOLUME)) {
92 printf ("Unable to boot %s !!\n", file.name);
95 while (read < file.file.FileSize) {
96 PRINTF ("read_file (%ld)\n", (file.file.FileSize - read));
101 (file.file.FileSize - read));
102 PRINTF ("read_file -> %d\n", nb);
104 printf ("read error\n");
111 /*-----------------------------------------------------------------------------
113 *-----------------------------------------------------------------------------
122 if ((file.file.dir.attr & ATTR_DIRECTORY) == 0) {
123 printf ("%s: not a directory !!\n", file.name);
127 if ((name = malloc (MAX_VNAMELEN + 1)) == NULL) {
128 PRINTF ("Allcation error\n");
132 while (vfat_lookup (&file.file,
138 ACCEPT_DIR | ACCEPT_PLAIN | MATCH_ANY,
141 /* Display file info */
142 printf ("%3.3s %9d %s %02d %04d %02d:%02d:%02d %s\n",
143 (dir.attr & ATTR_DIRECTORY) ? "dir" : " ",
144 __le32_to_cpu (dir.size),
145 month [DOS_MONTH (&dir) - 1],