fs/shmfs: Fix stat() system call for shmfs object
Set i_size for shmfs objects
This commit is contained in:
parent
07ce2f717a
commit
f0846e1d2d
@ -238,8 +238,13 @@ static int shmfs_truncate(FAR struct file *filep, off_t length)
|
|||||||
filep->f_inode->i_private = shmfs_alloc_object(length);
|
filep->f_inode->i_private = shmfs_alloc_object(length);
|
||||||
if (!filep->f_inode->i_private)
|
if (!filep->f_inode->i_private)
|
||||||
{
|
{
|
||||||
|
filep->f_inode->i_size = 0;
|
||||||
ret = -EFAULT;
|
ret = -EFAULT;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
filep->f_inode->i_size = length;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (object->length != length)
|
else if (object->length != length)
|
||||||
{
|
{
|
||||||
|
@ -284,6 +284,7 @@ int inode_stat(FAR struct inode *inode, FAR struct stat *buf, int resolve)
|
|||||||
if (INODE_IS_SHM(inode))
|
if (INODE_IS_SHM(inode))
|
||||||
{
|
{
|
||||||
buf->st_mode = S_IFSHM;
|
buf->st_mode = S_IFSHM;
|
||||||
|
buf->st_size = inode->i_size;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
@ -412,7 +412,7 @@ struct inode
|
|||||||
uint16_t i_flags; /* Flags for inode */
|
uint16_t i_flags; /* Flags for inode */
|
||||||
union inode_ops_u u; /* Inode operations */
|
union inode_ops_u u; /* Inode operations */
|
||||||
ino_t i_ino; /* Inode serial number */
|
ino_t i_ino; /* Inode serial number */
|
||||||
#ifdef CONFIG_PSEUDOFS_FILE
|
#if defined(CONFIG_PSEUDOFS_FILE) || defined(CONFIG_FS_SHMFS)
|
||||||
size_t i_size; /* The size of per inode driver */
|
size_t i_size; /* The size of per inode driver */
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_PSEUDOFS_ATTRIBUTES
|
#ifdef CONFIG_PSEUDOFS_ATTRIBUTES
|
||||||
|
Loading…
Reference in New Issue
Block a user