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 70fc5c3e775778a2cafdbdc2b37aa614ee678416
Author: dongjiuzhu1 <dongjiuz...@xiaomi.com>
AuthorDate: Mon Jun 2 17:30:15 2025 +0800

    fs/dup: remove unnecessary backup about fdcheck_tag and fdsan_tag
    
    1. The call to file_close_without_clear in file_dup3 does not clear
    the tag information, so there is no need to back it up.
    2. file_dup3 don't need to copy tag information, tag is only valid for fd.
    
    Signed-off-by: dongjiuzhu1 <dongjiuz...@xiaomi.com>
---
 fs/inode/fs_files.c | 22 ----------------------
 fs/vfs/fs_dup.c     | 20 --------------------
 fs/vfs/fs_dup2.c    | 10 ----------
 3 files changed, 52 deletions(-)

diff --git a/fs/inode/fs_files.c b/fs/inode/fs_files.c
index 310baeff71..cc3a02a2da 100644
--- a/fs/inode/fs_files.c
+++ b/fs/inode/fs_files.c
@@ -263,12 +263,6 @@ int nx_dup3_from_tcb(FAR struct tcb_s *tcb, int fd1, int 
fd2, int flags)
   FAR struct filelist *list;
   FAR struct file *filep1;
   FAR struct file *filep;
-#ifdef CONFIG_FDCHECK
-  uint8_t f_tag_fdcheck;
-#endif
-#ifdef CONFIG_FDSAN
-  uint64_t f_tag_fdsan;
-#endif
   bool new = false;
   int count;
   int ret;
@@ -313,14 +307,6 @@ int nx_dup3_from_tcb(FAR struct tcb_s *tcb, int fd1, int 
fd2, int flags)
                               fd2 % CONFIG_NFILE_DESCRIPTORS_PER_BLOCK,
                               &new);
 
-#ifdef CONFIG_FDSAN
-  f_tag_fdsan = filep->f_tag_fdsan;
-#endif
-
-#ifdef CONFIG_FDCHECK
-  f_tag_fdcheck = filep->f_tag_fdcheck;
-#endif
-
   /* Perform the dup3 operation */
 
   ret = file_dup3(filep1, filep, flags);
@@ -336,14 +322,6 @@ int nx_dup3_from_tcb(FAR struct tcb_s *tcb, int fd1, int 
fd2, int flags)
       return ret;
     }
 
-#ifdef CONFIG_FDSAN
-  filep->f_tag_fdsan = f_tag_fdsan;
-#endif
-
-#ifdef CONFIG_FDCHECK
-  filep->f_tag_fdcheck = f_tag_fdcheck;
-#endif
-
 #ifdef CONFIG_FDCHECK
   return fdcheck_protect(fd2);
 #else
diff --git a/fs/vfs/fs_dup.c b/fs/vfs/fs_dup.c
index 56f0454b87..7de1ec845f 100644
--- a/fs/vfs/fs_dup.c
+++ b/fs/vfs/fs_dup.c
@@ -57,13 +57,7 @@ int file_dup(FAR struct file *filep, int minfd, int flags)
   FAR struct file *filep2;
   int fd2;
   int ret;
-#ifdef CONFIG_FDSAN
-  uint64_t f_tag_fdsan; /* File owner fdsan tag, init to 0 */
-#endif
-
 #ifdef CONFIG_FDCHECK
-  uint8_t f_tag_fdcheck; /* File owner fdcheck tag, init to 0 */
-
   minfd = fdcheck_restore(minfd);
 #endif
 
@@ -74,23 +68,9 @@ int file_dup(FAR struct file *filep, int minfd, int flags)
     }
 
   ret = fs_getfilep(fd2, &filep2);
-#ifdef CONFIG_FDSAN
-  f_tag_fdsan = filep2->f_tag_fdsan;
-#endif
-
-#ifdef CONFIG_FDCHECK
-  f_tag_fdcheck = filep2->f_tag_fdcheck;
-#endif
   DEBUGASSERT(ret >= 0);
 
   ret = file_dup3(filep, filep2, flags);
-#ifdef CONFIG_FDSAN
-  filep2->f_tag_fdsan = f_tag_fdsan;
-#endif
-
-#ifdef CONFIG_FDCHECK
-  filep2->f_tag_fdcheck = f_tag_fdcheck;
-#endif
 
   fs_putfilep(filep2);
   if (ret >= 0)
diff --git a/fs/vfs/fs_dup2.c b/fs/vfs/fs_dup2.c
index ee1e36e576..d9e1d9e13a 100644
--- a/fs/vfs/fs_dup2.c
+++ b/fs/vfs/fs_dup2.c
@@ -163,16 +163,6 @@ int file_dup3(FAR struct file *filep1, FAR struct file 
*filep2, int flags)
         }
     }
 
-  /* Copy tag */
-
-#ifdef CONFIG_FDSAN
-  filep2->f_tag_fdsan = filep1->f_tag_fdsan;
-#endif
-
-#ifdef CONFIG_FDCHECK
-  filep2->f_tag_fdcheck = filep1->f_tag_fdcheck;
-#endif
-
   FS_ADD_BACKTRACE(filep2);
   return OK;
 }

Reply via email to