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 61c82404580 fs/lock: Allow driver lock
61c82404580 is described below

commit 61c82404580367de237ece3d3d437f906647239c
Author: Zhe Weng <weng...@xiaomi.com>
AuthorDate: Thu Mar 13 10:46:28 2025 +0800

    fs/lock: Allow driver lock
    
    Sometimes we need to flock a driver node, which we can support easily.
    
    Signed-off-by: Zhe Weng <weng...@xiaomi.com>
---
 fs/vfs/fs_lock.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/fs/vfs/fs_lock.c b/fs/vfs/fs_lock.c
index ff43d28f388..f685eace90c 100644
--- a/fs/vfs/fs_lock.c
+++ b/fs/vfs/fs_lock.c
@@ -100,11 +100,14 @@ static mutex_t g_protect_lock = NXMUTEX_INITIALIZER;
 static int file_lock_get_path(FAR struct file *filep, FAR char *path)
 {
   FAR struct tcb_s *tcb = this_task();
+  bool is_allowed_type;
 
-  /* We only apply file lock on mount points (f_inode won't be NULL). */
+  /* We only apply file lock on mountpt and driver (f_inode won't be NULL). */
 
-  if (!INODE_IS_MOUNTPT(filep->f_inode) ||
-      tcb->flags & TCB_FLAG_SIGNAL_ACTION)
+  is_allowed_type = INODE_IS_MOUNTPT(filep->f_inode) ||
+                    INODE_IS_DRIVER(filep->f_inode);
+
+  if (!is_allowed_type || tcb->flags & TCB_FLAG_SIGNAL_ACTION)
     {
       return -EBADF;
     }

Reply via email to