This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 9852428953 fs: procfs add poll support
9852428953 is described below

commit 985242895356d5592a9a3115428a2a5fd083bc7a
Author: yinshengkai <[email protected]>
AuthorDate: Sat Nov 25 20:11:03 2023 +0800

    fs: procfs add poll support
    
    Signed-off-by: yinshengkai <[email protected]>
---
 arch/arm/src/cxd56xx/cxd56_powermgr_procfs.c       |  1 +
 arch/arm/src/cxd56xx/cxd56_usbdev.c                |  1 +
 arch/arm/src/lc823450/lc823450_procfs_dvfs.c       |  1 +
 arch/arm64/src/common/arm64_fpu.c                  |  1 +
 .../rddrone-bms772/src/s32k1xx_nrstcheck_procfs.c  |  1 +
 drivers/clk/clk.c                                  |  1 +
 drivers/mmcsd/mmcsd_procfs.c                       |  1 +
 drivers/mtd/mtd_partition.c                        |  1 +
 drivers/power/pm/pm_procfs.c                       |  1 +
 fs/binfs/fs_binfs.c                                |  1 +
 fs/cromfs/fs_cromfs.c                              |  1 +
 fs/fat/fs_fat32.c                                  |  1 +
 fs/hostfs/hostfs.c                                 |  1 +
 fs/littlefs/lfs_vfs.c                              |  1 +
 fs/mount/fs_procfs_mount.c                         |  2 +-
 fs/nfs/nfs_vfsops.c                                |  1 +
 fs/nxffs/nxffs_initialize.c                        |  1 +
 fs/procfs/fs_procfs.c                              | 25 ++++++++++++++++++++++
 fs/procfs/fs_procfscpuinfo.c                       |  1 +
 fs/procfs/fs_procfscpuload.c                       |  1 +
 fs/procfs/fs_procfscritmon.c                       |  1 +
 fs/procfs/fs_procfsfdt.c                           |  1 +
 fs/procfs/fs_procfsiobinfo.c                       |  1 +
 fs/procfs/fs_procfsmeminfo.c                       |  2 ++
 fs/procfs/fs_procfsproc.c                          |  1 +
 fs/procfs/fs_procfstcbinfo.c                       |  1 +
 fs/procfs/fs_procfsuptime.c                        |  1 +
 fs/procfs/fs_procfsversion.c                       |  1 +
 fs/procfs/fs_skeleton.c                            |  1 +
 fs/romfs/fs_romfs.c                                |  1 +
 fs/rpmsgfs/rpmsgfs.c                               |  1 +
 fs/smartfs/smartfs_procfs.c                        |  1 +
 fs/smartfs/smartfs_smart.c                         |  1 +
 fs/spiffs/src/spiffs_vfs.c                         |  1 +
 fs/tmpfs/fs_tmpfs.c                                |  1 +
 fs/unionfs/fs_unionfs.c                            |  1 +
 fs/userfs/fs_userfs.c                              |  1 +
 fs/vfs/fs_poll.c                                   | 13 ++++++++---
 fs/zipfs/zip_vfs.c                                 |  1 +
 include/nuttx/fs/fs.h                              |  3 ++-
 include/nuttx/fs/procfs.h                          |  2 ++
 mm/mempool/mempool_procfs.c                        |  1 +
 net/procfs/net_procfs.c                            |  1 +
 net/procfs/net_procfs_route.c                      |  1 +
 sched/irq/irq_procfs.c                             |  1 +
 sched/module/mod_procfs.c                          |  1 +
 46 files changed, 82 insertions(+), 5 deletions(-)

