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

commit 25e2d7bef28f6a14dcf40218e0f4d24ba2d6edb1
Author: guohao15 <[email protected]>
AuthorDate: Thu Jan 18 12:20:37 2024 +0800

    inotify:add function filter type of inode
    
    only mountpt/driver/pseudodir need inotify
    
    Signed-off-by: guohao15 <[email protected]>
---
 fs/notify/inotify.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/fs/notify/inotify.c b/fs/notify/inotify.c
index 417ec351b0..8053ac62da 100644
--- a/fs/notify/inotify.c
+++ b/fs/notify/inotify.c
@@ -869,6 +869,28 @@ static void notify_queue_path_event(FAR const char *path, 
uint32_t mask)
     }
 }
 
+/****************************************************************************
+ * Name: notify_get_path
+ *
+ * Description:
+ *   Get the path from the file pointer.
+ *
+ ****************************************************************************/
+
+static int notify_get_path(FAR struct file *filep, FAR char *path)
+{
+  /* We only apply file lock on mount points (f_inode won't be NULL). */
+
+  if (!INODE_IS_MOUNTPT(filep->f_inode) &&
+      !INODE_IS_PSEUDODIR(filep->f_inode) &&
+      !INODE_IS_DRIVER(filep->f_inode))
+    {
+      return -EBADF;
+    }
+
+  return file_fcntl(filep, F_GETPATH, path);
+}
+
 /****************************************************************************
  * Name: notify_queue_filep_event
  *
@@ -883,11 +905,10 @@ static inline void notify_queue_filep_event(FAR struct 
file *filep,
   int ret;
 
   nxmutex_lock(&g_inotify_hash_lock);
-  ret = file_fcntl(filep, F_GETPATH, g_inotify_temp_buffer[0]);
+  ret = notify_get_path(filep, g_inotify_temp_buffer[0]);
   if (ret < 0)
     {
       nxmutex_unlock(&g_inotify_hash_lock);
-      finfo("Failed to get path\n");
       return;
     }
 

Reply via email to