fs: procfs add poll support
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
This commit is contained in:
parent
ca99e69c28
commit
9852428953
@ -114,6 +114,7 @@ const struct procfs_operations cxd56_powermgr_procfs_operations =
|
||||
cxd56_powermgr_procfs_close, /* close */
|
||||
cxd56_powermgr_procfs_read, /* read */
|
||||
NULL, /* write */
|
||||
NULL, /* poll */
|
||||
cxd56_powermgr_procfs_dup, /* dup */
|
||||
cxd56_powermgr_procfs_opendir, /* opendir */
|
||||
cxd56_powermgr_procfs_closedir, /* closedir */
|
||||
|
@ -618,6 +618,7 @@ const struct procfs_operations cxd56_usbdev_operations =
|
||||
cxd56_usbdev_close, /* close */
|
||||
cxd56_usbdev_read, /* read */
|
||||
NULL, /* write */
|
||||
NULL, /* poll */
|
||||
cxd56_usbdev_dup, /* dup */
|
||||
|
||||
NULL, /* opendir */
|
||||
|
@ -91,6 +91,7 @@ static const struct procfs_operations dvfs_procfsoperations =
|
||||
dvfs_close, /* close */
|
||||
dvfs_read, /* read */
|
||||
dvfs_write, /* write */
|
||||
NULL, /* poll */
|
||||
dvfs_dup, /* dup */
|
||||
NULL, /* opendir */
|
||||
NULL, /* closedir */
|
||||
|
@ -102,6 +102,7 @@ const struct procfs_operations arm64_fpu_procfs_operations =
|
||||
arm64_fpu_procfs_close, /* close */
|
||||
arm64_fpu_procfs_read, /* read */
|
||||
NULL, /* write */
|
||||
NULL, /* poll */
|
||||
NULL, /* dup */
|
||||
NULL, /* opendir */
|
||||
NULL, /* closedir */
|
||||
|
@ -94,6 +94,7 @@ const struct procfs_operations s32k1xx_nrstcheck_procfs_ops =
|
||||
s32k1xx_nrstcheck_procfs_close, /* close */
|
||||
s32k1xx_nrstcheck_procfs_read, /* read */
|
||||
NULL, /* write */
|
||||
NULL, /* poll */
|
||||
s32k1xx_nrstcheck_procfs_dup, /* dup */
|
||||
NULL, /* opendir */
|
||||
NULL, /* closedir */
|
||||
|
@ -114,6 +114,7 @@ const struct procfs_operations g_clk_operations =
|
||||
clk_procfs_close, /* close */
|
||||
clk_procfs_read, /* read */
|
||||
NULL, /* write */
|
||||
NULL, /* poll */
|
||||
|
||||
clk_procfs_dup, /* dup */
|
||||
|
||||
|
@ -112,6 +112,7 @@ static const struct procfs_operations g_mmcsd_operations =
|
||||
mmcsd_close, /* close */
|
||||
mmcsd_read, /* read */
|
||||
NULL, /* write */
|
||||
NULL, /* poll */
|
||||
|
||||
mmcsd_dup, /* dup */
|
||||
|
||||
|
@ -155,6 +155,7 @@ const struct procfs_operations g_part_operations =
|
||||
part_procfs_close, /* close */
|
||||
part_procfs_read, /* read */
|
||||
NULL, /* write */
|
||||
NULL, /* poll */
|
||||
|
||||
part_procfs_dup, /* dup */
|
||||
|
||||
|
@ -131,6 +131,7 @@ const struct procfs_operations g_pm_operations =
|
||||
pm_close, /* close */
|
||||
pm_read, /* read */
|
||||
NULL, /* write */
|
||||
NULL, /* poll */
|
||||
|
||||
pm_dup, /* dup */
|
||||
|
||||
|
@ -110,6 +110,7 @@ const struct mountpt_operations g_binfs_operations =
|
||||
binfs_ioctl, /* ioctl */
|
||||
NULL, /* mmap */
|
||||
NULL, /* truncate */
|
||||
NULL, /* poll */
|
||||
|
||||
NULL, /* sync */
|
||||
binfs_dup, /* dup */
|
||||
|
@ -186,6 +186,7 @@ const struct mountpt_operations g_cromfs_operations =
|
||||
cromfs_ioctl, /* ioctl */
|
||||
NULL, /* mmap */
|
||||
NULL, /* truncate */
|
||||
NULL, /* poll */
|
||||
|
||||
NULL, /* sync */
|
||||
cromfs_dup, /* dup */
|
||||
|
@ -127,6 +127,7 @@ const struct mountpt_operations g_fat_operations =
|
||||
fat_ioctl, /* ioctl */
|
||||
NULL, /* mmap */
|
||||
fat_truncate, /* truncate */
|
||||
NULL, /* poll */
|
||||
fat_sync, /* sync */
|
||||
fat_dup, /* dup */
|
||||
fat_fstat, /* fstat */
|
||||
|
@ -144,6 +144,7 @@ const struct mountpt_operations g_hostfs_operations =
|
||||
hostfs_ioctl, /* ioctl */
|
||||
NULL, /* mmap */
|
||||
hostfs_ftruncate, /* ftruncate */
|
||||
NULL, /* poll */
|
||||
|
||||
hostfs_sync, /* sync */
|
||||
hostfs_dup, /* dup */
|
||||
|
@ -150,6 +150,7 @@ const struct mountpt_operations g_littlefs_operations =
|
||||
littlefs_ioctl, /* ioctl */
|
||||
NULL, /* mmap */
|
||||
littlefs_truncate, /* truncate */
|
||||
NULL, /* poll */
|
||||
|
||||
littlefs_sync, /* sync */
|
||||
littlefs_dup, /* dup */
|
||||
|
@ -143,7 +143,7 @@ const struct procfs_operations g_mount_operations =
|
||||
mount_close, /* close */
|
||||
mount_read, /* read */
|
||||
NULL, /* write */
|
||||
|
||||
NULL, /* poll */
|
||||
mount_dup, /* dup */
|
||||
|
||||
NULL, /* opendir */
|
||||
|
@ -202,6 +202,7 @@ const struct mountpt_operations g_nfs_operations =
|
||||
NULL, /* ioctl */
|
||||
NULL, /* mmap */
|
||||
nfs_truncate, /* truncate */
|
||||
NULL, /* poll */
|
||||
|
||||
nfs_sync, /* sync */
|
||||
nfs_dup, /* dup */
|
||||
|
@ -60,6 +60,7 @@ const struct mountpt_operations g_nxffs_operations =
|
||||
#else
|
||||
NULL, /* truncate */
|
||||
#endif
|
||||
NULL, /* poll */
|
||||
|
||||
NULL, /* sync -- No buffered data */
|
||||
nxffs_dup, /* dup */
|
||||
|
@ -218,6 +218,8 @@ static ssize_t procfs_read(FAR struct file *filep, FAR char *buffer,
|
||||
size_t buflen);
|
||||
static ssize_t procfs_write(FAR struct file *filep, FAR const char *buffer,
|
||||
size_t buflen);
|
||||
static int procfs_poll(FAR struct file *filep, FAR struct pollfd *fds,
|
||||
bool setup);
|
||||
static int procfs_ioctl(FAR struct file *filep, int cmd,
|
||||
unsigned long arg);
|
||||
|
||||
@ -270,6 +272,7 @@ const struct mountpt_operations g_procfs_operations =
|
||||
procfs_ioctl, /* ioctl */
|
||||
NULL, /* mmap */
|
||||
NULL, /* truncate */
|
||||
procfs_poll, /* poll */
|
||||
|
||||
NULL, /* sync */
|
||||
procfs_dup, /* dup */
|
||||
@ -501,6 +504,28 @@ static ssize_t procfs_write(FAR struct file *filep, FAR const char *buffer,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int procfs_poll(FAR struct file *filep, FAR struct pollfd *fds,
|
||||
bool setup)
|
||||
{
|
||||
FAR struct procfs_file_s *handler;
|
||||
|
||||
finfo("fds=%p setup=%d\n", fds, setup);
|
||||
|
||||
/* Recover our private data from the struct file instance */
|
||||
|
||||
handler = (FAR struct procfs_file_s *)filep->f_priv;
|
||||
DEBUGASSERT(handler);
|
||||
|
||||
/* Call the handler's poll routine */
|
||||
|
||||
if (handler->procfsentry->ops->poll)
|
||||
{
|
||||
return handler->procfsentry->ops->poll(filep, fds, setup);
|
||||
}
|
||||
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: procfs_ioctl
|
||||
****************************************************************************/
|
||||
|
@ -79,6 +79,7 @@ const struct procfs_operations g_cpuinfo_operations =
|
||||
cpuinfo_close, /* close */
|
||||
cpuinfo_read, /* read */
|
||||
NULL, /* write */
|
||||
NULL, /* poll */
|
||||
cpuinfo_dup, /* dup */
|
||||
NULL, /* opendir */
|
||||
NULL, /* closedir */
|
||||
|
@ -101,6 +101,7 @@ const struct procfs_operations g_cpuload_operations =
|
||||
cpuload_close, /* close */
|
||||
cpuload_read, /* read */
|
||||
NULL, /* write */
|
||||
NULL, /* poll */
|
||||
|
||||
cpuload_dup, /* dup */
|
||||
|
||||
|
@ -99,6 +99,7 @@ const struct procfs_operations g_critmon_operations =
|
||||
critmon_close, /* close */
|
||||
critmon_read, /* read */
|
||||
NULL, /* write */
|
||||
NULL, /* poll */
|
||||
|
||||
critmon_dup, /* dup */
|
||||
|
||||
|
@ -85,6 +85,7 @@ const struct procfs_operations g_fdt_operations =
|
||||
fdt_close, /* close */
|
||||
fdt_read, /* read */
|
||||
NULL, /* write */
|
||||
NULL, /* poll */
|
||||
fdt_dup, /* dup */
|
||||
NULL, /* opendir */
|
||||
NULL, /* closedir */
|
||||
|
@ -98,6 +98,7 @@ const struct procfs_operations g_iobinfo_operations =
|
||||
iobinfo_close, /* close */
|
||||
iobinfo_read, /* read */
|
||||
NULL, /* write */
|
||||
NULL, /* poll */
|
||||
iobinfo_dup, /* dup */
|
||||
NULL, /* opendir */
|
||||
NULL, /* closedir */
|
||||
|
@ -123,6 +123,7 @@ const struct procfs_operations g_meminfo_operations =
|
||||
meminfo_close, /* close */
|
||||
meminfo_read, /* read */
|
||||
NULL, /* write */
|
||||
NULL, /* poll */
|
||||
meminfo_dup, /* dup */
|
||||
NULL, /* opendir */
|
||||
NULL, /* closedir */
|
||||
@ -138,6 +139,7 @@ const struct procfs_operations g_memdump_operations =
|
||||
meminfo_close, /* close */
|
||||
memdump_read, /* read */
|
||||
memdump_write, /* write */
|
||||
NULL, /* poll */
|
||||
meminfo_dup, /* dup */
|
||||
NULL, /* opendir */
|
||||
NULL, /* closedir */
|
||||
|
@ -250,6 +250,7 @@ const struct procfs_operations g_proc_operations =
|
||||
proc_close, /* close */
|
||||
proc_read, /* read */
|
||||
proc_write, /* write */
|
||||
NULL, /* poll */
|
||||
|
||||
proc_dup, /* dup */
|
||||
|
||||
|
@ -98,6 +98,7 @@ const struct procfs_operations g_tcbinfo_operations =
|
||||
tcbinfo_close, /* close */
|
||||
tcbinfo_read, /* read */
|
||||
NULL, /* write */
|
||||
NULL, /* poll */
|
||||
|
||||
tcbinfo_dup, /* dup */
|
||||
|
||||
|
@ -101,6 +101,7 @@ const struct procfs_operations g_uptime_operations =
|
||||
uptime_close, /* close */
|
||||
uptime_read, /* read */
|
||||
NULL, /* write */
|
||||
NULL, /* poll */
|
||||
|
||||
uptime_dup, /* dup */
|
||||
|
||||
|
@ -101,6 +101,7 @@ const struct procfs_operations g_version_operations =
|
||||
version_close, /* close */
|
||||
version_read, /* read */
|
||||
NULL, /* write */
|
||||
NULL, /* poll */
|
||||
|
||||
version_dup, /* dup */
|
||||
|
||||
|
@ -133,6 +133,7 @@ const struct procfs_operations skel_procfsoperations =
|
||||
#else
|
||||
skel_write, /* write */
|
||||
#endif
|
||||
NULL, /* poll */
|
||||
|
||||
skel_dup, /* dup */
|
||||
|
||||
|
@ -123,6 +123,7 @@ const struct mountpt_operations g_romfs_operations =
|
||||
romfs_ioctl, /* ioctl */
|
||||
romfs_mmap, /* mmap */
|
||||
NULL, /* truncate */
|
||||
NULL, /* poll */
|
||||
|
||||
NULL, /* sync */
|
||||
romfs_dup, /* dup */
|
||||
|
@ -163,6 +163,7 @@ const struct mountpt_operations g_rpmsgfs_operations =
|
||||
rpmsgfs_ioctl, /* ioctl */
|
||||
NULL, /* mmap */
|
||||
rpmsgfs_truncate, /* truncate */
|
||||
NULL, /* poll */
|
||||
|
||||
rpmsgfs_sync, /* sync */
|
||||
rpmsgfs_dup, /* dup */
|
||||
|
@ -177,6 +177,7 @@ const struct procfs_operations g_smartfs_operations =
|
||||
/* No write supported */
|
||||
|
||||
smartfs_write, /* write */
|
||||
NULL, /* poll */
|
||||
|
||||
smartfs_dup, /* dup */
|
||||
|
||||
|
@ -142,6 +142,7 @@ const struct mountpt_operations g_smartfs_operations =
|
||||
smartfs_ioctl, /* ioctl */
|
||||
NULL, /* mmap */
|
||||
smartfs_truncate, /* truncate */
|
||||
NULL, /* poll */
|
||||
|
||||
smartfs_sync, /* sync */
|
||||
smartfs_dup, /* dup */
|
||||
|
@ -143,6 +143,7 @@ const struct mountpt_operations g_spiffs_operations =
|
||||
spiffs_ioctl, /* ioctl */
|
||||
NULL, /* mmap */
|
||||
spiffs_truncate, /* truncate */
|
||||
NULL, /* poll */
|
||||
|
||||
spiffs_sync, /* sync */
|
||||
spiffs_dup, /* dup */
|
||||
|
@ -181,6 +181,7 @@ const struct mountpt_operations g_tmpfs_operations =
|
||||
NULL, /* ioctl */
|
||||
tmpfs_mmap, /* mmap */
|
||||
tmpfs_truncate, /* truncate */
|
||||
NULL, /* poll */
|
||||
|
||||
tmpfs_sync, /* sync */
|
||||
tmpfs_dup, /* dup */
|
||||
|
@ -215,6 +215,7 @@ const struct mountpt_operations g_unionfs_operations =
|
||||
unionfs_ioctl, /* ioctl */
|
||||
NULL, /* mmap */
|
||||
unionfs_truncate, /* truncate */
|
||||
NULL, /* pool */
|
||||
|
||||
unionfs_sync, /* sync */
|
||||
unionfs_dup, /* dup */
|
||||
|
@ -162,6 +162,7 @@ const struct mountpt_operations g_userfs_operations =
|
||||
userfs_ioctl, /* ioctl */
|
||||
NULL, /* mmap */
|
||||
userfs_truncate, /* truncate */
|
||||
NULL, /* poll */
|
||||
|
||||
userfs_sync, /* sync */
|
||||
userfs_dup, /* dup */
|
||||
|
@ -313,16 +313,23 @@ int file_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup)
|
||||
{
|
||||
/* Yes, it does... Setup the poll */
|
||||
|
||||
ret = (int)inode->u.i_ops->poll(filep, fds, setup);
|
||||
ret = inode->u.i_ops->poll(filep, fds, setup);
|
||||
}
|
||||
#ifndef CONFIG_DISABLE_MOUNTPOINT
|
||||
else if (INODE_IS_MOUNTPT(inode) && inode->u.i_mops != NULL &&
|
||||
inode->u.i_mops->poll != NULL)
|
||||
{
|
||||
ret = inode->u.i_mops->poll(filep, fds, setup);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Regular files (and block devices) are always readable and
|
||||
* writable. Open Group: "Regular files shall always poll TRUE for
|
||||
* reading and writing."
|
||||
*/
|
||||
|
||||
if (INODE_IS_MOUNTPT(inode) || INODE_IS_BLOCK(inode) ||
|
||||
INODE_IS_MTD(inode))
|
||||
else if (INODE_IS_MOUNTPT(inode) || INODE_IS_BLOCK(inode) ||
|
||||
INODE_IS_MTD(inode))
|
||||
{
|
||||
if (setup)
|
||||
{
|
||||
|
@ -134,6 +134,7 @@ const struct mountpt_operations g_zipfs_operations =
|
||||
NULL, /* ioctl */
|
||||
NULL, /* mmap */
|
||||
NULL, /* truncate */
|
||||
NULL, /* poll */
|
||||
|
||||
NULL, /* sync */
|
||||
zipfs_dup, /* dup */
|
||||
|
@ -319,7 +319,8 @@ struct mountpt_operations
|
||||
CODE int (*mmap)(FAR struct file *filep,
|
||||
FAR struct mm_map_entry_s *map);
|
||||
CODE int (*truncate)(FAR struct file *filep, off_t length);
|
||||
|
||||
CODE int (*poll)(FAR struct file *filep, FAR struct pollfd *fds,
|
||||
bool setup);
|
||||
/* The two structures need not be common after this point. The following
|
||||
* are extended methods needed to deal with the unique needs of mounted
|
||||
* file systems.
|
||||
|
@ -59,6 +59,8 @@ struct procfs_operations
|
||||
ssize_t (*write)(FAR struct file *filep,
|
||||
FAR const char *buffer,
|
||||
size_t buflen);
|
||||
int (*poll)(FAR struct file *filep, FAR struct pollfd *fds,
|
||||
bool setup);
|
||||
|
||||
/* The two structures need not be common after this point. The following
|
||||
* are extended methods needed to deal with the unique needs of mounted
|
||||
|
@ -78,6 +78,7 @@ const struct procfs_operations g_mempool_operations =
|
||||
mempool_close, /* close */
|
||||
mempool_read, /* read */
|
||||
NULL, /* write */
|
||||
NULL, /* poll */
|
||||
mempool_dup, /* dup */
|
||||
NULL, /* opendir */
|
||||
NULL, /* closedir */
|
||||
|
@ -168,6 +168,7 @@ const struct procfs_operations g_net_operations =
|
||||
netprocfs_close, /* close */
|
||||
netprocfs_read, /* read */
|
||||
NULL, /* write */
|
||||
NULL, /* poll */
|
||||
netprocfs_dup, /* dup */
|
||||
|
||||
netprocfs_opendir, /* opendir */
|
||||
|
@ -181,6 +181,7 @@ const struct procfs_operations g_netroute_operations =
|
||||
route_close, /* close */
|
||||
route_read, /* read */
|
||||
NULL, /* write */
|
||||
NULL, /* poll */
|
||||
|
||||
route_dup, /* dup */
|
||||
|
||||
|
@ -119,6 +119,7 @@ const struct procfs_operations g_irq_operations =
|
||||
irq_close, /* close */
|
||||
irq_read, /* read */
|
||||
NULL, /* write */
|
||||
NULL, /* poll */
|
||||
|
||||
irq_dup, /* dup */
|
||||
|
||||
|
@ -106,6 +106,7 @@ const struct procfs_operations g_module_operations =
|
||||
modprocfs_close, /* close */
|
||||
modprocfs_read, /* read */
|
||||
NULL, /* write */
|
||||
NULL, /* poll */
|
||||
modprocfs_dup, /* dup */
|
||||
|
||||
NULL, /* opendir */
|
||||
|
Loading…
Reference in New Issue
Block a user