diff --git a/arch/arm/src/cxd56xx/cxd56_powermgr_procfs.c 
b/arch/arm/src/cxd56xx/cxd56_powermgr_procfs.c
index 2ea95ab700..947bf48d58 100644
--- a/arch/arm/src/cxd56xx/cxd56_powermgr_procfs.c
+++ b/arch/arm/src/cxd56xx/cxd56_powermgr_procfs.c
@@ -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 */
diff --git a/arch/arm/src/cxd56xx/cxd56_usbdev.c 
b/arch/arm/src/cxd56xx/cxd56_usbdev.c
index f725a55b54..e54c756802 100644
--- a/arch/arm/src/cxd56xx/cxd56_usbdev.c
+++ b/arch/arm/src/cxd56xx/cxd56_usbdev.c
@@ -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 */
diff --git a/arch/arm/src/lc823450/lc823450_procfs_dvfs.c 
b/arch/arm/src/lc823450/lc823450_procfs_dvfs.c
index 42ee94fe67..d25a1c2bcb 100644
--- a/arch/arm/src/lc823450/lc823450_procfs_dvfs.c
+++ b/arch/arm/src/lc823450/lc823450_procfs_dvfs.c
@@ -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 */
diff --git a/arch/arm64/src/common/arm64_fpu.c 
b/arch/arm64/src/common/arm64_fpu.c
index 16172b3d36..c8202b57a6 100644
--- a/arch/arm64/src/common/arm64_fpu.c
+++ b/arch/arm64/src/common/arm64_fpu.c
@@ -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 */
diff --git a/boards/arm/s32k1xx/rddrone-bms772/src/s32k1xx_nrstcheck_procfs.c 
b/boards/arm/s32k1xx/rddrone-bms772/src/s32k1xx_nrstcheck_procfs.c
index 81f3b4783d..6c97f027c2 100644
--- a/boards/arm/s32k1xx/rddrone-bms772/src/s32k1xx_nrstcheck_procfs.c
+++ b/boards/arm/s32k1xx/rddrone-bms772/src/s32k1xx_nrstcheck_procfs.c
@@ -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 */
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index a745852176..6218f5a7ea 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -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 */
 
diff --git a/drivers/mmcsd/mmcsd_procfs.c b/drivers/mmcsd/mmcsd_procfs.c
index 5260d49d42..82256a727d 100644
--- a/drivers/mmcsd/mmcsd_procfs.c
+++ b/drivers/mmcsd/mmcsd_procfs.c
@@ -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 */
 
diff --git a/drivers/mtd/mtd_partition.c b/drivers/mtd/mtd_partition.c
index e0fc2f9076..8d04be670a 100644
--- a/drivers/mtd/mtd_partition.c
+++ b/drivers/mtd/mtd_partition.c
@@ -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 */
 
diff --git a/drivers/power/pm/pm_procfs.c b/drivers/power/pm/pm_procfs.c
index eba85b3b91..61760fb62c 100644
--- a/drivers/power/pm/pm_procfs.c
+++ b/drivers/power/pm/pm_procfs.c
@@ -131,6 +131,7 @@ const struct procfs_operations g_pm_operations =
   pm_close,      /* close */
   pm_read,       /* read */
   NULL,          /* write */
+  NULL,          /* poll */
 
   pm_dup,        /* dup */
 
