Misc. changes to support FAT32 fileysystem

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@219 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2007-05-13 20:20:07 +00:00
parent d8df31f3d8
commit b6335e8ef7
5 changed files with 39 additions and 29 deletions

View File

@ -129,5 +129,6 @@
development board (untested) development board (untested)
* Added support for block devices. * Added support for block devices.
* Simulated target now exports a VFAT filesystem * Simulated target now exports a VFAT filesystem
* Begin support for VFAT filesystem (not yet functional)
* Added mount() and umount() * Added mount() and umount()
* Started m68322 * Started m68322

View File

@ -8,7 +8,7 @@
<tr align="center" bgcolor="#e4e4e4"> <tr align="center" bgcolor="#e4e4e4">
<td> <td>
<h1><big><font color="#3c34ec"><i>NuttX RTOS</i></font></big></h1> <h1><big><font color="#3c34ec"><i>NuttX RTOS</i></font></big></h1>
<p>Last Updated: May 12, 2007</p> <p>Last Updated: May 13, 2007</p>
</td> </td>
</tr> </tr>
</table> </table>
@ -508,9 +508,9 @@ Other memory:
development board (untested) development board (untested)
* Added support for block devices. * Added support for block devices.
* Simulated target now exports a VFAT filesystem * Simulated target now exports a VFAT filesystem
* Begin support for VFAT filesystem (not yet functional)
* Added mount() and umount() * Added mount() and umount()
* Started m68322 * Started m68322
* Added support for the NXP 214x processor on the mcu123.com lpc214x
</pre></ul> </pre></ul>
<table width ="100%"> <table width ="100%">

View File

