fs/pseudofile: config pseudofile feature
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit is contained in:
parent
8336ee78b8
commit
f8ce0cd4ca
|
@ -94,6 +94,13 @@ config PSEUDOFS_SOFTLINKS
|
|||
to link a directory in the pseudo-file system, such as /bin, to
|
||||
to a directory in a mounted volume, say /mnt/sdcard/bin.
|
||||
|
||||
config PSEUDOFS_FILE
|
||||
bool "Pseudo file support"
|
||||
default n
|
||||
depends on !DISABLE_PSEUDOFS_OPERATIONS
|
||||
---help---
|
||||
Support to create a file on pseudo filesystem.
|
||||
|
||||
config SENDFILE_BUFSIZE
|
||||
int "sendfile() buffer size"
|
||||
default 512
|
||||
|
|
|
@ -427,8 +427,10 @@ int dir_allocate(FAR struct file *filep, FAR const char *relpath);
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_PSEUDOFS_FILE
|
||||
int pseudofile_create(FAR struct inode **node, FAR const char *path,
|
||||
mode_t mode);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: inode_is_pseudofile
|
||||
|
@ -438,7 +440,9 @@ int pseudofile_create(FAR struct inode **node, FAR const char *path,
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_PSEUDOFS_FILE
|
||||
bool inode_is_pseudofile(FAR struct inode *inode);
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
|
|
|
@ -25,7 +25,7 @@ CSRCS += fs_fchstat.c fs_fstat.c fs_fstatfs.c fs_ioctl.c fs_lseek.c
|
|||
CSRCS += fs_mkdir.c fs_open.c fs_poll.c fs_pread.c fs_pwrite.c fs_read.c
|
||||
CSRCS += fs_rename.c fs_rmdir.c fs_select.c fs_sendfile.c fs_stat.c
|
||||
CSRCS += fs_statfs.c fs_unlink.c fs_write.c fs_dir.c fs_fsync.c
|
||||
CSRCS += fs_truncate.c fs_pseudofile.c
|
||||
CSRCS += fs_truncate.c
|
||||
|
||||
# Certain interfaces are not available if there is no mountpoint support
|
||||
|
||||
|
@ -33,6 +33,12 @@ ifneq ($(CONFIG_PSEUDOFS_SOFTLINKS),0)
|
|||
CSRCS += fs_link.c fs_symlink.c fs_readlink.c
|
||||
endif
|
||||
|
||||
# Pseudofile support
|
||||
|
||||
ifeq ($(CONFIG_PSEUDOFS_FILE),y)
|
||||
CSRCS += fs_pseudofile.c
|
||||
endif
|
||||
|
||||
# Stream support
|
||||
|
||||
ifeq ($(CONFIG_FILE_STREAM),y)
|
||||
|
|
|
@ -104,7 +104,7 @@ static int file_vopen(FAR struct file *filep, FAR const char *path,
|
|||
ret = inode_find(&desc);
|
||||
if (ret < 0)
|
||||
{
|
||||
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
||||
#ifdef CONFIG_PSEUDOFS_FILE
|
||||
if ((oflags & O_CREAT) != 0)
|
||||
{
|
||||
ret = pseudofile_create(&desc.node, path, mode);
|
||||
|
|
|
@ -416,12 +416,15 @@ int inode_stat(FAR struct inode *inode, FAR struct stat *buf, int resolve)
|
|||
{
|
||||
/* What is it if it also has child inodes? */
|
||||
|
||||
#ifdef CONFIG_PSEUDOFS_FILE
|
||||
buf->st_size = inode->i_size;
|
||||
|
||||
if (inode_is_pseudofile(inode))
|
||||
{
|
||||
buf->st_mode |= S_IFREG;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
buf->st_mode |= S_IFCHR;
|
||||
}
|
||||
|
|
|
@ -405,7 +405,9 @@ struct inode
|
|||
uint16_t i_flags; /* Flags for inode */
|
||||
union inode_ops_u u; /* Inode operations */
|
||||
ino_t i_ino; /* Inode serial number */
|
||||
#ifdef CONFIG_PSEUDOFS_FILE
|
||||
size_t i_size; /* The size of per inode driver */
|
||||
#endif
|
||||
#ifdef CONFIG_PSEUDOFS_ATTRIBUTES
|
||||
mode_t i_mode; /* Access mode flags */
|
||||
uid_t i_owner; /* Owner */
|
||||
|
|
Loading…
Reference in New Issue