diff --git a/fs/binfs/fs_binfs.c b/fs/binfs/fs_binfs.c
index 8ec7226b51..4ea17cd4cc 100644
--- a/fs/binfs/fs_binfs.c
+++ b/fs/binfs/fs_binfs.c
@@ -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 */
diff --git a/fs/cromfs/fs_cromfs.c b/fs/cromfs/fs_cromfs.c
index fff9199dfa..bf83256904 100644
--- a/fs/cromfs/fs_cromfs.c
+++ b/fs/cromfs/fs_cromfs.c
@@ -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 */
diff --git a/fs/fat/fs_fat32.c b/fs/fat/fs_fat32.c
index 1edb7167ed..0f4bbe8940 100644
--- a/fs/fat/fs_fat32.c
+++ b/fs/fat/fs_fat32.c
@@ -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 */
diff --git a/fs/hostfs/hostfs.c b/fs/hostfs/hostfs.c
index e157e37958..d6bbd12b90 100644
--- a/fs/hostfs/hostfs.c
+++ b/fs/hostfs/hostfs.c
@@ -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 */
diff --git a/fs/littlefs/lfs_vfs.c b/fs/littlefs/lfs_vfs.c
index 332d3da59c..bc6c2cf7ad 100644
--- a/fs/littlefs/lfs_vfs.c
+++ b/fs/littlefs/lfs_vfs.c
@@ -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 */
diff --git a/fs/mount/fs_procfs_mount.c b/fs/mount/fs_procfs_mount.c
index a71ae7c579..36ace5ecc6 100644
--- a/fs/mount/fs_procfs_mount.c
+++ b/fs/mount/fs_procfs_mount.c
@@ -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 */
diff --git a/fs/nfs/nfs_vfsops.c b/fs/nfs/nfs_vfsops.c
index 49b5414bc8..e265bf8685 100644
--- a/fs/nfs/nfs_vfsops.c
+++ b/fs/nfs/nfs_vfsops.c
@@ -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 */
diff --git a/fs/nxffs/nxffs_initialize.c b/fs/nxffs/nxffs_initialize.c
index 51312da17f..b68569e1f2 100644
--- a/fs/nxffs/nxffs_initialize.c
+++ b/fs/nxffs/nxffs_initialize.c
@@ -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 */
diff --git a/fs/procfs/fs_procfs.c b/fs/procfs/fs_procfs.c
index 340b04edc0..f606aa4ae1 100644
--- a/fs/procfs/fs_procfs.c
+++ b/fs/procfs/fs_procfs.c
@@ -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
  ****************************************************************************/
diff --git a/fs/procfs/fs_procfscpuinfo.c b/fs/procfs/fs_procfscpuinfo.c
index c818dd6284..43d3c81e2e 100644
--- a/fs/procfs/fs_procfscpuinfo.c
+++ b/fs/procfs/fs_procfscpuinfo.c
@@ -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 */
diff --git a/fs/procfs/fs_procfscpuload.c b/fs/procfs/fs_procfscpuload.c
index 4bd75ee84e..6c55e3e0bd 100644
--- a/fs/procfs/fs_procfscpuload.c
+++ b/fs/procfs/fs_procfscpuload.c
@@ -101,6 +101,7 @@ const struct procfs_operations g_cpuload_operations =
   cpuload_close,      /* close */
   cpuload_read,       /* read */
   NULL,               /* write */
+  NULL,               /* poll */
 
   cpuload_dup,        /* dup */
 
diff --git a/fs/procfs/fs_procfscritmon.c b/fs/procfs/fs_procfscritmon.c
index b904fe77ee..5187dc91ed 100644
--- a/fs/procfs/fs_procfscritmon.c
+++ b/fs/procfs/fs_procfscritmon.c
@@ -99,6 +99,7 @@ const struct procfs_operations g_critmon_operations =
   critmon_close,      /* close */
   critmon_read,       /* read */
   NULL,               /* write */
+  NULL,               /* poll */
 
   critmon_dup,        /* dup */
 
diff --git a/fs/procfs/fs_procfsfdt.c b/fs/procfs/fs_procfsfdt.c
index abe12dc292..7583adb407 100644
--- a/fs/procfs/fs_procfsfdt.c
+++ b/fs/procfs/fs_procfsfdt.c
@@ -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 */
diff --git a/fs/procfs/fs_procfsiobinfo.c b/fs/procfs/fs_procfsiobinfo.c
index 04b6fbe7d9..859a94b667 100644
--- a/fs/procfs/fs_procfsiobinfo.c
+++ b/fs/procfs/fs_procfsiobinfo.c
@@ -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 */
diff --git a/fs/procfs/fs_procfsmeminfo.c b/fs/procfs/fs_procfsmeminfo.c
index aac6a8ab08..852e4a60b2 100644
--- a/fs/procfs/fs_procfsmeminfo.c
+++ b/fs/procfs/fs_procfsmeminfo.c
@@ -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 */
diff --git a/fs/procfs/fs_procfsproc.c b/fs/procfs/fs_procfsproc.c
index 0995985855..c6b7145c0f 100644
--- a/fs/procfs/fs_procfsproc.c
+++ b/fs/procfs/fs_procfsproc.c
@@ -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 */
 