@ -60,13 +60,13 @@
* Private Function Prototypes * Private Function Prototypes
****************************************************************************/ ****************************************************************************/
static int up_open(FAR struct file *filp); static int up_open(FAR struct inode *inode);
static int up_close(FAR struct file *filp); static int up_close(FAR struct inode *inode);
static ssize_t up_read(FAR struct file *filp, char *buffer, static ssize_t up_read(FAR struct inode *inode, unsigned char *buffer,
size_t start_sector, size_t nsectors); size_t start_sector, size_t nsectors);
static ssize_t up_write(FAR struct file *filp, const char *buffer, static ssize_t up_write(FAR struct inode *inode, const unsigned char *buffer,
size_t start_sector, size_t nsectors); size_t start_sector, size_t nsectors);
static size_t up_geometry(FAR struct file *filp, struct geometry *geometry); static int up_geometry(FAR struct inode *inode, struct geometry *geometry);
/**************************************************************************** /****************************************************************************
* Private Data * Private Data
@ -92,7 +92,7 @@ static const struct block_operations g_bops =
* *
****************************************************************************/ ****************************************************************************/
static int up_open(FAR struct file *filp) static int up_open(FAR struct inode *inode)
{ {
return OK; return OK;
} }
@ -104,7 +104,7 @@ static int up_open(FAR struct file *filp)
* *
****************************************************************************/ ****************************************************************************/
static int up_close(FAR struct file *filp) static int up_close(FAR struct inode *inode)
{ {
return OK; return OK;
} }
@ -116,10 +116,9 @@ static int up_close(FAR struct file *filp)
* *
****************************************************************************/ ****************************************************************************/
static ssize_t up_read(FAR struct file *filp, char *buffer, static ssize_t up_read(FAR struct inode *inode, unsigned char *buffer,
size_t start_sector, size_t nsectors) size_t start_sector, size_t nsectors)
{ {
struct inode *inode = filp->f_inode;
if (inode) if (inode)
{ {
char *src = inode->i_private; char *src = inode->i_private;
@ -143,10 +142,9 @@ static ssize_t up_read(FAR struct file *filp, char *buffer,
* *
****************************************************************************/ ****************************************************************************/
static ssize_t up_write(FAR struct file *filp, const char *buffer, static ssize_t up_write(FAR struct inode *inode, const unsigned char *buffer,
size_t start_sector, size_t nsectors) size_t start_sector, size_t nsectors)
{ {
struct inode *inode = filp->f_inode;
if (inode) if (inode)
{ {
char *dest = inode->i_private; char *dest = inode->i_private;
@ -170,12 +168,13 @@ static ssize_t up_write(FAR struct file *filp, const char *buffer,
* *
****************************************************************************/ ****************************************************************************/
static size_t up_geometry(FAR struct file *filp, struct geometry *geometry) static int up_geometry(FAR struct inode *inode, struct geometry *geometry)
{ {
struct inode *inode = filp->f_inode;
if (geometry) if (geometry)
{ {
geometry->geo_available = (inode->i_private != NULL); geometry->geo_available = (inode->i_private != NULL);
geometry->geo_mediachanged = FALSE;
geometry->geo_writeenabled = TRUE;
geometry->geo_nsectors = NSECTORS; geometry->geo_nsectors = NSECTORS;
geometry->geo_sectorsize = LOGICAL_SECTOR_SIZE; geometry->geo_sectorsize = LOGICAL_SECTOR_SIZE;
return OK; return OK;

View File

@ -198,7 +198,8 @@ CONFIG_PREALLOC_TIMERS=8
# #
# FAT filesystem configuration # FAT filesystem configuration
# CONFIG_FAT - Enable FAT filesystem support # CONFIG_FS_FAT - Enable FAT filesystem support
# CONFIG_FAT_SECTORSIZE - Max supported sector size
CONFIG_FS_FAT=y CONFIG_FS_FAT=y
# #

View File

@ -81,25 +81,30 @@ struct file_operations
struct geometry struct geometry
{ {
boolean geo_available; /* False if the device is not available */ boolean geo_available; /* TRUE: The device is vailable */
boolean geo_mediachanged; /* TRUE: The media has changed since last query */
boolean geo_writeenabled; /* TRUE: It is okay to write to this device */
size_t geo_nsectors; /* Number of sectors on the device */ size_t geo_nsectors; /* Number of sectors on the device */
size_t geo_sectorsize; /* Size of one sector */ size_t geo_sectorsize; /* Size of one sector */
}; };
/* This structure is provided by block devices when they register with the /* This structure is provided by block devices when they register with the
* system. It is used by file systems to perform filesystem transfers. * system. It is used by file systems to perform filesystem transfers. It
* differs from the normal driver vtable in several ways -- most notably in
* that it deals in struct inode vs. struct filep.
*/ */
struct inode;
struct block_operations struct block_operations
{ {
int (*open)(FAR struct file *filp); int (*open)(FAR struct inode *inode);
int (*close)(FAR struct file *filp); int (*close)(FAR struct inode *inode);
ssize_t (*read)(FAR struct file *filp, char *buffer, ssize_t (*read)(FAR struct inode *inode, unsigned char *buffer,
size_t start_sector, size_t nsectors); size_t start_sector, size_t nsectors);
ssize_t (*write)(FAR struct file *filp, const char *buffer, ssize_t (*write)(FAR struct inode *inode, const unsigned char *buffer,
size_t start_sector, size_t nsectors); size_t start_sector, size_t nsectors);
size_t (*geometry)(FAR struct file *filp, struct geometry *geometry); int (*geometry)(FAR struct inode *inode, struct geometry *geometry);
int (*ioctl)(FAR struct file *, int, unsigned long); int (*ioctl)(FAR struct inode *inode, int cmd, unsigned long arg);
}; };
/* This structure is provided by a filesystem to describe a mount point. /* This structure is provided by a filesystem to describe a mount point.
@ -135,6 +140,10 @@ struct mountpt_operations
int (*bind)(FAR struct inode *blkdriver, const void *data, void **handle); int (*bind)(FAR struct inode *blkdriver, const void *data, void **handle);
int (*unbind)(void *handle); int (*unbind)(void *handle);
/* NOTE: More operations will be needed here to support: disk usage stats, stat(),
* sync(), unlink(), mkdir(), chmod(), rename(), etc.
*/
}; };
/* This structure represents one inode in the Nuttx psuedo-file system */ /* This structure represents one inode in the Nuttx psuedo-file system */