*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
sector_t sector;
cluster_offset_t offset;
uint8_t *buf;
- cluster_t ret;
+ cluster_t ret = 0;
cluster_t old_value;
uint8_t fat;
DBG("current sector offset %d size %d\n",
file->offset, file->dirent->size);
- if (file->offset > file->dirent->size) {
+ if (file->offset > (offset_t) file->dirent->size) {
printf ("file offset %d larger than size %d\n",
file->offset, file->dirent->size);
return 0xffffffff;
DBG("\treset to start of file %08x\n", file->cluster);
}
- if (file->cluster_offset + bytes_per_cluster <= file->offset) {
+ if ((offset_t) (file->cluster_offset + bytes_per_cluster) <= file->offset) {
cluster_t cluster_distance;
cluster_offset = sector_offset / sectors_per_cluster;
if (!file->busy)
continue;
if (file->dirent == dirent) {
- if (file->cluster_offset >= dirent->size) {
+ if (file->cluster_offset >= (offset_t) dirent->size) {
file->cluster_offset = 0;
file->cluster = dirent->cluster;
}
DBG ("\tfirst cluster %08x have %d need %d\n", first_cluster, have_clusters, need_clusters);
if (have_clusters != need_clusters) {
- if (file->cluster && size > file->cluster_offset) {
+ if (file->cluster && (offset_t) size > file->cluster_offset) {
cluster_t offset_clusters = (file->cluster_offset + bytes_per_cluster) / bytes_per_cluster;
cluster_t extra_clusters = need_clusters - offset_clusters;
cluster_t next_cluster;
static void
_ao_fat_root_init(uint8_t *dent, char name[11], uint8_t attr)
{
+ (void) attr;
memset(dent, '\0', 0x20);
memmove(dent, name, 11);
/*
* ao_fat_full
*
- * Returns TRUE if the filesystem cannot take
+ * Returns true if the filesystem cannot take
* more data
*/
_ao_fat_open(char name[11], uint8_t mode)
{
uint16_t entry = 0;
- struct ao_fat_dirent dirent;
+ static struct ao_fat_dirent dirent;
int8_t status;
if (_ao_fat_setup() != AO_FAT_FILESYSTEM_SUCCESS)
offset = file->offset & SECTOR_MASK;
sector = _ao_fat_current_sector(file);
if (sector == 0xffffffff) {
- printf ("invalid sector at offset %d\n", file->offset);
return NULL;
}
buf = _ao_fat_sector_get(sector);
if (!buf)
- printf ("sector get failed. Sector %d. Partition end %d\n", sector, partition_end);
+ return NULL;
if (offset + len < SECTOR_SIZE)
*this_time = len;
else
goto done;
}
- if (file->offset + len > file->dirent->size)
+ if (file->offset + len > (offset_t) file->dirent->size)
len = file->dirent->size - file->offset;
if (len < 0)
while (len) {
buf = ao_fat_map_current(file, len, &offset, &this_time);
if (!buf) {
- printf ("map_current failed\n");
ret = -AO_FAT_EIO;
break;
}
goto done;
}
- if (file->offset + len > file->dirent->size) {
+ if (file->offset + len > (offset_t) file->dirent->size) {
ret = _ao_fat_set_size(file, file->offset + len);
if (ret < 0)
goto done;
while (len) {
buf = ao_fat_map_current(file, len, &offset, &this_time);
if (!buf) {
- printf ("map_current failed\n");
ret = -AO_FAT_EIO;
break;
}
ao_fat_unlink(char name[11])
{
uint16_t entry = 0;
- struct ao_fat_dirent dirent;
+ static struct ao_fat_dirent dirent;
int8_t ret;
ao_mutex_get(&ao_fat_mutex);
int8_t
ao_fat_rename(char old[11], char new[11])
{
+ (void) old;
+ (void) new;
return -AO_FAT_EIO;
}
ao_fat_list_cmd(void)
{
uint16_t entry = 0;
- struct ao_fat_dirent dirent;
+ static struct ao_fat_dirent dirent;
int i;
int8_t status;
putchar('.');
for (; i < 11; i++)
putchar(dirent.name[i]);
- for (i = 0; i < NUM_FAT_ATTR; i++)
+ for (i = 0; i < (int) NUM_FAT_ATTR; i++)
putchar (dirent.attr & ao_fat_attr[i].bit ? ao_fat_attr[i].label : ' ');
printf (" @%08x %d\n", dirent.cluster, dirent.size);
}
printf ("readdir failed: %d\n", status);
}
-static uint8_t
+static void
ao_fat_parse_name(char name[11])
{
uint8_t c;
static void
ao_fat_dump_cmd(void)
{
- char name[11];
+ static char name[11];
int8_t fd;
int cnt, i;
- char buf[32];
+ static char buf[32];
ao_fat_parse_name(name);
if (name[0] == '\0') {
static void
ao_fat_write_cmd(void)
{
- char name[11];
+ static char name[11];
int8_t fd;
- int cnt, i;
- char buf[64];
char c;
int status;
ao_cmd_status = ao_cmd_syntax_error;
return;
}
-
+
fd = ao_fat_open(name, AO_FAT_OPEN_READ);
if (fd < 0) {
printf ("Open failed: %d\n", fd);
ao_fat_init(void)
{
ao_bufio_init();
+#if FAT_COMMANDS
ao_cmd_register(&ao_fat_cmds[0]);
+#endif
}