fs: move memset to upper lever for statfs

if struct statfs add new members, such as f_fsid, no additional code
changes are required.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
zhanghongyu 2023-06-06 11:59:14 +08:00 committed by Xiang Xiao
parent f80539b6a8
commit b723e90356
15 changed files with 6 additions and 13 deletions

View File

@ -449,7 +449,6 @@ static int binfs_statfs(struct inode *mountpt, struct statfs *buf)
/* Fill in the statfs info */
memset(buf, 0, sizeof(struct statfs));
buf->f_type = BINFS_MAGIC;
buf->f_bsize = 0;
buf->f_blocks = 0;

View File

@ -1467,7 +1467,6 @@ static int cromfs_statfs(struct inode *mountpt, struct statfs *buf)
/* Fill in the statfs info. */
memset(buf, 0, sizeof(struct statfs));
buf->f_type = CROMFS_MAGIC;
buf->f_namelen = NAME_MAX;
buf->f_bsize = fs->cv_bsize;

View File

@ -2333,7 +2333,6 @@ static int fat_statfs(FAR struct inode *mountpt, FAR struct statfs *buf)
/* Fill in the statfs info */
memset(buf, 0, sizeof(struct statfs));
buf->f_type = MSDOS_SUPER_MAGIC;
/* We will claim that the optimal transfer size is the size of a cluster

View File

@ -1161,7 +1161,6 @@ static int hostfs_statfs(FAR struct inode *mountpt, FAR struct statfs *buf)
/* Call the host fs to perform the statfs */
memset(buf, 0, sizeof(struct statfs));
ret = host_statfs(fs->fs_root, buf);
buf->f_type = HOSTFS_MAGIC;

View File

@ -1242,7 +1242,6 @@ static int littlefs_statfs(FAR struct inode *mountpt, FAR struct statfs *buf)
/* Return something for the file system description */
memset(buf, 0, sizeof(*buf));
buf->f_type = LITTLEFS_SUPER_MAGIC;
buf->f_namelen = LFS_NAME_MAX;
buf->f_bsize = fs->cfg.block_size;

View File

@ -100,6 +100,7 @@ static int mountpoint_filter(FAR struct inode *node,
/* Get the status of the file system */
memset(&statbuf, 0, sizeof(struct statfs));
if (node->u.i_mops->statfs(node, &statbuf) == OK)
{
/* And pass the full path and file system status to the handler */

View File

@ -74,7 +74,6 @@ int nxffs_statfs(FAR struct inode *mountpt, FAR struct statfs *buf)
* REVISIT: Need f_bfree, f_bavail, f_files, f_ffree calculation
*/
memset(buf, 0, sizeof(struct statfs));
buf->f_type = NXFFS_MAGIC;
buf->f_bsize = volume->geo.blocksize;
buf->f_blocks = volume->nblocks;

View File

@ -1005,7 +1005,6 @@ static int procfs_statfs(FAR struct inode *mountpt, FAR struct statfs *buf)
{
/* Fill in the statfs info */
memset(buf, 0, sizeof(struct statfs));
buf->f_type = PROCFS_MAGIC;
buf->f_bsize = 0;
buf->f_blocks = 0;

View File

@ -1260,7 +1260,6 @@ static int romfs_statfs(FAR struct inode *mountpt, FAR struct statfs *buf)
/* Fill in the statfs info */
memset(buf, 0, sizeof(struct statfs));
buf->f_type = ROMFS_MAGIC;
/* We will claim that the optimal transfer size is the size of one sector */

View File

@ -1234,7 +1234,6 @@ static int rpmsgfs_statfs(FAR struct inode *mountpt, FAR struct statfs *buf)
/* Call the host fs to perform the statfs */
memset(buf, 0, sizeof(struct statfs));
ret = rpmsgfs_client_statfs(fs->handle, fs->fs_root, buf);
buf->f_type = RPMSGFS_MAGIC;

View File

@ -1610,7 +1610,6 @@ static int smartfs_statfs(FAR struct inode *mountpt, FAR struct statfs *buf)
/* Implement the logic!! */
memset(buf, 0, sizeof(struct statfs));
buf->f_type = SMARTFS_MAGIC;
/* Re-request the low-level format info to update free blocks */

View File

@ -2045,8 +2045,6 @@ static int unionfs_statfs(FAR struct inode *mountpt, FAR struct statfs *buf)
DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL && buf != NULL);
ui = (FAR struct unionfs_inode_s *)mountpt->i_private;
memset(buf, 0, sizeof(struct statfs));
/* Get statfs info from file system 1.
*
* REVISIT: What would it mean if one file system did not support statfs?
@ -2064,6 +2062,8 @@ static int unionfs_statfs(FAR struct inode *mountpt, FAR struct statfs *buf)
um2->um_node->u.i_mops != NULL);
ops2 = um2->um_node->u.i_mops;
memset(&buf1, 0, sizeof(struct statfs));
memset(&buf2, 0, sizeof(struct statfs));
if (ops1->statfs != NULL && ops2->statfs != NULL)
{
ret = ops1->statfs(um1->um_node, &buf1);

View File

@ -104,6 +104,7 @@ int fstatfs(int fd, FAR struct statfs *buf)
{
/* Perform the statfs() operation */
memset(buf, 0, sizeof(struct statfs));
ret = inode->u.i_mops->statfs(inode, buf);
}
}

View File

@ -43,7 +43,6 @@
static int statpseudofs(FAR struct inode *inode, FAR struct statfs *buf)
{
memset(buf, 0, sizeof(struct statfs));
buf->f_type = PROC_SUPER_MAGIC;
buf->f_namelen = NAME_MAX;
return OK;
@ -113,6 +112,7 @@ int statfs(FAR const char *path, FAR struct statfs *buf)
* are dealing with.
*/
memset(buf, 0, sizeof(struct statfs));
#ifndef CONFIG_DISABLE_MOUNTPOINT
if (INODE_IS_MOUNTPT(inode))
{

View File

@ -588,6 +588,7 @@ static inline int userfs_statfs_dispatch(FAR struct userfs_info_s *info,
/* Dispatch the request */
DEBUGASSERT(info->userops != NULL && info->userops->statfs != NULL);
memset(&resp.buf, 0, sizeof(struct statfs));
resp.ret = info->userops->statfs(info->volinfo, &resp.buf);
/* Send the response */