diff --git a/fs/procfs/fs_procfstcbinfo.c b/fs/procfs/fs_procfstcbinfo.c
index bdb6c3b955..4a96bea969 100644
--- a/fs/procfs/fs_procfstcbinfo.c
+++ b/fs/procfs/fs_procfstcbinfo.c
@@ -98,6 +98,7 @@ const struct procfs_operations g_tcbinfo_operations =
   tcbinfo_close,      /* close */
   tcbinfo_read,       /* read */
   NULL,               /* write */
+  NULL,               /* poll */
 
   tcbinfo_dup,        /* dup */
 
diff --git a/fs/procfs/fs_procfsuptime.c b/fs/procfs/fs_procfsuptime.c
index 4d4d49f546..eaa67c9e1a 100644
--- a/fs/procfs/fs_procfsuptime.c
+++ b/fs/procfs/fs_procfsuptime.c
@@ -101,6 +101,7 @@ const struct procfs_operations g_uptime_operations =
   uptime_close,      /* close */
   uptime_read,       /* read */
   NULL,              /* write */
+  NULL,              /* poll */
 
   uptime_dup,        /* dup */
 
diff --git a/fs/procfs/fs_procfsversion.c b/fs/procfs/fs_procfsversion.c
index 5832da50ed..dabd0be5f6 100644
--- a/fs/procfs/fs_procfsversion.c
+++ b/fs/procfs/fs_procfsversion.c
@@ -101,6 +101,7 @@ const struct procfs_operations g_version_operations =
   version_close,      /* close */
   version_read,       /* read */
   NULL,               /* write */
+  NULL,               /* poll */
 
   version_dup,        /* dup */
 
diff --git a/fs/procfs/fs_skeleton.c b/fs/procfs/fs_skeleton.c
index 190481d501..3ace7ee005 100644
--- a/fs/procfs/fs_skeleton.c
+++ b/fs/procfs/fs_skeleton.c
@@ -133,6 +133,7 @@ const struct procfs_operations skel_procfsoperations =
 #else
   skel_write,      /* write */
 #endif
+  NULL,            /* poll */
 
   skel_dup,        /* dup */
 
diff --git a/fs/romfs/fs_romfs.c b/fs/romfs/fs_romfs.c
index 48d60a0e3b..e5af8c988b 100644
--- a/fs/romfs/fs_romfs.c
+++ b/fs/romfs/fs_romfs.c
@@ -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 */
diff --git a/fs/rpmsgfs/rpmsgfs.c b/fs/rpmsgfs/rpmsgfs.c
index 4881a07898..ac8a6d5214 100644
--- a/fs/rpmsgfs/rpmsgfs.c
+++ b/fs/rpmsgfs/rpmsgfs.c
@@ -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 */
diff --git a/fs/smartfs/smartfs_procfs.c b/fs/smartfs/smartfs_procfs.c
index 156c2637b9..7e4e64afe7 100644
--- a/fs/smartfs/smartfs_procfs.c
+++ b/fs/smartfs/smartfs_procfs.c
@@ -177,6 +177,7 @@ const struct procfs_operations g_smartfs_operations =
   /* No write supported */
 
   smartfs_write,      /* write */
+  NULL,               /* poll */
 
   smartfs_dup,        /* dup */
 
