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
+1
View File
@@ -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 */
+7 -2
View File
@@ -541,6 +541,7 @@ static inline int fat_parselfname(const char **path,
} }
errout: errout:
dirinfo->fd_lfname[0] = '\0'; dirinfo->fd_lfname[0] = '\0';
return -EINVAL; return -EINVAL;
} }
@@ -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];
} }
@@ -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 */
+18 -13
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;
@@ -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;
} }
} }
} }
@@ -816,6 +819,7 @@ off_t fat_cluster2sector(FAR struct fat_mountpt_s *fs, uint32_t cluster)
{ {
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;
@@ -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
+2 -1
View File
@@ -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;
+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;
+37 -13
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;
} }
@@ -1542,6 +1556,7 @@ static int lfs_file_flush(FAR lfs_t *lfs, FAR lfs_file_t *file)
.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;
+3
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;
+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.
+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;
+15 -5
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);
@@ -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;
} }
+12 -6
View File
@@ -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);
+4 -2
View File
@@ -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)
+2 -1
View File
@@ -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
+1
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;
} }
+13 -6
View File
@@ -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.
@@ -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.
@@ -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);
} }
@@ -804,8 +807,11 @@ static void nxffs_packtransfer(FAR struct nxffs_volume_s *volume,
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 */
@@ -1100,7 +1106,8 @@ nxffs_setupwriter(FAR struct nxffs_volume_s *volume,
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,
sizeof(struct nxffs_entry_s));
pack->src.entry.name = NULL; pack->src.entry.name = NULL;
return wrfile; return wrfile;
} }
+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++;
} }
+4 -2
View File
@@ -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 */
+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",
+43 -22
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;
+11 -4
View File
@@ -826,8 +826,10 @@ 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.unusedsectors) /
(procfs_data.blockerases *
procfs_data.sectorsperblk); procfs_data.sectorsperblk);
} }
@@ -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,8 +1012,10 @@ 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 */
+10 -9
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)
@@ -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;
+32 -26
View File
@@ -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);
} }
@@ -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);
+92 -47
View File
@@ -480,7 +480,8 @@ static int spiffs_check_luentry_validate(FAR struct spiffs_s *fs,
ret = spiffs_check_rewrite_page(fs, cur_pgndx, pghdr, &new_pgndx); ret = spiffs_check_rewrite_page(fs, cur_pgndx, pghdr, &new_pgndx);
spiffs_checkinfo("Data page not found elsewhere, rewriting %04x to new page %04x\n", spiffs_checkinfo("Data page not found elsewhere, rewriting %04x "
"to new page %04x\n",
cur_pgndx, new_pgndx); cur_pgndx, new_pgndx);
if (ret < 0) if (ret < 0)
@@ -491,7 +492,8 @@ static int spiffs_check_luentry_validate(FAR struct spiffs_s *fs,
*reload_lu = true; *reload_lu = true;
spiffs_checkinfo("Page %04x rewritten to %04x, affected objndx_pgndx %04x\n", spiffs_checkinfo("Page %04x rewritten to %04x, "
"affected objndx_pgndx %04x\n",
cur_pgndx, new_pgndx, objndx_pgndx); cur_pgndx, new_pgndx, objndx_pgndx);
ret = spiffs_check_rewrite_index(fs, pghdr->objid, pghdr->spndx, ret = spiffs_check_rewrite_index(fs, pghdr->objid, pghdr->spndx,
@@ -541,8 +543,10 @@ static int spiffs_check_luentry_validate(FAR struct spiffs_s *fs,
* headers. lu cannot be trusted * headers. lu cannot be trusted
*/ */
ret = spiffs_objlu_find_id_and_span_byphdr(fs, ret =
pghdr->objid | SPIFFS_OBJID_NDXFLAG, spiffs_objlu_find_id_and_span_byphdr(fs,
pghdr->objid |
SPIFFS_OBJID_NDXFLAG,
0, 0, 0); 0, 0, 0);
if (ret >= 0) if (ret >= 0)
{ {
@@ -650,7 +654,8 @@ static int spiffs_check_luentry_validate(FAR struct spiffs_s *fs,
ret2 = spiffs_check_delobj_lazy(fs, pghdr->objid); ret2 = spiffs_check_delobj_lazy(fs, pghdr->objid);
if (ret2 < 0) if (ret2 < 0)
{ {
ferr("ERROR: spiffs_check_delobj_lazy() failed: %d\n", ret2); ferr("ERROR: spiffs_check_delobj_lazy() failed: %d\n",
ret2);
return ret2; return ret2;
} }
@@ -725,7 +730,8 @@ static int spiffs_check_luentry_validate(FAR struct spiffs_s *fs,
* span index * span index
*/ */
ret = spiffs_objlu_find_id_and_span(fs, ret =
spiffs_objlu_find_id_and_span(fs,
lu_objid & ~SPIFFS_OBJID_NDXFLAG, lu_objid & ~SPIFFS_OBJID_NDXFLAG,
0, 0, &data_pgndx_lu); 0, 0, &data_pgndx_lu);
if (ret == -ENOENT) if (ret == -ENOENT)
@@ -735,7 +741,8 @@ static int spiffs_check_luentry_validate(FAR struct spiffs_s *fs,
} }
else if (ret < 0) else if (ret < 0)
{ {
ferr("ERROR: spiffs_objlu_find_id_and_span() failed: %d\n", ret); ferr("ERROR: spiffs_objlu_find_id_and_span() failed: %d\n",
ret);
return ret; return ret;
} }
@@ -743,8 +750,10 @@ static int spiffs_check_luentry_validate(FAR struct spiffs_s *fs,
* and span index * and span index
*/ */
ret = spiffs_objlu_find_id_and_span(fs, ret =
pghdr->objid & ~SPIFFS_OBJID_NDXFLAG, spiffs_objlu_find_id_and_span(fs,
pghdr->objid &
~SPIFFS_OBJID_NDXFLAG,
0, 0, &data_pgndx_ph); 0, 0, &data_pgndx_ph);
if (ret == -ENOENT) if (ret == -ENOENT)
{ {
@@ -753,7 +762,8 @@ static int spiffs_check_luentry_validate(FAR struct spiffs_s *fs,
} }
else if (ret < 0) else if (ret < 0)
{ {
ferr("ERROR: spiffs_objlu_find_id_and_span() failed: %d\n", ret); ferr("ERROR: spiffs_objlu_find_id_and_span() failed: %d\n",
ret);
return ret; return ret;
} }
@@ -769,14 +779,16 @@ static int spiffs_check_luentry_validate(FAR struct spiffs_s *fs,
/* Got a data page for page header objid rewrite as objid_ph */ /* Got a data page for page header objid rewrite as objid_ph */
new_ph.objid = pghdr->objid | SPIFFS_OBJID_NDXFLAG; new_ph.objid = pghdr->objid | SPIFFS_OBJID_NDXFLAG;
ret = spiffs_check_rewrite_page(fs, cur_pgndx, &new_ph, &new_pgndx); ret = spiffs_check_rewrite_page(fs, cur_pgndx, &new_ph,
&new_pgndx);
spiffs_checkinfo("Rewrite page %04x as %04x to pgndx %04x\n", spiffs_checkinfo("Rewrite page %04x as %04x to pgndx %04x\n",
cur_pgndx, new_ph.objid, new_pgndx); cur_pgndx, new_ph.objid, new_pgndx);
if (ret < 0) if (ret < 0)
{ {
ferr("ERROR: spiffs_check_rewrite_page() failed: %d\n", ret); ferr("ERROR: spiffs_check_rewrite_page() failed: %d\n",
ret);
return ret; return ret;
} }
@@ -794,10 +806,12 @@ static int spiffs_check_luentry_validate(FAR struct spiffs_s *fs,
spiffs_checkinfo("Rewrite page %04x as %04x\n", spiffs_checkinfo("Rewrite page %04x as %04x\n",
cur_pgndx, new_ph.objid); cur_pgndx, new_ph.objid);
ret = spiffs_check_rewrite_page(fs, cur_pgndx, &new_ph, &new_pgndx); ret = spiffs_check_rewrite_page(fs, cur_pgndx, &new_ph,
&new_pgndx);
if (ret < 0) if (ret < 0)
{ {
ferr("ERROR: spiffs_check_rewrite_page() failed: %d\n", ret); ferr("ERROR: spiffs_check_rewrite_page() failed: %d\n",
ret);
return ret; return ret;
} }
@@ -1386,9 +1400,11 @@ int spiffs_check_pgconsistency(FAR struct spiffs_s *fs)
/* read header */ /* read header */
ret = spiffs_cache_read(fs, SPIFFS_OP_T_OBJ_LU2 | SPIFFS_OP_C_READ, ret =
spiffs_cache_read(fs, SPIFFS_OP_T_OBJ_LU2 | SPIFFS_OP_C_READ,
0, SPIFFS_PAGE_TO_PADDR(fs, cur_pgndx), 0, SPIFFS_PAGE_TO_PADDR(fs, cur_pgndx),
sizeof(struct spiffs_page_header_s), (uint8_t *) & pghdr); sizeof(struct spiffs_page_header_s),
(FAR uint8_t *)&pghdr);
if (ret < 0) if (ret < 0)
{ {
ferr("ERROR: spiffs_cache_read() failed: %d\n", ret); ferr("ERROR: spiffs_cache_read() failed: %d\n", ret);
@@ -1481,7 +1497,8 @@ int spiffs_check_pgconsistency(FAR struct spiffs_s *fs)
/* Bad reference */ /* Bad reference */
spiffs_checkinfo("pgndx=%04x bad pgndx / LU referenced from page %04x\n", spiffs_checkinfo("pgndx=%04x bad pgndx / LU referenced "
"from page %04x\n",
rpgndx, cur_pgndx); rpgndx, cur_pgndx);
/* Check for data page elsewhere */ /* Check for data page elsewhere */
@@ -1511,7 +1528,8 @@ int spiffs_check_pgconsistency(FAR struct spiffs_s *fs)
new_ph.flags = 0xff & ~(SPIFFS_PH_FLAG_USED | new_ph.flags = 0xff & ~(SPIFFS_PH_FLAG_USED |
SPIFFS_PH_FLAG_FINAL); SPIFFS_PH_FLAG_FINAL);
new_ph.objid = objndx_phdr->objid & ~SPIFFS_OBJID_NDXFLAG; new_ph.objid = objndx_phdr->objid &
~SPIFFS_OBJID_NDXFLAG;
new_ph.spndx = data_spndx_offset + i; new_ph.spndx = data_spndx_offset + i;
ret = spiffs_page_allocate_data(fs, new_ph.objid, ret = spiffs_page_allocate_data(fs, new_ph.objid,
@@ -1519,11 +1537,13 @@ int spiffs_check_pgconsistency(FAR struct spiffs_s *fs)
&data_pgndx); &data_pgndx);
if (ret < 0) if (ret < 0)
{ {
ferr("ERROR: spiffs_page_allocate_data() failed: %d\n", ret); ferr("ERROR: spiffs_page_allocate_data() failed: %d\n",
ret);
return ret; return ret;
} }
spiffs_checkinfo("Found no existing data page, created new @ %04x\n", spiffs_checkinfo("Found no existing data page, "
"created new @ %04x\n",
data_pgndx); data_pgndx);
} }
@@ -1531,15 +1551,18 @@ int spiffs_check_pgconsistency(FAR struct spiffs_s *fs)
spiffs_checkinfo("Rewriting index pgndx=%04x\n", cur_pgndx); spiffs_checkinfo("Rewriting index pgndx=%04x\n", cur_pgndx);
ret = spiffs_check_rewrite_index(fs, ret =
objndx_phdr->objid | SPIFFS_OBJID_NDXFLAG, spiffs_check_rewrite_index(fs,
objndx_phdr->objid |
SPIFFS_OBJID_NDXFLAG,
data_spndx_offset + i, data_spndx_offset + i,
data_pgndx, cur_pgndx); data_pgndx, cur_pgndx);
if (ret == -EFAULT) if (ret == -EFAULT)
{ {
/* Index bad also, cannot mend this file */ /* Index bad also, cannot mend this file */
spiffs_checkinfo("Index bad %d, cannot mend - delete object\n", spiffs_checkinfo("Index bad %d, cannot mend - "
"delete object\n",
ret); ret);
/* Delete file */ /* Delete file */
@@ -1547,13 +1570,15 @@ int spiffs_check_pgconsistency(FAR struct spiffs_s *fs)
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;
} }
} }
else if (ret < 0) else if (ret < 0)
{ {
ferr("ERROR: spiffs_check_rewrite_index() failed: %d\n", ret); ferr("ERROR: spiffs_check_rewrite_index() failed: %d\n",
ret);
return ret; return ret;
} }
@@ -1564,7 +1589,8 @@ int spiffs_check_pgconsistency(FAR struct spiffs_s *fs)
/* Valid reference. read referenced page header */ /* Valid reference. read referenced page header */
struct spiffs_page_header_s rphdr; struct spiffs_page_header_s rphdr;
ret = spiffs_cache_read(fs, ret =
spiffs_cache_read(fs,
SPIFFS_OP_T_OBJ_LU2 | SPIFFS_OP_C_READ, SPIFFS_OP_T_OBJ_LU2 | SPIFFS_OP_C_READ,
0, SPIFFS_PAGE_TO_PADDR(fs, rpgndx), 0, SPIFFS_PAGE_TO_PADDR(fs, rpgndx),
sizeof(struct spiffs_page_header_s), sizeof(struct spiffs_page_header_s),
@@ -1579,14 +1605,17 @@ int spiffs_check_pgconsistency(FAR struct spiffs_s *fs)
if (rphdr.objid != (pghdr.objid & ~SPIFFS_OBJID_NDXFLAG) || if (rphdr.objid != (pghdr.objid & ~SPIFFS_OBJID_NDXFLAG) ||
rphdr.spndx != data_spndx_offset + i || rphdr.spndx != data_spndx_offset + i ||
(rphdr.flags & (SPIFFS_PH_FLAG_DELET | SPIFFS_PH_FLAG_INDEX | (rphdr.flags & (SPIFFS_PH_FLAG_DELET |
SPIFFS_PH_FLAG_INDEX |
SPIFFS_PH_FLAG_USED)) != SPIFFS_PH_FLAG_USED)) !=
(SPIFFS_PH_FLAG_DELET | SPIFFS_PH_FLAG_INDEX)) (SPIFFS_PH_FLAG_DELET | SPIFFS_PH_FLAG_INDEX))
{ {
int16_t data_pgndx; int16_t data_pgndx;
spiffs_checkinfo("pgndx=%04x has inconsistent page header index objid/span:" spiffs_checkinfo("pgndx=%04x has inconsistent page "
"%04x/%04x, ref objid/span:%04x/%04x flags=%02x\n", "header index objid/span:"
"%04x/%04x, ref objid/span:%04x/%04x "
"flags=%02x\n",
rpgndx, rpgndx,
pghdr.objid & ~SPIFFS_OBJID_NDXFLAG, pghdr.objid & ~SPIFFS_OBJID_NDXFLAG,
data_spndx_offset + i, data_spndx_offset + i,
@@ -1595,11 +1624,12 @@ int spiffs_check_pgconsistency(FAR struct spiffs_s *fs)
/* Try finding correct page */ /* Try finding correct page */
ret = spiffs_objlu_find_id_and_span(fs, ret =
spiffs_objlu_find_id_and_span(fs,
pghdr.objid & pghdr.objid &
~SPIFFS_OBJID_NDXFLAG, ~SPIFFS_OBJID_NDXFLAG,
data_spndx_offset + i, rpgndx, data_spndx_offset + i,
&data_pgndx); rpgndx, &data_pgndx);
if (ret == -ENOENT) if (ret == -ENOENT)
{ {
ret = OK; ret = OK;
@@ -1607,7 +1637,8 @@ int spiffs_check_pgconsistency(FAR struct spiffs_s *fs)
} }
else if (ret < 0) else if (ret < 0)
{ {
ferr("ERROR: spiffs_objlu_find_id_and_span() failed: %d\n", ret); ferr("ERROR: spiffs_objlu_find_id_and_span() failed: %d\n",
ret);
return ret; return ret;
} }
@@ -1633,10 +1664,13 @@ int spiffs_check_pgconsistency(FAR struct spiffs_s *fs)
/* Found it, so rewrite index */ /* Found it, so rewrite index */
spiffs_checkinfo("Found correct data pgndx=%04x, " spiffs_checkinfo("Found correct data pgndx=%04x, "
"rewrite index pgndx=%04x objid=%04x\n", "rewrite index pgndx=%04x "
data_pgndx, cur_pgndx, pghdr.objid); "objid=%04x\n",
data_pgndx, cur_pgndx,
pghdr.objid);
ret = spiffs_check_rewrite_index(fs, pghdr.objid, ret =
spiffs_check_rewrite_index(fs, pghdr.objid,
data_spndx_offset + i, data_spndx_offset + i,
data_pgndx, cur_pgndx); data_pgndx, cur_pgndx);
if (ret == -EFAULT) if (ret == -EFAULT)
@@ -1650,7 +1684,8 @@ int spiffs_check_pgconsistency(FAR struct spiffs_s *fs)
} }
else if (ret < 0) else if (ret < 0)
{ {
ferr("ERROR: spiffs_check_rewrite_index() failed: %d\n", ret); ferr("ERROR: spiffs_check_rewrite_index() failed: %d\n",
ret);
return ret; return ret;
} }
@@ -1668,7 +1703,8 @@ int spiffs_check_pgconsistency(FAR struct spiffs_s *fs)
if ((fs->work[rpgndx_byte_ix] & (1 << (rpgndx_bit_ix + 1))) != 0) if ((fs->work[rpgndx_byte_ix] & (1 << (rpgndx_bit_ix + 1))) != 0)
{ {
spiffs_checkinfo("pgndx=%04x multiple referenced from page %04x\n", spiffs_checkinfo("pgndx=%04x multiple referenced "
"from page %04x\n",
rpgndx, cur_pgndx); rpgndx, cur_pgndx);
/* Here, we should have fixed all broken /* Here, we should have fixed all broken
@@ -1679,13 +1715,15 @@ int spiffs_check_pgconsistency(FAR struct spiffs_s *fs)
* page * page
*/ */
spiffs_checkinfo("Removing objid=%04x and page=%04x\n", spiffs_checkinfo("Removing objid=%04x and"
"page=%04x\n",
pghdr.objid, cur_pgndx); pghdr.objid, cur_pgndx);
ret = spiffs_check_delobj_lazy(fs, pghdr.objid); ret = spiffs_check_delobj_lazy(fs, pghdr.objid);
if (ret < 0) if (ret < 0)
{ {
ferr("ERROR: spiffs_check_delobj_lazy() failed: %d\n", ret); ferr("ERROR: spiffs_check_delobj_lazy() failed: %d\n",
ret);
return ret; return ret;
} }
@@ -1694,7 +1732,8 @@ int spiffs_check_pgconsistency(FAR struct spiffs_s *fs)
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;
} }
@@ -1790,15 +1829,18 @@ int spiffs_check_pgconsistency(FAR struct spiffs_s *fs)
/* Pointing to something else, check what */ /* Pointing to something else, check what */
ret = spiffs_cache_read(fs, ret =
SPIFFS_OP_T_OBJ_LU2 | SPIFFS_OP_C_READ, spiffs_cache_read(fs,
SPIFFS_OP_T_OBJ_LU2 |
SPIFFS_OP_C_READ,
0, 0,
SPIFFS_PAGE_TO_PADDR(fs, rpgndx), SPIFFS_PAGE_TO_PADDR(fs, rpgndx),
sizeof(struct spiffs_page_header_s), sizeof(struct spiffs_page_header_s),
(FAR uint8_t *)&rphdr); (FAR uint8_t *)&rphdr);
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;
} }
@@ -1814,7 +1856,8 @@ int spiffs_check_pgconsistency(FAR struct spiffs_s *fs)
* delete this page then * delete this page then
*/ */
spiffs_checkinfo("Corresponding ref is good but different: " spiffs_checkinfo("Corresponding ref is good but "
"different: "
"%04x, delete this %04x\n", "%04x, delete this %04x\n",
rpgndx, cur_pgndx); rpgndx, cur_pgndx);
@@ -1850,7 +1893,8 @@ int spiffs_check_pgconsistency(FAR struct spiffs_s *fs)
} }
else if (ret == -ENOENT) else if (ret == -ENOENT)
{ {
spiffs_checkinfo("Corresponding ref not found, delete %04x\n", spiffs_checkinfo("Corresponding ref not found, "
"delete %04x\n",
cur_pgndx); cur_pgndx);
delete_page = true; delete_page = true;
@@ -1890,7 +1934,8 @@ int spiffs_check_pgconsistency(FAR struct spiffs_s *fs)
ret2 = spiffs_check_delobj_lazy(fs, pghdr.objid); ret2 = spiffs_check_delobj_lazy(fs, pghdr.objid);
if (ret2 < 0) if (ret2 < 0)
{ {
ferr("ERROR: spiffs_check_delobj_lazy() failed: %d\n", ret2); ferr("ERROR: spiffs_check_delobj_lazy() failed: %d\n",
ret2);
return ret2; return ret2;
} }
} }
+20 -10
View File
@@ -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,7 +1783,8 @@ ssize_t spiffs_fobj_append(FAR struct spiffs_s *fs,
return ret; return ret;
} }
ret = spiffs_cache_write(fs, ret =
spiffs_cache_write(fs,
SPIFFS_OP_T_OBJNDX | SPIFFS_OP_C_UPDT, SPIFFS_OP_T_OBJNDX | SPIFFS_OP_C_UPDT,
fobj->objid, fobj->objid,
SPIFFS_PAGE_TO_PADDR(fs, cur_objndx_pgndx), SPIFFS_PAGE_TO_PADDR(fs, cur_objndx_pgndx),
@@ -1951,7 +1954,8 @@ ssize_t spiffs_fobj_append(FAR struct spiffs_s *fs,
} }
else else
{ {
ret = spiffs_objlu_find_id_and_span(fs, ret =
spiffs_objlu_find_id_and_span(fs,
fobj->objid | SPIFFS_OBJID_NDXFLAG, fobj->objid | SPIFFS_OBJID_NDXFLAG,
cur_objndx_spndx, 0, cur_objndx_spndx, 0,
&pgndx); &pgndx);
@@ -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,7 +2395,8 @@ ssize_t spiffs_fobj_modify(FAR struct spiffs_s *fs,
} }
else else
{ {
ret = spiffs_objlu_find_id_and_span(fs, ret =
spiffs_objlu_find_id_and_span(fs,
fobj->objid | SPIFFS_OBJID_NDXFLAG, fobj->objid | SPIFFS_OBJID_NDXFLAG,
cur_objndx_spndx, 0, cur_objndx_spndx, 0,
&pgndx); &pgndx);
@@ -2511,7 +2517,8 @@ ssize_t spiffs_fobj_modify(FAR struct spiffs_s *fs,
{ {
/* After modification */ /* After modification */
ret = spiffs_phys_cpy(fs, fobj->objid, ret =
spiffs_phys_cpy(fs, fobj->objid,
SPIFFS_PAGE_TO_PADDR(fs, data_pgndx) + SPIFFS_PAGE_TO_PADDR(fs, data_pgndx) +
sizeof(struct spiffs_page_header_s) + page_offs + sizeof(struct spiffs_page_header_s) + page_offs +
to_write, to_write,
@@ -2991,7 +2998,8 @@ int spiffs_fobj_truncate(FAR struct spiffs_s *fs,
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,7 +3272,8 @@ ssize_t spiffs_object_read(FAR struct spiffs_s *fs,
} }
else else
{ {
ret = spiffs_objlu_find_id_and_span(fs, ret =
spiffs_objlu_find_id_and_span(fs,
fobj->objid | SPIFFS_OBJID_NDXFLAG, fobj->objid | SPIFFS_OBJID_NDXFLAG,
cur_objndx_spndx, 0, cur_objndx_spndx, 0,
&objndx_pgndx); &objndx_pgndx);
@@ -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);
+13 -6
View File
@@ -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,7 +591,8 @@ 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_cache_read(fs,
SPIFFS_OP_T_OBJ_LU | SPIFFS_OP_C_READ, SPIFFS_OP_T_OBJ_LU | SPIFFS_OP_C_READ,
0, 0,
blkndx * SPIFFS_GEO_BLOCK_SIZE(fs) + blkndx * SPIFFS_GEO_BLOCK_SIZE(fs) +
@@ -598,7 +601,8 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
fs->lu_work); 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,7 +711,8 @@ 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_cache_read(fs,
SPIFFS_OP_T_OBJ_LU | SPIFFS_OP_C_READ, SPIFFS_OP_T_OBJ_LU | SPIFFS_OP_C_READ,
0, 0,
blkndx * SPIFFS_GEO_BLOCK_SIZE(fs) + blkndx * SPIFFS_GEO_BLOCK_SIZE(fs) +
@@ -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 ||
+12 -5
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,7 +706,8 @@ 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_fobj_write(fs, fobj,
spiffs_get_cache_page(fs, spiffs_get_cache(fs), spiffs_get_cache_page(fs, spiffs_get_cache(fs),
fobj->cache_page->cpndx), fobj->cache_page->cpndx),
fobj->cache_page->offset, fobj->cache_page->offset,
@@ -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;
@@ -786,7 +790,8 @@ 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_fobj_write(fs, fobj,
spiffs_get_cache_page(fs, spiffs_get_cache_page(fs,
spiffs_get_cache(fs), spiffs_get_cache(fs),
fobj->cache_page->cpndx), fobj->cache_page->cpndx),
@@ -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);
+5 -2
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);
+3 -1
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)
+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
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)?
*/ */
+1 -1
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);
+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);