mirror of
https://github.com/apache/nuttx.git
synced 2026-06-02 01:21:26 +08:00
Fix a bug in initial XIP offset
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1942 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -795,6 +795,9 @@
|
|||||||
include paths for Cygwin-based GCC were being converted to windows
|
include paths for Cygwin-based GCC were being converted to windows
|
||||||
native paths. That causes many problems -- breaking dependencies
|
native paths. That causes many problems -- breaking dependencies
|
||||||
for one.
|
for one.
|
||||||
|
* Fixed an important bug in ROMFS. The initial XIP offset was set
|
||||||
|
incorrectly so if sector zero was read first, there was a bad read.
|
||||||
|
I don't know how it worked before.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1487,6 +1487,9 @@ nuttx-0.4.9 2009-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
|||||||
include paths for Cygwin-based GCC were being converted to windows
|
include paths for Cygwin-based GCC were being converted to windows
|
||||||
native paths. That causes many problems -- breaking dependencies
|
native paths. That causes many problems -- breaking dependencies
|
||||||
for one.
|
for one.
|
||||||
|
* Fixed an important bug in ROMFS. The initial XIP offset was set
|
||||||
|
incorrectly so if sector zero was read first, there was a bad read.
|
||||||
|
I don't know how it worked before.
|
||||||
|
|
||||||
pascal-0.1.3 2009-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
pascal-0.1.3 2009-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
|
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ static const struct block_operations g_bops =
|
|||||||
|
|
||||||
static int rd_open(FAR struct inode *inode)
|
static int rd_open(FAR struct inode *inode)
|
||||||
{
|
{
|
||||||
|
fvdbg("Entry\n");
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,6 +129,7 @@ static int rd_open(FAR struct inode *inode)
|
|||||||
|
|
||||||
static int rd_close(FAR struct inode *inode)
|
static int rd_close(FAR struct inode *inode)
|
||||||
{
|
{
|
||||||
|
fvdbg("Entry\n");
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,11 +145,17 @@ static ssize_t rd_read(FAR struct inode *inode, unsigned char *buffer,
|
|||||||
{
|
{
|
||||||
struct rd_struct_s *dev;
|
struct rd_struct_s *dev;
|
||||||
|
|
||||||
|
fvdbg("sector: %d nsectors: %d sectorsize: %d\n");
|
||||||
|
|
||||||
DEBUGASSERT(inode && inode->i_private);
|
DEBUGASSERT(inode && inode->i_private);
|
||||||
dev = (struct rd_struct_s *)inode->i_private;
|
dev = (struct rd_struct_s *)inode->i_private;
|
||||||
if (start_sector < dev->rd_nsectors &&
|
if (start_sector < dev->rd_nsectors &&
|
||||||
start_sector + nsectors <= dev->rd_nsectors)
|
start_sector + nsectors <= dev->rd_nsectors)
|
||||||
{
|
{
|
||||||
|
fvdbg("Transfer %d bytes from %p\n",
|
||||||
|
nsectors * dev->rd_sectsize,
|
||||||
|
&dev->rd_buffer[start_sector * dev->rd_sectsize]);
|
||||||
|
|
||||||
memcpy(buffer,
|
memcpy(buffer,
|
||||||
&dev->rd_buffer[start_sector * dev->rd_sectsize],
|
&dev->rd_buffer[start_sector * dev->rd_sectsize],
|
||||||
nsectors * dev->rd_sectsize);
|
nsectors * dev->rd_sectsize);
|
||||||
@@ -169,6 +177,8 @@ static ssize_t rd_write(FAR struct inode *inode, const unsigned char *buffer,
|
|||||||
{
|
{
|
||||||
struct rd_struct_s *dev;
|
struct rd_struct_s *dev;
|
||||||
|
|
||||||
|
fvdbg("sector: %d nsectors: %d sectorsize: %d\n");
|
||||||
|
|
||||||
DEBUGASSERT(inode && inode->i_private);
|
DEBUGASSERT(inode && inode->i_private);
|
||||||
dev = (struct rd_struct_s *)inode->i_private;
|
dev = (struct rd_struct_s *)inode->i_private;
|
||||||
if (!dev->rd_writeenabled)
|
if (!dev->rd_writeenabled)
|
||||||
@@ -178,6 +188,10 @@ static ssize_t rd_write(FAR struct inode *inode, const unsigned char *buffer,
|
|||||||
else if (start_sector < dev->rd_nsectors &&
|
else if (start_sector < dev->rd_nsectors &&
|
||||||
start_sector + nsectors <= dev->rd_nsectors)
|
start_sector + nsectors <= dev->rd_nsectors)
|
||||||
{
|
{
|
||||||
|
fvdbg("Transfer %d bytes from %p\n",
|
||||||
|
nsectors * dev->rd_sectsize,
|
||||||
|
&dev->rd_buffer[start_sector * dev->rd_sectsize]);
|
||||||
|
|
||||||
memcpy(&dev->rd_buffer[start_sector * dev->rd_sectsize],
|
memcpy(&dev->rd_buffer[start_sector * dev->rd_sectsize],
|
||||||
buffer,
|
buffer,
|
||||||
nsectors * dev->rd_sectsize);
|
nsectors * dev->rd_sectsize);
|
||||||
@@ -198,6 +212,8 @@ static int rd_geometry(FAR struct inode *inode, struct geometry *geometry)
|
|||||||
{
|
{
|
||||||
struct rd_struct_s *dev;
|
struct rd_struct_s *dev;
|
||||||
|
|
||||||
|
fvdbg("Entry\n");
|
||||||
|
|
||||||
DEBUGASSERT(inode);
|
DEBUGASSERT(inode);
|
||||||
if (geometry)
|
if (geometry)
|
||||||
{
|
{
|
||||||
@@ -211,6 +227,12 @@ static int rd_geometry(FAR struct inode *inode, struct geometry *geometry)
|
|||||||
#endif
|
#endif
|
||||||
geometry->geo_nsectors = dev->rd_nsectors;
|
geometry->geo_nsectors = dev->rd_nsectors;
|
||||||
geometry->geo_sectorsize = dev->rd_sectsize;
|
geometry->geo_sectorsize = dev->rd_sectsize;
|
||||||
|
|
||||||
|
fvdbg("available: TRUE mediachanged: FALSE writeenabled: %s\n",
|
||||||
|
geometry->geo_writeenabled ? "TRUE" : "FALSE");
|
||||||
|
fvdbg("nsectors: %d sectorsize: %d\n",
|
||||||
|
geometry->geo_nsectors, geometry->geo_sectorsize);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@@ -228,6 +250,8 @@ static int rd_ioctl(FAR struct inode *inode, int cmd, unsigned long arg)
|
|||||||
struct rd_struct_s *dev ;
|
struct rd_struct_s *dev ;
|
||||||
void **ppv = (void**)arg;
|
void **ppv = (void**)arg;
|
||||||
|
|
||||||
|
fvdbg("Entry\n");
|
||||||
|
|
||||||
/* Only one ioctl command is supported */
|
/* Only one ioctl command is supported */
|
||||||
|
|
||||||
DEBUGASSERT(inode && inode->i_private);
|
DEBUGASSERT(inode && inode->i_private);
|
||||||
@@ -235,6 +259,8 @@ static int rd_ioctl(FAR struct inode *inode, int cmd, unsigned long arg)
|
|||||||
{
|
{
|
||||||
dev = (struct rd_struct_s *)inode->i_private;
|
dev = (struct rd_struct_s *)inode->i_private;
|
||||||
*ppv = (void*)dev->rd_buffer;
|
*ppv = (void*)dev->rd_buffer;
|
||||||
|
|
||||||
|
fvdbg("ppv: %p\n", *ppv);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,6 +289,8 @@ int romdisk_register(int minor, ubyte *buffer, uint32 nsectors, uint16 sectsize)
|
|||||||
char devname[16];
|
char devname[16];
|
||||||
int ret = -ENOMEM;
|
int ret = -ENOMEM;
|
||||||
|
|
||||||
|
fvdbg("buffer: %p nsectors: %d sectsize: %d\n", buffer, nsectors, sectsize);
|
||||||
|
|
||||||
/* Sanity check */
|
/* Sanity check */
|
||||||
|
|
||||||
#ifdef CONFIG_DEBUG
|
#ifdef CONFIG_DEBUG
|
||||||
|
|||||||
+63
-2
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* rm/romfs/fs_romfs.h
|
* rm/romfs/fs_romfs.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
*
|
*
|
||||||
* References: Linux/Documentation/filesystems/romfs.txt
|
* References: Linux/Documentation/filesystems/romfs.txt
|
||||||
@@ -141,6 +141,8 @@ static int romfs_open(FAR struct file *filep, const char *relpath,
|
|||||||
struct romfs_file_s *rf;
|
struct romfs_file_s *rf;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
fvdbg("Open '%s'\n", relpath);
|
||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
|
|
||||||
DEBUGASSERT(filep->f_priv == NULL && filep->f_inode != NULL);
|
DEBUGASSERT(filep->f_priv == NULL && filep->f_inode != NULL);
|
||||||
@@ -159,6 +161,7 @@ static int romfs_open(FAR struct file *filep, const char *relpath,
|
|||||||
ret = romfs_checkmount(rm);
|
ret = romfs_checkmount(rm);
|
||||||
if (ret != OK)
|
if (ret != OK)
|
||||||
{
|
{
|
||||||
|
fdbg("romfs_checkmount failed: %d\n", ret);
|
||||||
goto errout_with_semaphore;
|
goto errout_with_semaphore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,6 +171,7 @@ static int romfs_open(FAR struct file *filep, const char *relpath,
|
|||||||
|
|
||||||
if ((oflags & O_WRONLY) != 0 || (oflags & O_RDONLY) == 0)
|
if ((oflags & O_WRONLY) != 0 || (oflags & O_RDONLY) == 0)
|
||||||
{
|
{
|
||||||
|
fdbg("Only O_RDONLY supported\n");
|
||||||
ret = -EACCES;
|
ret = -EACCES;
|
||||||
goto errout_with_semaphore;
|
goto errout_with_semaphore;
|
||||||
}
|
}
|
||||||
@@ -181,6 +185,8 @@ static int romfs_open(FAR struct file *filep, const char *relpath,
|
|||||||
ret = romfs_finddirentry(rm, &dirinfo, relpath);
|
ret = romfs_finddirentry(rm, &dirinfo, relpath);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
fdbg("Failed to find directory directory entry for '%s': %d\n",
|
||||||
|
relpath, ret);
|
||||||
goto errout_with_semaphore;
|
goto errout_with_semaphore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,6 +199,7 @@ static int romfs_open(FAR struct file *filep, const char *relpath,
|
|||||||
/* It is a directory */
|
/* It is a directory */
|
||||||
|
|
||||||
ret = -EISDIR;
|
ret = -EISDIR;
|
||||||
|
fdbg("'%s' is a directory\n", relpath);
|
||||||
goto errout_with_semaphore;
|
goto errout_with_semaphore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,13 +207,14 @@ static int romfs_open(FAR struct file *filep, const char *relpath,
|
|||||||
# warning "Missing check for privileges based on inode->i_mode"
|
# warning "Missing check for privileges based on inode->i_mode"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Create an instance of the file private date to describe the opened
|
/* Create an instance of the file private data to describe the opened
|
||||||
* file.
|
* file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
rf = (struct romfs_file_s *)zalloc(sizeof(struct romfs_file_s));
|
rf = (struct romfs_file_s *)zalloc(sizeof(struct romfs_file_s));
|
||||||
if (!rf)
|
if (!rf)
|
||||||
{
|
{
|
||||||
|
fdbg("Failed to allocate private data\n", ret);
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto errout_with_semaphore;
|
goto errout_with_semaphore;
|
||||||
}
|
}
|
||||||
@@ -224,6 +232,7 @@ static int romfs_open(FAR struct file *filep, const char *relpath,
|
|||||||
&rf->rf_startoffset);
|
&rf->rf_startoffset);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
fdbg("Failed to locate start of file data: %d\n", ret);
|
||||||
goto errout_with_semaphore;
|
goto errout_with_semaphore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,6 +241,7 @@ static int romfs_open(FAR struct file *filep, const char *relpath,
|
|||||||
ret = romfs_fileconfigure(rm, rf);
|
ret = romfs_fileconfigure(rm, rf);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
fdbg("Failed configure buffering: %d\n", ret);
|
||||||
goto errout_with_semaphore;
|
goto errout_with_semaphore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,6 +278,8 @@ static int romfs_close(FAR struct file *filep)
|
|||||||
struct romfs_file_s *rf;
|
struct romfs_file_s *rf;
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
|
|
||||||
|
fvdbg("Closing\n");
|
||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
|
|
||||||
DEBUGASSERT(filep->f_priv != NULL && filep->f_inode != NULL);
|
DEBUGASSERT(filep->f_priv != NULL && filep->f_inode != NULL);
|
||||||
@@ -320,6 +332,8 @@ static ssize_t romfs_read(FAR struct file *filep, char *buffer, size_t buflen)
|
|||||||
int sectorndx;
|
int sectorndx;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
fvdbg("Read %d bytes from offset %d\n", buflen, filep->f_pos);
|
||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
|
|
||||||
DEBUGASSERT(filep->f_priv != NULL && filep->f_inode != NULL);
|
DEBUGASSERT(filep->f_priv != NULL && filep->f_inode != NULL);
|
||||||
@@ -337,6 +351,7 @@ static ssize_t romfs_read(FAR struct file *filep, char *buffer, size_t buflen)
|
|||||||
ret = romfs_checkmount(rm);
|
ret = romfs_checkmount(rm);
|
||||||
if (ret != OK)
|
if (ret != OK)
|
||||||
{
|
{
|
||||||
|
fdbg("romfs_checkmount failed: %d\n", ret);
|
||||||
goto errout_with_semaphore;
|
goto errout_with_semaphore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -381,9 +396,11 @@ static ssize_t romfs_read(FAR struct file *filep, char *buffer, size_t buflen)
|
|||||||
|
|
||||||
/* Read all of the sectors directly into user memory */
|
/* Read all of the sectors directly into user memory */
|
||||||
|
|
||||||
|
fvdbg("Read %d sectors starting with %d\n", nsectors, sector);
|
||||||
ret = romfs_hwread(rm, userbuffer, sector, nsectors);
|
ret = romfs_hwread(rm, userbuffer, sector, nsectors);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
fdbg("romfs_hwread failed: %d\n", ret);
|
||||||
goto errout_with_semaphore;
|
goto errout_with_semaphore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -397,9 +414,11 @@ static ssize_t romfs_read(FAR struct file *filep, char *buffer, size_t buflen)
|
|||||||
* it is already there then all is well.
|
* it is already there then all is well.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
fvdbg("Read sector %d\n", sector);
|
||||||
ret = romfs_filecacheread(rm, rf, sector);
|
ret = romfs_filecacheread(rm, rf, sector);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
fdbg("romfs_filecacheread failed: %d\n", ret);
|
||||||
goto errout_with_semaphore;
|
goto errout_with_semaphore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -419,6 +438,7 @@ static ssize_t romfs_read(FAR struct file *filep, char *buffer, size_t buflen)
|
|||||||
sector++;
|
sector++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fvdbg("Return %d bytes from sector offset %d\n", bytesread, sectorndx);
|
||||||
memcpy(userbuffer, &rf->rf_buffer[sectorndx], bytesread);
|
memcpy(userbuffer, &rf->rf_buffer[sectorndx], bytesread);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -449,6 +469,8 @@ static off_t romfs_seek(FAR struct file *filep, off_t offset, int whence)
|
|||||||
ssize_t position;
|
ssize_t position;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
fvdbg("Seek to offset: %d whence: %d\n", offset, whence);
|
||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
|
|
||||||
DEBUGASSERT(filep->f_priv != NULL && filep->f_inode != NULL);
|
DEBUGASSERT(filep->f_priv != NULL && filep->f_inode != NULL);
|
||||||
@@ -481,6 +503,7 @@ static off_t romfs_seek(FAR struct file *filep, off_t offset, int whence)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
fdbg("Whence is invalid: %d\n", whence);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -490,6 +513,7 @@ static off_t romfs_seek(FAR struct file *filep, off_t offset, int whence)
|
|||||||
ret = romfs_checkmount(rm);
|
ret = romfs_checkmount(rm);
|
||||||
if (ret != OK)
|
if (ret != OK)
|
||||||
{
|
{
|
||||||
|
fdbg("romfs_checkmount failed: %d\n", ret);
|
||||||
goto errout_with_semaphore;
|
goto errout_with_semaphore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -505,6 +529,7 @@ static off_t romfs_seek(FAR struct file *filep, off_t offset, int whence)
|
|||||||
/* Set file position and return success */
|
/* Set file position and return success */
|
||||||
|
|
||||||
filep->f_pos = position;
|
filep->f_pos = position;
|
||||||
|
fvdbg("New file position: %d\n", filep->f_pos);
|
||||||
|
|
||||||
romfs_semgive(rm);
|
romfs_semgive(rm);
|
||||||
return OK;
|
return OK;
|
||||||
@@ -524,6 +549,8 @@ static int romfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||||||
struct romfs_file_s *rf;
|
struct romfs_file_s *rf;
|
||||||
FAR void **ppv = (FAR void**)arg;
|
FAR void **ppv = (FAR void**)arg;
|
||||||
|
|
||||||
|
fvdbg("cmd: %d arg: %08lx\n", cmd, arg);
|
||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
|
|
||||||
DEBUGASSERT(filep->f_priv != NULL && filep->f_inode != NULL);
|
DEBUGASSERT(filep->f_priv != NULL && filep->f_inode != NULL);
|
||||||
@@ -547,6 +574,7 @@ static int romfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fdbg("Invalid cmd: %d \n", cmd);
|
||||||
return -ENOTTY;
|
return -ENOTTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -565,6 +593,8 @@ static int romfs_opendir(struct inode *mountpt, const char *relpath,
|
|||||||
struct romfs_dirinfo_s dirinfo;
|
struct romfs_dirinfo_s dirinfo;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
fvdbg("relpath: '%s'\n", relpath);
|
||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
|
|
||||||
DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL);
|
DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL);
|
||||||
@@ -579,6 +609,7 @@ static int romfs_opendir(struct inode *mountpt, const char *relpath,
|
|||||||
ret = romfs_checkmount(rm);
|
ret = romfs_checkmount(rm);
|
||||||
if (ret != OK)
|
if (ret != OK)
|
||||||
{
|
{
|
||||||
|
fdbg("romfs_checkmount failed: %d\n", ret);
|
||||||
goto errout_with_semaphore;
|
goto errout_with_semaphore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -587,6 +618,7 @@ static int romfs_opendir(struct inode *mountpt, const char *relpath,
|
|||||||
ret = romfs_finddirentry(rm, &dirinfo, relpath);
|
ret = romfs_finddirentry(rm, &dirinfo, relpath);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
fdbg("Failed to find directory '%s': %d\n", relpath, ret);
|
||||||
goto errout_with_semaphore;
|
goto errout_with_semaphore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -596,6 +628,7 @@ static int romfs_opendir(struct inode *mountpt, const char *relpath,
|
|||||||
{
|
{
|
||||||
/* The entry is not a directory */
|
/* The entry is not a directory */
|
||||||
|
|
||||||
|
fdbg("'%s' is not a directory: %d\n", relpath);
|
||||||
ret = -ENOTDIR;
|
ret = -ENOTDIR;
|
||||||
goto errout_with_semaphore;
|
goto errout_with_semaphore;
|
||||||
}
|
}
|
||||||
@@ -627,6 +660,8 @@ static int romfs_readdir(struct inode *mountpt, struct internal_dir_s *dir)
|
|||||||
uint32 size;
|
uint32 size;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
fvdbg("Entry\n");
|
||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
|
|
||||||
DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL);
|
DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL);
|
||||||
@@ -641,6 +676,7 @@ static int romfs_readdir(struct inode *mountpt, struct internal_dir_s *dir)
|
|||||||
ret = romfs_checkmount(rm);
|
ret = romfs_checkmount(rm);
|
||||||
if (ret != OK)
|
if (ret != OK)
|
||||||
{
|
{
|
||||||
|
fdbg("romfs_checkmount failed: %d\n", ret);
|
||||||
goto errout_with_semaphore;
|
goto errout_with_semaphore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -656,6 +692,7 @@ static int romfs_readdir(struct inode *mountpt, struct internal_dir_s *dir)
|
|||||||
* special error -ENOENT
|
* special error -ENOENT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
fdbg("End of directory\n");
|
||||||
ret = -ENOENT;
|
ret = -ENOENT;
|
||||||
goto errout_with_semaphore;
|
goto errout_with_semaphore;
|
||||||
}
|
}
|
||||||
@@ -666,6 +703,7 @@ static int romfs_readdir(struct inode *mountpt, struct internal_dir_s *dir)
|
|||||||
&next, &info, &size);
|
&next, &info, &size);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
fdbg("romfs_parsedirentry failed: %d\n", ret);
|
||||||
goto errout_with_semaphore;
|
goto errout_with_semaphore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -674,6 +712,7 @@ static int romfs_readdir(struct inode *mountpt, struct internal_dir_s *dir)
|
|||||||
ret = romfs_parsefilename(rm, dir->u.romfs.fr_curroffset, dir->fd_dir.d_name);
|
ret = romfs_parsefilename(rm, dir->u.romfs.fr_curroffset, dir->fd_dir.d_name);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
fdbg("romfs_parsefilename failed: %d\n", ret);
|
||||||
goto errout_with_semaphore;
|
goto errout_with_semaphore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -712,6 +751,8 @@ static int romfs_rewinddir(struct inode *mountpt, struct internal_dir_s *dir)
|
|||||||
struct romfs_mountpt_s *rm;
|
struct romfs_mountpt_s *rm;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
fvdbg("Entry\n");
|
||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
|
|
||||||
DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL);
|
DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL);
|
||||||
@@ -750,16 +791,20 @@ static int romfs_bind(FAR struct inode *blkdriver, const void *data,
|
|||||||
struct romfs_mountpt_s *rm;
|
struct romfs_mountpt_s *rm;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
fvdbg("Entry\n");
|
||||||
|
|
||||||
/* Open the block driver */
|
/* Open the block driver */
|
||||||
|
|
||||||
if (!blkdriver || !blkdriver->u.i_bops)
|
if (!blkdriver || !blkdriver->u.i_bops)
|
||||||
{
|
{
|
||||||
|
fdbg("No block driver/ops\n");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blkdriver->u.i_bops->open &&
|
if (blkdriver->u.i_bops->open &&
|
||||||
blkdriver->u.i_bops->open(blkdriver) != OK)
|
blkdriver->u.i_bops->open(blkdriver) != OK)
|
||||||
{
|
{
|
||||||
|
fdbg("No open method\n");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -768,6 +813,7 @@ static int romfs_bind(FAR struct inode *blkdriver, const void *data,
|
|||||||
rm = (struct romfs_mountpt_s *)zalloc(sizeof(struct romfs_mountpt_s));
|
rm = (struct romfs_mountpt_s *)zalloc(sizeof(struct romfs_mountpt_s));
|
||||||
if (!rm)
|
if (!rm)
|
||||||
{
|
{
|
||||||
|
fdbg("Failed to allocate mountpoint structure\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -784,6 +830,7 @@ static int romfs_bind(FAR struct inode *blkdriver, const void *data,
|
|||||||
ret = romfs_hwconfigure(rm);
|
ret = romfs_hwconfigure(rm);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
fdbg("romfs_hwconfigure failed: %d\n", ret);
|
||||||
goto errout_with_sem;
|
goto errout_with_sem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -794,6 +841,7 @@ static int romfs_bind(FAR struct inode *blkdriver, const void *data,
|
|||||||
ret = romfs_fsconfigure(rm);
|
ret = romfs_fsconfigure(rm);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
fdbg("romfs_fsconfigure failed: %d\n", ret);
|
||||||
goto errout_with_buffer;
|
goto errout_with_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -828,10 +876,14 @@ static int romfs_unbind(void *handle, FAR struct inode **blkdriver)
|
|||||||
struct romfs_mountpt_s *rm = (struct romfs_mountpt_s*)handle;
|
struct romfs_mountpt_s *rm = (struct romfs_mountpt_s*)handle;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
fvdbg("Entry\n");
|
||||||
|
|
||||||
|
#ifdef CONFIG_DEBUG
|
||||||
if (!rm)
|
if (!rm)
|
||||||
{
|
{
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Check if there are sill any files opened on the filesystem. */
|
/* Check if there are sill any files opened on the filesystem. */
|
||||||
|
|
||||||
@@ -841,6 +893,7 @@ static int romfs_unbind(void *handle, FAR struct inode **blkdriver)
|
|||||||
{
|
{
|
||||||
/* We cannot unmount now.. there are open files */
|
/* We cannot unmount now.. there are open files */
|
||||||
|
|
||||||
|
fdbg("There are open files\n");
|
||||||
ret = -EBUSY;
|
ret = -EBUSY;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -897,6 +950,8 @@ static int romfs_statfs(struct inode *mountpt, struct statfs *buf)
|
|||||||
struct romfs_mountpt_s *rm;
|
struct romfs_mountpt_s *rm;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
fvdbg("Entry\n");
|
||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
|
|
||||||
DEBUGASSERT(mountpt && mountpt->i_private);
|
DEBUGASSERT(mountpt && mountpt->i_private);
|
||||||
@@ -911,6 +966,7 @@ static int romfs_statfs(struct inode *mountpt, struct statfs *buf)
|
|||||||
ret = romfs_checkmount(rm);
|
ret = romfs_checkmount(rm);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
fdbg("romfs_checkmount failed: %d\n", ret);
|
||||||
goto errout_with_semaphore;
|
goto errout_with_semaphore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -951,6 +1007,8 @@ static int romfs_stat(struct inode *mountpt, const char *relpath, struct stat *b
|
|||||||
struct romfs_dirinfo_s dirinfo;
|
struct romfs_dirinfo_s dirinfo;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
fvdbg("Entry\n");
|
||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
|
|
||||||
DEBUGASSERT(mountpt && mountpt->i_private);
|
DEBUGASSERT(mountpt && mountpt->i_private);
|
||||||
@@ -965,6 +1023,7 @@ static int romfs_stat(struct inode *mountpt, const char *relpath, struct stat *b
|
|||||||
ret = romfs_checkmount(rm);
|
ret = romfs_checkmount(rm);
|
||||||
if (ret != OK)
|
if (ret != OK)
|
||||||
{
|
{
|
||||||
|
fdbg("romfs_checkmount failed: %d\n", ret);
|
||||||
goto errout_with_semaphore;
|
goto errout_with_semaphore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -976,6 +1035,7 @@ static int romfs_stat(struct inode *mountpt, const char *relpath, struct stat *b
|
|||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
fvdbg("Failed to find directory: %d\n", ret);
|
||||||
goto errout_with_semaphore;
|
goto errout_with_semaphore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1004,6 +1064,7 @@ static int romfs_stat(struct inode *mountpt, const char *relpath, struct stat *b
|
|||||||
{
|
{
|
||||||
/* Otherwise, pretend like the unsupported node does not exist */
|
/* Otherwise, pretend like the unsupported node does not exist */
|
||||||
|
|
||||||
|
fvdbg("Unsupported inode: %d\n", dirinfo.rd_next);
|
||||||
ret = -ENOENT;
|
ret = -ENOENT;
|
||||||
goto errout_with_semaphore;
|
goto errout_with_semaphore;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* rm/romfs/fs_romfsutil.h
|
* rm/romfs/fs_romfsutil.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
*
|
*
|
||||||
* References: Linux/Documentation/filesystems/romfs.txt
|
* References: Linux/Documentation/filesystems/romfs.txt
|
||||||
@@ -445,6 +445,10 @@ int romfs_filecacheread(struct romfs_mountpt_s *rm, struct romfs_file_s *rf, uin
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
fvdbg("sector: %d cached: %d sectorsize: %d XIP base: %p buffer: %p\n",
|
||||||
|
sector, rf->rf_cachesector, rm->rm_hwsectorsize,
|
||||||
|
rm->rm_xipbase, rf->rf_buffer);
|
||||||
|
|
||||||
/* rf->rf_cachesector holds the current sector that is buffer in or referenced
|
/* rf->rf_cachesector holds the current sector that is buffer in or referenced
|
||||||
* by rf->rf_buffer. If the requested sector is the same as this sector,
|
* by rf->rf_buffer. If the requested sector is the same as this sector,
|
||||||
* then we do nothing.
|
* then we do nothing.
|
||||||
@@ -461,14 +465,17 @@ int romfs_filecacheread(struct romfs_mountpt_s *rm, struct romfs_file_s *rf, uin
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
rf->rf_buffer = rm->rm_xipbase + sector * rm->rm_hwsectorsize;
|
rf->rf_buffer = rm->rm_xipbase + sector * rm->rm_hwsectorsize;
|
||||||
|
fvdbg("XIP buffer: %p\n", rf->rf_buffer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* In non-XIP mode, we will have to read the new sector.*/
|
/* In non-XIP mode, we will have to read the new sector.*/
|
||||||
|
|
||||||
|
fvdbg("Calling romfs_hwread\n");
|
||||||
ret = romfs_hwread(rm, rf->rf_buffer, sector, 1);
|
ret = romfs_hwread(rm, rf->rf_buffer, sector, 1);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
fdbg("romfs_hwread failed: %d\n", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -623,7 +630,7 @@ int romfs_fileconfigure(struct romfs_mountpt_s *rm, struct romfs_file_s *rf)
|
|||||||
/* We'll put a valid address in rf_buffer just in case. */
|
/* We'll put a valid address in rf_buffer just in case. */
|
||||||
|
|
||||||
rf->rf_cachesector = 0;
|
rf->rf_cachesector = 0;
|
||||||
rf->rf_buffer = rm->rm_xipbase + rf->rf_startoffset;
|
rf->rf_buffer = rm->rm_xipbase;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user