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,
28 #if defined(CONFIG_CMD_FDOS)
34 const char *month
[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
39 /*-----------------------------------------------------------------------------
41 *-----------------------------------------------------------------------------
43 int dos_open(char *name
)
49 /* We need to suppress the " char around the name */
50 if (name
[0] == '"') {
54 if (name
[lg
- 1] == '"') {
58 /* Open file system */
59 if (fs_init (&fs
) < 0) {
63 /* Init the file descriptor */
67 /* find the subdirectory containing the file */
68 if (open_subdir (&file
) < 0) {
72 fname
= basename (name
);
74 /* if we try to open root directory */
76 file
.file
= file
.subdir
;
80 /* find the file in the subdir */
82 if (vfat_lookup (&file
.subdir
,
88 ACCEPT_DIR
| ACCEPT_PLAIN
| SINGLE
| DO_OPEN
,
92 printf ("File not found\n");
99 /*-----------------------------------------------------------------------------
101 *-----------------------------------------------------------------------------
103 int dos_read (ulong addr
)
107 /* Try to boot a directory ? */
108 if (file
.file
.dir
.attr
& (ATTR_DIRECTORY
| ATTR_VOLUME
)) {
109 printf ("Unable to boot %s !!\n", file
.name
);
112 while (read
< file
.file
.FileSize
) {
113 PRINTF ("read_file (%ld)\n", (file
.file
.FileSize
- read
));
118 (file
.file
.FileSize
- read
));
119 PRINTF ("read_file -> %d\n", nb
);
121 printf ("read error\n");
128 /*-----------------------------------------------------------------------------
130 *-----------------------------------------------------------------------------
139 if ((file
.file
.dir
.attr
& ATTR_DIRECTORY
) == 0) {
140 printf ("%s: not a directory !!\n", file
.name
);
144 if ((name
= malloc (MAX_VNAMELEN
+ 1)) == NULL
) {
145 PRINTF ("Allcation error\n");
149 while (vfat_lookup (&file
.file
,
155 ACCEPT_DIR
| ACCEPT_PLAIN
| MATCH_ANY
,
158 /* Display file info */
159 printf ("%3.3s %9d %s %02d %04d %02d:%02d:%02d %s\n",
160 (dir
.attr
& ATTR_DIRECTORY
) ? "dir" : " ",
161 __le32_to_cpu (dir
.size
),
162 month
[DOS_MONTH (&dir
) - 1],