diff --git a/TODO b/TODO index f2d3a6128c3..057463a298a 100644 --- a/TODO +++ b/TODO @@ -37,7 +37,10 @@ o USB o Libraries o File system -- Add some concept like mount points to handle mounted "real" filesystems. +- Add disk usage stats, stat(), sync(), unlink(), mkdir(), chmod(), rename(), +etc. +- FAT32: long file names + o Console Output diff --git a/arch/sim/src/up_blockdevice.c b/arch/sim/src/up_blockdevice.c index 273cad950d9..0753561bc52 100644 --- a/arch/sim/src/up_blockdevice.c +++ b/arch/sim/src/up_blockdevice.c @@ -129,7 +129,7 @@ static ssize_t up_read(FAR struct inode *inode, unsigned char *buffer, memcpy(buffer, &src[start_sector*LOGICAL_SECTOR_SIZE], nsectors*LOGICAL_SECTOR_SIZE); - return OK; + return nsectors; } } return -EINVAL; @@ -155,7 +155,7 @@ static ssize_t up_write(FAR struct inode *inode, const unsigned char *buffer, memcpy(&dest[start_sector*LOGICAL_SECTOR_SIZE], buffer, nsectors*LOGICAL_SECTOR_SIZE); - return OK; + return nsectors; } } return -EINVAL; diff --git a/examples/README.txt b/examples/README.txt index 6d3d14e8b3a..3d595dd193e 100644 --- a/examples/README.txt +++ b/examples/README.txt @@ -13,6 +13,10 @@ examples/nsh shell-like application. With some additional development, NSH will someday be a great NuttX application debugger. +examples/mount + + This contains a simple test of filesystem mountpoints. + examples/null This is the do nothing application. It is only used for bringing diff --git a/fs/fs_fat32.c b/fs/fs_fat32.c index 35870b3ae55..9edd320c4d0 100644 --- a/fs/fs_fat32.c +++ b/fs/fs_fat32.c @@ -480,8 +480,6 @@ static int fat_checkbootrecord(struct fat_mountpt_s *fs) if (MBR_GETSIGNATURE(fs->fs_buffer) != 0xaa55 || MBR_GETROOTENTCNT(fs->fs_buffer) != 0 || - MBR_GETFATSZ16(fs->fs_buffer) != 0 || - MBR_GETTOTSEC16(fs->fs_buffer) != 0 || MBR_GETBYTESPERSEC(fs->fs_buffer) != fs->fs_hwsectorsize) { return -ENODEV; @@ -495,7 +493,12 @@ static int fat_checkbootrecord(struct fat_mountpt_s *fs) * Determine the number of sectors in a FAT. */ - fs->fs_fatsize = MBR_GETFATSZ32(fs->fs_buffer); + fs->fs_fatsize = MBR_GETFATSZ16(fs->fs_buffer); /* Should be zero */ + if (!fs->fs_fatsize) + { + fs->fs_fatsize = MBR_GETFATSZ32(fs->fs_buffer); + } + if (fs->fs_fatsize >= fs->fs_hwnsectors) { return -ENODEV; @@ -503,7 +506,12 @@ static int fat_checkbootrecord(struct fat_mountpt_s *fs) /* Get the total number of sectors on the volume. */ - fs->fs_fattotsec = MBR_GETTOTSEC32(fs->fs_buffer); + fs->fs_fattotsec = MBR_GETTOTSEC16(fs->fs_buffer); /* Should be zero */ + if (!fs->fs_fattotsec) + { + fs->fs_fattotsec = MBR_GETTOTSEC32(fs->fs_buffer); + } + if (fs->fs_fattotsec > fs->fs_hwnsectors) { return -ENODEV;