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
FAR void *ptr;
} u;
#ifdef CONFIG_PRIORITY_INHERITANCE
struct sched_param param;
#endif
+2 -2
View File
@@ -515,7 +515,7 @@ static int cromfs_open(FAR struct file *filep, FAR const char *relpath,
return -EACCES;
}
/* Locate the node for this relative path */
/* Locate the node for this relative path */
node = NULL;
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;
/* Locate the node for this relative path */
/* Locate the node for this relative path */
node = NULL;
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");
ret = -ENOTBLK;
goto errout;
}
}
/* Close the block driver. Not that no mutually exclusive access
* 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) ||
((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);
if (ret < 0)
{
goto errout_with_semaphore;
}
ret = fat_ffcacheflush(fs, ff);
if (ret < 0)
{
goto errout_with_semaphore;
}
/* Now mark the clean cache buffer as the current sector. */
@@ -998,7 +998,7 @@ fat_write_restart:
byteswritten += writesize;
buflen -= writesize;
sectorindex = filep->f_pos & SEC_NDXMASK(fs);
}
}
/* 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)
{
/* The entry is not a directory */
/* The entry is not a directory */
ret = -ENOTDIR;
goto errout_with_semaphore;
ret = -ENOTDIR;
goto errout_with_semaphore;
}
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 =
((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);
if (ret < 0)
{
goto errout_with_semaphore;
goto errout_with_semaphore;
}
/* 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;
}
parentsector = fs->fs_currentsector;
/* 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
if (endndx == 8)
{
/* Is there mixed case in the name? */
/* Is there mixed case in the name? */
#ifdef CONFIG_FAT_LFN
if (namecase == FATCASE_UPPER)
{
/* Mixed case in the name -- use the long file name */
if (namecase == FATCASE_UPPER)
{
/* 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
/* Set lower case name bit */
@@ -541,8 +541,9 @@ static inline int fat_parselfname(const char **path,
}
errout:
dirinfo->fd_lfname[0] = '\0';
return -EINVAL;
dirinfo->fd_lfname[0] = '\0';
return -EINVAL;
}
#endif
@@ -634,13 +635,13 @@ static inline int fat_createalias(struct fat_dirinfo_s *dirinfo)
if (namechars < 1)
{
/* Use the extension as the name */
/* Use the extension as the name */
DEBUGASSERT(ext && extchars > 0);
src = ext;
ext = NULL;
namechars = extchars;
extchars = 0;
DEBUGASSERT(ext && extchars > 0);
src = ext;
ext = NULL;
namechars = extchars;
extchars = 0;
}
else
{
@@ -866,7 +867,7 @@ static inline int fat_uniquealias(struct fat_mountpt_s *fs,
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";
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_lfncluster = dirinfo->fd_seq.ds_cluster;
#endif
return OK;
return OK;
}
/* No... get the next directory index and try again */
@@ -1530,6 +1531,7 @@ static inline int fat_allocatelfnentry(struct fat_mountpt_s *fs,
{
nentries++;
}
DEBUGASSERT(nentries > 0 && nentries <= LDIR_MAXLFNS);
/* 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);
}
#endif
/* Copy the next character into the filename */
*buffer++ = ch;
@@ -1736,6 +1739,7 @@ static inline int fat_getsfname(uint8_t *direntry, char *buffer,
ch = tolower(ch);
}
#endif
/* Copy the next character into the filename */
*buffer++ = ch;
@@ -2095,7 +2099,8 @@ static int fat_putlfname(struct fat_mountpt_s *fs,
*/
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 */
@@ -2479,7 +2484,7 @@ int fat_allocatedirentry(struct fat_mountpt_s *fs,
if (cluster)
{
/* Cluster chain can be extended */
/* Cluster chain can be extended */
dirinfo->dir.fd_currcluster = 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)
{
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. */
@@ -212,7 +213,8 @@ static int fat_checkbootrecord(struct fat_mountpt_s *fs)
/* 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)
{
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_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;
return OK;
@@ -388,7 +391,7 @@ void fat_semtake(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)
{
{
ret = fat_checkfsinfo(fs);
if (ret != OK)
{
goto errout_with_buffer;
}
}
{
goto errout_with_buffer;
}
}
/* 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;
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);
if (nSectorsRead == nsectors)
if (nsectorsread == nsectors)
{
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;
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);
if (nSectorsWritten == nsectors)
if (nsectorswritten == nsectors)
{
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;
if (cluster >= fs->fs_nclusters - 2)
{
return -EINVAL;
return -EINVAL;
}
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 */
value = (fs->fs_buffer[fatindex] & 0xf0) | ((nextcluster >> 8) & 0x0f);
value = (fs->fs_buffer[fatindex] & 0xf0) |
((nextcluster >> 8) & 0x0f);
}
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 ||
(pos + remaining) >= ff->ff_size))
{
/* Flush unwritten data in the sector cache. */
/* Flush unwritten data in the sector cache. */
ret = fat_ffcacheflush(fs, ff);
if (ret < 0)
{
return ret;
}
ret = fat_ffcacheflush(fs, ff);
if (ret < 0)
{
return ret;
}
/* 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;
remaining -= zerosize;
sectndx = pos & SEC_NDXMASK(fs);
}
}
/* 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++)
{
/* If the cluster is unassigned, then increment the count of free clusters */
if ((uint16_t)fat_getcluster(fs, sector) == 0)
@@ -2111,6 +2115,7 @@ int fat_nfreeclusters(struct fat_mountpt_s *fs, off_t *pfreeclusters)
{
nfreeclusters++;
}
offset += 2;
}
else
@@ -2125,14 +2130,14 @@ int fat_nfreeclusters(struct fat_mountpt_s *fs, off_t *pfreeclusters)
}
}
fs->fs_fsifreecount = nfreeclusters;
if (fs->fs_type == FSTYPE_FAT32)
{
fs->fs_fsidirty = true;
}
fs->fs_fsifreecount = nfreeclusters;
if (fs->fs_type == FSTYPE_FAT32)
{
fs->fs_fsidirty = true;
}
*pfreeclusters = nfreeclusters;
return OK;
*pfreeclusters = nfreeclusters;
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
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);
}
@@ -290,9 +290,10 @@ int file_dup2(FAR struct file *filep1, FAR struct file *filep2)
return OK;
/* Handler various error conditions */
/* Handle various error conditions */
errout_with_inode:
inode_release(filep2->f_inode);
filep2->f_oflags = 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)
{
list->fl_files[i].f_oflags = oflags;
list->fl_files[i].f_pos = pos;
list->fl_files[i].f_inode = inode;
list->fl_files[i].f_priv = NULL;
_files_semgive(list);
return i;
list->fl_files[i].f_oflags = oflags;
list->fl_files[i].f_pos = pos;
list->fl_files[i].f_inode = inode;
list->fl_files[i].f_priv = NULL;
_files_semgive(list);
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
*/
node->i_flags |= FSNODEFLAG_DELETED;
return -EBUSY;
node->i_flags |= FSNODEFLAG_DELETED;
return -EBUSY;
}
else
{
+2 -1
View File
@@ -396,6 +396,7 @@ static int _inode_search(FAR struct inode_search_s *desc)
}
}
#endif
/* Keep looking at the next level "down" */
above = node;
@@ -517,7 +518,7 @@ int inode_search(FAR struct inode_search_s *desc)
if (INODE_IS_MOUNTPT(node))
{
/* Yes... set up for the MOUNTPOINT logic below. */
/* Yes... set up for the MOUNTPOINT logic below. */
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]
};
bool valid = false;
int i;
@@ -618,6 +619,7 @@ static int lfs_dir_fetch(FAR lfs_t *lfs, FAR lfs_dir_t *dir,
{
continue;
}
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;
lfs_block_t oldpair[2];
bool relocated;
int err;
int i;
/* increment revision count */
@@ -702,13 +705,14 @@ static int lfs_dir_commit(FAR lfs_t *lfs, FAR lfs_dir_t *dir,
if (true)
{
uint32_t crc;
int err = lfs_bd_erase(lfs, dir->pair[0]);
err = lfs_bd_erase(lfs, dir->pair[0]);
if (err)
{
if (err == LFS_ERR_CORRUPT)
{
goto relocate;
}
return err;
}
@@ -723,6 +727,7 @@ static int lfs_dir_commit(FAR lfs_t *lfs, FAR lfs_dir_t *dir,
{
goto relocate;
}
return err;
}
@@ -742,6 +747,7 @@ static int lfs_dir_commit(FAR lfs_t *lfs, FAR lfs_dir_t *dir,
{
goto relocate;
}
return err;
}
@@ -766,6 +772,7 @@ static int lfs_dir_commit(FAR lfs_t *lfs, FAR lfs_dir_t *dir,
{
goto relocate;
}
return err;
}
@@ -783,6 +790,7 @@ static int lfs_dir_commit(FAR lfs_t *lfs, FAR lfs_dir_t *dir,
{
goto relocate;
}
return err;
}
@@ -793,6 +801,7 @@ static int lfs_dir_commit(FAR lfs_t *lfs, FAR lfs_dir_t *dir,
{
goto relocate;
}
return err;
}
@@ -815,6 +824,7 @@ static int lfs_dir_commit(FAR lfs_t *lfs, FAR lfs_dir_t *dir,
break;
relocate:
/* Commit was corrupted */
LFS_DEBUG("Bad block at %" PRIu32, dir->pair[0]);
@@ -833,9 +843,9 @@ relocate:
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)
{
return err;
@@ -1095,13 +1105,14 @@ static int lfs_dir_find(FAR lfs_t *lfs, FAR lfs_dir_t *dir,
size_t sufflen;
int depth;
nextname:
/* skip slashes */
nextname:
/* Skip slashes */
pathname += strspn(pathname, "/");
pathlen = strcspn(pathname, "/");
/* skip '.' and root '..' */
/* Skip '.' and root '..' */
if ((pathlen == 1 && memcmp(pathname, ".", 1) == 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;
}
/* skip if matched by '..' in name */
/* Skip if matched by '..' in name */
suffix = pathname + pathlen;
depth = 1;
@@ -1341,6 +1352,7 @@ static int lfs_ctz_extend(FAR lfs_t *lfs, FAR lfs_cache_t *rcache,
{
goto relocate;
}
return err;
}
}
@@ -1390,10 +1402,11 @@ static int lfs_ctz_extend(FAR lfs_t *lfs, FAR lfs_cache_t *rcache,
return 0;
}
relocate:
relocate:
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);
}
@@ -1479,6 +1492,7 @@ relocate:
{
goto relocate;
}
return err;
}
@@ -1536,12 +1550,13 @@ static int lfs_file_flush(FAR lfs_t *lfs, FAR lfs_file_t *file)
lfs_file_t orig =
{
.head = file->head,
.size = file->size,
.head = file->head,
.size = file->size,
.flags = LFS_O_RDONLY,
.pos = file->pos,
.pos = file->pos,
.cache = lfs->rcache,
};
lfs_cache_drop(lfs, &lfs->rcache);
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)
{
@@ -1583,11 +1598,14 @@ static int lfs_file_flush(FAR lfs_t *lfs, FAR lfs_file_t *file)
{
goto relocate;
}
return err;
}
break;
relocate:
relocate:
err = lfs_file_relocate(lfs, file);
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->size = file->pos;
@@ -2565,6 +2583,7 @@ lfs_ssize_t lfs_file_write(FAR lfs_t *lfs, FAR lfs_file_t *file,
{
goto relocate;
}
file->flags |= LFS_F_ERRED;
return err;
}
@@ -2954,6 +2973,7 @@ int lfs_rename(FAR lfs_t *lfs, FAR const char *oldpath,
{
return err;
}
lfs->moving = false;
/* remove old entry */
@@ -3076,6 +3096,7 @@ int lfs_format(FAR lfs_t *lfs, FAR const struct lfs_config_s *cfg)
}
},
1);
if (err && err != LFS_ERR_CORRUPT)
{
goto cleanup;
@@ -3132,7 +3153,7 @@ int lfs_mount(FAR lfs_t *lfs, FAR const struct lfs_config_s *cfg)
/* 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)
{
goto cleanup;
@@ -3195,6 +3216,7 @@ int lfs_traverse(FAR lfs_t *lfs, CODE int (*cb)(void *, lfs_block_t),
{
0, 1
};
FAR lfs_file_t *f;
if (lfs_pairisnull(lfs->root))
@@ -3292,11 +3314,13 @@ int lfs_deorphan(FAR lfs_t *lfs)
{
.d.size = 0x80000000
};
lfs_dir_t cwd =
{
.d.tail[0] = 0,
.d.tail[1] = 1
};
lfs_size_t i;
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;
}
littlefs_semgive(fs);
return ret;
@@ -414,6 +415,7 @@ static ssize_t littlefs_write(FAR struct file *filep, const char *buffer,
{
filep->f_pos += ret;
}
littlefs_semgive(fs);
return ret;
@@ -444,6 +446,7 @@ static off_t littlefs_seek(FAR struct file *filep, off_t offset, int whence)
{
filep->f_pos = ret;
}
littlefs_semgive(fs);
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)
{
FAR struct statfs *buf = arg;
FAR struct statfs *buf = arg;
buf->f_bfree--;
buf->f_bavail--;
buf->f_bfree--;
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)
{
case OK_EXIST:
/* 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
* 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:
/* If we get here, then the volume must not be mounted */
DEBUGASSERT(!priv->mounted);
@@ -277,6 +279,7 @@ static int automount_unmount(FAR struct automounter_state_s *priv)
switch (ret)
{
case OK_EXIST:
/* If we get here, then the volume must be mounted */
DEBUGASSERT(priv->mounted);
@@ -321,6 +324,7 @@ static int automount_unmount(FAR struct automounter_state_s *priv)
/* Fall through */
case OK_NOENT:
/* The mountpoint is not present. This is normal behavior in the
* case where the user manually un-mounted the volume before removing
* 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)
{
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)
{
/* Just decrement the reference count (without deleting it) */
/* Just decrement the reference count (without deleting it) */
DEBUGASSERT(mountpt_inode->i_crefs > 0);
mountpt_inode->i_crefs--;
DEBUGASSERT(mountpt_inode->i_crefs > 0);
mountpt_inode->i_crefs--;
}
else
#endif
@@ -180,7 +180,7 @@ int umount2(FAR const char *target, unsigned int flags)
{
errcode = -ret;
goto errout_with_mountpt;
}
}
/* Release the mountpoint inode and any block driver inode
* 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 */
if (mqdes)
{
sched_lock();
if (mqdes)
{
sched_lock();
/* Find the message queue associated with the message descriptor */
/* Find the message queue associated with the message descriptor */
msgq = mqdes->msgq;
DEBUGASSERT(msgq && msgq->inode);
msgq = mqdes->msgq;
DEBUGASSERT(msgq && msgq->inode);
/* Close/free the message descriptor */
/* Close/free the message descriptor */
ret = nxmq_desclose_group(mqdes, group);
if (ret >= 0)
{
/* Get the inode from the message queue structure */
ret = nxmq_desclose_group(mqdes, group);
if (ret >= 0)
{
/* Get the inode from the message queue structure */
inode = msgq->inode;
DEBUGASSERT(inode->u.i_mqueue == msgq);
inode = msgq->inode;
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;
}
+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 */
mqdes = nxmq_create_des(NULL, msgq, oflags);
if (!mqdes)
{
errcode = ENOMEM;
goto errout_with_msgq;
}
mqdes = nxmq_create_des(NULL, msgq, oflags);
if (!mqdes)
{
errcode = ENOMEM;
goto errout_with_msgq;
}
/* 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));
}
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,
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 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);
}
reqlen += sizeof(uint32_t);
/* 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 */
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 */
@@ -1016,7 +1018,9 @@ static ssize_t nfs_write(FAR struct file *filep, const char *buffer,
writesize = 0;
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;
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;
}
/* 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);
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
*/
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;
/* 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);
error = nfs_request(nmp, NFSPROC_WRITE,
(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)
{
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)
{
error = EIO;
goto errout_with_semaphore;
error = EIO;
goto errout_with_semaphore;
}
writesize = tmp;
@@ -1546,9 +1554,9 @@ static int nfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
*/
else
{
finfo("No data but not end of directory???\n");
error = EAGAIN;
{
finfo("No data but not end of directory???\n");
error = EAGAIN;
}
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;
break;
}
finfo("type: %d->%d\n", (int)tmp, dir->fd_dir.d_type);
errout_with_semaphore:
@@ -1703,6 +1712,7 @@ static void nfs_decode_args(FAR struct nfs_mount_parameters *nprmt,
{
tmp = NFS_MAXTIMEO;
}
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);
errout_with_semaphore:
nfs_semgive(nmp);
return -error;
nfs_semgive(nmp);
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)
{
rpc->rc_timeout = true;
}
}
}
/* 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));
error = rpcclnt_request(rpc, RPCMNT_MOUNT, RPCPROG_MNT, RPCMNT_VER3,
(FAR void *)&request.mountd, sizeof(struct call_args_mount),
(FAR void *)&response.mdata, sizeof(struct rpc_reply_mount));
(FAR void *)&request.mountd,
sizeof(struct call_args_mount),
(FAR void *)&response.mdata
sizeof(struct rpc_reply_mount));
if (error != 0)
{
ferr("ERROR: rpcclnt_request failed: %d\n", error);
@@ -636,8 +638,10 @@ int rpcclnt_umount(struct rpcclnt *rpc)
request.sdata.pmap.port = 0;
error = rpcclnt_request(rpc, PMAPPROC_GETPORT, PMAPPROG, PMAPVERS,
(FAR void *)&request.sdata, sizeof(struct call_args_pmap),
(FAR void *)&response.rdata, sizeof(struct rpc_reply_pmap));
(FAR void *)&request.sdata,
sizeof(struct call_args_pmap),
(FAR void *)&response.rdata,
sizeof(struct rpc_reply_pmap));
if (error != 0)
{
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));
error = rpcclnt_request(rpc, RPCMNT_UMOUNT, RPCPROG_MNT, RPCMNT_VER3,
(FAR void *)&request.mountd, sizeof(struct call_args_umount),
(FAR void *)&response.mdata, sizeof(struct rpc_reply_umount));
(FAR void *)&request.mountd,
sizeof(struct call_args_umount),
(FAR void *)&response.mdata,
sizeof(struct rpc_reply_umount));
if (error != 0)
{
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;
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)
{
+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. */
return ERROR;
return ERROR;
}
/* 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);
if (crc != ecrc)
{
{
syslog(LOG_NOTICE, g_format,
blkinfo->block, offset, "INODE", "CRC BAD", datlen);
return ERROR;
}
}
/* 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);
if (crc != ecrc)
{
{
syslog(LOG_NOTICE, g_format,
blkinfo->block, offset, "DATA ", "CRC BAD", datlen);
return ERROR;
}
}
/* 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)
{
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 (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, 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;
blkinfo.block < blkinfo.nblocks;
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 (; ; )
{
{
/* Get the next, valid NXFFS inode 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
*/
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
* 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);
}
return ret;
}
@@ -1021,25 +1022,25 @@ int nxffs_open(FAR struct file *filep, FAR const char *relpath,
* extension is supported.
*/
switch (oflags & (O_WROK | O_RDOK))
{
case 0:
default:
ferr("ERROR: One of O_WRONLY/O_RDONLY must be provided\n");
return -EINVAL;
switch (oflags & (O_WROK | O_RDOK))
{
case 0:
default:
ferr("ERROR: One of O_WRONLY/O_RDONLY must be provided\n");
return -EINVAL;
case O_WROK:
ret = nxffs_wropen(volume, relpath, oflags, &ofile);
break;
case O_WROK:
ret = nxffs_wropen(volume, relpath, oflags, &ofile);
break;
case O_RDOK:
ret = nxffs_rdopen(volume, relpath, &ofile);
break;
case O_RDOK:
ret = nxffs_rdopen(volume, relpath, &ofile);
break;
case O_WROK | O_RDOK:
ferr("ERROR: O_RDWR is not supported\n");
return -ENOSYS;
}
case O_WROK | O_RDOK:
ferr("ERROR: O_RDWR is not supported\n");
return -ENOSYS;
}
/* 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;
ret = nxffs_validblock(volume, &volume->ioblock);
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
* 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 */
return 0;
return 0;
}
/* 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);
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
* and try again later.
@@ -556,7 +557,7 @@ static int nxffs_destsetup(FAR struct nxffs_volume_s *volume,
ret = -ENOSPC;
goto errout;
}
}
/* 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);
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
* and try again later.
@@ -589,7 +591,7 @@ static int nxffs_destsetup(FAR struct nxffs_volume_s *volume,
ret = -ENOSPC;
goto errout;
}
}
/* 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) */
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);
}
@@ -791,33 +794,36 @@ static void nxffs_wrdathdr(FAR struct nxffs_volume_s *volume,
static void nxffs_packtransfer(FAR struct nxffs_volume_s *volume,
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);
if (xfrlen > 0)
{
nxffs_ioseek(volume, pack->src.blkoffset + SIZEOF_NXFFS_DATA_HDR + pack->src.blkpos);
memcpy(&pack->iobuffer[pack->iooffset], &volume->cache[volume->iooffset], xfrlen);
uint16_t xfrlen = MIN(srclen, destlen);
if (xfrlen > 0)
{
nxffs_ioseek(volume,
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.blkpos += xfrlen;
pack->dest.fpos += xfrlen; /* Destination data offsets */
pack->dest.blkpos += xfrlen;
pack->dest.blklen += xfrlen; /* Destination data block size */
pack->iooffset += xfrlen; /* Destination I/O block offset */
volume->iooffset += xfrlen; /* Source I/O block offset */
volume->froffset += xfrlen; /* Free FLASH offset */
}
pack->src.fpos += xfrlen; /* Source data offsets */
pack->src.blkpos += xfrlen;
pack->dest.fpos += xfrlen; /* Destination data offsets */
pack->dest.blkpos += xfrlen;
pack->dest.blklen += xfrlen; /* Destination data block size */
pack->iooffset += xfrlen; /* Destination I/O block offset */
volume->iooffset += xfrlen; /* Source I/O block 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)
{
/* Yes.. Write the destination data block header and return success */
if (pack->iooffset >= volume->geo.blocksize)
{
/* Yes.. Write the destination data block header and return success */
nxffs_wrdathdr(volume, pack);
return OK;
}
nxffs_wrdathdr(volume, pack);
return OK;
}
}
return -ENOSYS;
@@ -1094,15 +1100,16 @@ nxffs_setupwriter(FAR struct nxffs_volume_s *volume,
{
/* Initialize for the packing operation. */
memset(&pack->dest, 0, sizeof(struct nxffs_packstream_s));
pack->dest.entry.name = strdup(wrfile->ofile.entry.name);
pack->dest.entry.utc = wrfile->ofile.entry.utc;
pack->dest.entry.datlen = wrfile->ofile.entry.datlen;
memset(&pack->dest, 0, sizeof(struct nxffs_packstream_s));
pack->dest.entry.name = strdup(wrfile->ofile.entry.name);
pack->dest.entry.utc = wrfile->ofile.entry.utc;
pack->dest.entry.datlen = wrfile->ofile.entry.datlen;
memset(&pack->src, 0, sizeof(struct nxffs_packstream_s));
memcpy(&pack->src.entry, &wrfile->ofile.entry, sizeof(struct nxffs_entry_s));
pack->src.entry.name = NULL;
return wrfile;
memset(&pack->src, 0, sizeof(struct nxffs_packstream_s));
memcpy(&pack->src.entry, &wrfile->ofile.entry,
sizeof(struct nxffs_entry_s));
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)
{
/* Yes.. Write the destination data block header and return success */
if (pack->iooffset >= volume->geo.blocksize)
{
/* Yes.. Write the destination data block header and return success */
nxffs_wrdathdr(volume, pack);
return OK;
}
nxffs_wrdathdr(volume, pack);
return OK;
}
}
return -ENOSYS;
+6 -3
View File
@@ -221,7 +221,8 @@ static int nxffs_badblocks(FAR struct nxffs_volume_s *volume)
else
{
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);
}
@@ -241,10 +242,12 @@ static int nxffs_badblocks(FAR struct nxffs_volume_s *volume)
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)
{
ferr("ERROR: Write erase block %d failed: %d\n", lblock, nxfrd);
ferr("ERROR: Write erase block %d failed: %d\n",
lblock, nxfrd);
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_bsize = volume->geo.blocksize;
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;
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 */
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_size = entry.datlen;
buf->st_atime = entry.utc;
@@ -193,7 +195,6 @@ errout:
int nxffs_fstat(FAR const struct file *filep, FAR struct stat *buf)
{
FAR struct nxffs_volume_s *volume;
FAR struct nxffs_ofile_s *ofile;
int ret;
+1
View File
@@ -158,6 +158,7 @@ size_t nxffs_erased(FAR const uint8_t *buffer, size_t buflen)
{
break;
}
buffer++;
}
+10 -8
View File
@@ -899,15 +899,15 @@ int nxffs_wrverify(FAR struct nxffs_volume_s *volume, size_t 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 =
volume->ioblock * volume->geo.blocksize + iooffset;
off_t offset =
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;
return OK;
volume->froffset = offset + size;
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->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
@@ -983,7 +984,8 @@ int nxffs_wrblkhdr(FAR struct nxffs_volume_s *volume,
/* 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);
/* 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;
}
/* 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,
len) == 0)
@@ -863,7 +863,7 @@ static int procfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
#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)
{
+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
*/
static const char* g_iob_user_names[] =
static FAR const char *g_iob_user_names[] =
{
#ifdef CONFIG_SYSLOG_BUFFER
"syslog",
+48 -27
View File
@@ -440,16 +440,20 @@ static FAR const struct proc_node_s *proc_findnode(FAR const char *relpath)
*
* 111111111122222222223
* 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}
* PPID: xxxxx Parent thread ID
* Group: xxxxx Group ID
* CPU: xxx CPU (CONFIG_SMP only)
* State: xxxxxxxx,xxxxxxxxx {Invalid, Waiting, Ready, Running, Inactive},
* {Unlock, Semaphore, Signal, MQ empty, MQ full}
* State: xxxxxxxx,xxxxxxxxx {Invalid, Waiting, Ready, Running,
* Inactive},
* {Unlock, Semaphore, Signal, MQ empty,
* MQ full}
* Flags: xxx N,P,X
* 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
*
****************************************************************************/
@@ -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;
linesize = snprintf(procfile->line, STATUS_LINELEN, " 0x%p\n", ptcb->arg);
copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset);
linesize = snprintf(procfile->line, STATUS_LINELEN, " 0x%p\n",
ptcb->arg);
copysize = procfs_memcpy(procfile->line, linesize, buffer,
remaining, &offset);
totalsize += 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++)
{
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;
buffer += copysize;
@@ -711,7 +718,8 @@ static ssize_t proc_cmdline(FAR struct proc_file_s *procfile,
}
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;
return totalsize;
@@ -931,7 +939,8 @@ static ssize_t proc_groupstatus(FAR struct proc_file_s *procfile,
#ifdef HAVE_GROUP_MEMBERS
linesize = snprintf(procfile->line, STATUS_LINELEN, "%-12s%d\n",
"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;
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",
"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;
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)
linesize = snprintf(procfile->line, STATUS_LINELEN, "%-12s%d\n",
"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;
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",
"Flags:", group->tg_flags);
copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset);
copysize = procfs_memcpy(procfile->line, linesize, buffer,
remaining, &offset);
totalsize += 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",
"Members:", group->tg_nmembers);
copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset);
copysize = procfs_memcpy(procfile->line, linesize, buffer,
remaining, &offset);
totalsize += 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:");
copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset);
copysize = procfs_memcpy(procfile->line, linesize, buffer,
remaining, &offset);
totalsize += 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++)
{
linesize = snprintf(procfile->line, STATUS_LINELEN, " %d", group->tg_members[i]);
copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset);
linesize = snprintf(procfile->line, STATUS_LINELEN, " %d",
group->tg_members[i]);
copysize = procfs_memcpy(procfile->line, linesize, buffer,
remaining, &offset);
totalsize += copysize;
buffer += copysize;
@@ -1083,9 +1099,11 @@ static ssize_t proc_groupfd(FAR struct proc_file_s *procfile,
if (file->f_inode)
{
linesize = snprintf(procfile->line, STATUS_LINELEN, "%3d %8ld %04x\n",
i, (long)file->f_pos, file->f_oflags);
copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset);
linesize = snprintf(procfile->line, STATUS_LINELEN,
"%3d %8ld %04x\n", i, (long)file->f_pos,
file->f_oflags);
copysize = procfs_memcpy(procfile->line, linesize, buffer,
remaining, &offset);
totalsize += copysize;
buffer += copysize;
@@ -1122,10 +1140,13 @@ static ssize_t proc_groupfd(FAR struct proc_file_s *procfile,
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,
socket->s_crefs, socket->s_type, socket->s_flags);
copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset);
socket->s_crefs, socket->s_type,
socket->s_flags);
copysize = procfs_memcpy(procfile->line, linesize, buffer,
remaining, &offset);
totalsize += 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);
return -ENOENT;
}
}
/* A valid PID would be in the range of 0-32767 (0 is reserved for the
* 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->pid = pid;
dir->u.procfs = (FAR void *)procdir;
return OK;
procdir->pid = pid;
dir->u.procfs = (FAR void *)procdir;
return OK;
}
/****************************************************************************
@@ -1787,7 +1808,7 @@ static int proc_stat(const char *relpath, struct stat *buf)
{
ferr("ERROR: Invalid path \"%s\"\n", relpath);
return -ENOENT;
}
}
/* A valid PID would be in the range of 0-32767 (0 is reserved for the
* IDLE thread).
+1 -1
View File
@@ -1077,7 +1077,7 @@ static int romfs_unbind(FAR void *handle, FAR struct inode **blkdriver,
}
else
{
/* Unmount ... close the block driver */
/* Unmount ... close the block driver */
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);
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);
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 */
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)
{
nxsem_post(&rm->rm_sem);
nxsem_post(&rm->rm_sem);
}
/****************************************************************************
@@ -786,9 +786,9 @@ int romfs_finddirentry(struct romfs_mountpt_s *rm,
if (!terminator)
{
/* Yes.. return success */
/* Yes.. return success */
return OK;
return OK;
}
/* 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.
*/
next = romfs_devread32(rm, ndx + ROMFS_FHDR_NEXT);
next = romfs_devread32(rm, ndx + ROMFS_FHDR_NEXT);
*pnext = (save & RFNEXT_OFFSETMASK) | (next & RFNEXT_ALLMODEMASK);
*pinfo = romfs_devread32(rm, ndx + ROMFS_FHDR_INFO);
*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
{
utilization = 100 * (procfs_data.blockerases * procfs_data.sectorsperblk -
procfs_data.unusedsectors) / (procfs_data.blockerases *
procfs_data.sectorsperblk);
utilization = 100 * (procfs_data.blockerases *
procfs_data.sectorsperblk -
procfs_data.unusedsectors) /
(procfs_data.blockerases *
procfs_data.sectorsperblk);
}
/* 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 */
priv->offset = 0xFF;
priv->offset = 0xff;
}
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 */
priv->offset = 0xFF;
priv->offset = 0xff;
}
return len;
@@ -995,8 +997,11 @@ static size_t smartfs_erasemap_read(FAR struct file *filep, FAR char *buffer,
priv->offset++;
if (len >= buflen)
return len;
{
return len;
}
}
copylen++;
}
@@ -1007,7 +1012,9 @@ static size_t smartfs_erasemap_read(FAR struct file *filep, FAR char *buffer,
buffer[len++] = '\n';
priv->offset++;
if (len >= buflen)
return len;
{
return len;
}
}
/* 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 */
if (parentdirsector != 0xFFFF)
if (parentdirsector != 0xffff)
{
/* We can create in the given parent directory */
ret = smartfs_createentry(fs, parentdirsector, filename,
SMARTFS_DIRENT_TYPE_FILE, mode,
&sf->entry, 0xFFFF, sf);
&sf->entry, 0xffff, sf);
if (ret != OK)
{
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 */
ret = FS_IOCTL(fs, BIOC_ALLOCSECT, 0xFFFF);
ret = FS_IOCTL(fs, BIOC_ALLOCSECT, 0xffff);
if (ret < 0)
{
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 */
ret = FS_IOCTL(fs, BIOC_ALLOCSECT, 0xFFFF);
ret = FS_IOCTL(fs, BIOC_ALLOCSECT, 0xffff);
if (ret < 0)
{
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:
/* Relinquish exclusive access */
smartfs_semgive(fs);
@@ -1201,6 +1202,7 @@ static int smartfs_opendir(FAR struct inode *mountpt, FAR const char *relpath,
ret = OK;
errout_with_semaphore:
/* If space for the entry name was allocated, then free it */
if (entry.name != NULL)
@@ -1482,7 +1484,7 @@ static int smartfs_unbind(FAR void *handle, FAR struct inode **blkdriver,
}
else
{
/* Unmount ... close the block driver */
/* Unmount ... close the block driver */
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. */
smartfs_deleteentry(fs, &entry);
}
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.
*/
if (parentdirsector == 0xFFFF)
if (parentdirsector == 0xffff)
{
/* 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 */
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)
{
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 */
if (newparentdirsector != 0xFFFF)
if (newparentdirsector != 0xffff)
{
/* 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];
#if CONFIG_SMARTFS_ERASEDSTATE == 0xFF
#if CONFIG_SMARTFS_ERASEDSTATE == 0xff
direntry->flags &= ~SMARTFS_DIRENT_ACTIVE;
#else
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)
{
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 */
fs->fs_rwbuffer = (char *) 0xDEADBEEF;
fs->fs_workbuffer = (char *) 0xDEADBEEF;
fs->fs_rwbuffer = (char *) 0xdeadbeef;
fs->fs_workbuffer = (char *) 0xdeadbeef;
}
/* Now removed ourselves from the linked list */
@@ -584,10 +584,10 @@ int smartfs_finddirentry(struct smartfs_mountpt_s *fs,
/* Read the directory */
offset = 0xFFFF;
offset = 0xffff;
#if CONFIG_SMARTFS_ERASEDSTATE == 0xFF
while (dirsector != 0xFFFF)
#if CONFIG_SMARTFS_ERASEDSTATE == 0xff
while (dirsector != 0xffff)
#else
while (dirsector != 0)
#endif
@@ -673,12 +673,14 @@ int smartfs_finddirentry(struct smartfs_mountpt_s *fs,
kmm_malloc(fs->fs_llformat.namesize + 1);
}
memset(direntry->name, 0, fs->fs_llformat.namesize + 1);
strncpy(direntry->name, entry->name, fs->fs_llformat.namesize);
memset(direntry->name, 0,
fs->fs_llformat.namesize + 1);
strncpy(direntry->name, entry->name,
fs->fs_llformat.namesize);
direntry->datlen = 0;
/* Scan the file's sectors to calculate the length and perform
* a rudimentary check.
/* Scan the file's sectors to calculate the length and
* perform a rudimentary check.
*/
#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 */
if (*((uint16_t *)header->used) != SMARTFS_ERASEDSTATE_16BIT)
if (*((FAR uint16_t *)header->used) !=
SMARTFS_ERASEDSTATE_16BIT)
{
direntry->datlen += *((uint16_t *)header->used);
}
@@ -738,10 +741,10 @@ int smartfs_finddirentry(struct smartfs_mountpt_s *fs,
SMARTFS_DIRENT_TYPE_DIR)
#endif
{
/* Not a directory! Report the error */
/* Not a directory! Report the error */
ret = -ENOTDIR;
goto errout;
ret = -ENOTDIR;
goto errout;
}
/* "Push" the directory and continue searching */
@@ -805,7 +808,7 @@ int smartfs_finddirentry(struct smartfs_mountpt_s *fs,
}
else
{
*parentdirsector = 0xFFFF;
*parentdirsector = 0xffff;
*filename = NULL;
}
@@ -823,7 +826,7 @@ errout:
*
* Description: Creates a new entry in the specified parent directory, using
* 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.
*
****************************************************************************/
@@ -927,7 +930,7 @@ int smartfs_createentry(FAR struct smartfs_mountpt_s *fs,
{
/* 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)
{
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 */
#if CONFIG_SMARTFS_ERASEDSTATE == 0xFF
#if CONFIG_SMARTFS_ERASEDSTATE == 0xff
#ifdef CONFIG_SMARTFS_ALIGNED_ACCESS
smartfs_wrle16(&entry->flags, (uint16_t) (SMARTFS_DIRENT_ACTIVE |
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_MODE));
#endif
#else /* CONFIG_SMARTFS_ERASEDSTATE == 0xFF */
#else /* CONFIG_SMARTFS_ERASEDSTATE == 0xff */
#ifdef CONFIG_SMARTFS_ALIGNED_ACCESS
smartfs_wrle16(&entry->flags, (uint16_t) (SMARTFS_DIRENT_EMPTY | type |
(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 |
(mode & SMARTFS_DIRENT_MODE));
#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 */
ret = FS_IOCTL(fs, BIOC_ALLOCSECT, 0xFFFF);
ret = FS_IOCTL(fs, BIOC_ALLOCSECT, 0xffff);
if (ret < 0)
{
goto errout;
@@ -1164,19 +1167,21 @@ int smartfs_deleteentry(struct smartfs_mountpt_s *fs,
/* Mark this entry as inactive */
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
smartfs_wrle16(&direntry->flags, smartfs_rdle16(&direntry->flags) & ~SMARTFS_DIRENT_ACTIVE);
smartfs_wrle16(&direntry->flags,
smartfs_rdle16(&direntry->flags) & ~SMARTFS_DIRENT_ACTIVE);
#else
direntry->flags &= ~SMARTFS_DIRENT_ACTIVE;
#endif
#else /* CONFIG_SMARTFS_ERASEDSTATE == 0xFF */
#else /* CONFIG_SMARTFS_ERASEDSTATE == 0xff */
#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
direntry->flags |= SMARTFS_DIRENT_ACTIVE;
#endif
#endif /* CONFIG_SMARTFS_ERASEDSTATE == 0xFF */
#endif /* CONFIG_SMARTFS_ERASEDSTATE == 0xff */
/* 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. */
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.buffer = header->nextsector;
@@ -1976,7 +1982,7 @@ int smartfs_extendfile(FAR struct smartfs_mountpt_s *fs,
{
/* First get a new chained sector */
ret = FS_IOCTL(fs, BIOC_ALLOCSECT, 0xFFFF);
ret = FS_IOCTL(fs, BIOC_ALLOCSECT, 0xffff);
if (ret < 0)
{
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 */
ret = FS_IOCTL(fs, BIOC_ALLOCSECT, 0xFFFF);
ret = FS_IOCTL(fs, BIOC_ALLOCSECT, 0xffff);
if (ret < 0)
{
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)
{
#ifdef CONFIG_DEBUG_FS_INFO
FAR static const char *evname[] =
{
FAR static const char *evname[] =
{
"UPD", "NEW", "DEL", "MOV", "HUP", "???"
};
};
#endif
FAR struct spiffs_file_s *fobj;
@@ -1581,7 +1581,8 @@ void spiffs_fobj_event(FAR struct spiffs_s *fs,
if (fobj->cache_page &&
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);
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)
{
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);
spiffs_cache_page_release(fs, fobj->cache_page);
@@ -1781,12 +1783,13 @@ ssize_t spiffs_fobj_append(FAR struct spiffs_s *fs,
return ret;
}
ret = spiffs_cache_write(fs,
SPIFFS_OP_T_OBJNDX | SPIFFS_OP_C_UPDT,
fobj->objid,
SPIFFS_PAGE_TO_PADDR(fs, cur_objndx_pgndx),
SPIFFS_GEO_PAGE_SIZE(fs),
fs->work);
ret =
spiffs_cache_write(fs,
SPIFFS_OP_T_OBJNDX | SPIFFS_OP_C_UPDT,
fobj->objid,
SPIFFS_PAGE_TO_PADDR(fs, cur_objndx_pgndx),
SPIFFS_GEO_PAGE_SIZE(fs),
fs->work);
if (ret < 0)
{
ferr("ERROR: spiffs_cache_write() failed: %d\n",
@@ -1951,10 +1954,11 @@ ssize_t spiffs_fobj_append(FAR struct spiffs_s *fs,
}
else
{
ret = spiffs_objlu_find_id_and_span(fs,
fobj->objid | SPIFFS_OBJID_NDXFLAG,
cur_objndx_spndx, 0,
&pgndx);
ret =
spiffs_objlu_find_id_and_span(fs,
fobj->objid | SPIFFS_OBJID_NDXFLAG,
cur_objndx_spndx, 0,
&pgndx);
if (ret < 0)
{
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,
&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);
if (ret < 0)
@@ -2390,10 +2395,11 @@ ssize_t spiffs_fobj_modify(FAR struct spiffs_s *fs,
}
else
{
ret = spiffs_objlu_find_id_and_span(fs,
fobj->objid | SPIFFS_OBJID_NDXFLAG,
cur_objndx_spndx, 0,
&pgndx);
ret =
spiffs_objlu_find_id_and_span(fs,
fobj->objid | SPIFFS_OBJID_NDXFLAG,
cur_objndx_spndx, 0,
&pgndx);
if (ret < 0)
{
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 */
ret = spiffs_phys_cpy(fs, fobj->objid,
SPIFFS_PAGE_TO_PADDR(fs, data_pgndx) +
sizeof(struct spiffs_page_header_s) + page_offs +
to_write,
SPIFFS_PAGE_TO_PADDR(fs, orig_data_pgndx)
+ sizeof(struct spiffs_page_header_s) + page_offs +
to_write,
SPIFFS_DATA_PAGE_SIZE(fs) -
(page_offs + to_write));
ret =
spiffs_phys_cpy(fs, fobj->objid,
SPIFFS_PAGE_TO_PADDR(fs, data_pgndx) +
sizeof(struct spiffs_page_header_s) + page_offs +
to_write,
SPIFFS_PAGE_TO_PADDR(fs, orig_data_pgndx)
+ sizeof(struct spiffs_page_header_s) + page_offs +
to_write,
SPIFFS_DATA_PAGE_SIZE(fs) -
(page_offs + to_write));
if (ret < 0)
{
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;
uint32_t bytes_to_remove;
/* Delete last page, partially */
/* Delete last page, partially */
bytes_to_remove =
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);
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
{
ret = spiffs_objlu_find_id_and_span(fs,
fobj->objid | SPIFFS_OBJID_NDXFLAG,
cur_objndx_spndx, 0,
&objndx_pgndx);
ret =
spiffs_objlu_find_id_and_span(fs,
fobj->objid | SPIFFS_OBJID_NDXFLAG,
cur_objndx_spndx, 0,
&objndx_pgndx);
if (ret < 0)
{
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;
}
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,
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,
SPIFFS_ERASE_COUNT_PADDR(fs, cur_block),
sizeof(int16_t), (uint8_t *) & erase_count);
if (ret < 0)
{
ferr("ERROR: spiffs_cache_read() failed: %d\n", ret);
return ret;
}
if (ret < 0)
{
ferr("ERROR: spiffs_cache_read() failed: %d\n", ret);
return ret;
}
/* Calculate the erase age */
/* Calculate the erase age */
if (fs->max_erase_count > erase_count)
{
erase_age = fs->max_erase_count - erase_count;
}
else
{
erase_age =
SPIFFS_OBJID_FREE - (erase_count - fs->max_erase_count);
}
if (fs->max_erase_count > erase_count)
{
erase_age = fs->max_erase_count - erase_count;
}
else
{
erase_age =
SPIFFS_OBJID_FREE - (erase_count - fs->max_erase_count);
}
score =
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)
{
case FIND_OBJ_DATA:
/* Find a data page. */
if (id != SPIFFS_OBJID_DELETED &&
@@ -540,6 +541,7 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
break;
case MOVE_OBJ_DATA:
/* Evacuate found data pages for corresponding object index
* 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 */
ret = spiffs_cache_read(fs,
SPIFFS_OP_T_OBJ_LU | SPIFFS_OP_C_READ,
0,
blkndx * SPIFFS_GEO_BLOCK_SIZE(fs) +
SPIFFS_PAGE_TO_PADDR(fs, obj_lookup_page),
SPIFFS_GEO_PAGE_SIZE(fs),
fs->lu_work);
ret =
spiffs_cache_read(fs,
SPIFFS_OP_T_OBJ_LU | SPIFFS_OP_C_READ,
0,
blkndx * SPIFFS_GEO_BLOCK_SIZE(fs) +
SPIFFS_PAGE_TO_PADDR(fs, obj_lookup_page),
SPIFFS_GEO_PAGE_SIZE(fs),
fs->lu_work);
if (ret < 0)
{
ferr("ERROR: spiffs_cache_read() failed: %d\n", ret);
ferr("ERROR: spiffs_cache_read() failed: %d\n",
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);
if (ret < 0)
{
ferr("ERROR: spiffs_page_delete() failed: %d\n", ret);
ferr("ERROR: spiffs_page_delete() failed: %d\n",
ret);
return ret;
}
@@ -656,6 +661,7 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
break;
case MOVE_OBJ_NDX:
/* Find and evacuate object index pages */
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 */
ret = spiffs_cache_read(fs,
SPIFFS_OP_T_OBJ_LU | SPIFFS_OP_C_READ,
0,
blkndx * SPIFFS_GEO_BLOCK_SIZE(fs) +
SPIFFS_PAGE_TO_PADDR(fs, obj_lookup_page),
SPIFFS_GEO_PAGE_SIZE(fs), fs->lu_work);
ret =
spiffs_cache_read(fs,
SPIFFS_OP_T_OBJ_LU | SPIFFS_OP_C_READ,
0,
blkndx * SPIFFS_GEO_BLOCK_SIZE(fs) +
SPIFFS_PAGE_TO_PADDR(fs, obj_lookup_page),
SPIFFS_GEO_PAGE_SIZE(fs), fs->lu_work);
if (ret < 0)
{
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;
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,
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");
break;
}
}
while (++tries < CONFIG_SPIFFS_GC_MAXRUNS &&
(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 ||
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
* 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->offset, fobj->cache_page->size);
nwritten = spiffs_fobj_write(fs, fobj,
spiffs_get_cache_page(fs, spiffs_get_cache(fs),
fobj->cache_page->cpndx),
fobj->cache_page->offset,
fobj->cache_page->size);
nwritten =
spiffs_fobj_write(fs, fobj,
spiffs_get_cache_page(fs, spiffs_get_cache(fs),
fobj->cache_page->cpndx),
fobj->cache_page->offset,
fobj->cache_page->size);
spiffs_cache_page_release(fs, fobj->cache_page);
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;
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,
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);
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;
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 success_with_lock;
goto success_with_lock;
}
}
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->offset, fobj->cache_page->size);
nwritten = spiffs_fobj_write(fs, fobj,
spiffs_get_cache_page(fs,
spiffs_get_cache(fs),
fobj->cache_page->cpndx),
fobj->cache_page->offset,
fobj->cache_page->size);
nwritten =
spiffs_fobj_write(fs, fobj,
spiffs_get_cache_page(fs,
spiffs_get_cache(fs),
fobj->cache_page->cpndx),
fobj->cache_page->offset,
fobj->cache_page->size);
spiffs_cache_page_release(fs, fobj->cache_page);
if (nwritten < 0)
@@ -813,6 +818,7 @@ static ssize_t spiffs_write(FAR struct file *filep, FAR const char *buffer,
}
success_with_lock:
/* Update the file position */
filep->f_pos += nwritten;
@@ -1042,6 +1048,7 @@ static int spiffs_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
#endif
default:
/* Pass through to the contained MTD driver */
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);
}
/* Free allocated working buffers */
/* Free allocated working buffers */
if (fs->work != NULL)
{
@@ -1541,7 +1548,7 @@ static int spiffs_unbind(FAR void *handle, FAR struct inode **mtdinode,
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);
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);
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;
+11 -8
View File
@@ -755,7 +755,7 @@ static int tmpfs_create_file(FAR struct tmpfs_s *fs,
*tfo = newtfo;
return OK;
/* Error exits */
/* Error exits */
errout_with_file:
nxsem_destroy(&newtfo->tfo_exclsem.ts_sem);
@@ -917,7 +917,7 @@ static int tmpfs_create_directory(FAR struct tmpfs_s *fs,
return OK;
/* Error exits */
/* Error exits */
errout_with_directory:
nxsem_destroy(&newtdo->tdo_exclsem.ts_sem);
@@ -1330,6 +1330,7 @@ static int tmpfs_foreach(FAR struct tmpfs_directory_s *tdo,
switch (ret)
{
case TMPFS_CONTINUE: /* Continue enumeration */
/* Release the object and index to the next entry */
tmpfs_release_lockedobject(to);
@@ -1337,12 +1338,14 @@ static int tmpfs_foreach(FAR struct tmpfs_directory_s *tdo,
break;
case TMPFS_HALT: /* Stop enumeration */
/* Release the object and cancel the traversal */
tmpfs_release_lockedobject(to);
return -ECANCELED;
case TMPFS_UNLINKED: /* Only the directory entry was deleted */
/* Release the object and continue with the same index */
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)
{
/* No.. then we fail with -ENOENT */
/* No.. then we fail with -ENOENT */
ret = -ENOENT;
goto errout_with_fslock;
}
ret = -ENOENT;
goto errout_with_fslock;
}
/* Yes.. create the file object. There will be a reference and a lock
* 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;
}
}
}
/* 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);
if (ret < 0)
{
goto errout_with_newparent;
goto errout_with_newparent;
}
/* 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;
/* 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);
if (relpath)
@@ -1849,7 +1851,7 @@ static int unionfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
}
return OK;
}
}
/* 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,
&mpinode->i_private);
if (ret < 0)
{
goto errout_with_mountpt;
}
{
goto errout_with_mountpt;
}
inode_semgive();
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);
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)
+47 -39
View File
@@ -125,12 +125,13 @@ int file_vfcntl(FAR struct file *filep, int cmd, va_list ap)
break;
case F_GETFL:
/* Get the file status flags and file access modes, defined in <fcntl.h>,
* for the file description associated with fd. The file access modes
* can be extracted from the return value using the mask O_ACCMODE, which is
* defined in <fcntl.h>. File status flags and file access modes are associated
* with the file description and do not affect other file descriptors that
* refer to the same file with different open file descriptions.
/* Get the file status flags and file access modes, defined in
* <fcntl.h>, for the file description associated with fd. The file
* access modes can be extracted from the return value using the
* mask O_ACCMODE, which is defined in <fcntl.h>. File status flags
* and file access modes are associated with the file description
* 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;
case F_SETFL:
/* Set the file status flags, defined in <fcntl.h>, for the file description
* associated with fd from the corresponding bits in the third argument,
* arg, taken as type int. Bits corresponding to the file access mode and
* the file creation flags, as defined in <fcntl.h>, that are set in arg shall
* be ignored. If any bits in arg other than those mentioned here are changed
* by the application, the result is unspecified.
/* Set the file status flags, defined in <fcntl.h>, for the file
* description associated with fd from the corresponding bits in
* the third argument, arg, taken as type int. Bits corresponding
* to the file access mode and the file creation flags, as defined
* in <fcntl.h>, that are set in arg shall be ignored. If any bits
* 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;
case F_GETOWN:
/* If fd refers to a socket, get the process or process group ID specified
* to receive SIGURG signals when out-of-band data is available. Positive values
* indicate a process ID; negative values, other than -1, indicate a process group
* ID. If fd does not refer to a socket, the results are unspecified.
/* If fd refers to a socket, get the process or process group ID
* specified to receive SIGURG signals when out-of-band data is
* available. Positive values indicate a process ID; negative
* values, other than -1, indicate a process group ID. If fd does
* not refer to a socket, the results are unspecified.
*/
case F_SETOWN:
/* If fd refers to a socket, set the process or process group ID specified
* to receive SIGURG signals when out-of-band data is available, using the value
* of the third argument, arg, taken as type int. Positive values indicate a
* process ID; negative values, other than -1, indicate a process group ID. If
* fd does not refer to a socket, the results are unspecified.
/* If fd refers to a socket, set the process or process group ID
* specified to receive SIGURG signals when out-of-band data is
* available, using the value of the third argument, arg, taken as
* type int. Positive values indicate a process ID; negative values,
* 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 */
break;
case F_GETLK:
/* Get the first lock which blocks the lock description pointed to by the third
* argument, arg, taken as a pointer to type struct flock, defined in <fcntl.h>.
* The information retrieved shall overwrite the information passed to fcntl() in
* the structure flock. If no lock is found that would prevent this lock from being
* created, then the structure shall be left unchanged except for the lock type
* which shall be set to F_UNLCK.
/* Get the first lock which blocks the lock description pointed to
* by the third argument, arg, taken as a pointer to type struct
* flock, defined in <fcntl.h>. The information retrieved shall
* overwrite the information passed to fcntl() in the structure
* flock. If no lock is found that would prevent this lock from
* being created, then the structure shall be left unchanged except
* for the lock type which shall be set to F_UNLCK.
*/
case F_SETLK:
/* Set or clear a file segment lock according to the lock description pointed to
* by the third argument, arg, taken as a pointer to type struct flock, defined in
* <fcntl.h>. F_SETLK can establish shared (or read) locks (F_RDLCK) or exclusive
* (or write) locks (F_WRLCK), as well as to remove either type of lock (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.
/* Set or clear a file segment lock according to the lock
* description pointed to by the third argument, arg, taken as a
* pointer to type struct flock, defined in <fcntl.h>. F_SETLK can
* establish shared (or read) locks (F_RDLCK) or exclusive (or
* write) locks (F_WRLCK), as well as to remove either type of lock
* (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:
/* This command shall be equivalent to F_SETLK except that if a shared or exclusive
* lock is blocked by other locks, the thread shall wait until the request can be
* satisfied. If a signal that is to be caught is received while fcntl() is waiting
* for a region, fcntl() shall be interrupted. Upon return from the signal handler,
* fcntl() shall return -1 with errno set to [EINTR], and the lock operation shall
* not be done.
/* This command shall be equivalent to F_SETLK except that if a
* shared or exclusive lock is blocked by other locks, the thread
* shall wait until the request can be satisfied. If a signal that
* is to be caught is received while fcntl() is waiting for a
* region, fcntl() shall be interrupted. Upon return from the signal
* handler, fcntl() shall return -1 with errno set to [EINTR], and
* the lock operation shall not be done.
*/
ret = -ENOSYS; /* Not implemented */
+1 -1
View File
@@ -185,7 +185,7 @@ off_t lseek(int fd, off_t offset, int whence)
goto errout;
}
return newpos;
return newpos;
errout:
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.
*/
if (INODE_IS_BLOCK(inode) || INODE_IS_MTD(inode))
{
/* Release the inode reference */
if (INODE_IS_BLOCK(inode) || INODE_IS_MTD(inode))
{
/* 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);
if (fd < 0)
{
ret = fd;
goto errout_with_search;
}
fd = block_proxy(path, oflags);
if (fd < 0)
{
ret = fd;
goto errout_with_search;
}
/* Return the file descriptor */
/* Return the file descriptor */
RELEASE_SEARCH(&desc);
return fd;
}
else
RELEASE_SEARCH(&desc);
return fd;
}
else
#endif
/* 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.
*/
ret = nxsem_tickwait(&sem, clock_systimer(), ticks);
if (ret < 0)
{
if (ret == -ETIMEDOUT)
{
/* Return zero (OK) in the event of a timeout */
ret = nxsem_tickwait(&sem, clock_systimer(), ticks);
if (ret < 0)
{
if (ret == -ETIMEDOUT)
{
/* 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
{
+1
View File
@@ -160,6 +160,7 @@ next_subdir:
goto errout;
}
#endif
/* 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)?
*/
+3 -3
View File
@@ -174,7 +174,7 @@ int stat_recursive(FAR const char *path, FAR struct stat *buf)
RELEASE_SEARCH(&desc);
return OK;
/* Failure conditions always set the errno appropriately */
/* Failure conditions always set the errno appropriately */
errout_with_inode:
inode_release(inode);
@@ -290,14 +290,14 @@ int inode_stat(FAR struct inode *inode, FAR struct stat *buf)
else
#endif
#if defined(CONFIG_FS_SHM)
if (INODE_IS_SHM(inode))
if (INODE_IS_SHM(inode))
{
buf->st_mode = S_IFSHM;
}
else
#endif
#if defined(CONFIG_MTD)
if (INODE_IS_MTD(inode))
if (INODE_IS_MTD(inode))
{
buf->st_mode = S_IFMTD;
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);
return OK;
/* Failure conditions always set the errno appropriately */
/* Failure conditions always set the errno appropriately */
errout_with_inode:
inode_release(inode);