diff options
| author | Po Lu | 2024-04-01 09:26:03 +0800 |
|---|---|---|
| committer | Po Lu | 2024-04-01 09:26:03 +0800 |
| commit | 0cf9b58228580bfa400cdaf35eac04d375fe4785 (patch) | |
| tree | 850bbf9b583fc80269c914f0baef9b384f54d551 | |
| parent | 09f381d70d8852d90cdd3c8d7e1e2786dbc61f92 (diff) | |
| download | emacs-0cf9b58228580bfa400cdaf35eac04d375fe4785.tar.gz emacs-0cf9b58228580bfa400cdaf35eac04d375fe4785.zip | |
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.
| -rw-r--r-- | src/androidvfs.c | 25 |
1 files 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) | |||
| 6730 | 6730 | ||
| 6731 | if (dir->directory) | 6731 | if (dir->directory) |
| 6732 | closedir (dir->directory); | 6732 | closedir (dir->directory); |
| 6733 | else if (root_fd_references--) | 6733 | |
| 6734 | if (root_fd_references--) | ||
| 6734 | ; | 6735 | ; |
| 6735 | else | 6736 | else |
| 6736 | { | 6737 | { |
| @@ -6745,13 +6746,7 @@ android_root_closedir (struct android_vdir *vdir) | |||
| 6745 | static int | 6746 | static int |
| 6746 | android_root_dirfd (struct android_vdir *vdir) | 6747 | android_root_dirfd (struct android_vdir *vdir) |
| 6747 | { | 6748 | { |
| 6748 | struct android_unix_vdir *dir; | 6749 | eassert (root_fd != -1); |
| 6749 | |||
| 6750 | dir = (struct android_unix_vdir *) vdir; | ||
| 6751 | |||
| 6752 | if (dir->directory) | ||
| 6753 | return dirfd (dir->directory); | ||
| 6754 | |||
| 6755 | return root_fd; | 6750 | return root_fd; |
| 6756 | } | 6751 | } |
| 6757 | 6752 | ||
| @@ -6778,13 +6773,13 @@ android_root_opendir (struct android_vnode *vnode) | |||
| 6778 | dir->directory = directory; | 6773 | dir->directory = directory; |
| 6779 | dir->index = 0; | 6774 | dir->index = 0; |
| 6780 | 6775 | ||
| 6781 | if (!directory) | 6776 | /* Allocate a temporary file descriptor for this ersatz root. This is |
| 6782 | { | 6777 | required regardless of the value of DIRECTORY, as android_fstatat |
| 6783 | /* Allocate a temporary file descriptor for this ersatz root. */ | 6778 | and co. will not defer to the VFS layer if a directory file |
| 6784 | if (root_fd < 0) | 6779 | descriptor is not known to be special. */ |
| 6785 | root_fd = open ("/dev/null", O_RDONLY | O_CLOEXEC); | 6780 | if (root_fd < 0) |
| 6786 | root_fd_references++; | 6781 | root_fd = open ("/dev/null", O_RDONLY | O_CLOEXEC); |
| 6787 | } | 6782 | root_fd_references++; |
| 6788 | 6783 | ||
| 6789 | return &dir->vdir; | 6784 | return &dir->vdir; |
| 6790 | } | 6785 | } |