diff --git a/fs/smartfs/smartfs_smart.c b/fs/smartfs/smartfs_smart.c
index c55b6a7a89..c0e92c7b66 100644
--- a/fs/smartfs/smartfs_smart.c
+++ b/fs/smartfs/smartfs_smart.c
@@ -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 */
diff --git a/fs/spiffs/src/spiffs_vfs.c b/fs/spiffs/src/spiffs_vfs.c
index 449a038a72..f8e6967a45 100644
--- a/fs/spiffs/src/spiffs_vfs.c
+++ b/fs/spiffs/src/spiffs_vfs.c
@@ -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 */
diff --git a/fs/tmpfs/fs_tmpfs.c b/fs/tmpfs/fs_tmpfs.c
index f465cd529d..46a5bf1001 100644
--- a/fs/tmpfs/fs_tmpfs.c
+++ b/fs/tmpfs/fs_tmpfs.c
@@ -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 */
diff --git a/fs/unionfs/fs_unionfs.c b/fs/unionfs/fs_unionfs.c
index 2a998526c0..e89a261d6a 100644
--- a/fs/unionfs/fs_unionfs.c
+++ b/fs/unionfs/fs_unionfs.c
@@ -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 */
diff --git a/fs/userfs/fs_userfs.c b/fs/userfs/fs_userfs.c
index 5302e3147a..89e844637a 100644
--- a/fs/userfs/fs_userfs.c
+++ b/fs/userfs/fs_userfs.c
@@ -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 */
diff --git a/fs/vfs/fs_poll.c b/fs/vfs/fs_poll.c
index b3f23fecc3..7c23197c47 100644
--- a/fs/vfs/fs_poll.c
+++ b/fs/vfs/fs_poll.c
@@ -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)
             {
diff --git a/fs/zipfs/zip_vfs.c b/fs/zipfs/zip_vfs.c
index 296962878d..5e385a26cc 100644
--- a/fs/zipfs/zip_vfs.c
+++ b/fs/zipfs/zip_vfs.c
@@ -134,6 +134,7 @@ const struct mountpt_operations g_zipfs_operations =
   NULL,                /* ioctl */
   NULL,                /* mmap */
   NULL,                /* truncate */
+  NULL,                /* poll */
 
   NULL,                /* sync */
   zipfs_dup,           /* dup */
diff --git a/include/nuttx/fs/fs.h b/include/nuttx/fs/fs.h
index 032f1c6147..f17a04f5eb 100644
--- a/include/nuttx/fs/fs.h
+++ b/include/nuttx/fs/fs.h
@@ -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.
diff --git a/include/nuttx/fs/procfs.h b/include/nuttx/fs/procfs.h
index f14dceeca9..902d612587 100644
--- a/include/nuttx/fs/procfs.h
+++ b/include/nuttx/fs/procfs.h
@@ -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
diff --git a/mm/mempool/mempool_procfs.c b/mm/mempool/mempool_procfs.c
index 0cb99742ed..5e86b90c23 100644
--- a/mm/mempool/mempool_procfs.c
+++ b/mm/mempool/mempool_procfs.c
@@ -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 */
diff --git a/net/procfs/net_procfs.c b/net/procfs/net_procfs.c
index 65ec11f097..80960ca213 100644
--- a/net/procfs/net_procfs.c
+++ b/net/procfs/net_procfs.c
@@ -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 */
diff --git a/net/procfs/net_procfs_route.c b/net/procfs/net_procfs_route.c
index f3384276f5..19c4c794a8 100644
--- a/net/procfs/net_procfs_route.c
+++ b/net/procfs/net_procfs_route.c
@@ -181,6 +181,7 @@ const struct procfs_operations g_netroute_operations =
   route_close,         /* close */
   route_read,          /* read */
   NULL,                /* write */
+  NULL,                /* poll */
 
   route_dup,           /* dup */
 
diff --git a/sched/irq/irq_procfs.c b/sched/irq/irq_procfs.c
index 7f5618579a..bc878fa9f2 100644
--- a/sched/irq/irq_procfs.c
+++ b/sched/irq/irq_procfs.c
@@ -119,6 +119,7 @@ const struct procfs_operations g_irq_operations =
   irq_close,      /* close */
   irq_read,       /* read */
   NULL,           /* write */
+  NULL,           /* poll */
 
   irq_dup,        /* dup */
 
diff --git a/sched/module/mod_procfs.c b/sched/module/mod_procfs.c
index 2a89e6302f..1176e6e939 100644
--- a/sched/module/mod_procfs.c
+++ b/sched/module/mod_procfs.c
@@ -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 */

Reply via email to