3 * Stäubli Faverges - <www.staubli.com>
4 * Pierre AUBERT p.aubert@staubli.com
6 * See file CREDITS for list of people who contributed to this
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
33 const char *month [] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
38 /*-----------------------------------------------------------------------------
40 *-----------------------------------------------------------------------------
42 int dos_open(char *name)
48 /* We need to suppress the " char around the name */
49 if (name [0] == '"') {
53 if (name [lg - 1] == '"') {
57 /* Open file system */
58 if (fs_init (&fs) < 0) {
62 /* Init the file descriptor */
66 /* find the subdirectory containing the file */
67 if (open_subdir (&file) < 0) {
71 fname = basename (name);
73 /* if we try to open root directory */
75 file.file = file.subdir;
79 /* find the file in the subdir */
81 if (vfat_lookup (&file.subdir,
87 ACCEPT_DIR | ACCEPT_PLAIN | SINGLE | DO_OPEN,
91 printf ("File not found\n");
98 /*-----------------------------------------------------------------------------
100 *-----------------------------------------------------------------------------
102 int dos_read (ulong addr)
106 /* Try to boot a directory ? */
107 if (file.file.dir.attr & (ATTR_DIRECTORY | ATTR_VOLUME)) {
108 printf ("Unable to boot %s !!\n", file.name);
111 while (read < file.file.FileSize) {
112 PRINTF ("read_file (%ld)\n", (file.file.FileSize - read));
117 (file.file.FileSize - read));
118 PRINTF ("read_file -> %d\n", nb);
120 printf ("read error\n");
127 /*-----------------------------------------------------------------------------
129 *-----------------------------------------------------------------------------
138 if ((file.file.dir.attr & ATTR_DIRECTORY) == 0) {
139 printf ("%s: not a directory !!\n", file.name);
143 if ((name = malloc (MAX_VNAMELEN + 1)) == NULL) {
144 PRINTF ("Allcation error\n");
148 while (vfat_lookup (&file.file,
154 ACCEPT_DIR | ACCEPT_PLAIN | MATCH_ANY,
157 /* Display file info */
158 printf ("%3.3s %9d %s %02d %04d %02d:%02d:%02d %s\n",
159 (dir.attr & ATTR_DIRECTORY) ? "dir" : " ",
160 __le32_to_cpu (dir.size),
161 month [DOS_MONTH (&dir) - 1],