fs/: Run all .c files under fs/ through tools/nxstyle.

This commit is contained in:
Gregory Nutt
2019-10-27 11:48:14 -06:00
parent ad9dc2b608
commit bd3cc792ff
50 changed files with 833 additions and 633 deletions
+1
View File
@@ -82,6 +82,7 @@ FAR struct aio_container_s *aio_contain(FAR struct aiocb *aiocbp)
#endif #endif
FAR void *ptr; FAR void *ptr;
} u; } u;
#ifdef CONFIG_PRIORITY_INHERITANCE #ifdef CONFIG_PRIORITY_INHERITANCE
struct sched_param param; struct sched_param param;
#endif #endif
+2 -2
View File
@@ -515,7 +515,7 @@ static int cromfs_open(FAR struct file *filep, FAR const char *relpath,
return -EACCES; return -EACCES;
} }
/* Locate the node for this relative path */ /* Locate the node for this relative path */
node = NULL; node = NULL;
ret = cromfs_findnode(fs, &node, relpath); ret = cromfs_findnode(fs, &node, relpath);
@@ -960,7 +960,7 @@ static int cromfs_opendir(FAR struct inode *mountpt, FAR const char *relpath,
fs = mountpt->i_private; fs = mountpt->i_private;
/* Locate the node for this relative path */ /* Locate the node for this relative path */
node = NULL; node = NULL;
ret = cromfs_findnode(fs, &node, relpath); ret = cromfs_findnode(fs, &node, relpath);
+1 -1
View File
@@ -87,7 +87,7 @@ int close_blockdriver(FAR struct inode *inode)
ferr("ERROR: inode is not a block driver\n"); ferr("ERROR: inode is not a block driver\n");
ret = -ENOTBLK; ret = -ENOTBLK;
goto errout; goto errout;
} }
/* Close the block driver. Not that no mutually exclusive access /* Close the block driver. Not that no mutually exclusive access
* to the driver is enforced here. That must be done in the driver * to the driver is enforced here. That must be done in the driver
+13 -12
View File
@@ -937,13 +937,13 @@ fat_write_restart:
if ((sectorindex == 0) && ((buflen >= fs->fs_hwsectorsize) || if ((sectorindex == 0) && ((buflen >= fs->fs_hwsectorsize) ||
((filep->f_pos + buflen) >= ff->ff_size))) ((filep->f_pos + buflen) >= ff->ff_size)))
{ {
/* Flush unwritten data in the sector cache. */ /* Flush unwritten data in the sector cache. */
ret = fat_ffcacheflush(fs, ff); ret = fat_ffcacheflush(fs, ff);
if (ret < 0) if (ret < 0)
{ {
goto errout_with_semaphore; goto errout_with_semaphore;
} }
/* Now mark the clean cache buffer as the current sector. */ /* Now mark the clean cache buffer as the current sector. */
@@ -998,7 +998,7 @@ fat_write_restart:
byteswritten += writesize; byteswritten += writesize;
buflen -= writesize; buflen -= writesize;
sectorindex = filep->f_pos & SEC_NDXMASK(fs); sectorindex = filep->f_pos & SEC_NDXMASK(fs);
} }
/* The transfer has completed without error. Update the file size */ /* The transfer has completed without error. Update the file size */
@@ -1604,14 +1604,14 @@ static int fat_opendir(FAR struct inode *mountpt, FAR const char *relpath,
if ((DIR_GETATTRIBUTES(direntry) & FATATTR_DIRECTORY) == 0) if ((DIR_GETATTRIBUTES(direntry) & FATATTR_DIRECTORY) == 0)
{ {
/* The entry is not a directory */ /* The entry is not a directory */
ret = -ENOTDIR; ret = -ENOTDIR;
goto errout_with_semaphore; goto errout_with_semaphore;
} }
else else
{ {
/* The entry is a directory (but not the root directory) */ /* The entry is a directory (but not the root directory) */
dir->u.fat.fd_startcluster = dir->u.fat.fd_startcluster =
((uint32_t)DIR_GETFSTCLUSTHI(direntry) << 16) | ((uint32_t)DIR_GETFSTCLUSTHI(direntry) << 16) |
@@ -2235,7 +2235,7 @@ static int fat_statfs(FAR struct inode *mountpt, FAR struct statfs *buf)
ret = fat_checkmount(fs); ret = fat_checkmount(fs);
if (ret < 0) if (ret < 0)
{ {
goto errout_with_semaphore; goto errout_with_semaphore;
} }
/* Fill in the statfs info */ /* Fill in the statfs info */
@@ -2392,6 +2392,7 @@ static int fat_mkdir(FAR struct inode *mountpt, FAR const char *relpath,
{ {
goto errout_with_semaphore; goto errout_with_semaphore;
} }
parentsector = fs->fs_currentsector; parentsector = fs->fs_currentsector;
/* Allocate a cluster for new directory */ /* Allocate a cluster for new directory */
+25 -20
View File
@@ -393,19 +393,19 @@ static inline int fat_parsesfname(const char **path,
#ifdef CONFIG_FAT_LCNAMES #ifdef CONFIG_FAT_LCNAMES
if (endndx == 8) if (endndx == 8)
{ {
/* Is there mixed case in the name? */ /* Is there mixed case in the name? */
#ifdef CONFIG_FAT_LFN #ifdef CONFIG_FAT_LFN
if (namecase == FATCASE_UPPER) if (namecase == FATCASE_UPPER)
{ {
/* Mixed case in the name -- use the long file name */ /* Mixed case in the name -- use the long file name */
goto errout; goto errout;
} }
/* So far, only lower case in the name */ /* So far, only lower case in the name */
namecase = FATCASE_LOWER; namecase = FATCASE_LOWER;
#endif #endif
/* Set lower case name bit */ /* Set lower case name bit */
@@ -541,8 +541,9 @@ static inline int fat_parselfname(const char **path,
} }
errout: errout:
dirinfo->fd_lfname[0] = '\0';
return -EINVAL; dirinfo->fd_lfname[0] = '\0';
return -EINVAL;
} }
#endif #endif
@@ -634,13 +635,13 @@ static inline int fat_createalias(struct fat_dirinfo_s *dirinfo)
if (namechars < 1) if (namechars < 1)
{ {
/* Use the extension as the name */ /* Use the extension as the name */
DEBUGASSERT(ext && extchars > 0); DEBUGASSERT(ext && extchars > 0);
src = ext; src = ext;
ext = NULL; ext = NULL;
namechars = extchars; namechars = extchars;
extchars = 0; extchars = 0;
} }
else else
{ {
@@ -866,7 +867,7 @@ static inline int fat_uniquealias(struct fat_mountpt_s *fs,
for (i = 0; i < tilde - 2; i++) for (i = 0; i < tilde - 2; i++)
{ {
uint8_t nibble = (hash >> (i * 4)) & 0x0F; uint8_t nibble = (hash >> (i * 4)) & 0x0f;
const char *digits = "0123456789ABCDEF"; const char *digits = "0123456789ABCDEF";
dirinfo->fd_name[tilde - 1 - i] = digits[nibble]; dirinfo->fd_name[tilde - 1 - i] = digits[nibble];
} }
@@ -1067,7 +1068,7 @@ static int fat_findsfnentry(struct fat_mountpt_s *fs,
dirinfo->fd_seq.ds_lfnoffset = dirinfo->fd_seq.ds_offset; dirinfo->fd_seq.ds_lfnoffset = dirinfo->fd_seq.ds_offset;
dirinfo->fd_seq.ds_lfncluster = dirinfo->fd_seq.ds_cluster; dirinfo->fd_seq.ds_lfncluster = dirinfo->fd_seq.ds_cluster;
#endif #endif
return OK; return OK;
} }
/* No... get the next directory index and try again */ /* No... get the next directory index and try again */
@@ -1530,6 +1531,7 @@ static inline int fat_allocatelfnentry(struct fat_mountpt_s *fs,
{ {
nentries++; nentries++;
} }
DEBUGASSERT(nentries > 0 && nentries <= LDIR_MAXLFNS); DEBUGASSERT(nentries > 0 && nentries <= LDIR_MAXLFNS);
/* Plus another for short file name entry that follows the sequence of LFN /* Plus another for short file name entry that follows the sequence of LFN
@@ -1696,6 +1698,7 @@ static inline int fat_getsfname(uint8_t *direntry, char *buffer,
ch = tolower(ch); ch = tolower(ch);
} }
#endif #endif
/* Copy the next character into the filename */ /* Copy the next character into the filename */
*buffer++ = ch; *buffer++ = ch;
@@ -1736,6 +1739,7 @@ static inline int fat_getsfname(uint8_t *direntry, char *buffer,
ch = tolower(ch); ch = tolower(ch);
} }
#endif #endif
/* Copy the next character into the filename */ /* Copy the next character into the filename */
*buffer++ = ch; *buffer++ = ch;
@@ -2095,7 +2099,8 @@ static int fat_putlfname(struct fat_mountpt_s *fs,
*/ */
startsector = fat_cluster2sector(fs, dirinfo->dir.fd_currcluster); startsector = fat_cluster2sector(fs, dirinfo->dir.fd_currcluster);
dirinfo->dir.fd_index += (dirinfo->dir.fd_currsector - startsector) * DIRSEC_NDIRS(fs); dirinfo->dir.fd_index += (dirinfo->dir.fd_currsector - startsector) *
DIRSEC_NDIRS(fs);
/* Make sure that the alias is unique in this directory */ /* Make sure that the alias is unique in this directory */
@@ -2479,7 +2484,7 @@ int fat_allocatedirentry(struct fat_mountpt_s *fs,
if (cluster) if (cluster)
{ {
/* Cluster chain can be extended */ /* Cluster chain can be extended */
dirinfo->dir.fd_currcluster = cluster; dirinfo->dir.fd_currcluster = cluster;
dirinfo->dir.fd_currsector = fat_cluster2sector(fs, cluster); dirinfo->dir.fd_currsector = fat_cluster2sector(fs, cluster);
+39 -34
View File
@@ -151,7 +151,8 @@ static int fat_checkbootrecord(struct fat_mountpt_s *fs)
if (fs->fs_rootentcnt != 0) if (fs->fs_rootentcnt != 0)
{ {
notfat32 = true; /* Must be zero for FAT32 */ notfat32 = true; /* Must be zero for FAT32 */
rootdirsectors = (32 * fs->fs_rootentcnt + fs->fs_hwsectorsize - 1) / fs->fs_hwsectorsize; rootdirsectors = (32 * fs->fs_rootentcnt + fs->fs_hwsectorsize - 1) /
fs->fs_hwsectorsize;
} }
/* Determine the number of sectors in a FAT. */ /* Determine the number of sectors in a FAT. */
@@ -212,7 +213,8 @@ static int fat_checkbootrecord(struct fat_mountpt_s *fs)
/* Get the total number of data sectors */ /* Get the total number of data sectors */
ndatasectors = fs->fs_fattotsec - fs->fs_fatresvdseccount - ntotalfatsects - rootdirsectors; ndatasectors = fs->fs_fattotsec - fs->fs_fatresvdseccount -
ntotalfatsects - rootdirsectors;
if (ndatasectors > fs->fs_hwnsectors) if (ndatasectors > fs->fs_hwnsectors)
{ {
fwarn("WARNING: ndatasectors %d fs_hwnsectors: %d\n", fwarn("WARNING: ndatasectors %d fs_hwnsectors: %d\n",
@@ -269,7 +271,8 @@ static int fat_checkbootrecord(struct fat_mountpt_s *fs)
fs->fs_rootbase = fs->fs_fatbase + ntotalfatsects; fs->fs_rootbase = fs->fs_fatbase + ntotalfatsects;
} }
fs->fs_database = fs->fs_fatbase + ntotalfatsects + fs->fs_rootentcnt / DIRSEC_NDIRS(fs); fs->fs_database = fs->fs_fatbase + ntotalfatsects + fs->fs_rootentcnt /
DIRSEC_NDIRS(fs);
fs->fs_fsifreecount = 0xffffffff; fs->fs_fsifreecount = 0xffffffff;
return OK; return OK;
@@ -388,7 +391,7 @@ void fat_semtake(struct fat_mountpt_s *fs)
void fat_semgive(struct fat_mountpt_s *fs) void fat_semgive(struct fat_mountpt_s *fs)
{ {
nxsem_post(&fs->fs_sem); nxsem_post(&fs->fs_sem);
} }
/**************************************************************************** /****************************************************************************
@@ -652,13 +655,13 @@ int fat_mount(struct fat_mountpt_s *fs, bool writeable)
*/ */
if (fs->fs_type == FSTYPE_FAT32) if (fs->fs_type == FSTYPE_FAT32)
{ {
ret = fat_checkfsinfo(fs); ret = fat_checkfsinfo(fs);
if (ret != OK) if (ret != OK)
{ {
goto errout_with_buffer; goto errout_with_buffer;
} }
} }
/* We did it! */ /* We did it! */
@@ -751,15 +754,15 @@ int fat_hwread(struct fat_mountpt_s *fs, uint8_t *buffer, off_t sector,
struct inode *inode = fs->fs_blkdriver; struct inode *inode = fs->fs_blkdriver;
if (inode && inode->u.i_bops && inode->u.i_bops->read) if (inode && inode->u.i_bops && inode->u.i_bops->read)
{ {
ssize_t nSectorsRead = inode->u.i_bops->read(inode, buffer, ssize_t nsectorsread = inode->u.i_bops->read(inode, buffer,
sector, nsectors); sector, nsectors);
if (nSectorsRead == nsectors) if (nsectorsread == nsectors)
{ {
ret = OK; ret = OK;
} }
else if (nSectorsRead < 0) else if (nsectorsread < 0)
{ {
ret = nSectorsRead; ret = nsectorsread;
} }
} }
} }
@@ -784,16 +787,16 @@ int fat_hwwrite(struct fat_mountpt_s *fs, uint8_t *buffer, off_t sector,
struct inode *inode = fs->fs_blkdriver; struct inode *inode = fs->fs_blkdriver;
if (inode && inode->u.i_bops && inode->u.i_bops->write) if (inode && inode->u.i_bops && inode->u.i_bops->write)
{ {
ssize_t nSectorsWritten = ssize_t nsectorswritten =
inode->u.i_bops->write(inode, buffer, sector, nsectors); inode->u.i_bops->write(inode, buffer, sector, nsectors);
if (nSectorsWritten == nsectors) if (nsectorswritten == nsectors)
{ {
ret = OK; ret = OK;
} }
else if (nSectorsWritten < 0) else if (nsectorswritten < 0)
{ {
ret = nSectorsWritten; ret = nsectorswritten;
} }
} }
} }
@@ -814,8 +817,9 @@ off_t fat_cluster2sector(FAR struct fat_mountpt_s *fs, uint32_t cluster)
cluster -= 2; cluster -= 2;
if (cluster >= fs->fs_nclusters - 2) if (cluster >= fs->fs_nclusters - 2)
{ {
return -EINVAL; return -EINVAL;
} }
return cluster * fs->fs_fatsecperclus + fs->fs_database; return cluster * fs->fs_fatsecperclus + fs->fs_database;
} }
@@ -1058,7 +1062,8 @@ int fat_putcluster(struct fat_mountpt_s *fs, uint32_t clusterno,
{ {
/* Save the MS four bits of the next cluster */ /* Save the MS four bits of the next cluster */
value = (fs->fs_buffer[fatindex] & 0xf0) | ((nextcluster >> 8) & 0x0f); value = (fs->fs_buffer[fatindex] & 0xf0) |
((nextcluster >> 8) & 0x0f);
} }
fs->fs_buffer[fatindex] = value; fs->fs_buffer[fatindex] = value;
@@ -1699,13 +1704,13 @@ int fat_dirextend(FAR struct fat_mountpt_s *fs, FAR struct fat_file_s *ff,
if (sectndx == 0 && (remaining >= fs->fs_hwsectorsize || if (sectndx == 0 && (remaining >= fs->fs_hwsectorsize ||
(pos + remaining) >= ff->ff_size)) (pos + remaining) >= ff->ff_size))
{ {
/* Flush unwritten data in the sector cache. */ /* Flush unwritten data in the sector cache. */
ret = fat_ffcacheflush(fs, ff); ret = fat_ffcacheflush(fs, ff);
if (ret < 0) if (ret < 0)
{ {
return ret; return ret;
} }
/* Now mark the clean cache buffer as the current sector. */ /* Now mark the clean cache buffer as the current sector. */
@@ -1755,7 +1760,7 @@ int fat_dirextend(FAR struct fat_mountpt_s *fs, FAR struct fat_file_s *ff,
pos += zerosize; pos += zerosize;
remaining -= zerosize; remaining -= zerosize;
sectndx = pos & SEC_NDXMASK(fs); sectndx = pos & SEC_NDXMASK(fs);
} }
/* The truncation has completed without error. Update the file size */ /* The truncation has completed without error. Update the file size */
@@ -2060,7 +2065,6 @@ int fat_nfreeclusters(struct fat_mountpt_s *fs, off_t *pfreeclusters)
for (sector = 2; sector < fs->fs_nclusters; sector++) for (sector = 2; sector < fs->fs_nclusters; sector++)
{ {
/* If the cluster is unassigned, then increment the count of free clusters */ /* If the cluster is unassigned, then increment the count of free clusters */
if ((uint16_t)fat_getcluster(fs, sector) == 0) if ((uint16_t)fat_getcluster(fs, sector) == 0)
@@ -2111,6 +2115,7 @@ int fat_nfreeclusters(struct fat_mountpt_s *fs, off_t *pfreeclusters)
{ {
nfreeclusters++; nfreeclusters++;
} }
offset += 2; offset += 2;
} }
else else
@@ -2125,14 +2130,14 @@ int fat_nfreeclusters(struct fat_mountpt_s *fs, off_t *pfreeclusters)
} }
} }
fs->fs_fsifreecount = nfreeclusters; fs->fs_fsifreecount = nfreeclusters;
if (fs->fs_type == FSTYPE_FAT32) if (fs->fs_type == FSTYPE_FAT32)
{ {
fs->fs_fsidirty = true; fs->fs_fsidirty = true;
} }
*pfreeclusters = nfreeclusters; *pfreeclusters = nfreeclusters;
return OK; return OK;
} }
/**************************************************************************** /****************************************************************************
+9 -8
View File
@@ -263,7 +263,7 @@ int file_dup2(FAR struct file *filep1, FAR struct file *filep2)
#ifndef CONFIG_DISABLE_MOUNTPOINT #ifndef CONFIG_DISABLE_MOUNTPOINT
if (INODE_IS_MOUNTPT(inode)) if (INODE_IS_MOUNTPT(inode))
{ {
/* Dup the open file on the in the new file structure */ /* Dup the open file on the in the new file structure */
ret = inode->u.i_mops->dup(filep1, filep2); ret = inode->u.i_mops->dup(filep1, filep2);
} }
@@ -290,9 +290,10 @@ int file_dup2(FAR struct file *filep1, FAR struct file *filep2)
return OK; return OK;
/* Handler various error conditions */ /* Handle various error conditions */
errout_with_inode: errout_with_inode:
inode_release(filep2->f_inode); inode_release(filep2->f_inode);
filep2->f_oflags = 0; filep2->f_oflags = 0;
filep2->f_pos = 0; filep2->f_pos = 0;
@@ -331,12 +332,12 @@ int files_allocate(FAR struct inode *inode, int oflags, off_t pos, int minfd)
{ {
if (!list->fl_files[i].f_inode) if (!list->fl_files[i].f_inode)
{ {
list->fl_files[i].f_oflags = oflags; list->fl_files[i].f_oflags = oflags;
list->fl_files[i].f_pos = pos; list->fl_files[i].f_pos = pos;
list->fl_files[i].f_inode = inode; list->fl_files[i].f_inode = inode;
list->fl_files[i].f_priv = NULL; list->fl_files[i].f_priv = NULL;
_files_semgive(list); _files_semgive(list);
return i; return i;
} }
} }
+2 -2
View File
@@ -156,8 +156,8 @@ int inode_remove(FAR const char *path)
* releases the inode, we will then, finally delete the subtree * releases the inode, we will then, finally delete the subtree
*/ */
node->i_flags |= FSNODEFLAG_DELETED; node->i_flags |= FSNODEFLAG_DELETED;
return -EBUSY; return -EBUSY;
} }
else else
{ {
+2 -1
View File
@@ -396,6 +396,7 @@ static int _inode_search(FAR struct inode_search_s *desc)
} }
} }
#endif #endif
/* Keep looking at the next level "down" */ /* Keep looking at the next level "down" */
above = node; above = node;
@@ -517,7 +518,7 @@ int inode_search(FAR struct inode_search_s *desc)
if (INODE_IS_MOUNTPT(node)) if (INODE_IS_MOUNTPT(node))
{ {
/* Yes... set up for the MOUNTPOINT logic below. */ /* Yes... set up for the MOUNTPOINT logic below. */
desc->relpath = relpath; desc->relpath = relpath;
} }
+40 -16
View File
@@ -601,6 +601,7 @@ static int lfs_dir_fetch(FAR lfs_t *lfs, FAR lfs_dir_t *dir,
{ {
pair[0], pair[1] pair[0], pair[1]
}; };
bool valid = false; bool valid = false;
int i; int i;
@@ -618,6 +619,7 @@ static int lfs_dir_fetch(FAR lfs_t *lfs, FAR lfs_dir_t *dir,
{ {
continue; continue;
} }
return err; return err;
} }
@@ -679,6 +681,7 @@ static int lfs_dir_commit(FAR lfs_t *lfs, FAR lfs_dir_t *dir,
FAR lfs_dir_t *d; FAR lfs_dir_t *d;
lfs_block_t oldpair[2]; lfs_block_t oldpair[2];
bool relocated; bool relocated;
int err;
int i; int i;
/* increment revision count */ /* increment revision count */
@@ -702,13 +705,14 @@ static int lfs_dir_commit(FAR lfs_t *lfs, FAR lfs_dir_t *dir,
if (true) if (true)
{ {
uint32_t crc; uint32_t crc;
int err = lfs_bd_erase(lfs, dir->pair[0]); err = lfs_bd_erase(lfs, dir->pair[0]);
if (err) if (err)
{ {
if (err == LFS_ERR_CORRUPT) if (err == LFS_ERR_CORRUPT)
{ {
goto relocate; goto relocate;
} }
return err; return err;
} }
@@ -723,6 +727,7 @@ static int lfs_dir_commit(FAR lfs_t *lfs, FAR lfs_dir_t *dir,
{ {
goto relocate; goto relocate;
} }
return err; return err;
} }
@@ -742,6 +747,7 @@ static int lfs_dir_commit(FAR lfs_t *lfs, FAR lfs_dir_t *dir,
{ {
goto relocate; goto relocate;
} }
return err; return err;
} }
@@ -766,6 +772,7 @@ static int lfs_dir_commit(FAR lfs_t *lfs, FAR lfs_dir_t *dir,
{ {
goto relocate; goto relocate;
} }
return err; return err;
} }
@@ -783,6 +790,7 @@ static int lfs_dir_commit(FAR lfs_t *lfs, FAR lfs_dir_t *dir,
{ {
goto relocate; goto relocate;
} }
return err; return err;
} }
@@ -793,6 +801,7 @@ static int lfs_dir_commit(FAR lfs_t *lfs, FAR lfs_dir_t *dir,
{ {
goto relocate; goto relocate;
} }
return err; return err;
} }
@@ -815,6 +824,7 @@ static int lfs_dir_commit(FAR lfs_t *lfs, FAR lfs_dir_t *dir,
break; break;
relocate: relocate:
/* Commit was corrupted */ /* Commit was corrupted */
LFS_DEBUG("Bad block at %" PRIu32, dir->pair[0]); LFS_DEBUG("Bad block at %" PRIu32, dir->pair[0]);
@@ -833,9 +843,9 @@ relocate:
return LFS_ERR_CORRUPT; return LFS_ERR_CORRUPT;
} }
/* relocate half of pair */ /* Relocate half of pair */
int err = lfs_alloc(lfs, &dir->pair[0]); err = lfs_alloc(lfs, &dir->pair[0]);
if (err) if (err)
{ {
return err; return err;
@@ -1095,13 +1105,14 @@ static int lfs_dir_find(FAR lfs_t *lfs, FAR lfs_dir_t *dir,
size_t sufflen; size_t sufflen;
int depth; int depth;
nextname: nextname:
/* skip slashes */
/* Skip slashes */
pathname += strspn(pathname, "/"); pathname += strspn(pathname, "/");
pathlen = strcspn(pathname, "/"); pathlen = strcspn(pathname, "/");
/* skip '.' and root '..' */ /* Skip '.' and root '..' */
if ((pathlen == 1 && memcmp(pathname, ".", 1) == 0) || if ((pathlen == 1 && memcmp(pathname, ".", 1) == 0) ||
(pathlen == 2 && memcmp(pathname, "..", 2) == 0)) (pathlen == 2 && memcmp(pathname, "..", 2) == 0))
@@ -1110,7 +1121,7 @@ static int lfs_dir_find(FAR lfs_t *lfs, FAR lfs_dir_t *dir,
goto nextname; goto nextname;
} }
/* skip if matched by '..' in name */ /* Skip if matched by '..' in name */
suffix = pathname + pathlen; suffix = pathname + pathlen;
depth = 1; depth = 1;
@@ -1341,6 +1352,7 @@ static int lfs_ctz_extend(FAR lfs_t *lfs, FAR lfs_cache_t *rcache,
{ {
goto relocate; goto relocate;
} }
return err; return err;
} }
} }
@@ -1390,10 +1402,11 @@ static int lfs_ctz_extend(FAR lfs_t *lfs, FAR lfs_cache_t *rcache,
return 0; return 0;
} }
relocate: relocate:
LFS_DEBUG("Bad block at %" PRIu32, nblock); LFS_DEBUG("Bad block at %" PRIu32, nblock);
/* just clear cache and try a new block */ /* Just clear cache and try a new block */
lfs_cache_drop(lfs, &lfs->pcache); lfs_cache_drop(lfs, &lfs->pcache);
} }
@@ -1479,6 +1492,7 @@ relocate:
{ {
goto relocate; goto relocate;
} }
return err; return err;
} }
@@ -1536,12 +1550,13 @@ static int lfs_file_flush(FAR lfs_t *lfs, FAR lfs_file_t *file)
lfs_file_t orig = lfs_file_t orig =
{ {
.head = file->head, .head = file->head,
.size = file->size, .size = file->size,
.flags = LFS_O_RDONLY, .flags = LFS_O_RDONLY,
.pos = file->pos, .pos = file->pos,
.cache = lfs->rcache, .cache = lfs->rcache,
}; };
lfs_cache_drop(lfs, &lfs->rcache); lfs_cache_drop(lfs, &lfs->rcache);
while (file->pos < file->size) while (file->pos < file->size)
@@ -1572,7 +1587,7 @@ static int lfs_file_flush(FAR lfs_t *lfs, FAR lfs_file_t *file)
} }
} }
/* write out what we have */ /* Write out what we have */
while (true) while (true)
{ {
@@ -1583,11 +1598,14 @@ static int lfs_file_flush(FAR lfs_t *lfs, FAR lfs_file_t *file)
{ {
goto relocate; goto relocate;
} }
return err; return err;
} }
break; break;
relocate:
relocate:
err = lfs_file_relocate(lfs, file); err = lfs_file_relocate(lfs, file);
if (err) if (err)
{ {
@@ -1595,7 +1613,7 @@ static int lfs_file_flush(FAR lfs_t *lfs, FAR lfs_file_t *file)
} }
} }
/* actual file updates */ /* Actual file updates */
file->head = file->block; file->head = file->block;
file->size = file->pos; file->size = file->pos;
@@ -2565,6 +2583,7 @@ lfs_ssize_t lfs_file_write(FAR lfs_t *lfs, FAR lfs_file_t *file,
{ {
goto relocate; goto relocate;
} }
file->flags |= LFS_F_ERRED; file->flags |= LFS_F_ERRED;
return err; return err;
} }
@@ -2954,6 +2973,7 @@ int lfs_rename(FAR lfs_t *lfs, FAR const char *oldpath,
{ {
return err; return err;
} }
lfs->moving = false; lfs->moving = false;
/* remove old entry */ /* remove old entry */
@@ -3076,6 +3096,7 @@ int lfs_format(FAR lfs_t *lfs, FAR const struct lfs_config_s *cfg)
} }
}, },
1); 1);
if (err && err != LFS_ERR_CORRUPT) if (err && err != LFS_ERR_CORRUPT)
{ {
goto cleanup; goto cleanup;
@@ -3132,7 +3153,7 @@ int lfs_mount(FAR lfs_t *lfs, FAR const struct lfs_config_s *cfg)
/* load superblock */ /* load superblock */
err = lfs_dir_fetch(lfs, &dir, (const lfs_block_t[2]){0, 1}); err = lfs_dir_fetch(lfs, &dir, (const lfs_block_t[2]){ 0, 1 });
if (err && err != LFS_ERR_CORRUPT) if (err && err != LFS_ERR_CORRUPT)
{ {
goto cleanup; goto cleanup;
@@ -3195,6 +3216,7 @@ int lfs_traverse(FAR lfs_t *lfs, CODE int (*cb)(void *, lfs_block_t),
{ {
0, 1 0, 1
}; };
FAR lfs_file_t *f; FAR lfs_file_t *f;
if (lfs_pairisnull(lfs->root)) if (lfs_pairisnull(lfs->root))
@@ -3292,11 +3314,13 @@ int lfs_deorphan(FAR lfs_t *lfs)
{ {
.d.size = 0x80000000 .d.size = 0x80000000
}; };
lfs_dir_t cwd = lfs_dir_t cwd =
{ {
.d.tail[0] = 0, .d.tail[0] = 0,
.d.tail[1] = 1 .d.tail[1] = 1
}; };
lfs_size_t i; lfs_size_t i;
int err; int err;
+7 -4
View File
@@ -383,6 +383,7 @@ static ssize_t littlefs_read(FAR struct file *filep, FAR char *buffer,
{ {
filep->f_pos += ret; filep->f_pos += ret;
} }
littlefs_semgive(fs); littlefs_semgive(fs);
return ret; return ret;
@@ -414,6 +415,7 @@ static ssize_t littlefs_write(FAR struct file *filep, const char *buffer,
{ {
filep->f_pos += ret; filep->f_pos += ret;
} }
littlefs_semgive(fs); littlefs_semgive(fs);
return ret; return ret;
@@ -444,6 +446,7 @@ static off_t littlefs_seek(FAR struct file *filep, off_t offset, int whence)
{ {
filep->f_pos = ret; filep->f_pos = ret;
} }
littlefs_semgive(fs); littlefs_semgive(fs);
return ret; return ret;
@@ -1060,12 +1063,12 @@ static int littlefs_unbind(FAR void *handle, FAR struct inode **driver,
static int littlefs_used_block(void *arg, lfs_block_t block) static int littlefs_used_block(void *arg, lfs_block_t block)
{ {
FAR struct statfs *buf = arg; FAR struct statfs *buf = arg;
buf->f_bfree--; buf->f_bfree--;
buf->f_bavail--; buf->f_bavail--;
return 0; return 0;
} }
/**************************************************************************** /****************************************************************************
+4
View File
@@ -200,6 +200,7 @@ static void automount_mount(FAR struct automounter_state_s *priv)
switch (ret) switch (ret)
{ {
case OK_EXIST: case OK_EXIST:
/* REVISIT: What should we do in this case? I think that this would /* REVISIT: What should we do in this case? I think that this would
* happen only if a previous unmount failed? I suppose that we should * happen only if a previous unmount failed? I suppose that we should
* try to unmount again because the mount might be stale. * try to unmount again because the mount might be stale.
@@ -220,6 +221,7 @@ static void automount_mount(FAR struct automounter_state_s *priv)
*/ */
case OK_NOENT: case OK_NOENT:
/* If we get here, then the volume must not be mounted */ /* If we get here, then the volume must not be mounted */
DEBUGASSERT(!priv->mounted); DEBUGASSERT(!priv->mounted);
@@ -277,6 +279,7 @@ static int automount_unmount(FAR struct automounter_state_s *priv)
switch (ret) switch (ret)
{ {
case OK_EXIST: case OK_EXIST:
/* If we get here, then the volume must be mounted */ /* If we get here, then the volume must be mounted */
DEBUGASSERT(priv->mounted); DEBUGASSERT(priv->mounted);
@@ -321,6 +324,7 @@ static int automount_unmount(FAR struct automounter_state_s *priv)
/* Fall through */ /* Fall through */
case OK_NOENT: case OK_NOENT:
/* The mountpoint is not present. This is normal behavior in the /* The mountpoint is not present. This is normal behavior in the
* case where the user manually un-mounted the volume before removing * case where the user manually un-mounted the volume before removing
* media. Nice job, Mr. user. * media. Nice job, Mr. user.
+1 -1
View File
@@ -256,7 +256,7 @@ mount_findfs(FAR const struct fsmap_t *fstab, FAR const char *filesystemtype)
{ {
if (strcmp(filesystemtype, fsmap->fs_filesystemtype) == 0) if (strcmp(filesystemtype, fsmap->fs_filesystemtype) == 0)
{ {
return fsmap->fs_mops; return fsmap->fs_mops;
} }
} }
+4 -4
View File
@@ -156,10 +156,10 @@ int umount2(FAR const char *target, unsigned int flags)
if (mountpt_inode->i_child != NULL) if (mountpt_inode->i_child != NULL)
{ {
/* Just decrement the reference count (without deleting it) */ /* Just decrement the reference count (without deleting it) */
DEBUGASSERT(mountpt_inode->i_crefs > 0); DEBUGASSERT(mountpt_inode->i_crefs > 0);
mountpt_inode->i_crefs--; mountpt_inode->i_crefs--;
} }
else else
#endif #endif
@@ -180,7 +180,7 @@ int umount2(FAR const char *target, unsigned int flags)
{ {
errcode = -ret; errcode = -ret;
goto errout_with_mountpt; goto errout_with_mountpt;
} }
/* Release the mountpoint inode and any block driver inode /* Release the mountpoint inode and any block driver inode
* returned by the file system unbind above. This should cause * returned by the file system unbind above. This should cause
+18 -18
View File
@@ -83,32 +83,32 @@ int nxmq_close_group(mqd_t mqdes, FAR struct task_group_s *group)
/* Verify the inputs */ /* Verify the inputs */
if (mqdes) if (mqdes)
{ {
sched_lock(); sched_lock();
/* Find the message queue associated with the message descriptor */ /* Find the message queue associated with the message descriptor */
msgq = mqdes->msgq; msgq = mqdes->msgq;
DEBUGASSERT(msgq && msgq->inode); DEBUGASSERT(msgq && msgq->inode);
/* Close/free the message descriptor */ /* Close/free the message descriptor */
ret = nxmq_desclose_group(mqdes, group); ret = nxmq_desclose_group(mqdes, group);
if (ret >= 0) if (ret >= 0)
{ {
/* Get the inode from the message queue structure */ /* Get the inode from the message queue structure */
inode = msgq->inode; inode = msgq->inode;
DEBUGASSERT(inode->u.i_mqueue == msgq); DEBUGASSERT(inode->u.i_mqueue == msgq);
/* Decrement the reference count on the inode, possibly freeing it */ /* Decrement the reference count on the inode, possibly freeing it */
mq_inode_release(inode); mq_inode_release(inode);
} }
sched_unlock(); sched_unlock();
} }
return ret; return ret;
} }
+6 -6
View File
@@ -217,12 +217,12 @@ mqd_t mq_open(FAR const char *mq_name, int oflags, ...)
/* Create a message queue descriptor for the TCB */ /* Create a message queue descriptor for the TCB */
mqdes = nxmq_create_des(NULL, msgq, oflags); mqdes = nxmq_create_des(NULL, msgq, oflags);
if (!mqdes) if (!mqdes)
{ {
errcode = ENOMEM; errcode = ENOMEM;
goto errout_with_msgq; goto errout_with_msgq;
} }
/* Bind the message queue and the inode structure */ /* Bind the message queue and the inode structure */
+3 -1
View File
@@ -357,6 +357,7 @@ int nfs_lookup(struct nfsmount *nmp, FAR const char *filename,
{ {
memcpy(obj_attributes, ptr, sizeof(struct nfs_fattr)); memcpy(obj_attributes, ptr, sizeof(struct nfs_fattr));
} }
ptr += uint32_increment(sizeof(struct nfs_fattr)); ptr += uint32_increment(sizeof(struct nfs_fattr));
} }
@@ -386,7 +387,8 @@ int nfs_lookup(struct nfsmount *nmp, FAR const char *filename,
****************************************************************************/ ****************************************************************************/
int nfs_findnode(struct nfsmount *nmp, FAR const char *relpath, int nfs_findnode(struct nfsmount *nmp, FAR const char *relpath,
FAR struct file_handle *fhandle, FAR struct nfs_fattr *obj_attributes, FAR struct file_handle *fhandle,
FAR struct nfs_fattr *obj_attributes,
FAR struct nfs_fattr *dir_attributes) FAR struct nfs_fattr *dir_attributes)
{ {
FAR const char *path = relpath; FAR const char *path = relpath;
+22 -12
View File
@@ -291,6 +291,7 @@ static int nfs_filecreate(FAR struct nfsmount *nmp, FAR struct nfsnode *np,
{ {
*ptr++ = HTONL(NFSV3CREATE_UNCHECKED); *ptr++ = HTONL(NFSV3CREATE_UNCHECKED);
} }
reqlen += sizeof(uint32_t); reqlen += sizeof(uint32_t);
/* Mode information is not provided if EXCLUSIVE creation is used. /* Mode information is not provided if EXCLUSIVE creation is used.
@@ -363,7 +364,8 @@ static int nfs_filecreate(FAR struct nfsmount *nmp, FAR struct nfsnode *np,
{ {
/* Parse the returned data */ /* Parse the returned data */
ptr = (FAR uint32_t *)&((FAR struct rpc_reply_create *)nmp->nm_iobuffer)->create; ptr = (FAR uint32_t *)&((FAR struct rpc_reply_create *)
nmp->nm_iobuffer)->create;
/* Save the file handle in the file data structure */ /* Save the file handle in the file data structure */
@@ -1016,7 +1018,9 @@ static ssize_t nfs_write(FAR struct file *filep, const char *buffer,
writesize = 0; writesize = 0;
for (byteswritten = 0; byteswritten < buflen; ) for (byteswritten = 0; byteswritten < buflen; )
{ {
/* Make sure that the attempted write size does not exceed the RPC maximum */ /* Make sure that the attempted write size does not exceed the RPC
* maximum.
*/
writesize = buflen; writesize = buflen;
if (writesize > nmp->nm_wsize) if (writesize > nmp->nm_wsize)
@@ -1024,7 +1028,9 @@ static ssize_t nfs_write(FAR struct file *filep, const char *buffer,
writesize = nmp->nm_wsize; writesize = nmp->nm_wsize;
} }
/* Make sure that the attempted read size does not exceed the IO buffer size */ /* Make sure that the attempted read size does not exceed the IO
* buffer size.
*/
bufsize = SIZEOF_rpc_call_write(writesize); bufsize = SIZEOF_rpc_call_write(writesize);
if (bufsize > nmp->nm_buflen) if (bufsize > nmp->nm_buflen)
@@ -1037,7 +1043,8 @@ static ssize_t nfs_write(FAR struct file *filep, const char *buffer,
* RPC calls in that the entry RPC calls messasge lies in the I/O buffer * RPC calls in that the entry RPC calls messasge lies in the I/O buffer
*/ */
ptr = (FAR uint32_t *)&((FAR struct rpc_call_write *)nmp->nm_iobuffer)->write; ptr = (FAR uint32_t *)&((FAR struct rpc_call_write *)
nmp->nm_iobuffer)->write;
reqlen = 0; reqlen = 0;
/* Copy the variable length, file handle */ /* Copy the variable length, file handle */
@@ -1073,7 +1080,8 @@ static ssize_t nfs_write(FAR struct file *filep, const char *buffer,
nfs_statistics(NFSPROC_WRITE); nfs_statistics(NFSPROC_WRITE);
error = nfs_request(nmp, NFSPROC_WRITE, error = nfs_request(nmp, NFSPROC_WRITE,
(FAR void *)nmp->nm_iobuffer, reqlen, (FAR void *)nmp->nm_iobuffer, reqlen,
(FAR void *)&nmp->nm_msgbuffer.write, sizeof(struct rpc_reply_write)); (FAR void *)&nmp->nm_msgbuffer.write,
sizeof(struct rpc_reply_write));
if (error) if (error)
{ {
ferr("ERROR: nfs_request failed: %d\n", error); ferr("ERROR: nfs_request failed: %d\n", error);
@@ -1112,8 +1120,8 @@ static ssize_t nfs_write(FAR struct file *filep, const char *buffer,
if (tmp < 1 || tmp > writesize) if (tmp < 1 || tmp > writesize)
{ {
error = EIO; error = EIO;
goto errout_with_semaphore; goto errout_with_semaphore;
} }
writesize = tmp; writesize = tmp;
@@ -1546,9 +1554,9 @@ static int nfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
*/ */
else else
{ {
finfo("No data but not end of directory???\n"); finfo("No data but not end of directory???\n");
error = EAGAIN; error = EAGAIN;
} }
goto errout_with_semaphore; goto errout_with_semaphore;
@@ -1640,6 +1648,7 @@ static int nfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
dir->fd_dir.d_type = DTYPE_CHR; dir->fd_dir.d_type = DTYPE_CHR;
break; break;
} }
finfo("type: %d->%d\n", (int)tmp, dir->fd_dir.d_type); finfo("type: %d->%d\n", (int)tmp, dir->fd_dir.d_type);
errout_with_semaphore: errout_with_semaphore:
@@ -1703,6 +1712,7 @@ static void nfs_decode_args(FAR struct nfs_mount_parameters *nprmt,
{ {
tmp = NFS_MAXTIMEO; tmp = NFS_MAXTIMEO;
} }
nprmt->timeo = tmp; nprmt->timeo = tmp;
} }
@@ -2331,8 +2341,8 @@ static int nfs_remove(struct inode *mountpt, const char *relpath)
(FAR void *)nmp->nm_iobuffer, nmp->nm_buflen); (FAR void *)nmp->nm_iobuffer, nmp->nm_buflen);
errout_with_semaphore: errout_with_semaphore:
nfs_semgive(nmp); nfs_semgive(nmp);
return -error; return -error;
} }
/**************************************************************************** /****************************************************************************
+13 -7
View File
@@ -237,7 +237,7 @@ static int rpcclnt_reply(FAR struct rpcclnt *rpc, int procid, int prog,
if (error == EAGAIN || error == ETIMEDOUT) if (error == EAGAIN || error == ETIMEDOUT)
{ {
rpc->rc_timeout = true; rpc->rc_timeout = true;
} }
} }
/* Get the xid and check that it is an RPC replysvr */ /* Get the xid and check that it is an RPC replysvr */
@@ -505,8 +505,10 @@ int rpcclnt_connect(struct rpcclnt *rpc)
request.mountd.mount.len = txdr_unsigned(sizeof(request.mountd.mount.rpath)); request.mountd.mount.len = txdr_unsigned(sizeof(request.mountd.mount.rpath));
error = rpcclnt_request(rpc, RPCMNT_MOUNT, RPCPROG_MNT, RPCMNT_VER3, error = rpcclnt_request(rpc, RPCMNT_MOUNT, RPCPROG_MNT, RPCMNT_VER3,
(FAR void *)&request.mountd, sizeof(struct call_args_mount), (FAR void *)&request.mountd,
(FAR void *)&response.mdata, sizeof(struct rpc_reply_mount)); sizeof(struct call_args_mount),
(FAR void *)&response.mdata
sizeof(struct rpc_reply_mount));
if (error != 0) if (error != 0)
{ {
ferr("ERROR: rpcclnt_request failed: %d\n", error); ferr("ERROR: rpcclnt_request failed: %d\n", error);
@@ -636,8 +638,10 @@ int rpcclnt_umount(struct rpcclnt *rpc)
request.sdata.pmap.port = 0; request.sdata.pmap.port = 0;
error = rpcclnt_request(rpc, PMAPPROC_GETPORT, PMAPPROG, PMAPVERS, error = rpcclnt_request(rpc, PMAPPROC_GETPORT, PMAPPROG, PMAPVERS,
(FAR void *)&request.sdata, sizeof(struct call_args_pmap), (FAR void *)&request.sdata,
(FAR void *)&response.rdata, sizeof(struct rpc_reply_pmap)); sizeof(struct call_args_pmap),
(FAR void *)&response.rdata,
sizeof(struct rpc_reply_pmap));
if (error != 0) if (error != 0)
{ {
ferr("ERROR: rpcclnt_request failed: %d\n", error); ferr("ERROR: rpcclnt_request failed: %d\n", error);
@@ -661,8 +665,10 @@ int rpcclnt_umount(struct rpcclnt *rpc)
request.mountd.umount.len = txdr_unsigned(sizeof(request.mountd.umount.rpath)); request.mountd.umount.len = txdr_unsigned(sizeof(request.mountd.umount.rpath));
error = rpcclnt_request(rpc, RPCMNT_UMOUNT, RPCPROG_MNT, RPCMNT_VER3, error = rpcclnt_request(rpc, RPCMNT_UMOUNT, RPCPROG_MNT, RPCMNT_VER3,
(FAR void *)&request.mountd, sizeof(struct call_args_umount), (FAR void *)&request.mountd,
(FAR void *)&response.mdata, sizeof(struct rpc_reply_umount)); sizeof(struct call_args_umount),
(FAR void *)&response.mdata,
sizeof(struct rpc_reply_umount));
if (error != 0) if (error != 0)
{ {
ferr("ERROR: rpcclnt_request failed: %d\n", error); ferr("ERROR: rpcclnt_request failed: %d\n", error);
+1 -1
View File
@@ -101,7 +101,7 @@ int nxffs_verifyblock(FAR struct nxffs_volume_s *volume, off_t block)
blkhdr = (FAR struct nxffs_block_s *)volume->cache; blkhdr = (FAR struct nxffs_block_s *)volume->cache;
if (memcmp(blkhdr->magic, g_blockmagic, NXFFS_MAGICSIZE) == 0) if (memcmp(blkhdr->magic, g_blockmagic, NXFFS_MAGICSIZE) == 0)
{ {
/* This does appear to be a block */ /* This does appear to be a block */
if (blkhdr->state == BLOCK_STATE_GOOD) if (blkhdr->state == BLOCK_STATE_GOOD)
{ {
+9 -7
View File
@@ -187,7 +187,7 @@ static inline ssize_t nxffs_analyzeinode(FAR struct nxffs_blkinfo_s *blkinfo,
{ {
/* No.. Assume that this is not an inode. */ /* No.. Assume that this is not an inode. */
return ERROR; return ERROR;
} }
/* Calculate the CRC */ /* Calculate the CRC */
@@ -200,11 +200,11 @@ static inline ssize_t nxffs_analyzeinode(FAR struct nxffs_blkinfo_s *blkinfo,
crc = crc32part(&blkinfo->buffer[noffs - blkinfo->offset], inode.namlen, crc); crc = crc32part(&blkinfo->buffer[noffs - blkinfo->offset], inode.namlen, crc);
if (crc != ecrc) if (crc != ecrc)
{ {
syslog(LOG_NOTICE, g_format, syslog(LOG_NOTICE, g_format,
blkinfo->block, offset, "INODE", "CRC BAD", datlen); blkinfo->block, offset, "INODE", "CRC BAD", datlen);
return ERROR; return ERROR;
} }
/* If must be a good header */ /* If must be a good header */
@@ -276,11 +276,11 @@ static inline ssize_t nxffs_analyzedata(FAR struct nxffs_blkinfo_s *blkinfo,
crc = crc32part(&blkinfo->buffer[offset + SIZEOF_NXFFS_DATA_HDR], datlen, crc); crc = crc32part(&blkinfo->buffer[offset + SIZEOF_NXFFS_DATA_HDR], datlen, crc);
if (crc != ecrc) if (crc != ecrc)
{ {
syslog(LOG_NOTICE, g_format, syslog(LOG_NOTICE, g_format,
blkinfo->block, offset, "DATA ", "CRC BAD", datlen); blkinfo->block, offset, "DATA ", "CRC BAD", datlen);
return ERROR; return ERROR;
} }
/* If must be a good header */ /* If must be a good header */
@@ -323,7 +323,8 @@ static inline void nxffs_analyze(FAR struct nxffs_blkinfo_s *blkinfo)
else if (blkhdr->state == BLOCK_STATE_GOOD) else if (blkhdr->state == BLOCK_STATE_GOOD)
{ {
size_t datsize = blkinfo->geo.blocksize - SIZEOF_NXFFS_BLOCK_HDR; size_t datsize = blkinfo->geo.blocksize - SIZEOF_NXFFS_BLOCK_HDR;
size_t nerased = nxffs_erased(blkinfo->buffer + SIZEOF_NXFFS_BLOCK_HDR, datsize); size_t nerased = nxffs_erased(blkinfo->buffer + SIZEOF_NXFFS_BLOCK_HDR,
datsize);
if (nerased == datsize) if (nerased == datsize)
{ {
if (blkinfo->verbose) if (blkinfo->verbose)
@@ -459,7 +460,8 @@ int nxffs_dump(FAR struct mtd_dev_s *mtd, bool verbose)
syslog(LOG_NOTICE, "NXFFS Dump:\n"); syslog(LOG_NOTICE, "NXFFS Dump:\n");
syslog(LOG_NOTICE, g_hdrformat); syslog(LOG_NOTICE, g_hdrformat);
blkinfo.nblocks = blkinfo.geo.erasesize * blkinfo.geo.neraseblocks / blkinfo.geo.blocksize; blkinfo.nblocks = blkinfo.geo.erasesize * blkinfo.geo.neraseblocks /
blkinfo.geo.blocksize;
for (blkinfo.block = 0, blkinfo.offset = 0; for (blkinfo.block = 0, blkinfo.offset = 0;
blkinfo.block < blkinfo.nblocks; blkinfo.block < blkinfo.nblocks;
blkinfo.block++, blkinfo.offset += blkinfo.geo.blocksize) blkinfo.block++, blkinfo.offset += blkinfo.geo.blocksize)
+3 -2
View File
@@ -390,7 +390,7 @@ int nxffs_findinode(FAR struct nxffs_volume_s *volume, FAR const char *name,
*/ */
for (; ; ) for (; ; )
{ {
/* Get the next, valid NXFFS inode entry */ /* Get the next, valid NXFFS inode entry */
ret = nxffs_nextentry(volume, offset, entry); ret = nxffs_nextentry(volume, offset, entry);
@@ -460,7 +460,8 @@ off_t nxffs_inodeend(FAR struct nxffs_volume_s *volume,
* of the block minus the minimum number of headers: block sna data * of the block minus the minimum number of headers: block sna data
*/ */
uint16_t maxsize = volume->geo.blocksize - SIZEOF_NXFFS_BLOCK_HDR - SIZEOF_NXFFS_DATA_HDR; uint16_t maxsize = volume->geo.blocksize - SIZEOF_NXFFS_BLOCK_HDR -
SIZEOF_NXFFS_DATA_HDR;
/* This is the minimum number of blocks require to span all of the /* This is the minimum number of blocks require to span all of the
* inode data. One additional block could possibly be required -- we * inode data. One additional block could possibly be required -- we
+17 -16
View File
@@ -122,6 +122,7 @@ static inline int nxffs_hdrpos(FAR struct nxffs_volume_s *volume,
wrfile->ofile.entry.hoffset = nxffs_iotell(volume); wrfile->ofile.entry.hoffset = nxffs_iotell(volume);
} }
return ret; return ret;
} }
@@ -1021,25 +1022,25 @@ int nxffs_open(FAR struct file *filep, FAR const char *relpath,
* extension is supported. * extension is supported.
*/ */
switch (oflags & (O_WROK | O_RDOK)) switch (oflags & (O_WROK | O_RDOK))
{ {
case 0: case 0:
default: default:
ferr("ERROR: One of O_WRONLY/O_RDONLY must be provided\n"); ferr("ERROR: One of O_WRONLY/O_RDONLY must be provided\n");
return -EINVAL; return -EINVAL;
case O_WROK: case O_WROK:
ret = nxffs_wropen(volume, relpath, oflags, &ofile); ret = nxffs_wropen(volume, relpath, oflags, &ofile);
break; break;
case O_RDOK: case O_RDOK:
ret = nxffs_rdopen(volume, relpath, &ofile); ret = nxffs_rdopen(volume, relpath, &ofile);
break; break;
case O_WROK | O_RDOK: case O_WROK | O_RDOK:
ferr("ERROR: O_RDWR is not supported\n"); ferr("ERROR: O_RDWR is not supported\n");
return -ENOSYS; return -ENOSYS;
} }
/* Save the reference to the open-specific state in filep->f_priv */ /* Save the reference to the open-specific state in filep->f_priv */
+59 -52
View File
@@ -214,11 +214,11 @@ static inline off_t nxffs_mediacheck(FAR struct nxffs_volume_s *volume,
volume->ioblock = 0; volume->ioblock = 0;
ret = nxffs_validblock(volume, &volume->ioblock); ret = nxffs_validblock(volume, &volume->ioblock);
if (ret < 0) if (ret < 0)
{ {
/* No valid blocks? Return offset zero. */ /* No valid blocks? Return offset zero. */
return 0; return 0;
} }
/* The offset to the free location to pack is then just after the block /* The offset to the free location to pack is then just after the block
* header in this block. * header in this block.
@@ -234,7 +234,7 @@ static inline off_t nxffs_mediacheck(FAR struct nxffs_volume_s *volume,
{ {
/* No valid entries on the media -- Return offset zero */ /* No valid entries on the media -- Return offset zero */
return 0; return 0;
} }
/* Okay.. the start block and first entry have been found */ /* Okay.. the start block and first entry have been found */
@@ -548,7 +548,8 @@ static int nxffs_destsetup(FAR struct nxffs_volume_s *volume,
*/ */
mindata = MIN(NXFFS_MINDATA, pack->dest.entry.datlen); mindata = MIN(NXFFS_MINDATA, pack->dest.entry.datlen);
if (pack->iooffset + SIZEOF_NXFFS_DATA_HDR + mindata > volume->geo.blocksize) if (pack->iooffset + SIZEOF_NXFFS_DATA_HDR + mindata >
volume->geo.blocksize)
{ {
/* No.. return an indication that we are at the end of the block /* No.. return an indication that we are at the end of the block
* and try again later. * and try again later.
@@ -556,7 +557,7 @@ static int nxffs_destsetup(FAR struct nxffs_volume_s *volume,
ret = -ENOSPC; ret = -ENOSPC;
goto errout; goto errout;
} }
/* Yes.. reserve space for the data block header */ /* Yes.. reserve space for the data block header */
@@ -581,7 +582,8 @@ static int nxffs_destsetup(FAR struct nxffs_volume_s *volume,
*/ */
mindata = MIN(NXFFS_MINDATA, pack->dest.entry.datlen); mindata = MIN(NXFFS_MINDATA, pack->dest.entry.datlen);
if (pack->iooffset + SIZEOF_NXFFS_DATA_HDR + mindata > volume->geo.blocksize) if (pack->iooffset + SIZEOF_NXFFS_DATA_HDR + mindata >
volume->geo.blocksize)
{ {
/* No.. return an indication that we are at the end of the block /* No.. return an indication that we are at the end of the block
* and try again later. * and try again later.
@@ -589,7 +591,7 @@ static int nxffs_destsetup(FAR struct nxffs_volume_s *volume,
ret = -ENOSPC; ret = -ENOSPC;
goto errout; goto errout;
} }
/* Yes.. reserve space for the data block header */ /* Yes.. reserve space for the data block header */
@@ -762,7 +764,8 @@ static void nxffs_wrdathdr(FAR struct nxffs_volume_s *volume,
/* Update the entire data block CRC (including the header) */ /* Update the entire data block CRC (including the header) */
crc = crc32(&pack->iobuffer[iooffset], pack->dest.blklen + SIZEOF_NXFFS_DATA_HDR); crc = crc32(&pack->iobuffer[iooffset],
pack->dest.blklen + SIZEOF_NXFFS_DATA_HDR);
nxffs_wrle32(dathdr->crc, crc); nxffs_wrle32(dathdr->crc, crc);
} }
@@ -791,33 +794,36 @@ static void nxffs_wrdathdr(FAR struct nxffs_volume_s *volume,
static void nxffs_packtransfer(FAR struct nxffs_volume_s *volume, static void nxffs_packtransfer(FAR struct nxffs_volume_s *volume,
FAR struct nxffs_pack_s *pack) FAR struct nxffs_pack_s *pack)
{ {
/* Determine how much data is available in the dest pack buffer */ /* Determine how much data is available in the dest pack buffer */
uint16_t destlen = volume->geo.blocksize - pack->iooffset; uint16_t destlen = volume->geo.blocksize - pack->iooffset;
/* Dermined how much data is available in the src data block */ /* Dermined how much data is available in the src data block */
uint16_t srclen = pack->src.blklen - pack->src.blkpos; uint16_t srclen = pack->src.blklen - pack->src.blkpos;
/* Transfer the smaller of the two amounts data */ /* Transfer the smaller of the two amounts data */
uint16_t xfrlen = MIN(srclen, destlen); uint16_t xfrlen = MIN(srclen, destlen);
if (xfrlen > 0) if (xfrlen > 0)
{ {
nxffs_ioseek(volume, pack->src.blkoffset + SIZEOF_NXFFS_DATA_HDR + pack->src.blkpos); nxffs_ioseek(volume,
memcpy(&pack->iobuffer[pack->iooffset], &volume->cache[volume->iooffset], xfrlen); pack->src.blkoffset + SIZEOF_NXFFS_DATA_HDR +
pack->src.blkpos);
memcpy(&pack->iobuffer[pack->iooffset],
&volume->cache[volume->iooffset], xfrlen);
/* Increment counts and offset for this data transfer */ /* Increment counts and offset for this data transfer */
pack->src.fpos += xfrlen; /* Source data offsets */ pack->src.fpos += xfrlen; /* Source data offsets */
pack->src.blkpos += xfrlen; pack->src.blkpos += xfrlen;
pack->dest.fpos += xfrlen; /* Destination data offsets */ pack->dest.fpos += xfrlen; /* Destination data offsets */
pack->dest.blkpos += xfrlen; pack->dest.blkpos += xfrlen;
pack->dest.blklen += xfrlen; /* Destination data block size */ pack->dest.blklen += xfrlen; /* Destination data block size */
pack->iooffset += xfrlen; /* Destination I/O block offset */ pack->iooffset += xfrlen; /* Destination I/O block offset */
volume->iooffset += xfrlen; /* Source I/O block offset */ volume->iooffset += xfrlen; /* Source I/O block offset */
volume->froffset += xfrlen; /* Free FLASH offset */ volume->froffset += xfrlen; /* Free FLASH offset */
} }
} }
/**************************************************************************** /****************************************************************************
@@ -1031,15 +1037,15 @@ static inline int nxffs_packblock(FAR struct nxffs_volume_s *volume,
} }
} }
/* Check if the destination block is full */ /* Check if the destination block is full */
if (pack->iooffset >= volume->geo.blocksize) if (pack->iooffset >= volume->geo.blocksize)
{ {
/* Yes.. Write the destination data block header and return success */ /* Yes.. Write the destination data block header and return success */
nxffs_wrdathdr(volume, pack); nxffs_wrdathdr(volume, pack);
return OK; return OK;
} }
} }
return -ENOSYS; return -ENOSYS;
@@ -1094,15 +1100,16 @@ nxffs_setupwriter(FAR struct nxffs_volume_s *volume,
{ {
/* Initialize for the packing operation. */ /* Initialize for the packing operation. */
memset(&pack->dest, 0, sizeof(struct nxffs_packstream_s)); memset(&pack->dest, 0, sizeof(struct nxffs_packstream_s));
pack->dest.entry.name = strdup(wrfile->ofile.entry.name); pack->dest.entry.name = strdup(wrfile->ofile.entry.name);
pack->dest.entry.utc = wrfile->ofile.entry.utc; pack->dest.entry.utc = wrfile->ofile.entry.utc;
pack->dest.entry.datlen = wrfile->ofile.entry.datlen; pack->dest.entry.datlen = wrfile->ofile.entry.datlen;
memset(&pack->src, 0, sizeof(struct nxffs_packstream_s)); memset(&pack->src, 0, sizeof(struct nxffs_packstream_s));
memcpy(&pack->src.entry, &wrfile->ofile.entry, sizeof(struct nxffs_entry_s)); memcpy(&pack->src.entry, &wrfile->ofile.entry,
pack->src.entry.name = NULL; sizeof(struct nxffs_entry_s));
return wrfile; pack->src.entry.name = NULL;
return wrfile;
} }
} }
@@ -1230,15 +1237,15 @@ static inline int nxffs_packwriter(FAR struct nxffs_volume_s *volume,
} }
} }
/* Check if the destination block is full */ /* Check if the destination block is full */
if (pack->iooffset >= volume->geo.blocksize) if (pack->iooffset >= volume->geo.blocksize)
{ {
/* Yes.. Write the destination data block header and return success */ /* Yes.. Write the destination data block header and return success */
nxffs_wrdathdr(volume, pack); nxffs_wrdathdr(volume, pack);
return OK; return OK;
} }
} }
return -ENOSYS; return -ENOSYS;
+6 -3
View File
@@ -221,7 +221,8 @@ static int nxffs_badblocks(FAR struct nxffs_volume_s *volume)
else else
{ {
size_t blocksize = volume->geo.blocksize - SIZEOF_NXFFS_BLOCK_HDR; size_t blocksize = volume->geo.blocksize - SIZEOF_NXFFS_BLOCK_HDR;
size_t erasesize = nxffs_erased(&blkptr[SIZEOF_NXFFS_BLOCK_HDR], blocksize); size_t erasesize = nxffs_erased(&blkptr[SIZEOF_NXFFS_BLOCK_HDR],
blocksize);
good = (blocksize == erasesize); good = (blocksize == erasesize);
} }
@@ -241,10 +242,12 @@ static int nxffs_badblocks(FAR struct nxffs_volume_s *volume)
if (modified) if (modified)
{ {
nxfrd = MTD_BWRITE(volume->mtd, lblock, volume->blkper, volume->pack); nxfrd = MTD_BWRITE(volume->mtd, lblock, volume->blkper,
volume->pack);
if (nxfrd != volume->blkper) if (nxfrd != volume->blkper)
{ {
ferr("ERROR: Write erase block %d failed: %d\n", lblock, nxfrd); ferr("ERROR: Write erase block %d failed: %d\n",
lblock, nxfrd);
return -EIO; return -EIO;
} }
} }
+4 -3
View File
@@ -96,7 +96,8 @@ int nxffs_statfs(FAR struct inode *mountpt, FAR struct statfs *buf)
buf->f_type = NXFFS_MAGIC; buf->f_type = NXFFS_MAGIC;
buf->f_bsize = volume->geo.blocksize; buf->f_bsize = volume->geo.blocksize;
buf->f_blocks = volume->nblocks; buf->f_blocks = volume->nblocks;
buf->f_namelen = volume->geo.blocksize - SIZEOF_NXFFS_BLOCK_HDR - SIZEOF_NXFFS_INODE_HDR; buf->f_namelen = volume->geo.blocksize - SIZEOF_NXFFS_BLOCK_HDR -
SIZEOF_NXFFS_INODE_HDR;
ret = OK; ret = OK;
nxsem_post(&volume->exclsem); nxsem_post(&volume->exclsem);
@@ -154,7 +155,8 @@ int nxffs_stat(FAR struct inode *mountpt, FAR const char *relpath,
/* Return status information based on the directory entry */ /* Return status information based on the directory entry */
buf->st_blocks = entry.datlen / (volume->geo.blocksize - SIZEOF_NXFFS_BLOCK_HDR); buf->st_blocks = entry.datlen /
(volume->geo.blocksize - SIZEOF_NXFFS_BLOCK_HDR);
buf->st_mode = S_IFREG | S_IXOTH | S_IXGRP | S_IXUSR; buf->st_mode = S_IFREG | S_IXOTH | S_IXGRP | S_IXUSR;
buf->st_size = entry.datlen; buf->st_size = entry.datlen;
buf->st_atime = entry.utc; buf->st_atime = entry.utc;
@@ -193,7 +195,6 @@ errout:
int nxffs_fstat(FAR const struct file *filep, FAR struct stat *buf) int nxffs_fstat(FAR const struct file *filep, FAR struct stat *buf)
{ {
FAR struct nxffs_volume_s *volume; FAR struct nxffs_volume_s *volume;
FAR struct nxffs_ofile_s *ofile; FAR struct nxffs_ofile_s *ofile;
int ret; int ret;
+1
View File
@@ -158,6 +158,7 @@ size_t nxffs_erased(FAR const uint8_t *buffer, size_t buflen)
{ {
break; break;
} }
buffer++; buffer++;
} }
+10 -8
View File
@@ -899,15 +899,15 @@ int nxffs_wrverify(FAR struct nxffs_volume_s *volume, size_t size)
if (nerased >= size) if (nerased >= size)
{ {
/* Yes.. this this is where we will put the object */ /* Yes.. this this is where we will put the object */
off_t offset = off_t offset =
volume->ioblock * volume->geo.blocksize + iooffset; volume->ioblock * volume->geo.blocksize + iooffset;
/* Update the free flash offset and return success */ /* Update the free flash offset and return success */
volume->froffset = offset + size; volume->froffset = offset + size;
return OK; return OK;
} }
} }
@@ -938,7 +938,8 @@ int nxffs_wrverify(FAR struct nxffs_volume_s *volume, size_t size)
} }
volume->iooffset = SIZEOF_NXFFS_BLOCK_HDR; volume->iooffset = SIZEOF_NXFFS_BLOCK_HDR;
volume->froffset = volume->ioblock * volume->geo.blocksize + SIZEOF_NXFFS_BLOCK_HDR; volume->froffset = volume->ioblock * volume->geo.blocksize +
SIZEOF_NXFFS_BLOCK_HDR;
} }
/* Return -ENOSPC if there is no erased memory left in the volume for /* Return -ENOSPC if there is no erased memory left in the volume for
@@ -983,7 +984,8 @@ int nxffs_wrblkhdr(FAR struct nxffs_volume_s *volume,
/* Update the entire data block CRC (including the header) */ /* Update the entire data block CRC (including the header) */
wrfile->crc = crc32(&volume->cache[volume->iooffset], wrfile->datlen + SIZEOF_NXFFS_DATA_HDR); wrfile->crc = crc32(&volume->cache[volume->iooffset],
wrfile->datlen + SIZEOF_NXFFS_DATA_HDR);
nxffs_wrle32(dathdr->crc, wrfile->crc); nxffs_wrle32(dathdr->crc, wrfile->crc);
/* And write the data block to FLASH */ /* And write the data block to FLASH */
+2 -2
View File
@@ -638,7 +638,7 @@ static int procfs_opendir(FAR struct inode *mountpt, FAR const char *relpath,
return ret; return ret;
} }
/* Test for a sub-string match (e.g. "ls /proc/fs") */ /* Test for a sub-string match (e.g. "ls /proc/fs") */
else if (strncmp(g_procfs_entries[x].pathpattern, relpath, else if (strncmp(g_procfs_entries[x].pathpattern, relpath,
len) == 0) len) == 0)
@@ -863,7 +863,7 @@ static int procfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
#endif /* CONFIG_FS_PROCFS_EXCLUDE_PROCESS */ #endif /* CONFIG_FS_PROCFS_EXCLUDE_PROCESS */
} }
/* Are we reading an intermediate subdirectory? */ /* Are we reading an intermediate subdirectory? */
else if (priv->level > 0 && priv->procfsentry == NULL) else if (priv->level > 0 && priv->procfsentry == NULL)
{ {
+1 -1
View File
@@ -106,7 +106,7 @@ static int iobinfo_stat(FAR const char *relpath, FAR struct stat *buf);
* logic found in the enum iob_user_e declaration found in iob.h * logic found in the enum iob_user_e declaration found in iob.h
*/ */
static const char* g_iob_user_names[] = static FAR const char *g_iob_user_names[] =
{ {
#ifdef CONFIG_SYSLOG_BUFFER #ifdef CONFIG_SYSLOG_BUFFER
"syslog", "syslog",
+48 -27
View File
@@ -440,16 +440,20 @@ static FAR const struct proc_node_s *proc_findnode(FAR const char *relpath)
* *
* 111111111122222222223 * 111111111122222222223
* 123456789012345678901234567890 * 123456789012345678901234567890
* Name: xxxx... Task/thread name (See CONFIG_TASK_NAME_SIZE) * Name: xxxx... Task/thread name (See
* CONFIG_TASK_NAME_SIZE)
* Type: xxxxxxx {Task, pthread, Kthread, Invalid} * Type: xxxxxxx {Task, pthread, Kthread, Invalid}
* PPID: xxxxx Parent thread ID * PPID: xxxxx Parent thread ID
* Group: xxxxx Group ID * Group: xxxxx Group ID
* CPU: xxx CPU (CONFIG_SMP only) * CPU: xxx CPU (CONFIG_SMP only)
* State: xxxxxxxx,xxxxxxxxx {Invalid, Waiting, Ready, Running, Inactive}, * State: xxxxxxxx,xxxxxxxxx {Invalid, Waiting, Ready, Running,
* {Unlock, Semaphore, Signal, MQ empty, MQ full} * Inactive},
* {Unlock, Semaphore, Signal, MQ empty,
* MQ full}
* Flags: xxx N,P,X * Flags: xxx N,P,X
* Priority: nnn Decimal, 0-255 * Priority: nnn Decimal, 0-255
* Scheduler: xxxxxxxxxxxxxx {SCHED_FIFO, SCHED_RR, SCHED_SPORADIC, SCHED_OTHER} * Scheduler: xxxxxxxxxxxxxx {SCHED_FIFO, SCHED_RR, SCHED_SPORADIC,
* SCHED_OTHER}
* Sigmask: nnnnnnnn Hexadecimal, 32-bit * Sigmask: nnnnnnnn Hexadecimal, 32-bit
* *
****************************************************************************/ ****************************************************************************/
@@ -680,8 +684,10 @@ static ssize_t proc_cmdline(FAR struct proc_file_s *procfile,
{ {
FAR struct pthread_tcb_s *ptcb = (FAR struct pthread_tcb_s *)tcb; FAR struct pthread_tcb_s *ptcb = (FAR struct pthread_tcb_s *)tcb;
linesize = snprintf(procfile->line, STATUS_LINELEN, " 0x%p\n", ptcb->arg); linesize = snprintf(procfile->line, STATUS_LINELEN, " 0x%p\n",
copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset); ptcb->arg);
copysize = procfs_memcpy(procfile->line, linesize, buffer,
remaining, &offset);
totalsize += copysize; totalsize += copysize;
buffer += copysize; buffer += copysize;
@@ -698,7 +704,8 @@ static ssize_t proc_cmdline(FAR struct proc_file_s *procfile,
for (argv = ttcb->argv + 1; *argv; argv++) for (argv = ttcb->argv + 1; *argv; argv++)
{ {
linesize = snprintf(procfile->line, STATUS_LINELEN, " %s", *argv); linesize = snprintf(procfile->line, STATUS_LINELEN, " %s", *argv);
copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset); copysize = procfs_memcpy(procfile->line, linesize, buffer,
remaining, &offset);
totalsize += copysize; totalsize += copysize;
buffer += copysize; buffer += copysize;
@@ -711,7 +718,8 @@ static ssize_t proc_cmdline(FAR struct proc_file_s *procfile,
} }
linesize = snprintf(procfile->line, STATUS_LINELEN, "\n"); linesize = snprintf(procfile->line, STATUS_LINELEN, "\n");
copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset); copysize = procfs_memcpy(procfile->line, linesize, buffer,
remaining, &offset);
totalsize += copysize; totalsize += copysize;
return totalsize; return totalsize;
@@ -931,7 +939,8 @@ static ssize_t proc_groupstatus(FAR struct proc_file_s *procfile,
#ifdef HAVE_GROUP_MEMBERS #ifdef HAVE_GROUP_MEMBERS
linesize = snprintf(procfile->line, STATUS_LINELEN, "%-12s%d\n", linesize = snprintf(procfile->line, STATUS_LINELEN, "%-12s%d\n",
"Group ID:", group->tg_grpid); "Group ID:", group->tg_grpid);
copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset); copysize = procfs_memcpy(procfile->line, linesize, buffer,
remaining, &offset);
totalsize += copysize; totalsize += copysize;
buffer += copysize; buffer += copysize;
@@ -944,7 +953,8 @@ static ssize_t proc_groupstatus(FAR struct proc_file_s *procfile,
linesize = snprintf(procfile->line, STATUS_LINELEN, "%-12s%d\n", linesize = snprintf(procfile->line, STATUS_LINELEN, "%-12s%d\n",
"Parent ID:", group->tg_pgrpid); "Parent ID:", group->tg_pgrpid);
copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset); copysize = procfs_memcpy(procfile->line, linesize, buffer,
remaining, &offset);
totalsize += copysize; totalsize += copysize;
buffer += copysize; buffer += copysize;
@@ -959,7 +969,8 @@ static ssize_t proc_groupstatus(FAR struct proc_file_s *procfile,
#if !defined(CONFIG_DISABLE_PTHREAD) && defined(CONFIG_SCHED_HAVE_PARENT) #if !defined(CONFIG_DISABLE_PTHREAD) && defined(CONFIG_SCHED_HAVE_PARENT)
linesize = snprintf(procfile->line, STATUS_LINELEN, "%-12s%d\n", linesize = snprintf(procfile->line, STATUS_LINELEN, "%-12s%d\n",
"Main task:", group->tg_task); "Main task:", group->tg_task);
copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset); copysize = procfs_memcpy(procfile->line, linesize, buffer,
remaining, &offset);
totalsize += copysize; totalsize += copysize;
buffer += copysize; buffer += copysize;
@@ -973,7 +984,8 @@ static ssize_t proc_groupstatus(FAR struct proc_file_s *procfile,
linesize = snprintf(procfile->line, STATUS_LINELEN, "%-12s0x%02x\n", linesize = snprintf(procfile->line, STATUS_LINELEN, "%-12s0x%02x\n",
"Flags:", group->tg_flags); "Flags:", group->tg_flags);
copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset); copysize = procfs_memcpy(procfile->line, linesize, buffer,
remaining, &offset);
totalsize += copysize; totalsize += copysize;
buffer += copysize; buffer += copysize;
@@ -986,7 +998,8 @@ static ssize_t proc_groupstatus(FAR struct proc_file_s *procfile,
linesize = snprintf(procfile->line, STATUS_LINELEN, "%-12s%d\n", linesize = snprintf(procfile->line, STATUS_LINELEN, "%-12s%d\n",
"Members:", group->tg_nmembers); "Members:", group->tg_nmembers);
copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset); copysize = procfs_memcpy(procfile->line, linesize, buffer,
remaining, &offset);
totalsize += copysize; totalsize += copysize;
buffer += copysize; buffer += copysize;
@@ -999,7 +1012,8 @@ static ssize_t proc_groupstatus(FAR struct proc_file_s *procfile,
} }
linesize = snprintf(procfile->line, STATUS_LINELEN, "Member IDs:"); linesize = snprintf(procfile->line, STATUS_LINELEN, "Member IDs:");
copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset); copysize = procfs_memcpy(procfile->line, linesize, buffer,
remaining, &offset);
totalsize += copysize; totalsize += copysize;
buffer += copysize; buffer += copysize;
@@ -1012,8 +1026,10 @@ static ssize_t proc_groupstatus(FAR struct proc_file_s *procfile,
for (i = 0; i < group->tg_nmembers; i++) for (i = 0; i < group->tg_nmembers; i++)
{ {
linesize = snprintf(procfile->line, STATUS_LINELEN, " %d", group->tg_members[i]); linesize = snprintf(procfile->line, STATUS_LINELEN, " %d",
copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset); group->tg_members[i]);
copysize = procfs_memcpy(procfile->line, linesize, buffer,
remaining, &offset);
totalsize += copysize; totalsize += copysize;
buffer += copysize; buffer += copysize;
@@ -1083,9 +1099,11 @@ static ssize_t proc_groupfd(FAR struct proc_file_s *procfile,
if (file->f_inode) if (file->f_inode)
{ {
linesize = snprintf(procfile->line, STATUS_LINELEN, "%3d %8ld %04x\n", linesize = snprintf(procfile->line, STATUS_LINELEN,
i, (long)file->f_pos, file->f_oflags); "%3d %8ld %04x\n", i, (long)file->f_pos,
copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset); file->f_oflags);
copysize = procfs_memcpy(procfile->line, linesize, buffer,
remaining, &offset);
totalsize += copysize; totalsize += copysize;
buffer += copysize; buffer += copysize;
@@ -1122,10 +1140,13 @@ static ssize_t proc_groupfd(FAR struct proc_file_s *procfile,
if (socket->s_conn) if (socket->s_conn)
{ {
linesize = snprintf(procfile->line, STATUS_LINELEN, "%3d %2d %3d %02x", linesize = snprintf(procfile->line, STATUS_LINELEN,
"%3d %2d %3d %02x",
i + CONFIG_NFILE_DESCRIPTORS, i + CONFIG_NFILE_DESCRIPTORS,
socket->s_crefs, socket->s_type, socket->s_flags); socket->s_crefs, socket->s_type,
copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset); socket->s_flags);
copysize = procfs_memcpy(procfile->line, linesize, buffer,
remaining, &offset);
totalsize += copysize; totalsize += copysize;
buffer += copysize; buffer += copysize;
@@ -1541,7 +1562,7 @@ static int proc_opendir(FAR const char *relpath, FAR struct fs_dirent_s *dir)
ferr("ERROR: Invalid path \"%s\"\n", relpath); ferr("ERROR: Invalid path \"%s\"\n", relpath);
return -ENOENT; return -ENOENT;
} }
/* A valid PID would be in the range of 0-32767 (0 is reserved for the /* A valid PID would be in the range of 0-32767 (0 is reserved for the
* IDLE thread). * IDLE thread).
@@ -1617,9 +1638,9 @@ static int proc_opendir(FAR const char *relpath, FAR struct fs_dirent_s *dir)
procdir->node = &g_level0node; procdir->node = &g_level0node;
} }
procdir->pid = pid; procdir->pid = pid;
dir->u.procfs = (FAR void *)procdir; dir->u.procfs = (FAR void *)procdir;
return OK; return OK;
} }
/**************************************************************************** /****************************************************************************
@@ -1787,7 +1808,7 @@ static int proc_stat(const char *relpath, struct stat *buf)
{ {
ferr("ERROR: Invalid path \"%s\"\n", relpath); ferr("ERROR: Invalid path \"%s\"\n", relpath);
return -ENOENT; return -ENOENT;
} }
/* A valid PID would be in the range of 0-32767 (0 is reserved for the /* A valid PID would be in the range of 0-32767 (0 is reserved for the
* IDLE thread). * IDLE thread).
+1 -1
View File
@@ -1077,7 +1077,7 @@ static int romfs_unbind(FAR void *handle, FAR struct inode **blkdriver,
} }
else else
{ {
/* Unmount ... close the block driver */ /* Unmount ... close the block driver */
if (rm->rm_blkdriver) if (rm->rm_blkdriver)
{ {
+10 -10
View File
@@ -196,7 +196,7 @@ int16_t romfs_devcacheread(struct romfs_mountpt_s *rm, uint32_t offset)
ret = romfs_hwread(rm, rm->rm_buffer, sector, 1); ret = romfs_hwread(rm, rm->rm_buffer, sector, 1);
if (ret < 0) if (ret < 0)
{ {
return (int16_t)ret; return (int16_t)ret;
} }
} }
@@ -306,20 +306,20 @@ static inline int romfs_searchdir(struct romfs_mountpt_s *rm,
ret = romfs_checkentry(rm, offset, entryname, entrylen, dirinfo); ret = romfs_checkentry(rm, offset, entryname, entrylen, dirinfo);
if (ret == OK) if (ret == OK)
{ {
/* Its a match! Return success */ /* Its a match! Return success */
return OK; return OK;
} }
/* No match... select the offset to the next entry */ /* No match... select the offset to the next entry */
offset = next; offset = next;
} }
while (next != 0); while (next != 0);
/* There is nothing in this directory with that name */ /* There is nothing in this directory with that name */
return -ENOENT; return -ENOENT;
} }
/**************************************************************************** /****************************************************************************
@@ -355,7 +355,7 @@ void romfs_semtake(struct romfs_mountpt_s *rm)
void romfs_semgive(struct romfs_mountpt_s *rm) void romfs_semgive(struct romfs_mountpt_s *rm)
{ {
nxsem_post(&rm->rm_sem); nxsem_post(&rm->rm_sem);
} }
/**************************************************************************** /****************************************************************************
@@ -786,9 +786,9 @@ int romfs_finddirentry(struct romfs_mountpt_s *rm,
if (!terminator) if (!terminator)
{ {
/* Yes.. return success */ /* Yes.. return success */
return OK; return OK;
} }
/* No... If that was not the last path component, then it had /* No... If that was not the last path component, then it had
@@ -856,7 +856,7 @@ int romfs_parsedirentry(struct romfs_mountpt_s *rm, uint32_t offset,
* associated name may not, however. * associated name may not, however.
*/ */
next = romfs_devread32(rm, ndx + ROMFS_FHDR_NEXT); next = romfs_devread32(rm, ndx + ROMFS_FHDR_NEXT);
*pnext = (save & RFNEXT_OFFSETMASK) | (next & RFNEXT_ALLMODEMASK); *pnext = (save & RFNEXT_OFFSETMASK) | (next & RFNEXT_ALLMODEMASK);
*pinfo = romfs_devread32(rm, ndx + ROMFS_FHDR_INFO); *pinfo = romfs_devread32(rm, ndx + ROMFS_FHDR_INFO);
*psize = romfs_devread32(rm, ndx + ROMFS_FHDR_SIZE); *psize = romfs_devread32(rm, ndx + ROMFS_FHDR_SIZE);
+14 -7
View File
@@ -826,9 +826,11 @@ static size_t smartfs_status_read(FAR struct file *filep, FAR char *buffer,
} }
else else
{ {
utilization = 100 * (procfs_data.blockerases * procfs_data.sectorsperblk - utilization = 100 * (procfs_data.blockerases *
procfs_data.unusedsectors) / (procfs_data.blockerases * procfs_data.sectorsperblk -
procfs_data.sectorsperblk); procfs_data.unusedsectors) /
(procfs_data.blockerases *
procfs_data.sectorsperblk);
} }
/* Format and return data in the buffer */ /* Format and return data in the buffer */
@@ -857,7 +859,7 @@ static size_t smartfs_status_read(FAR struct file *filep, FAR char *buffer,
/* Indicate we have already provided all the data */ /* Indicate we have already provided all the data */
priv->offset = 0xFF; priv->offset = 0xff;
} }
return len; return len;
@@ -921,7 +923,7 @@ static size_t smartfs_mem_read(FAR struct file *filep, FAR char *buffer,
/* Indicate we have done the read */ /* Indicate we have done the read */
priv->offset = 0xFF; priv->offset = 0xff;
} }
return len; return len;
@@ -995,8 +997,11 @@ static size_t smartfs_erasemap_read(FAR struct file *filep, FAR char *buffer,
priv->offset++; priv->offset++;
if (len >= buflen) if (len >= buflen)
return len; {
return len;
}
} }
copylen++; copylen++;
} }
@@ -1007,7 +1012,9 @@ static size_t smartfs_erasemap_read(FAR struct file *filep, FAR char *buffer,
buffer[len++] = '\n'; buffer[len++] = '\n';
priv->offset++; priv->offset++;
if (len >= buflen) if (len >= buflen)
return len; {
return len;
}
} }
/* Terminate the string */ /* Terminate the string */
+11 -10
View File
@@ -294,13 +294,13 @@ static int smartfs_open(FAR struct file *filep, const char *relpath,
/* Yes... test if the parent directory is valid */ /* Yes... test if the parent directory is valid */
if (parentdirsector != 0xFFFF) if (parentdirsector != 0xffff)
{ {
/* We can create in the given parent directory */ /* We can create in the given parent directory */
ret = smartfs_createentry(fs, parentdirsector, filename, ret = smartfs_createentry(fs, parentdirsector, filename,
SMARTFS_DIRENT_TYPE_FILE, mode, SMARTFS_DIRENT_TYPE_FILE, mode,
&sf->entry, 0xFFFF, sf); &sf->entry, 0xffff, sf);
if (ret != OK) if (ret != OK)
{ {
goto errout_with_buffer; goto errout_with_buffer;
@@ -821,7 +821,7 @@ static ssize_t smartfs_write(FAR struct file *filep, const char *buffer,
{ {
/* First get a new chained sector */ /* First get a new chained sector */
ret = FS_IOCTL(fs, BIOC_ALLOCSECT, 0xFFFF); ret = FS_IOCTL(fs, BIOC_ALLOCSECT, 0xffff);
if (ret < 0) if (ret < 0)
{ {
ferr("ERROR: Error %d allocating new sector\n", ret); ferr("ERROR: Error %d allocating new sector\n", ret);
@@ -876,7 +876,7 @@ static ssize_t smartfs_write(FAR struct file *filep, const char *buffer,
{ {
/* Allocate a new sector */ /* Allocate a new sector */
ret = FS_IOCTL(fs, BIOC_ALLOCSECT, 0xFFFF); ret = FS_IOCTL(fs, BIOC_ALLOCSECT, 0xffff);
if (ret < 0) if (ret < 0)
{ {
ferr("ERROR: Error %d allocating new sector\n", ret); ferr("ERROR: Error %d allocating new sector\n", ret);
@@ -1148,6 +1148,7 @@ static int smartfs_truncate(FAR struct file *filep, off_t length)
} }
errout_with_semaphore: errout_with_semaphore:
/* Relinquish exclusive access */ /* Relinquish exclusive access */
smartfs_semgive(fs); smartfs_semgive(fs);
@@ -1201,6 +1202,7 @@ static int smartfs_opendir(FAR struct inode *mountpt, FAR const char *relpath,
ret = OK; ret = OK;
errout_with_semaphore: errout_with_semaphore:
/* If space for the entry name was allocated, then free it */ /* If space for the entry name was allocated, then free it */
if (entry.name != NULL) if (entry.name != NULL)
@@ -1482,7 +1484,7 @@ static int smartfs_unbind(FAR void *handle, FAR struct inode **blkdriver,
} }
else else
{ {
/* Unmount ... close the block driver */ /* Unmount ... close the block driver */
ret = smartfs_unmount(fs); ret = smartfs_unmount(fs);
} }
@@ -1586,7 +1588,6 @@ static int smartfs_unlink(struct inode *mountpt, const char *relpath)
/* Okay, we are clear to delete the file. Use the deleteentry routine. */ /* Okay, we are clear to delete the file. Use the deleteentry routine. */
smartfs_deleteentry(fs, &entry); smartfs_deleteentry(fs, &entry);
} }
else else
{ {
@@ -1656,7 +1657,7 @@ static int smartfs_mkdir(struct inode *mountpt, const char *relpath, mode_t mode
* the right permissions and if the parentdirsector is valid. * the right permissions and if the parentdirsector is valid.
*/ */
if (parentdirsector == 0xFFFF) if (parentdirsector == 0xffff)
{ {
/* Invalid entry in the path (non-existant dir segment) */ /* Invalid entry in the path (non-existant dir segment) */
@@ -1668,7 +1669,7 @@ static int smartfs_mkdir(struct inode *mountpt, const char *relpath, mode_t mode
/* Create the directory */ /* Create the directory */
ret = smartfs_createentry(fs, parentdirsector, filename, ret = smartfs_createentry(fs, parentdirsector, filename,
SMARTFS_DIRENT_TYPE_DIR, mode, &entry, 0xFFFF, NULL); SMARTFS_DIRENT_TYPE_DIR, mode, &entry, 0xffff, NULL);
if (ret != OK) if (ret != OK)
{ {
goto errout_with_semaphore; goto errout_with_semaphore;
@@ -1839,7 +1840,7 @@ int smartfs_rename(struct inode *mountpt, const char *oldrelpath,
/* Test if the new parent directory is valid */ /* Test if the new parent directory is valid */
if (newparentdirsector != 0xFFFF) if (newparentdirsector != 0xffff)
{ {
/* We can move to the given parent directory */ /* We can move to the given parent directory */
@@ -1867,7 +1868,7 @@ int smartfs_rename(struct inode *mountpt, const char *oldrelpath,
} }
direntry = (struct smartfs_entry_header_s *) &fs->fs_rwbuffer[oldentry.doffset]; direntry = (struct smartfs_entry_header_s *) &fs->fs_rwbuffer[oldentry.doffset];
#if CONFIG_SMARTFS_ERASEDSTATE == 0xFF #if CONFIG_SMARTFS_ERASEDSTATE == 0xff
direntry->flags &= ~SMARTFS_DIRENT_ACTIVE; direntry->flags &= ~SMARTFS_DIRENT_ACTIVE;
#else #else
direntry->flags |= SMARTFS_DIRENT_ACTIVE; direntry->flags |= SMARTFS_DIRENT_ACTIVE;
+36 -30
View File
@@ -98,7 +98,7 @@ void smartfs_semtake(struct smartfs_mountpt_s *fs)
void smartfs_semgive(struct smartfs_mountpt_s *fs) void smartfs_semgive(struct smartfs_mountpt_s *fs)
{ {
nxsem_post(fs->fs_sem); nxsem_post(fs->fs_sem);
} }
/**************************************************************************** /****************************************************************************
@@ -427,8 +427,8 @@ int smartfs_unmount(struct smartfs_mountpt_s *fs)
/* Set the buffer's to invalid value to catch program bugs */ /* Set the buffer's to invalid value to catch program bugs */
fs->fs_rwbuffer = (char *) 0xDEADBEEF; fs->fs_rwbuffer = (char *) 0xdeadbeef;
fs->fs_workbuffer = (char *) 0xDEADBEEF; fs->fs_workbuffer = (char *) 0xdeadbeef;
} }
/* Now removed ourselves from the linked list */ /* Now removed ourselves from the linked list */
@@ -584,10 +584,10 @@ int smartfs_finddirentry(struct smartfs_mountpt_s *fs,
/* Read the directory */ /* Read the directory */
offset = 0xFFFF; offset = 0xffff;
#if CONFIG_SMARTFS_ERASEDSTATE == 0xFF #if CONFIG_SMARTFS_ERASEDSTATE == 0xff
while (dirsector != 0xFFFF) while (dirsector != 0xffff)
#else #else
while (dirsector != 0) while (dirsector != 0)
#endif #endif
@@ -673,12 +673,14 @@ int smartfs_finddirentry(struct smartfs_mountpt_s *fs,
kmm_malloc(fs->fs_llformat.namesize + 1); kmm_malloc(fs->fs_llformat.namesize + 1);
} }
memset(direntry->name, 0, fs->fs_llformat.namesize + 1); memset(direntry->name, 0,
strncpy(direntry->name, entry->name, fs->fs_llformat.namesize); fs->fs_llformat.namesize + 1);
strncpy(direntry->name, entry->name,
fs->fs_llformat.namesize);
direntry->datlen = 0; direntry->datlen = 0;
/* Scan the file's sectors to calculate the length and perform /* Scan the file's sectors to calculate the length and
* a rudimentary check. * perform a rudimentary check.
*/ */
#ifdef CONFIG_SMARTFS_ALIGNED_ACCESS #ifdef CONFIG_SMARTFS_ALIGNED_ACCESS
@@ -712,7 +714,8 @@ int smartfs_finddirentry(struct smartfs_mountpt_s *fs,
/* Add used bytes to the total and point to next sector */ /* Add used bytes to the total and point to next sector */
if (*((uint16_t *)header->used) != SMARTFS_ERASEDSTATE_16BIT) if (*((FAR uint16_t *)header->used) !=
SMARTFS_ERASEDSTATE_16BIT)
{ {
direntry->datlen += *((uint16_t *)header->used); direntry->datlen += *((uint16_t *)header->used);
} }
@@ -738,10 +741,10 @@ int smartfs_finddirentry(struct smartfs_mountpt_s *fs,
SMARTFS_DIRENT_TYPE_DIR) SMARTFS_DIRENT_TYPE_DIR)
#endif #endif
{ {
/* Not a directory! Report the error */ /* Not a directory! Report the error */
ret = -ENOTDIR; ret = -ENOTDIR;
goto errout; goto errout;
} }
/* "Push" the directory and continue searching */ /* "Push" the directory and continue searching */
@@ -805,7 +808,7 @@ int smartfs_finddirentry(struct smartfs_mountpt_s *fs,
} }
else else
{ {
*parentdirsector = 0xFFFF; *parentdirsector = 0xffff;
*filename = NULL; *filename = NULL;
} }
@@ -823,7 +826,7 @@ errout:
* *
* Description: Creates a new entry in the specified parent directory, using * Description: Creates a new entry in the specified parent directory, using
* the specified type and name. If the given sectorno is * the specified type and name. If the given sectorno is
* 0xFFFF, then a new sector is allocated for the new entry, * 0xffff, then a new sector is allocated for the new entry,
* otherwise the supplied sectorno is used. * otherwise the supplied sectorno is used.
* *
****************************************************************************/ ****************************************************************************/
@@ -927,7 +930,7 @@ int smartfs_createentry(FAR struct smartfs_mountpt_s *fs,
{ {
/* Allocate a new sector and chain it to the last one */ /* Allocate a new sector and chain it to the last one */
ret = FS_IOCTL(fs, BIOC_ALLOCSECT, 0xFFFF); ret = FS_IOCTL(fs, BIOC_ALLOCSECT, 0xffff);
if (ret < 0) if (ret < 0)
{ {
goto errout; goto errout;
@@ -957,7 +960,7 @@ int smartfs_createentry(FAR struct smartfs_mountpt_s *fs,
/* We found an insertion point. Create the entry at sector,offset */ /* We found an insertion point. Create the entry at sector,offset */
#if CONFIG_SMARTFS_ERASEDSTATE == 0xFF #if CONFIG_SMARTFS_ERASEDSTATE == 0xff
#ifdef CONFIG_SMARTFS_ALIGNED_ACCESS #ifdef CONFIG_SMARTFS_ALIGNED_ACCESS
smartfs_wrle16(&entry->flags, (uint16_t) (SMARTFS_DIRENT_ACTIVE | smartfs_wrle16(&entry->flags, (uint16_t) (SMARTFS_DIRENT_ACTIVE |
SMARTFS_DIRENT_DELETING | SMARTFS_DIRENT_RESERVED | type | (mode & SMARTFS_DIRENT_DELETING | SMARTFS_DIRENT_RESERVED | type | (mode &
@@ -967,7 +970,7 @@ int smartfs_createentry(FAR struct smartfs_mountpt_s *fs,
SMARTFS_DIRENT_DELETING | SMARTFS_DIRENT_RESERVED | type | (mode & SMARTFS_DIRENT_DELETING | SMARTFS_DIRENT_RESERVED | type | (mode &
SMARTFS_DIRENT_MODE)); SMARTFS_DIRENT_MODE));
#endif #endif
#else /* CONFIG_SMARTFS_ERASEDSTATE == 0xFF */ #else /* CONFIG_SMARTFS_ERASEDSTATE == 0xff */
#ifdef CONFIG_SMARTFS_ALIGNED_ACCESS #ifdef CONFIG_SMARTFS_ALIGNED_ACCESS
smartfs_wrle16(&entry->flags, (uint16_t) (SMARTFS_DIRENT_EMPTY | type | smartfs_wrle16(&entry->flags, (uint16_t) (SMARTFS_DIRENT_EMPTY | type |
(mode & SMARTFS_DIRENT_MODE))); (mode & SMARTFS_DIRENT_MODE)));
@@ -975,13 +978,13 @@ int smartfs_createentry(FAR struct smartfs_mountpt_s *fs,
entry->flags = (uint16_t) (SMARTFS_DIRENT_EMPTY | type | entry->flags = (uint16_t) (SMARTFS_DIRENT_EMPTY | type |
(mode & SMARTFS_DIRENT_MODE)); (mode & SMARTFS_DIRENT_MODE));
#endif #endif
#endif /* CONFIG_SMARTFS_ERASEDSTATE == 0xFF */ #endif /* CONFIG_SMARTFS_ERASEDSTATE == 0xff */
if (sectorno == 0xFFFF) if (sectorno == 0xffff)
{ {
/* Allocate a new sector for the file / dir */ /* Allocate a new sector for the file / dir */
ret = FS_IOCTL(fs, BIOC_ALLOCSECT, 0xFFFF); ret = FS_IOCTL(fs, BIOC_ALLOCSECT, 0xffff);
if (ret < 0) if (ret < 0)
{ {
goto errout; goto errout;
@@ -1164,19 +1167,21 @@ int smartfs_deleteentry(struct smartfs_mountpt_s *fs,
/* Mark this entry as inactive */ /* Mark this entry as inactive */
direntry = (struct smartfs_entry_header_s *) &fs->fs_rwbuffer[entry->doffset]; direntry = (struct smartfs_entry_header_s *) &fs->fs_rwbuffer[entry->doffset];
#if CONFIG_SMARTFS_ERASEDSTATE == 0xFF #if CONFIG_SMARTFS_ERASEDSTATE == 0xff
#ifdef CONFIG_SMARTFS_ALIGNED_ACCESS #ifdef CONFIG_SMARTFS_ALIGNED_ACCESS
smartfs_wrle16(&direntry->flags, smartfs_rdle16(&direntry->flags) & ~SMARTFS_DIRENT_ACTIVE); smartfs_wrle16(&direntry->flags,
smartfs_rdle16(&direntry->flags) & ~SMARTFS_DIRENT_ACTIVE);
#else #else
direntry->flags &= ~SMARTFS_DIRENT_ACTIVE; direntry->flags &= ~SMARTFS_DIRENT_ACTIVE;
#endif #endif
#else /* CONFIG_SMARTFS_ERASEDSTATE == 0xFF */ #else /* CONFIG_SMARTFS_ERASEDSTATE == 0xff */
#ifdef CONFIG_SMARTFS_ALIGNED_ACCESS #ifdef CONFIG_SMARTFS_ALIGNED_ACCESS
smartfs_wrle16(&direntry->flags, smartfs_rdle16(&direntry->flags) | SMARTFS_DIRENT_ACTIVE); smartfs_wrle16(&direntry->flags,
smartfs_rdle16(&direntry->flags) | SMARTFS_DIRENT_ACTIVE);
#else #else
direntry->flags |= SMARTFS_DIRENT_ACTIVE; direntry->flags |= SMARTFS_DIRENT_ACTIVE;
#endif #endif
#endif /* CONFIG_SMARTFS_ERASEDSTATE == 0xFF */ #endif /* CONFIG_SMARTFS_ERASEDSTATE == 0xff */
/* Write the updated flags back to the sector */ /* Write the updated flags back to the sector */
@@ -1264,7 +1269,8 @@ int smartfs_deleteentry(struct smartfs_mountpt_s *fs,
/* We found ourselves in the chain. Update the chain. */ /* We found ourselves in the chain. Update the chain. */
SMARTFS_NEXTSECTOR(header) = nextsector; SMARTFS_NEXTSECTOR(header) = nextsector;
readwrite.offset = offsetof(struct smartfs_chain_header_s, nextsector); readwrite.offset = offsetof(struct smartfs_chain_header_s,
nextsector);
readwrite.count = sizeof(uint16_t); readwrite.count = sizeof(uint16_t);
readwrite.buffer = header->nextsector; readwrite.buffer = header->nextsector;
@@ -1976,7 +1982,7 @@ int smartfs_extendfile(FAR struct smartfs_mountpt_s *fs,
{ {
/* First get a new chained sector */ /* First get a new chained sector */
ret = FS_IOCTL(fs, BIOC_ALLOCSECT, 0xFFFF); ret = FS_IOCTL(fs, BIOC_ALLOCSECT, 0xffff);
if (ret < 0) if (ret < 0)
{ {
ferr("ERROR: Error %d allocating new sector\n", ret); ferr("ERROR: Error %d allocating new sector\n", ret);
@@ -2031,7 +2037,7 @@ int smartfs_extendfile(FAR struct smartfs_mountpt_s *fs,
{ {
/* Allocate a new sector */ /* Allocate a new sector */
ret = FS_IOCTL(fs, BIOC_ALLOCSECT, 0xFFFF); ret = FS_IOCTL(fs, BIOC_ALLOCSECT, 0xffff);
if (ret < 0) if (ret < 0)
{ {
ferr("ERROR: Error %d allocating new sector\n", ret); ferr("ERROR: Error %d allocating new sector\n", ret);
File diff suppressed because it is too large Load Diff
+46 -36
View File
@@ -1513,10 +1513,10 @@ void spiffs_fobj_event(FAR struct spiffs_s *fs,
int16_t new_pgndx, uint32_t new_size) int16_t new_pgndx, uint32_t new_size)
{ {
#ifdef CONFIG_DEBUG_FS_INFO #ifdef CONFIG_DEBUG_FS_INFO
FAR static const char *evname[] = FAR static const char *evname[] =
{ {
"UPD", "NEW", "DEL", "MOV", "HUP", "???" "UPD", "NEW", "DEL", "MOV", "HUP", "???"
}; };
#endif #endif
FAR struct spiffs_file_s *fobj; FAR struct spiffs_file_s *fobj;
@@ -1581,7 +1581,8 @@ void spiffs_fobj_event(FAR struct spiffs_s *fs,
if (fobj->cache_page && if (fobj->cache_page &&
fobj->cache_page->offset > act_new_size + 1) fobj->cache_page->offset > act_new_size + 1)
{ {
spiffs_cacheinfo("File truncated, dropping cache page=%d, no writeback\n", spiffs_cacheinfo("File truncated, dropping cache page=%d, "
"no writeback\n",
fobj->cache_page->cpndx); fobj->cache_page->cpndx);
spiffs_cache_page_release(fs, fobj->cache_page); spiffs_cache_page_release(fs, fobj->cache_page);
@@ -1594,7 +1595,8 @@ void spiffs_fobj_event(FAR struct spiffs_s *fs,
if (fobj->cache_page) if (fobj->cache_page)
{ {
spiffs_cacheinfo("File deleted, dropping cache page=%d, no writeback\n", spiffs_cacheinfo("File deleted, dropping cache page=%d, "
"no writeback\n",
fobj->cache_page->cpndx); fobj->cache_page->cpndx);
spiffs_cache_page_release(fs, fobj->cache_page); spiffs_cache_page_release(fs, fobj->cache_page);
@@ -1781,12 +1783,13 @@ ssize_t spiffs_fobj_append(FAR struct spiffs_s *fs,
return ret; return ret;
} }
ret = spiffs_cache_write(fs, ret =
SPIFFS_OP_T_OBJNDX | SPIFFS_OP_C_UPDT, spiffs_cache_write(fs,
fobj->objid, SPIFFS_OP_T_OBJNDX | SPIFFS_OP_C_UPDT,
SPIFFS_PAGE_TO_PADDR(fs, cur_objndx_pgndx), fobj->objid,
SPIFFS_GEO_PAGE_SIZE(fs), SPIFFS_PAGE_TO_PADDR(fs, cur_objndx_pgndx),
fs->work); SPIFFS_GEO_PAGE_SIZE(fs),
fs->work);
if (ret < 0) if (ret < 0)
{ {
ferr("ERROR: spiffs_cache_write() failed: %d\n", ferr("ERROR: spiffs_cache_write() failed: %d\n",
@@ -1951,10 +1954,11 @@ ssize_t spiffs_fobj_append(FAR struct spiffs_s *fs,
} }
else else
{ {
ret = spiffs_objlu_find_id_and_span(fs, ret =
fobj->objid | SPIFFS_OBJID_NDXFLAG, spiffs_objlu_find_id_and_span(fs,
cur_objndx_spndx, 0, fobj->objid | SPIFFS_OBJID_NDXFLAG,
&pgndx); cur_objndx_spndx, 0,
&pgndx);
if (ret < 0) if (ret < 0)
{ {
ferr("ERROR: spiffs_objlu_find_id_and_span() failed: %d\n", ferr("ERROR: spiffs_objlu_find_id_and_span() failed: %d\n",
@@ -2331,7 +2335,8 @@ ssize_t spiffs_fobj_modify(FAR struct spiffs_s *fs,
fobj->objid, 0, cur_objndx_pgndx, fobj->objid, 0, cur_objndx_pgndx,
&new_objndx_pgndx); &new_objndx_pgndx);
finfo("Store previous modified objndx page, %04x:%04x, nwritten=%d\n", finfo("Store previous modified objndx page, %04x:%04x, "
"nwritten=%d\n",
new_objndx_pgndx, objndx->phdr.spndx, nwritten); new_objndx_pgndx, objndx->phdr.spndx, nwritten);
if (ret < 0) if (ret < 0)
@@ -2390,10 +2395,11 @@ ssize_t spiffs_fobj_modify(FAR struct spiffs_s *fs,
} }
else else
{ {
ret = spiffs_objlu_find_id_and_span(fs, ret =
fobj->objid | SPIFFS_OBJID_NDXFLAG, spiffs_objlu_find_id_and_span(fs,
cur_objndx_spndx, 0, fobj->objid | SPIFFS_OBJID_NDXFLAG,
&pgndx); cur_objndx_spndx, 0,
&pgndx);
if (ret < 0) if (ret < 0)
{ {
ferr("ERROR: spiffs_objlu_find_id_and_span() failed: %d\n", ferr("ERROR: spiffs_objlu_find_id_and_span() failed: %d\n",
@@ -2511,15 +2517,16 @@ ssize_t spiffs_fobj_modify(FAR struct spiffs_s *fs,
{ {
/* After modification */ /* After modification */
ret = spiffs_phys_cpy(fs, fobj->objid, ret =
SPIFFS_PAGE_TO_PADDR(fs, data_pgndx) + spiffs_phys_cpy(fs, fobj->objid,
sizeof(struct spiffs_page_header_s) + page_offs + SPIFFS_PAGE_TO_PADDR(fs, data_pgndx) +
to_write, sizeof(struct spiffs_page_header_s) + page_offs +
SPIFFS_PAGE_TO_PADDR(fs, orig_data_pgndx) to_write,
+ sizeof(struct spiffs_page_header_s) + page_offs + SPIFFS_PAGE_TO_PADDR(fs, orig_data_pgndx)
to_write, + sizeof(struct spiffs_page_header_s) + page_offs +
SPIFFS_DATA_PAGE_SIZE(fs) - to_write,
(page_offs + to_write)); SPIFFS_DATA_PAGE_SIZE(fs) -
(page_offs + to_write));
if (ret < 0) if (ret < 0)
{ {
ferr("ERROR: spiffs_phys_cpy() failed: %d\n", ret); ferr("ERROR: spiffs_phys_cpy() failed: %d\n", ret);
@@ -2986,12 +2993,13 @@ int spiffs_fobj_truncate(FAR struct spiffs_s *fs,
int16_t new_data_pgndx; int16_t new_data_pgndx;
uint32_t bytes_to_remove; uint32_t bytes_to_remove;
/* Delete last page, partially */ /* Delete last page, partially */
bytes_to_remove = bytes_to_remove =
SPIFFS_DATA_PAGE_SIZE(fs) - (new_size % SPIFFS_DATA_PAGE_SIZE(fs)); SPIFFS_DATA_PAGE_SIZE(fs) - (new_size % SPIFFS_DATA_PAGE_SIZE(fs));
finfo("Delete %d bytes from data page=%04x for data spndx=%04x, cur_size=%d\n", finfo("Delete %d bytes from data page=%04x for data spndx=%04x, "
"cur_size=%d\n",
bytes_to_remove, data_pgndx, data_spndx, cur_size); bytes_to_remove, data_pgndx, data_spndx, cur_size);
ret = spiffs_page_data_check(fs, fobj, data_pgndx, data_spndx); ret = spiffs_page_data_check(fs, fobj, data_pgndx, data_spndx);
@@ -3264,10 +3272,11 @@ ssize_t spiffs_object_read(FAR struct spiffs_s *fs,
} }
else else
{ {
ret = spiffs_objlu_find_id_and_span(fs, ret =
fobj->objid | SPIFFS_OBJID_NDXFLAG, spiffs_objlu_find_id_and_span(fs,
cur_objndx_spndx, 0, fobj->objid | SPIFFS_OBJID_NDXFLAG,
&objndx_pgndx); cur_objndx_spndx, 0,
&objndx_pgndx);
if (ret < 0) if (ret < 0)
{ {
ferr("ERROR: spiffs_objlu_find_id_and_span() failed: %d\n", ferr("ERROR: spiffs_objlu_find_id_and_span() failed: %d\n",
@@ -3505,7 +3514,8 @@ int spiffs_objlu_find_free_objid(FAR struct spiffs_s *fs, int16_t *objid,
return -ENOSPC; return -ENOSPC;
} }
finfo("COMP select index=%d min_count=%d min=%04x max=%04x compact:%d\n", finfo("COMP select index=%d min_count=%d min=%04x max=%04x "
"compact:%d\n",
min_i, min_count, state.min_objid, state.max_objid, min_i, min_count, state.min_objid, state.max_objid,
state.compaction); state.compaction);
+39 -32
View File
@@ -344,23 +344,23 @@ static int spiffs_gc_find_candidate(FAR struct spiffs_s *fs,
ret = spiffs_cache_read(fs, SPIFFS_OP_C_READ | SPIFFS_OP_T_OBJ_LU2, 0, ret = spiffs_cache_read(fs, SPIFFS_OP_C_READ | SPIFFS_OP_T_OBJ_LU2, 0,
SPIFFS_ERASE_COUNT_PADDR(fs, cur_block), SPIFFS_ERASE_COUNT_PADDR(fs, cur_block),
sizeof(int16_t), (uint8_t *) & erase_count); sizeof(int16_t), (uint8_t *) & erase_count);
if (ret < 0) if (ret < 0)
{ {
ferr("ERROR: spiffs_cache_read() failed: %d\n", ret); ferr("ERROR: spiffs_cache_read() failed: %d\n", ret);
return ret; return ret;
} }
/* Calculate the erase age */ /* Calculate the erase age */
if (fs->max_erase_count > erase_count) if (fs->max_erase_count > erase_count)
{ {
erase_age = fs->max_erase_count - erase_count; erase_age = fs->max_erase_count - erase_count;
} }
else else
{ {
erase_age = erase_age =
SPIFFS_OBJID_FREE - (erase_count - fs->max_erase_count); SPIFFS_OBJID_FREE - (erase_count - fs->max_erase_count);
} }
score = score =
deleted_pages_in_block * CONFIG_SPIFFS_GC_DELWGT + deleted_pages_in_block * CONFIG_SPIFFS_GC_DELWGT +
@@ -519,6 +519,7 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
switch (gc.state) switch (gc.state)
{ {
case FIND_OBJ_DATA: case FIND_OBJ_DATA:
/* Find a data page. */ /* Find a data page. */
if (id != SPIFFS_OBJID_DELETED && if (id != SPIFFS_OBJID_DELETED &&
@@ -540,6 +541,7 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
break; break;
case MOVE_OBJ_DATA: case MOVE_OBJ_DATA:
/* Evacuate found data pages for corresponding object index /* Evacuate found data pages for corresponding object index
* we have in memory, update memory representation * we have in memory, update memory representation
*/ */
@@ -589,16 +591,18 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
/* Move wipes obj_lu, reload it */ /* Move wipes obj_lu, reload it */
ret = spiffs_cache_read(fs, ret =
SPIFFS_OP_T_OBJ_LU | SPIFFS_OP_C_READ, spiffs_cache_read(fs,
0, SPIFFS_OP_T_OBJ_LU | SPIFFS_OP_C_READ,
blkndx * SPIFFS_GEO_BLOCK_SIZE(fs) + 0,
SPIFFS_PAGE_TO_PADDR(fs, obj_lookup_page), blkndx * SPIFFS_GEO_BLOCK_SIZE(fs) +
SPIFFS_GEO_PAGE_SIZE(fs), SPIFFS_PAGE_TO_PADDR(fs, obj_lookup_page),
fs->lu_work); SPIFFS_GEO_PAGE_SIZE(fs),
fs->lu_work);
if (ret < 0) if (ret < 0)
{ {
ferr("ERROR: spiffs_cache_read() failed: %d\n", ret); ferr("ERROR: spiffs_cache_read() failed: %d\n",
ret);
return ret; return ret;
} }
} }
@@ -615,7 +619,8 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
ret = spiffs_page_delete(fs, cur_pgndx); ret = spiffs_page_delete(fs, cur_pgndx);
if (ret < 0) if (ret < 0)
{ {
ferr("ERROR: spiffs_page_delete() failed: %d\n", ret); ferr("ERROR: spiffs_page_delete() failed: %d\n",
ret);
return ret; return ret;
} }
@@ -656,6 +661,7 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
break; break;
case MOVE_OBJ_NDX: case MOVE_OBJ_NDX:
/* Find and evacuate object index pages */ /* Find and evacuate object index pages */
if (id != SPIFFS_OBJID_DELETED && if (id != SPIFFS_OBJID_DELETED &&
@@ -705,12 +711,13 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
/* Move wipes obj_lu, reload it */ /* Move wipes obj_lu, reload it */
ret = spiffs_cache_read(fs, ret =
SPIFFS_OP_T_OBJ_LU | SPIFFS_OP_C_READ, spiffs_cache_read(fs,
0, SPIFFS_OP_T_OBJ_LU | SPIFFS_OP_C_READ,
blkndx * SPIFFS_GEO_BLOCK_SIZE(fs) + 0,
SPIFFS_PAGE_TO_PADDR(fs, obj_lookup_page), blkndx * SPIFFS_GEO_BLOCK_SIZE(fs) +
SPIFFS_GEO_PAGE_SIZE(fs), fs->lu_work); SPIFFS_PAGE_TO_PADDR(fs, obj_lookup_page),
SPIFFS_GEO_PAGE_SIZE(fs), fs->lu_work);
if (ret < 0) if (ret < 0)
{ {
ferr("ERROR: spiffs_cache_read() failed: %d\n", ret); ferr("ERROR: spiffs_cache_read() failed: %d\n", ret);
@@ -1155,7 +1162,8 @@ int spiffs_gc_check(FAR struct spiffs_s *fs, off_t len)
int16_t cand; int16_t cand;
int32_t prev_free_pages = free_pages; int32_t prev_free_pages = free_pages;
spiffs_gcinfo("#%d: run gc free_blocks=%d pfree=%d pallo=%d pdele=%d [%d] len=%d of %d\n", spiffs_gcinfo("#%d: run gc free_blocks=%d pfree=%d pallo=%d pdele=%d [%d] "
"len=%d of %d\n",
tries, fs->free_blocks, free_pages, tries, fs->free_blocks, free_pages,
fs->alloc_pages, fs->deleted_pages, fs->alloc_pages, fs->deleted_pages,
(free_pages + fs->alloc_pages + fs->deleted_pages), (free_pages + fs->alloc_pages + fs->deleted_pages),
@@ -1218,7 +1226,6 @@ int spiffs_gc_check(FAR struct spiffs_s *fs, off_t len)
spiffs_gcinfo("Early abort, no result on gc when fs crammed\n"); spiffs_gcinfo("Early abort, no result on gc when fs crammed\n");
break; break;
} }
} }
while (++tries < CONFIG_SPIFFS_GC_MAXRUNS && while (++tries < CONFIG_SPIFFS_GC_MAXRUNS &&
(fs->free_blocks <= 2 || (fs->free_blocks <= 2 ||
+25 -18
View File
@@ -694,7 +694,8 @@ static ssize_t spiffs_write(FAR struct file *filep, FAR const char *buffer,
if (offset < fobj->cache_page->offset || if (offset < fobj->cache_page->offset ||
offset > fobj->cache_page->offset + fobj->cache_page->size || offset > fobj->cache_page->offset + fobj->cache_page->size ||
offset + buflen > fobj->cache_page->offset + SPIFFS_GEO_PAGE_SIZE(fs)) offset + buflen > fobj->cache_page->offset +
SPIFFS_GEO_PAGE_SIZE(fs))
{ {
/* Boundary violation, write back cache first and allocate /* Boundary violation, write back cache first and allocate
* new * new
@@ -705,11 +706,12 @@ static ssize_t spiffs_write(FAR struct file *filep, FAR const char *buffer,
fobj->cache_page->cpndx, fobj->objid, fobj->cache_page->cpndx, fobj->objid,
fobj->cache_page->offset, fobj->cache_page->size); fobj->cache_page->offset, fobj->cache_page->size);
nwritten = spiffs_fobj_write(fs, fobj, nwritten =
spiffs_get_cache_page(fs, spiffs_get_cache(fs), spiffs_fobj_write(fs, fobj,
fobj->cache_page->cpndx), spiffs_get_cache_page(fs, spiffs_get_cache(fs),
fobj->cache_page->offset, fobj->cache_page->cpndx),
fobj->cache_page->size); fobj->cache_page->offset,
fobj->cache_page->size);
spiffs_cache_page_release(fs, fobj->cache_page); spiffs_cache_page_release(fs, fobj->cache_page);
if (nwritten < 0) if (nwritten < 0)
{ {
@@ -746,7 +748,8 @@ static ssize_t spiffs_write(FAR struct file *filep, FAR const char *buffer,
offset_in_cpage = offset - fobj->cache_page->offset; offset_in_cpage = offset - fobj->cache_page->offset;
spiffs_cacheinfo("Storing to cache page %d for fobj %d offset=%d:%d buflen=%d\n", spiffs_cacheinfo("Storing to cache page %d for fobj %d "
"offset=%d:%d buflen=%d\n",
fobj->cache_page->cpndx, fobj->objid, offset, fobj->cache_page->cpndx, fobj->objid, offset,
offset_in_cpage, buflen); offset_in_cpage, buflen);
@@ -754,7 +757,8 @@ static ssize_t spiffs_write(FAR struct file *filep, FAR const char *buffer,
cpage_data = spiffs_get_cache_page(fs, cache, fobj->cache_page->cpndx); cpage_data = spiffs_get_cache_page(fs, cache, fobj->cache_page->cpndx);
memcpy(&cpage_data[offset_in_cpage], buffer, buflen); memcpy(&cpage_data[offset_in_cpage], buffer, buflen);
fobj->cache_page->size = MAX(fobj->cache_page->size, offset_in_cpage + buflen); fobj->cache_page->size = MAX(fobj->cache_page->size,
offset_in_cpage + buflen);
nwritten = buflen; nwritten = buflen;
goto success_with_lock; goto success_with_lock;
@@ -768,7 +772,7 @@ static ssize_t spiffs_write(FAR struct file *filep, FAR const char *buffer,
goto errout_with_lock; goto errout_with_lock;
} }
goto success_with_lock; goto success_with_lock;
} }
} }
else else
@@ -786,12 +790,13 @@ static ssize_t spiffs_write(FAR struct file *filep, FAR const char *buffer,
fobj->cache_page->cpndx, fobj->objid, fobj->cache_page->cpndx, fobj->objid,
fobj->cache_page->offset, fobj->cache_page->size); fobj->cache_page->offset, fobj->cache_page->size);
nwritten = spiffs_fobj_write(fs, fobj, nwritten =
spiffs_get_cache_page(fs, spiffs_fobj_write(fs, fobj,
spiffs_get_cache(fs), spiffs_get_cache_page(fs,
fobj->cache_page->cpndx), spiffs_get_cache(fs),
fobj->cache_page->offset, fobj->cache_page->cpndx),
fobj->cache_page->size); fobj->cache_page->offset,
fobj->cache_page->size);
spiffs_cache_page_release(fs, fobj->cache_page); spiffs_cache_page_release(fs, fobj->cache_page);
if (nwritten < 0) if (nwritten < 0)
@@ -813,6 +818,7 @@ static ssize_t spiffs_write(FAR struct file *filep, FAR const char *buffer,
} }
success_with_lock: success_with_lock:
/* Update the file position */ /* Update the file position */
filep->f_pos += nwritten; filep->f_pos += nwritten;
@@ -1042,6 +1048,7 @@ static int spiffs_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
#endif #endif
default: default:
/* Pass through to the contained MTD driver */ /* Pass through to the contained MTD driver */
ret = MTD_IOCTL(fs->mtd, cmd, arg); ret = MTD_IOCTL(fs->mtd, cmd, arg);
@@ -1529,7 +1536,7 @@ static int spiffs_unbind(FAR void *handle, FAR struct inode **mtdinode,
spiffs_fobj_free(fs, fobj, false); spiffs_fobj_free(fs, fobj, false);
} }
/* Free allocated working buffers */ /* Free allocated working buffers */
if (fs->work != NULL) if (fs->work != NULL)
{ {
@@ -1541,7 +1548,7 @@ static int spiffs_unbind(FAR void *handle, FAR struct inode **mtdinode,
kmm_free(fs->cache); kmm_free(fs->cache);
} }
/* Free the volume memory (note that the semaphore is now stale!) */ /* Free the volume memory (note that the semaphore is now stale!) */
nxsem_destroy(&fs->exclsem.sem); nxsem_destroy(&fs->exclsem.sem);
kmm_free(fs); kmm_free(fs);
@@ -1586,7 +1593,7 @@ static int spiffs_statfs(FAR struct inode *mountpt, FAR struct statfs *buf)
obj_lupages = SPIFFS_OBJ_LOOKUP_PAGES(fs); obj_lupages = SPIFFS_OBJ_LOOKUP_PAGES(fs);
data_pgsize = SPIFFS_DATA_PAGE_SIZE(fs); data_pgsize = SPIFFS_DATA_PAGE_SIZE(fs);
/* -2 for spare blocks, +1 for emergency page */ /* -2 for spare blocks, +1 for emergency page */
ndata_pages = (blocks - 2) * (pages_per_block - obj_lupages) + 1; ndata_pages = (blocks - 2) * (pages_per_block - obj_lupages) + 1;
+11 -8
View File
@@ -755,7 +755,7 @@ static int tmpfs_create_file(FAR struct tmpfs_s *fs,
*tfo = newtfo; *tfo = newtfo;
return OK; return OK;
/* Error exits */ /* Error exits */
errout_with_file: errout_with_file:
nxsem_destroy(&newtfo->tfo_exclsem.ts_sem); nxsem_destroy(&newtfo->tfo_exclsem.ts_sem);
@@ -917,7 +917,7 @@ static int tmpfs_create_directory(FAR struct tmpfs_s *fs,
return OK; return OK;
/* Error exits */ /* Error exits */
errout_with_directory: errout_with_directory:
nxsem_destroy(&newtdo->tdo_exclsem.ts_sem); nxsem_destroy(&newtdo->tdo_exclsem.ts_sem);
@@ -1330,6 +1330,7 @@ static int tmpfs_foreach(FAR struct tmpfs_directory_s *tdo,
switch (ret) switch (ret)
{ {
case TMPFS_CONTINUE: /* Continue enumeration */ case TMPFS_CONTINUE: /* Continue enumeration */
/* Release the object and index to the next entry */ /* Release the object and index to the next entry */
tmpfs_release_lockedobject(to); tmpfs_release_lockedobject(to);
@@ -1337,12 +1338,14 @@ static int tmpfs_foreach(FAR struct tmpfs_directory_s *tdo,
break; break;
case TMPFS_HALT: /* Stop enumeration */ case TMPFS_HALT: /* Stop enumeration */
/* Release the object and cancel the traversal */ /* Release the object and cancel the traversal */
tmpfs_release_lockedobject(to); tmpfs_release_lockedobject(to);
return -ECANCELED; return -ECANCELED;
case TMPFS_UNLINKED: /* Only the directory entry was deleted */ case TMPFS_UNLINKED: /* Only the directory entry was deleted */
/* Release the object and continue with the same index */ /* Release the object and continue with the same index */
tmpfs_release_lockedobject(to); tmpfs_release_lockedobject(to);
@@ -1449,11 +1452,11 @@ static int tmpfs_open(FAR struct file *filep, FAR const char *relpath,
if ((oflags & O_CREAT) == 0) if ((oflags & O_CREAT) == 0)
{ {
/* No.. then we fail with -ENOENT */ /* No.. then we fail with -ENOENT */
ret = -ENOENT; ret = -ENOENT;
goto errout_with_fslock; goto errout_with_fslock;
} }
/* Yes.. create the file object. There will be a reference and a lock /* Yes.. create the file object. There will be a reference and a lock
* on the new file object. * on the new file object.
@@ -1464,7 +1467,7 @@ static int tmpfs_open(FAR struct file *filep, FAR const char *relpath,
{ {
goto errout_with_fslock; goto errout_with_fslock;
} }
} }
/* Some other error occurred */ /* Some other error occurred */
@@ -2523,7 +2526,7 @@ static int tmpfs_rename(FAR struct inode *mountpt, FAR const char *oldrelpath,
ret = tmpfs_find_object(fs, oldrelpath, &to, &oldparent); ret = tmpfs_find_object(fs, oldrelpath, &to, &oldparent);
if (ret < 0) if (ret < 0)
{ {
goto errout_with_newparent; goto errout_with_newparent;
} }
/* Get the old file name from the relative path */ /* Get the old file name from the relative path */
+7 -5
View File
@@ -1818,7 +1818,9 @@ static int unionfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
fu->fu_eod = true; fu->fu_eod = true;
/* Check if have already reported something of this name in file system 1. */ /* Check if have already reported something of this name
* in file system 1.
*/
relpath = unionfs_relpath(fu->fu_relpath, um->um_prefix); relpath = unionfs_relpath(fu->fu_relpath, um->um_prefix);
if (relpath) if (relpath)
@@ -1849,7 +1851,7 @@ static int unionfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
} }
return OK; return OK;
} }
/* No.. check for a normal directory access */ /* No.. check for a normal directory access */
@@ -2851,9 +2853,9 @@ int unionfs_mount(FAR const char *fspath1, FAR const char *prefix1,
ret = unionfs_dobind(fspath1, prefix1, fspath2, prefix2, ret = unionfs_dobind(fspath1, prefix1, fspath2, prefix2,
&mpinode->i_private); &mpinode->i_private);
if (ret < 0) if (ret < 0)
{ {
goto errout_with_mountpt; goto errout_with_mountpt;
} }
inode_semgive(); inode_semgive();
return OK; return OK;
+2 -1
View File
@@ -468,7 +468,8 @@ static ssize_t userfs_write(FAR struct file *filep, FAR const char *buffer,
filep->f_inode->i_private != NULL); filep->f_inode->i_private != NULL);
priv = filep->f_inode->i_private; priv = filep->f_inode->i_private;
/* Perform multiple writes if the write length exceeds the configured maximum (mxwrite). /* Perform multiple writes if the write length exceeds the configured
* maximum (mxwrite).
*/ */
if (buflen > priv->mxwrite) if (buflen > priv->mxwrite)
+47 -39
View File
@@ -125,12 +125,13 @@ int file_vfcntl(FAR struct file *filep, int cmd, va_list ap)
break; break;
case F_GETFL: case F_GETFL:
/* Get the file status flags and file access modes, defined in <fcntl.h>, /* Get the file status flags and file access modes, defined in
* for the file description associated with fd. The file access modes * <fcntl.h>, for the file description associated with fd. The file
* can be extracted from the return value using the mask O_ACCMODE, which is * access modes can be extracted from the return value using the
* defined in <fcntl.h>. File status flags and file access modes are associated * mask O_ACCMODE, which is defined in <fcntl.h>. File status flags
* with the file description and do not affect other file descriptors that * and file access modes are associated with the file description
* refer to the same file with different open file descriptions. * and do not affect other file descriptors that refer to the same
* file with different open file descriptions.
*/ */
{ {
@@ -139,12 +140,13 @@ int file_vfcntl(FAR struct file *filep, int cmd, va_list ap)
break; break;
case F_SETFL: case F_SETFL:
/* Set the file status flags, defined in <fcntl.h>, for the file description /* Set the file status flags, defined in <fcntl.h>, for the file
* associated with fd from the corresponding bits in the third argument, * description associated with fd from the corresponding bits in
* arg, taken as type int. Bits corresponding to the file access mode and * the third argument, arg, taken as type int. Bits corresponding
* the file creation flags, as defined in <fcntl.h>, that are set in arg shall * to the file access mode and the file creation flags, as defined
* be ignored. If any bits in arg other than those mentioned here are changed * in <fcntl.h>, that are set in arg shall be ignored. If any bits
* by the application, the result is unspecified. * in arg other than those mentioned here are changed by the
* application, the result is unspecified.
*/ */
{ {
@@ -158,48 +160,54 @@ int file_vfcntl(FAR struct file *filep, int cmd, va_list ap)
break; break;
case F_GETOWN: case F_GETOWN:
/* If fd refers to a socket, get the process or process group ID specified /* If fd refers to a socket, get the process or process group ID
* to receive SIGURG signals when out-of-band data is available. Positive values * specified to receive SIGURG signals when out-of-band data is
* indicate a process ID; negative values, other than -1, indicate a process group * available. Positive values indicate a process ID; negative
* ID. If fd does not refer to a socket, the results are unspecified. * values, other than -1, indicate a process group ID. If fd does
* not refer to a socket, the results are unspecified.
*/ */
case F_SETOWN: case F_SETOWN:
/* If fd refers to a socket, set the process or process group ID specified /* If fd refers to a socket, set the process or process group ID
* to receive SIGURG signals when out-of-band data is available, using the value * specified to receive SIGURG signals when out-of-band data is
* of the third argument, arg, taken as type int. Positive values indicate a * available, using the value of the third argument, arg, taken as
* process ID; negative values, other than -1, indicate a process group ID. If * type int. Positive values indicate a process ID; negative values,
* fd does not refer to a socket, the results are unspecified. * other than -1, indicate a process group ID. If fd does not refer
* to a socket, the results are unspecified.
*/ */
ret = -EBADF; /* Only valid on socket descriptors */ ret = -EBADF; /* Only valid on socket descriptors */
break; break;
case F_GETLK: case F_GETLK:
/* Get the first lock which blocks the lock description pointed to by the third /* Get the first lock which blocks the lock description pointed to
* argument, arg, taken as a pointer to type struct flock, defined in <fcntl.h>. * by the third argument, arg, taken as a pointer to type struct
* The information retrieved shall overwrite the information passed to fcntl() in * flock, defined in <fcntl.h>. The information retrieved shall
* the structure flock. If no lock is found that would prevent this lock from being * overwrite the information passed to fcntl() in the structure
* created, then the structure shall be left unchanged except for the lock type * flock. If no lock is found that would prevent this lock from
* which shall be set to F_UNLCK. * being created, then the structure shall be left unchanged except
* for the lock type which shall be set to F_UNLCK.
*/ */
case F_SETLK: case F_SETLK:
/* Set or clear a file segment lock according to the lock description pointed to /* Set or clear a file segment lock according to the lock
* by the third argument, arg, taken as a pointer to type struct flock, defined in * description pointed to by the third argument, arg, taken as a
* <fcntl.h>. F_SETLK can establish shared (or read) locks (F_RDLCK) or exclusive * pointer to type struct flock, defined in <fcntl.h>. F_SETLK can
* (or write) locks (F_WRLCK), as well as to remove either type of lock (F_UNLCK). * establish shared (or read) locks (F_RDLCK) or exclusive (or
* F_RDLCK, F_WRLCK, and F_UNLCK are defined in <fcntl.h>. If a shared or exclusive * write) locks (F_WRLCK), as well as to remove either type of lock
* lock cannot be set, fcntl() shall return immediately with a return value of -1. * (F_UNLCK). F_RDLCK, F_WRLCK, and F_UNLCK are defined in
* <fcntl.h>. If a shared or exclusive lock cannot be set, fcntl()
* shall return immediately with a return value of -1.
*/ */
case F_SETLKW: case F_SETLKW:
/* This command shall be equivalent to F_SETLK except that if a shared or exclusive /* This command shall be equivalent to F_SETLK except that if a
* lock is blocked by other locks, the thread shall wait until the request can be * shared or exclusive lock is blocked by other locks, the thread
* satisfied. If a signal that is to be caught is received while fcntl() is waiting * shall wait until the request can be satisfied. If a signal that
* for a region, fcntl() shall be interrupted. Upon return from the signal handler, * is to be caught is received while fcntl() is waiting for a
* fcntl() shall return -1 with errno set to [EINTR], and the lock operation shall * region, fcntl() shall be interrupted. Upon return from the signal
* not be done. * handler, fcntl() shall return -1 with errno set to [EINTR], and
* the lock operation shall not be done.
*/ */
ret = -ENOSYS; /* Not implemented */ ret = -ENOSYS; /* Not implemented */
+1 -1
View File
@@ -185,7 +185,7 @@ off_t lseek(int fd, off_t offset, int whence)
goto errout; goto errout;
} }
return newpos; return newpos;
errout: errout:
set_errno(errcode); set_errno(errcode);
+16 -16
View File
@@ -157,27 +157,27 @@ int nx_vopen(FAR const char *path, int oflags, va_list ap)
* NOTE: This will recurse to open the character driver proxy. * NOTE: This will recurse to open the character driver proxy.
*/ */
if (INODE_IS_BLOCK(inode) || INODE_IS_MTD(inode)) if (INODE_IS_BLOCK(inode) || INODE_IS_MTD(inode))
{ {
/* Release the inode reference */ /* Release the inode reference */
inode_release(inode); inode_release(inode);
/* Get the file descriptor of the opened character driver proxy */ /* Get the file descriptor of the opened character driver proxy */
fd = block_proxy(path, oflags); fd = block_proxy(path, oflags);
if (fd < 0) if (fd < 0)
{ {
ret = fd; ret = fd;
goto errout_with_search; goto errout_with_search;
} }
/* Return the file descriptor */ /* Return the file descriptor */
RELEASE_SEARCH(&desc); RELEASE_SEARCH(&desc);
return fd; return fd;
} }
else else
#endif #endif
/* Verify that the inode is either a "normal" character driver or a /* Verify that the inode is either a "normal" character driver or a
+10 -10
View File
@@ -501,18 +501,18 @@ int poll(FAR struct pollfd *fds, nfds_t nfds, int timeout)
* will return immediately. * will return immediately.
*/ */
ret = nxsem_tickwait(&sem, clock_systimer(), ticks); ret = nxsem_tickwait(&sem, clock_systimer(), ticks);
if (ret < 0) if (ret < 0)
{ {
if (ret == -ETIMEDOUT) if (ret == -ETIMEDOUT)
{ {
/* Return zero (OK) in the event of a timeout */ /* Return zero (OK) in the event of a timeout */
ret = OK; ret = OK;
} }
/* EINTR is the only other error expected in normal operation */ /* EINTR is the only other error expected in normal operation */
} }
} }
else else
{ {
+1
View File
@@ -160,6 +160,7 @@ next_subdir:
goto errout; goto errout;
} }
#endif #endif
/* We found it and it appears to be a "normal" inode. Is it a /* We found it and it appears to be a "normal" inode. Is it a
* directory (i.e, an operation-less inode or an inode with children)? * directory (i.e, an operation-less inode or an inode with children)?
*/ */
+3 -3
View File
@@ -174,7 +174,7 @@ int stat_recursive(FAR const char *path, FAR struct stat *buf)
RELEASE_SEARCH(&desc); RELEASE_SEARCH(&desc);
return OK; return OK;
/* Failure conditions always set the errno appropriately */ /* Failure conditions always set the errno appropriately */
errout_with_inode: errout_with_inode:
inode_release(inode); inode_release(inode);
@@ -290,14 +290,14 @@ int inode_stat(FAR struct inode *inode, FAR struct stat *buf)
else else
#endif #endif
#if defined(CONFIG_FS_SHM) #if defined(CONFIG_FS_SHM)
if (INODE_IS_SHM(inode)) if (INODE_IS_SHM(inode))
{ {
buf->st_mode = S_IFSHM; buf->st_mode = S_IFSHM;
} }
else else
#endif #endif
#if defined(CONFIG_MTD) #if defined(CONFIG_MTD)
if (INODE_IS_MTD(inode)) if (INODE_IS_MTD(inode))
{ {
buf->st_mode = S_IFMTD; buf->st_mode = S_IFMTD;
buf->st_mode |= S_IROTH | S_IRGRP | S_IRUSR; buf->st_mode |= S_IROTH | S_IRGRP | S_IRUSR;
+1 -1
View File
@@ -171,7 +171,7 @@ int statfs(FAR const char *path, FAR struct statfs *buf)
RELEASE_SEARCH(&desc); RELEASE_SEARCH(&desc);
return OK; return OK;
/* Failure conditions always set the errno appropriately */ /* Failure conditions always set the errno appropriately */
errout_with_inode: errout_with_inode:
inode_release(inode); inode_release(inode);