fs/vfs/fs_stat.c: fill file size for mtd inode

Now when stat() is calling for mtd device it also set size of file as number of bytes of all sectors related to this mtd device.
This commit is contained in:
Oleg 2020-05-25 19:22:15 +03:00 committed by patacongo
parent fefd893b65
commit dd9d9878ad
1 changed files with 10 additions and 0 deletions

View File

@ -46,6 +46,8 @@
#include <errno.h>
#include "inode/inode.h"
#include <nuttx/mtd/mtd.h>
#include <nuttx/fs/ioctl.h>
/****************************************************************************
* Pre-processor Definitions
@ -303,6 +305,14 @@ int inode_stat(FAR struct inode *inode, FAR struct stat *buf)
buf->st_mode = S_IFMTD;
buf->st_mode |= S_IROTH | S_IRGRP | S_IRUSR;
buf->st_mode |= S_IWOTH | S_IWGRP | S_IWUSR;
struct mtd_geometry_s mtdgeo;
if (inode->u.i_mtd
&& MTD_IOCTL(inode->u.i_mtd, MTDIOC_GEOMETRY,
(unsigned long)((uintptr_t)&mtdgeo)) >= 0)
{
buf->st_size = mtdgeo.neraseblocks * mtdgeo.erasesize;
}
}
else
#endif