nuttx/fs: Fix some spacing and alignment issues

This commit is contained in:
Gregory Nutt
2015-10-11 11:39:29 -06:00
parent 185b941c27
commit c70987e551
51 changed files with 568 additions and 539 deletions
+17 -16
View File
@@ -229,7 +229,7 @@ static int fat_open(FAR struct file *filep, FAR const char *relpath,
/* It would be an error if we are asked to create it exclusively */
if ((oflags & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL))
if ((oflags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))
{
/* Already exists -- can't create it exclusively */
@@ -256,7 +256,7 @@ static int fat_open(FAR struct file *filep, FAR const char *relpath,
* access is ignored.
*/
if ((oflags & (O_TRUNC|O_WRONLY)) == (O_TRUNC|O_WRONLY))
if ((oflags & (O_TRUNC | O_WRONLY)) == (O_TRUNC | O_WRONLY))
{
/* Truncate the file to zero length */
@@ -314,7 +314,7 @@ static int fat_open(FAR struct file *filep, FAR const char *relpath,
* file.
*/
ff = (struct fat_file_s *)kmm_zalloc(sizeof(struct fat_file_s));
ff = (FAR struct fat_file_s *)kmm_zalloc(sizeof(struct fat_file_s));
if (!ff)
{
ret = -ENOMEM;
@@ -323,7 +323,7 @@ static int fat_open(FAR struct file *filep, FAR const char *relpath,
/* Create a file buffer to support partial sector accesses */
ff->ff_buffer = (uint8_t*)fat_io_alloc(fs->fs_hwsectorsize);
ff->ff_buffer = (FAR uint8_t *)fat_io_alloc(fs->fs_hwsectorsize);
if (!ff->ff_buffer)
{
ret = -ENOMEM;
@@ -366,7 +366,7 @@ static int fat_open(FAR struct file *filep, FAR const char *relpath,
/* In write/append mode, we need to set the file pointer to the end of the file */
if ((oflags & (O_APPEND|O_WRONLY)) == (O_APPEND|O_WRONLY))
if ((oflags & (O_APPEND | O_WRONLY)) == (O_APPEND | O_WRONLY))
{
off_t offset = fat_seek(filep, ff->ff_size, SEEK_SET);
if (offset < 0)
@@ -482,7 +482,7 @@ static ssize_t fat_read(FAR struct file *filep, FAR char *buffer,
unsigned int nsectors;
size_t bytesleft;
int32_t cluster;
FAR uint8_t *userbuffer = (uint8_t*)buffer;
FAR uint8_t *userbuffer = (FAR uint8_t *)buffer;
int sectorindex;
int ret;
bool force_indirect = false;
@@ -710,7 +710,7 @@ static ssize_t fat_write(FAR struct file *filep, FAR const char *buffer,
unsigned int byteswritten;
unsigned int writesize;
unsigned int nsectors;
FAR uint8_t *userbuffer = (uint8_t*)buffer;
FAR uint8_t *userbuffer = (FAR uint8_t *)buffer;
int sectorindex;
int ret;
bool force_indirect = false;
@@ -970,7 +970,7 @@ fat_write_restart:
*/
memcpy(&ff->ff_buffer[sectorindex], userbuffer, writesize);
ff->ff_bflags |= (FFBUFF_DIRTY|FFBUFF_VALID|FFBUFF_MODIFIED);
ff->ff_bflags |= (FFBUFF_DIRTY | FFBUFF_VALID | FFBUFF_MODIFIED);
}
/* Set up for the next write */
@@ -1119,7 +1119,7 @@ static off_t fat_seek(FAR struct file *filep, off_t offset, int whence)
*/
clustersize = fs->fs_fatsecperclus * fs->fs_hwsectorsize;
for (;;)
for (; ; )
{
/* Skip over clusters prior to the one containing
* the requested position.
@@ -1436,7 +1436,7 @@ static int fat_dup(FAR const struct file *oldp, FAR struct file *newp)
* dup'ed file.
*/
newff = (struct fat_file_s *)kmm_malloc(sizeof(struct fat_file_s));
newff = (FAR struct fat_file_s *)kmm_malloc(sizeof(struct fat_file_s));
if (!newff)
{
ret = -ENOMEM;
@@ -1445,7 +1445,7 @@ static int fat_dup(FAR const struct file *oldp, FAR struct file *newp)
/* Create a file buffer to support partial sector accesses */
newff->ff_buffer = (uint8_t*)fat_io_alloc(fs->fs_hwsectorsize);
newff->ff_buffer = (FAR uint8_t *)fat_io_alloc(fs->fs_hwsectorsize);
if (!newff->ff_buffer)
{
ret = -ENOMEM;
@@ -1873,7 +1873,7 @@ static int fat_bind(FAR struct inode *blkdriver, FAR const void *data,
return ret;
}
*handle = (void*)fs;
*handle = (FAR void *)fs;
fat_semgive(fs);
return OK;
}
@@ -1889,7 +1889,7 @@ static int fat_bind(FAR struct inode *blkdriver, FAR const void *data,
static int fat_unbind(FAR void *handle, FAR struct inode **blkdriver,
unsigned int flags)
{
FAR struct fat_mountpt_s *fs = (FAR struct fat_mountpt_s*)handle;
FAR struct fat_mountpt_s *fs = (FAR struct fat_mountpt_s *)handle;
if (!fs)
{
@@ -2525,7 +2525,8 @@ static int fat_stat(FAR struct inode *mountpt, FAR const char *relpath,
{
/* It's directory name of the mount point */
buf->st_mode = S_IFDIR|S_IROTH|S_IRGRP|S_IRUSR|S_IWOTH|S_IWGRP|S_IWUSR;
buf->st_mode = S_IFDIR | S_IROTH | S_IRGRP | S_IRUSR | S_IWOTH |
S_IWGRP | S_IWUSR;
ret = OK;
goto errout_with_semaphore;
}
@@ -2544,10 +2545,10 @@ static int fat_stat(FAR struct inode *mountpt, FAR const char *relpath,
* by everyone but may be writeable by no-one.
*/
buf->st_mode = S_IROTH|S_IRGRP|S_IRUSR;
buf->st_mode = S_IROTH | S_IRGRP | S_IRUSR;
if ((attribute & FATATTR_READONLY) == 0)
{
buf->st_mode |= S_IWOTH|S_IWGRP|S_IWUSR;
buf->st_mode |= S_IWOTH | S_IWGRP | S_IWUSR;
}
/* We will report only types file or directory */
+4 -2
View File
@@ -128,8 +128,10 @@ static int fat_attrib(const char *path, fat_attrib_t *retattrib,
/* Set or clear any bits as requested */
newattributes &= ~(clearbits & (FATATTR_READONLY|FATATTR_HIDDEN|FATATTR_SYSTEM|FATATTR_ARCHIVE));
newattributes |= (setbits & (FATATTR_READONLY|FATATTR_HIDDEN|FATATTR_SYSTEM|FATATTR_ARCHIVE));
newattributes &= ~(clearbits & (FATATTR_READONLY | FATATTR_HIDDEN |
FATATTR_SYSTEM | FATATTR_ARCHIVE));
newattributes |= (setbits & (FATATTR_READONLY | FATATTR_HIDDEN |
FATATTR_SYSTEM | FATATTR_ARCHIVE));
/* Did any thingchange? */
+103 -103
View File
@@ -271,7 +271,7 @@ static inline int fat_parsesfname(const char **path,
/* Loop until the name is successfully parsed or an error occurs */
endndx = 8;
for (;;)
for (; ; )
{
/* Get the next byte from the path */
@@ -279,7 +279,7 @@ static inline int fat_parsesfname(const char **path,
/* Check if this the last byte in this node of the name */
if ((ch == '\0' || ch == '/') && ndx != 0 )
if ((ch == '\0' || ch == '/') && ndx != 0)
{
/* Return the accumulated NT flags and the terminating character */
@@ -348,12 +348,12 @@ static inline int fat_parsesfname(const char **path,
goto errout;
}
/* So far, only upper case in the name*/
/* So far, only upper case in the name */
namecase = FATCASE_UPPER;
#endif
/* Clear lower case name bit in mask*/
/* Clear lower case name bit in mask */
ntlcenable &= ~FATNTRES_LCNAME;
}
@@ -369,7 +369,7 @@ static inline int fat_parsesfname(const char **path,
goto errout;
}
/* So far, only upper case in the extension*/
/* So far, only upper case in the extension */
extcase = FATCASE_UPPER;
#endif
@@ -415,7 +415,7 @@ static inline int fat_parsesfname(const char **path,
goto errout;
}
/* So far, only lower case in the name*/
/* So far, only lower case in the name */
namecase = FATCASE_LOWER;
#endif
@@ -436,7 +436,7 @@ static inline int fat_parsesfname(const char **path,
goto errout;
}
/* So far, only lower case in the extension*/
/* So far, only lower case in the extension */
extcase = FATCASE_LOWER;
#endif
@@ -503,7 +503,7 @@ static inline int fat_parselfname(const char **path,
/* Loop until the name is successfully parsed or an error occurs */
for (;;)
for (; ; )
{
/* Get the next byte from the path */
@@ -511,7 +511,7 @@ static inline int fat_parselfname(const char **path,
/* Check if this the last byte in this node of the name */
if ((ch == '\0' || ch == '/') && ndx != 0 )
if ((ch == '\0' || ch == '/') && ndx != 0)
{
/* Null terminate the string */
@@ -594,8 +594,8 @@ static inline int fat_createalias(struct fat_dirinfo_s *dirinfo)
/* First, let's decide what is name and what is extension */
len = strlen((char*)dirinfo->fd_lfname);
ext = strrchr((char*)dirinfo->fd_lfname, '.');
len = strlen((FAR char *)dirinfo->fd_lfname);
ext = strrchr((FAR char *)dirinfo->fd_lfname, '.');
if (ext)
{
ptrdiff_t tmp;
@@ -604,7 +604,7 @@ static inline int fat_createalias(struct fat_dirinfo_s *dirinfo)
* beginning of the string is then the name length.
*/
tmp = ext - (char*)dirinfo->fd_lfname;
tmp = ext - (FAR char *)dirinfo->fd_lfname;
namechars = tmp;
/* And the rest, excluding the '.' is the extension. */
@@ -656,7 +656,7 @@ static inline int fat_createalias(struct fat_dirinfo_s *dirinfo)
}
else
{
src = (char*)dirinfo->fd_lfname;
src = (FAR char *)dirinfo->fd_lfname;
}
/* Then copy the name and extension, handling upper case conversions and
@@ -666,7 +666,7 @@ static inline int fat_createalias(struct fat_dirinfo_s *dirinfo)
ndx = 0; /* Position to write the next name character */
endndx = 6; /* Maximum index before we write ~! and switch to the extension */
for (;;)
for (; ; )
{
/* Get the next byte from the path. Break out of the loop if we
* encounter the end of null-terminated the long file name string.
@@ -991,7 +991,7 @@ static int fat_findsfnentry(struct fat_mountpt_s *fs,
* the matching short name
*/
for (;;)
for (; ; )
{
/* Read the next sector into memory */
@@ -1017,7 +1017,7 @@ static int fat_findsfnentry(struct fat_mountpt_s *fs,
if (direntry[DIR_NAME] != DIR0_EMPTY &&
!(DIR_GETATTRIBUTES(direntry) & FATATTR_VOLUMEID) &&
!memcmp(&direntry[DIR_NAME], dirinfo->fd_name, DIR_MAXFNAME) )
!memcmp(&direntry[DIR_NAME], dirinfo->fd_name, DIR_MAXFNAME))
{
/* Yes.. Return success */
@@ -1085,7 +1085,7 @@ static bool fat_cmplfnchunk(uint8_t *chunk, const uint8_t *substr, int nchunk)
* should match the ASCII code.
*/
wch = (wchar_t)fat_getuint16((uint8_t*)chunk);
wch = (wchar_t)fat_getuint16((FAR uint8_t *)chunk);
if ((wch & 0xff) != (wchar_t)ch)
{
return false;
@@ -1130,7 +1130,7 @@ static bool fat_cmplfname(const uint8_t *direntry, const uint8_t *substr)
* terminator).
*/
len = strlen((char*)substr) + 1;
len = strlen((FAR char *)substr) + 1;
/* Check bytes 1-5 */
@@ -1186,7 +1186,7 @@ static inline int fat_findlfnentry(struct fat_mountpt_s *fs,
* LDIR_MAXFNAME+1 we do not have to check the length of the string).
*/
namelen = strlen((char*)dirinfo->fd_lfname);
namelen = strlen((FAR char *)dirinfo->fd_lfname);
DEBUGASSERT(namelen <= LDIR_MAXFNAME+1);
/* How many LFN directory entries are we expecting? */
@@ -1219,7 +1219,7 @@ static inline int fat_findlfnentry(struct fat_mountpt_s *fs,
* the match shore name
*/
for (;;)
for (; ; )
{
/* Read the next sector into memory */
@@ -1406,7 +1406,7 @@ static inline int fat_allocatesfnentry(struct fat_mountpt_s *fs,
/* Then search for a free short file name directory entry */
for (;;)
for (; ; )
{
/* Read the directory sector into fs_buffer */
@@ -1518,7 +1518,7 @@ static inline int fat_allocatelfnentry(struct fat_mountpt_s *fs,
*/
needed = nentries;
for (;;)
for (; ; )
{
/* Read the directory sector into fs_buffer */
@@ -1613,111 +1613,111 @@ static inline int fat_getsfname(uint8_t *direntry, char *buffer,
unsigned int buflen)
{
#ifdef CONFIG_FAT_LCNAMES
uint8_t ntflags;
uint8_t ntflags;
#endif
int ch;
int ndx;
int ch;
int ndx;
/* Check if we will be doing upper to lower case conversions */
/* Check if we will be doing upper to lower case conversions */
#ifdef CONFIG_FAT_LCNAMES
ntflags = DIR_GETNTRES(direntry);
ntflags = DIR_GETNTRES(direntry);
#endif
/* Reserve a byte for the NUL terminator */
/* Reserve a byte for the NUL terminator */
buflen--;
buflen--;
/* Get the 8-byte filename */
/* Get the 8-byte filename */
for (ndx = 0; ndx < 8 && buflen > 0; ndx++)
{
/* Get the next filename character from the directory entry */
for (ndx = 0; ndx < 8 && buflen > 0; ndx++)
{
/* Get the next filename character from the directory entry */
ch = direntry[ndx];
ch = direntry[ndx];
/* Any space (or ndx==8) terminates the filename */
/* Any space (or ndx==8) terminates the filename */
if (ch == ' ')
{
break;
}
if (ch == ' ')
{
break;
}
/* In this version, we never write 0xe5 in the directory filenames
* (because we do not handle any character sets where 0xe5 is valid
* in a filaname), but we could encounted this in a filesystem
* written by some other system
*/
/* In this version, we never write 0xe5 in the directory filenames
* (because we do not handle any character sets where 0xe5 is valid
* in a filaname), but we could encounted this in a filesystem
* written by some other system
*/
if (ndx == 0 && ch == DIR0_E5)
{
ch = 0xe5;
}
if (ndx == 0 && ch == DIR0_E5)
{
ch = 0xe5;
}
/* Check if we should perform upper to lower case conversion
* of the (whole) filename.
*/
/* Check if we should perform upper to lower case conversion
* of the (whole) filename.
*/
#ifdef CONFIG_FAT_LCNAMES
if (ntflags & FATNTRES_LCNAME && isupper(ch))
{
ch = tolower(ch);
}
if (ntflags & FATNTRES_LCNAME && isupper(ch))
{
ch = tolower(ch);
}
#endif
/* Copy the next character into the filename */
/* Copy the next character into the filename */
*buffer++ = ch;
buflen--;
}
*buffer++ = ch;
buflen--;
}
/* Check if there is an extension */
/* Check if there is an extension */
if (direntry[8] != ' ' && buflen > 0)
{
/* Yes, output the dot before the extension */
if (direntry[8] != ' ' && buflen > 0)
{
/* Yes, output the dot before the extension */
*buffer++ = '.';
buflen--;
*buffer++ = '.';
buflen--;
/* Then output the (up to) 3 character extension */
/* Then output the (up to) 3 character extension */
for (ndx = 8; ndx < 11 && buflen > 0; ndx++)
{
/* Get the next extensions character from the directory entry */
for (ndx = 8; ndx < 11 && buflen > 0; ndx++)
{
/* Get the next extensions character from the directory entry */
ch = direntry[DIR_NAME + ndx];
ch = direntry[DIR_NAME + ndx];
/* Any space (or ndx==11) terminates the extension */
/* Any space (or ndx==11) terminates the extension */
if (ch == ' ')
{
break;
}
if (ch == ' ')
{
break;
}
/* Check if we should perform upper to lower case conversion
* of the (whole) filename.
*/
/* Check if we should perform upper to lower case conversion
* of the (whole) filename.
*/
#ifdef CONFIG_FAT_LCNAMES
if (ntflags & FATNTRES_LCEXT && isupper(ch))
{
ch = tolower(ch);
}
if (ntflags & FATNTRES_LCEXT && isupper(ch))
{
ch = tolower(ch);
}
#endif
/* Copy the next character into the filename */
/* Copy the next character into the filename */
*buffer++ = ch;
buflen--;
}
}
*buffer++ = ch;
buflen--;
}
}
/* Put a null terminator at the end of the filename. We don't have to
* check if there is room because we reserved a byte for the NUL
* terminator at the beginning of this function.
*/
/* Put a null terminator at the end of the filename. We don't have to
* check if there is room because we reserved a byte for the NUL
* terminator at the beginning of this function.
*/
*buffer = '\0';
return OK;
*buffer = '\0';
return OK;
}
/****************************************************************************
@@ -1798,7 +1798,7 @@ static inline int fat_getlfname(struct fat_mountpt_s *fs, struct fs_dirent_s *di
/* Loop until the whole file name has been transferred */
for (;;)
for (; ; )
{
/* Get the string offset associated with the "last" entry. */
@@ -2028,7 +2028,7 @@ static int fat_putlfname(struct fat_mountpt_s *fs,
* LDIR_MAXLFNCHARS (13).
*/
namelen = strlen((char*)dirinfo->fd_lfname);
namelen = strlen((FAR char *)dirinfo->fd_lfname);
DEBUGASSERT(namelen <= LDIR_MAXFNAME+1);
/* How many LFN directory entries do we need to write? */
@@ -2093,7 +2093,7 @@ static int fat_putlfname(struct fat_mountpt_s *fs,
/* Now loop, writing each long file name entry */
for (;;)
for (; ; )
{
/* Get the string offset associated with the directory entry. */
@@ -2314,7 +2314,7 @@ int fat_finddirentry(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo,
/* Now loop until the directory entry corresponding to the path is found */
for (;;)
for (; ; )
{
/* Convert the next the path segment name into the kind of name that
* we would see in the directory entry.
@@ -2441,7 +2441,7 @@ int fat_allocatedirentry(struct fat_mountpt_s *fs,
* or until to fail to extend the directory cluster chain.
*/
for (;;)
for (; ; )
{
/* Can this cluster chain be extended */
@@ -2520,9 +2520,9 @@ int fat_allocatedirentry(struct fat_mountpt_s *fs,
return cluster;
}
/* Flush out any cached data in fs_buffer.. we are going to use
* it to initialize the new directory cluster.
*/
/* Flush out any cached data in fs_buffer.. we are going to use
* it to initialize the new directory cluster.
*/
ret = fat_fscacheflush(fs);
if (ret < 0)
@@ -2591,7 +2591,7 @@ int fat_freedirentry(struct fat_mountpt_s *fs, struct fat_dirseq_s *seq)
* and for the single short file name entry.
*/
for (;;)
for (; ; )
{
/* Read the directory sector into the sector cache */
@@ -2896,7 +2896,7 @@ int fat_remove(struct fat_mountpt_s *fs, const char *relpath, bool directory)
* (2) the directory is found to be empty, or (3) some error occurs.
*/
for (;;)
for (; ; )
{
unsigned int subdirindex;
uint8_t *subdirentry;
+39 -38
View File
@@ -322,9 +322,9 @@ uint32_t fat_getuint32(uint8_t *ptr)
* Name: fat_putuint16
****************************************************************************/
void fat_putuint16(uint8_t *ptr, uint16_t value16)
void fat_putuint16(FAR uint8_t *ptr, uint16_t value16)
{
uint8_t *val = (uint8_t*)&value16;
FAR uint8_t *val = (FAR uint8_t *)&value16;
#ifdef CONFIG_ENDIAN_BIG
/* If the target is big-endian then the bytes always have to be swapped so
@@ -348,9 +348,9 @@ void fat_putuint16(uint8_t *ptr, uint16_t value16)
* Name: fat_putuint32
****************************************************************************/
void fat_putuint32(uint8_t *ptr, uint32_t value32)
void fat_putuint32(FAR uint8_t *ptr, uint32_t value32)
{
uint16_t *val = (uint16_t*)&value32;
FAR uint16_t *val = (FAR uint16_t *)&value32;
#ifdef CONFIG_ENDIAN_BIG
/* If the target is big-endian then the bytes always have to be swapped so
@@ -554,7 +554,7 @@ int fat_mount(struct fat_mountpt_s *fs, bool writeable)
/* Allocate a buffer to hold one hardware sector */
fs->fs_buffer = (uint8_t*)fat_io_alloc(fs->fs_hwsectorsize);
fs->fs_buffer = (FAR uint8_t *)fat_io_alloc(fs->fs_hwsectorsize);
if (!fs->fs_buffer)
{
ret = -ENOMEM;
@@ -585,12 +585,12 @@ int fat_mount(struct fat_mountpt_s *fs, bool writeable)
* indexed by 16x the partition number.
*/
int i;
for (i = 0; i < 4; i++)
{
/* Check if the partition exists and, if so, get the bootsector for that
* partition and see if we can find the boot record there.
*/
int i;
for (i = 0; i < 4; i++)
{
/* Check if the partition exists and, if so, get the bootsector for that
* partition and see if we can find the boot record there.
*/
uint8_t part = PART_GETTYPE(i, fs->fs_buffer);
fvdbg("Partition %d, offset %d, type %d\n", i, PART_ENTRY(i), part);
@@ -748,7 +748,7 @@ int fat_hwread(struct fat_mountpt_s *fs, uint8_t *buffer, off_t sector,
unsigned int nsectors)
{
int ret = -ENODEV;
if (fs && fs->fs_blkdriver )
if (fs && fs->fs_blkdriver)
{
struct inode *inode = fs->fs_blkdriver;
if (inode && inode->u.i_bops && inode->u.i_bops->read)
@@ -781,7 +781,7 @@ int fat_hwwrite(struct fat_mountpt_s *fs, uint8_t *buffer, off_t sector,
unsigned int nsectors)
{
int ret = -ENODEV;
if (fs && fs->fs_blkdriver )
if (fs && fs->fs_blkdriver)
{
struct inode *inode = fs->fs_blkdriver;
if (inode && inode->u.i_bops && inode->u.i_bops->write)
@@ -811,7 +811,7 @@ int fat_hwwrite(struct fat_mountpt_s *fs, uint8_t *buffer, off_t sector,
*
****************************************************************************/
off_t fat_cluster2sector(struct fat_mountpt_s *fs, uint32_t cluster )
off_t fat_cluster2sector(FAR struct fat_mountpt_s *fs, uint32_t cluster)
{
cluster -= 2;
if (cluster >= fs->fs_nclusters - 2)
@@ -993,7 +993,7 @@ int fat_putcluster(struct fat_mountpt_s *fs, uint32_t clusterno,
/* Make sure that the sector at this offset is in the cache */
if (fat_fscacheread(fs, fatsector)< 0)
if (fat_fscacheread(fs, fatsector) < 0)
{
/* Read error */
@@ -1239,7 +1239,7 @@ int32_t fat_extendchain(struct fat_mountpt_s *fs, uint32_t cluster)
*/
newcluster = startcluster;
for (;;)
for (; ; )
{
/* Examine the next cluster in the FAT */
@@ -1303,7 +1303,7 @@ int32_t fat_extendchain(struct fat_mountpt_s *fs, uint32_t cluster)
return ret;
}
/* And link if to the start cluster (if any)*/
/* And link if to the start cluster (if any) */
if (cluster)
{
@@ -1563,29 +1563,29 @@ int fat_fscacheread(struct fat_mountpt_s *fs, off_t sector)
* we do nothing. Otherwise, we will have to read the new sector.
*/
if (fs->fs_currentsector != sector)
{
/* We will need to read the new sector. First, flush the cached
* sector if it is dirty.
*/
if (fs->fs_currentsector != sector)
{
/* We will need to read the new sector. First, flush the cached
* sector if it is dirty.
*/
ret = fat_fscacheflush(fs);
if (ret < 0)
{
return ret;
}
ret = fat_fscacheflush(fs);
if (ret < 0)
{
return ret;
}
/* Then read the specified sector into the cache */
/* Then read the specified sector into the cache */
ret = fat_hwread(fs, fs->fs_buffer, sector, 1);
if (ret < 0)
{
return ret;
}
ret = fat_hwread(fs, fs->fs_buffer, sector, 1);
if (ret < 0)
{
return ret;
}
/* Update the cached sector number */
/* Update the cached sector number */
fs->fs_currentsector = sector;
fs->fs_currentsector = sector;
}
return OK;
@@ -1608,7 +1608,8 @@ int fat_ffcacheflush(struct fat_mountpt_s *fs, struct fat_file_s *ff)
*/
if (ff->ff_cachesector &&
(ff->ff_bflags & (FFBUFF_DIRTY|FFBUFF_VALID)) == (FFBUFF_DIRTY|FFBUFF_VALID))
(ff->ff_bflags & (FFBUFF_DIRTY | FFBUFF_VALID)) ==
(FFBUFF_DIRTY | FFBUFF_VALID))
{
/* Write the dirty sector */
@@ -1875,7 +1876,7 @@ int fat_currentsector(struct fat_mountpt_s *fs, struct fat_file_s *ff,
{
int sectoroffset;
if (position <= ff->ff_size )
if (position <= ff->ff_size)
{
/* sectoroffset is the sector number offset into the current cluster */
@@ -1883,7 +1884,7 @@ int fat_currentsector(struct fat_mountpt_s *fs, struct fat_file_s *ff,
/* The current cluster is the first sector of the cluster plus
* the sector offset
*/
*/
ff->ff_currentsector = fat_cluster2sector(fs, ff->ff_currentcluster)
+ sectoroffset;
+2 -2
View File
@@ -299,9 +299,9 @@ int mkfatfs(FAR const char *pathname, FAR struct fat_format_s *fmt)
/* Allocate a buffer that will be working sector memory */
#ifdef CONFIG_FAT_DMAMEMORY
var.fv_sect = (uint8_t*)fat_dma_alloc(var.fv_sectorsize);
var.fv_sect = (FAR uint8_t *)fat_dma_alloc(var.fv_sectorsize);
#else
var.fv_sect = (uint8_t*)kmm_malloc(var.fv_sectorsize);
var.fv_sect = (FAR uint8_t *)kmm_malloc(var.fv_sectorsize);
#endif
if (!var.fv_sect)
+4 -4
View File
@@ -81,7 +81,7 @@ static inline void mkfatfs_initmbr(FAR struct fat_format_s *fmt,
/* 8@3: Usually "MSWIN4.1" */
strcpy((char*)&var->fv_sect[BS_OEMNAME], "NUTTX ");
strcpy((FAR char *)&var->fv_sect[BS_OEMNAME], "NUTTX ");
/* 2@11: Bytes per sector: 512, 1024, 2048, 4096 */
@@ -177,7 +177,7 @@ static inline void mkfatfs_initmbr(FAR struct fat_format_s *fmt,
MBR_PUTFATSZ32(var->fv_sect, var->fv_nfatsects);
/* 2@40: 0-3:Active FAT, 7=0 both FATS, 7=1 one FAT -- left zero*/
/* 2@40: 0-3:Active FAT, 7=0 both FATS, 7=1 one FAT -- left zero */
/* 2@42: MSB:Major LSB:Minor revision number (0.0) -- left zero */
/* 4@44: Cluster no. of 1st cluster of root dir */
@@ -357,7 +357,7 @@ static inline int mkfatfs_writembr(FAR struct fat_format_s *fmt,
if (ret >= 0)
{
/* Create an image of the fsinfo sector*/
/* Create an image of the fsinfo sector */
mkfatfs_initfsinfo(fmt, var);
@@ -408,7 +408,7 @@ static inline int mkfatfs_writefat(FAR struct fat_format_s *fmt,
if (sectno == 0)
{
memset(var->fv_sect, 0, var->fv_sectorsize);
switch(fmt->ff_fattype)
switch (fmt->ff_fattype)
{
case 12:
/* Mark the first two full FAT entries -- 24 bits, 3 bytes total */