emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 0cf9b582285: Fix listing of Android root directory when it is acc


From: Po Lu
Subject: master 0cf9b582285: Fix listing of Android root directory when it is accessible
Date: Sun, 31 Mar 2024 21:26:20 -0400 (EDT)

branch: master
commit 0cf9b58228580bfa400cdaf35eac04d375fe4785
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Fix listing of Android root directory when it is accessible
    
    * src/androidvfs.c (android_root_closedir, android_root_dirfd)
    (android_root_opendir): Allocate an ersatz file descriptor even
    if directory is non-NULL, so that at-funcs will properly return
    file status for virtual files in the root directory.
---
 src/androidvfs.c | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/src/androidvfs.c b/src/androidvfs.c
index e8eb9f2d41c..2e23ed40cf5 100644
--- a/src/androidvfs.c
+++ b/src/androidvfs.c
@@ -6730,7 +6730,8 @@ android_root_closedir (struct android_vdir *vdir)
 
   if (dir->directory)
     closedir (dir->directory);
-  else if (root_fd_references--)
+
+  if (root_fd_references--)
     ;
   else
     {
@@ -6745,13 +6746,7 @@ android_root_closedir (struct android_vdir *vdir)
 static int
 android_root_dirfd (struct android_vdir *vdir)
 {
-  struct android_unix_vdir *dir;
-
-  dir = (struct android_unix_vdir *) vdir;
-
-  if (dir->directory)
-    return dirfd (dir->directory);
-
+  eassert (root_fd != -1);
   return root_fd;
 }
 
@@ -6778,13 +6773,13 @@ android_root_opendir (struct android_vnode *vnode)
   dir->directory = directory;
   dir->index = 0;
 
-  if (!directory)
-    {
-      /* Allocate a temporary file descriptor for this ersatz root.  */
-      if (root_fd < 0)
-       root_fd = open ("/dev/null", O_RDONLY | O_CLOEXEC);
-      root_fd_references++;
-    }
+  /* Allocate a temporary file descriptor for this ersatz root.  This is
+     required regardless of the value of DIRECTORY, as android_fstatat
+     and co. will not defer to the VFS layer if a directory file
+     descriptor is not known to be special.  */
+  if (root_fd < 0)
+    root_fd = open ("/dev/null", O_RDONLY | O_CLOEXEC);
+  root_fd_references++;
 
   return &dir->vdir;
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]