diff options
| author | Po Lu | 2024-06-19 16:41:59 +0800 |
|---|---|---|
| committer | Po Lu | 2024-06-19 16:41:59 +0800 |
| commit | db18613c962ea4db42aa9bdd4c211f6b8312bd49 (patch) | |
| tree | b7b2e47967c5a75fe33c8ecc78770c7ca0a6bad8 /src | |
| parent | 5fceb53856583384e7adeab52494d1afc6eae666 (diff) | |
| download | emacs-db18613c962ea4db42aa9bdd4c211f6b8312bd49.tar.gz emacs-db18613c962ea4db42aa9bdd4c211f6b8312bd49.zip | |
Don't follow symlinks in returning directory attributes of /
* src/androidvfs.c (struct android_vops) <stat>: New argument
for flags.
(android_unix_stat): Implement in terms of fstatat, not stat,
and provide flags to the same.
(android_afs_stat, android_content_stat, android_authority_stat)
(android_saf_root_stat, android_saf_tree_stat)
(android_saf_new_stat, android_fstatat): Adjust to match.
Diffstat (limited to 'src')
| -rw-r--r-- | src/androidvfs.c | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/src/androidvfs.c b/src/androidvfs.c index 28a23920533..346eb639b11 100644 --- a/src/androidvfs.c +++ b/src/androidvfs.c | |||
| @@ -203,9 +203,10 @@ struct android_vops | |||
| 203 | Value is otherwise the same as `rename'. */ | 203 | Value is otherwise the same as `rename'. */ |
| 204 | int (*rename) (struct android_vnode *, struct android_vnode *, bool); | 204 | int (*rename) (struct android_vnode *, struct android_vnode *, bool); |
| 205 | 205 | ||
| 206 | /* Return statistics for the specified VNODE. | 206 | /* Return statistics for the specified VNODE, and FLAGS, as in a call |
| 207 | Value and errno are the same as with Unix `stat'. */ | 207 | to `fstatat'. Value and errno are the same as with Unix |
| 208 | int (*stat) (struct android_vnode *, struct stat *); | 208 | `stat'. */ |
| 209 | int (*stat) (struct android_vnode *, struct stat *, int); | ||
| 209 | 210 | ||
| 210 | /* Return whether or not VNODE is accessible. | 211 | /* Return whether or not VNODE is accessible. |
| 211 | Value, errno and MODE are the same as with Unix `access'. */ | 212 | Value, errno and MODE are the same as with Unix `access'. */ |
| @@ -649,7 +650,7 @@ static int android_unix_symlink (const char *, struct android_vnode *); | |||
| 649 | static int android_unix_rmdir (struct android_vnode *); | 650 | static int android_unix_rmdir (struct android_vnode *); |
| 650 | static int android_unix_rename (struct android_vnode *, | 651 | static int android_unix_rename (struct android_vnode *, |
| 651 | struct android_vnode *, bool); | 652 | struct android_vnode *, bool); |
| 652 | static int android_unix_stat (struct android_vnode *, struct stat *); | 653 | static int android_unix_stat (struct android_vnode *, struct stat *, int); |
| 653 | static int android_unix_access (struct android_vnode *, int); | 654 | static int android_unix_access (struct android_vnode *, int); |
| 654 | static int android_unix_mkdir (struct android_vnode *, mode_t); | 655 | static int android_unix_mkdir (struct android_vnode *, mode_t); |
| 655 | static int android_unix_chmod (struct android_vnode *, mode_t, int); | 656 | static int android_unix_chmod (struct android_vnode *, mode_t, int); |
| @@ -896,12 +897,13 @@ android_unix_rename (struct android_vnode *src, | |||
| 896 | } | 897 | } |
| 897 | 898 | ||
| 898 | static int | 899 | static int |
| 899 | android_unix_stat (struct android_vnode *vnode, struct stat *statb) | 900 | android_unix_stat (struct android_vnode *vnode, struct stat *statb, |
| 901 | int flags) | ||
| 900 | { | 902 | { |
| 901 | struct android_unix_vnode *vp; | 903 | struct android_unix_vnode *vp; |
| 902 | 904 | ||
| 903 | vp = (struct android_unix_vnode *) vnode; | 905 | vp = (struct android_unix_vnode *) vnode; |
| 904 | return stat (vp->name, statb); | 906 | return fstatat (AT_FDCWD, vp->name, statb, flags); |
| 905 | } | 907 | } |
| 906 | 908 | ||
| 907 | static int | 909 | static int |
| @@ -1669,7 +1671,7 @@ static int android_afs_symlink (const char *, struct android_vnode *); | |||
| 1669 | static int android_afs_rmdir (struct android_vnode *); | 1671 | static int android_afs_rmdir (struct android_vnode *); |
| 1670 | static int android_afs_rename (struct android_vnode *, | 1672 | static int android_afs_rename (struct android_vnode *, |
| 1671 | struct android_vnode *, bool); | 1673 | struct android_vnode *, bool); |
| 1672 | static int android_afs_stat (struct android_vnode *, struct stat *); | 1674 | static int android_afs_stat (struct android_vnode *, struct stat *, int); |
| 1673 | static int android_afs_access (struct android_vnode *, int); | 1675 | static int android_afs_access (struct android_vnode *, int); |
| 1674 | static int android_afs_mkdir (struct android_vnode *, mode_t); | 1676 | static int android_afs_mkdir (struct android_vnode *, mode_t); |
| 1675 | static int android_afs_chmod (struct android_vnode *, mode_t, int); | 1677 | static int android_afs_chmod (struct android_vnode *, mode_t, int); |
| @@ -2090,7 +2092,8 @@ android_afs_rename (struct android_vnode *src, struct android_vnode *dst, | |||
| 2090 | } | 2092 | } |
| 2091 | 2093 | ||
| 2092 | static int | 2094 | static int |
| 2093 | android_afs_stat (struct android_vnode *vnode, struct stat *statb) | 2095 | android_afs_stat (struct android_vnode *vnode, struct stat *statb, |
| 2096 | int flags) | ||
| 2094 | { | 2097 | { |
| 2095 | const char *dir; | 2098 | const char *dir; |
| 2096 | struct android_afs_vnode *vp; | 2099 | struct android_afs_vnode *vp; |
| @@ -2506,7 +2509,7 @@ static int android_content_symlink (const char *, struct android_vnode *); | |||
| 2506 | static int android_content_rmdir (struct android_vnode *); | 2509 | static int android_content_rmdir (struct android_vnode *); |
| 2507 | static int android_content_rename (struct android_vnode *, | 2510 | static int android_content_rename (struct android_vnode *, |
| 2508 | struct android_vnode *, bool); | 2511 | struct android_vnode *, bool); |
| 2509 | static int android_content_stat (struct android_vnode *, struct stat *); | 2512 | static int android_content_stat (struct android_vnode *, struct stat *, int); |
| 2510 | static int android_content_access (struct android_vnode *, int); | 2513 | static int android_content_access (struct android_vnode *, int); |
| 2511 | static int android_content_mkdir (struct android_vnode *, mode_t); | 2514 | static int android_content_mkdir (struct android_vnode *, mode_t); |
| 2512 | static int android_content_chmod (struct android_vnode *, mode_t, int); | 2515 | static int android_content_chmod (struct android_vnode *, mode_t, int); |
| @@ -2696,7 +2699,7 @@ android_content_rename (struct android_vnode *src, | |||
| 2696 | 2699 | ||
| 2697 | static int | 2700 | static int |
| 2698 | android_content_stat (struct android_vnode *vnode, | 2701 | android_content_stat (struct android_vnode *vnode, |
| 2699 | struct stat *statb) | 2702 | struct stat *statb, int flags) |
| 2700 | { | 2703 | { |
| 2701 | memset (statb, 0, sizeof *statb); | 2704 | memset (statb, 0, sizeof *statb); |
| 2702 | 2705 | ||
| @@ -3190,7 +3193,7 @@ static int android_authority_symlink (const char *, struct android_vnode *); | |||
| 3190 | static int android_authority_rmdir (struct android_vnode *); | 3193 | static int android_authority_rmdir (struct android_vnode *); |
| 3191 | static int android_authority_rename (struct android_vnode *, | 3194 | static int android_authority_rename (struct android_vnode *, |
| 3192 | struct android_vnode *, bool); | 3195 | struct android_vnode *, bool); |
| 3193 | static int android_authority_stat (struct android_vnode *, struct stat *); | 3196 | static int android_authority_stat (struct android_vnode *, struct stat *, int); |
| 3194 | static int android_authority_access (struct android_vnode *, int); | 3197 | static int android_authority_access (struct android_vnode *, int); |
| 3195 | static int android_authority_mkdir (struct android_vnode *, mode_t); | 3198 | static int android_authority_mkdir (struct android_vnode *, mode_t); |
| 3196 | static int android_authority_chmod (struct android_vnode *, mode_t, int); | 3199 | static int android_authority_chmod (struct android_vnode *, mode_t, int); |
| @@ -3415,7 +3418,7 @@ android_authority_rename (struct android_vnode *src, | |||
| 3415 | 3418 | ||
| 3416 | static int | 3419 | static int |
| 3417 | android_authority_stat (struct android_vnode *vnode, | 3420 | android_authority_stat (struct android_vnode *vnode, |
| 3418 | struct stat *statb) | 3421 | struct stat *statb, int flags) |
| 3419 | { | 3422 | { |
| 3420 | int rc, fd, save_errno; | 3423 | int rc, fd, save_errno; |
| 3421 | struct android_authority_vnode *vp; | 3424 | struct android_authority_vnode *vp; |
| @@ -3642,7 +3645,7 @@ static int android_saf_root_symlink (const char *, struct android_vnode *); | |||
| 3642 | static int android_saf_root_rmdir (struct android_vnode *); | 3645 | static int android_saf_root_rmdir (struct android_vnode *); |
| 3643 | static int android_saf_root_rename (struct android_vnode *, | 3646 | static int android_saf_root_rename (struct android_vnode *, |
| 3644 | struct android_vnode *, bool); | 3647 | struct android_vnode *, bool); |
| 3645 | static int android_saf_root_stat (struct android_vnode *, struct stat *); | 3648 | static int android_saf_root_stat (struct android_vnode *, struct stat *, int); |
| 3646 | static int android_saf_root_access (struct android_vnode *, int); | 3649 | static int android_saf_root_access (struct android_vnode *, int); |
| 3647 | static int android_saf_root_mkdir (struct android_vnode *, mode_t); | 3650 | static int android_saf_root_mkdir (struct android_vnode *, mode_t); |
| 3648 | static int android_saf_root_chmod (struct android_vnode *, mode_t, int); | 3651 | static int android_saf_root_chmod (struct android_vnode *, mode_t, int); |
| @@ -3870,7 +3873,7 @@ android_saf_root_rename (struct android_vnode *src, | |||
| 3870 | 3873 | ||
| 3871 | static int | 3874 | static int |
| 3872 | android_saf_root_stat (struct android_vnode *vnode, | 3875 | android_saf_root_stat (struct android_vnode *vnode, |
| 3873 | struct stat *statb) | 3876 | struct stat *statb, int flags) |
| 3874 | { | 3877 | { |
| 3875 | struct android_saf_root_vnode *vp; | 3878 | struct android_saf_root_vnode *vp; |
| 3876 | 3879 | ||
| @@ -4706,7 +4709,7 @@ static int android_saf_tree_symlink (const char *, struct android_vnode *); | |||
| 4706 | static int android_saf_tree_rmdir (struct android_vnode *); | 4709 | static int android_saf_tree_rmdir (struct android_vnode *); |
| 4707 | static int android_saf_tree_rename (struct android_vnode *, | 4710 | static int android_saf_tree_rename (struct android_vnode *, |
| 4708 | struct android_vnode *, bool); | 4711 | struct android_vnode *, bool); |
| 4709 | static int android_saf_tree_stat (struct android_vnode *, struct stat *); | 4712 | static int android_saf_tree_stat (struct android_vnode *, struct stat *, int); |
| 4710 | static int android_saf_tree_access (struct android_vnode *, int); | 4713 | static int android_saf_tree_access (struct android_vnode *, int); |
| 4711 | static int android_saf_tree_mkdir (struct android_vnode *, mode_t); | 4714 | static int android_saf_tree_mkdir (struct android_vnode *, mode_t); |
| 4712 | static int android_saf_tree_chmod (struct android_vnode *, mode_t, int); | 4715 | static int android_saf_tree_chmod (struct android_vnode *, mode_t, int); |
| @@ -5369,7 +5372,7 @@ android_saf_tree_rename (struct android_vnode *src, | |||
| 5369 | 5372 | ||
| 5370 | static int | 5373 | static int |
| 5371 | android_saf_tree_stat (struct android_vnode *vnode, | 5374 | android_saf_tree_stat (struct android_vnode *vnode, |
| 5372 | struct stat *statb) | 5375 | struct stat *statb, int flags) |
| 5373 | { | 5376 | { |
| 5374 | struct android_saf_tree_vnode *vp; | 5377 | struct android_saf_tree_vnode *vp; |
| 5375 | 5378 | ||
| @@ -6156,7 +6159,7 @@ static int android_saf_new_symlink (const char *, struct android_vnode *); | |||
| 6156 | static int android_saf_new_rmdir (struct android_vnode *); | 6159 | static int android_saf_new_rmdir (struct android_vnode *); |
| 6157 | static int android_saf_new_rename (struct android_vnode *, | 6160 | static int android_saf_new_rename (struct android_vnode *, |
| 6158 | struct android_vnode *, bool); | 6161 | struct android_vnode *, bool); |
| 6159 | static int android_saf_new_stat (struct android_vnode *, struct stat *); | 6162 | static int android_saf_new_stat (struct android_vnode *, struct stat *, int); |
| 6160 | static int android_saf_new_access (struct android_vnode *, int); | 6163 | static int android_saf_new_access (struct android_vnode *, int); |
| 6161 | static int android_saf_new_mkdir (struct android_vnode *, mode_t); | 6164 | static int android_saf_new_mkdir (struct android_vnode *, mode_t); |
| 6162 | static int android_saf_new_chmod (struct android_vnode *, mode_t, int); | 6165 | static int android_saf_new_chmod (struct android_vnode *, mode_t, int); |
| @@ -6335,7 +6338,7 @@ android_saf_new_rename (struct android_vnode *src, | |||
| 6335 | 6338 | ||
| 6336 | static int | 6339 | static int |
| 6337 | android_saf_new_stat (struct android_vnode *vnode, | 6340 | android_saf_new_stat (struct android_vnode *vnode, |
| 6338 | struct stat *statb) | 6341 | struct stat *statb, int flags) |
| 6339 | { | 6342 | { |
| 6340 | errno = ENOENT; | 6343 | errno = ENOENT; |
| 6341 | return -1; | 6344 | return -1; |
| @@ -7418,7 +7421,7 @@ android_fstatat (int dirfd, const char *restrict pathname, | |||
| 7418 | if (!vp) | 7421 | if (!vp) |
| 7419 | return -1; | 7422 | return -1; |
| 7420 | 7423 | ||
| 7421 | rc = (*vp->ops->stat) (vp, statbuf); | 7424 | rc = (*vp->ops->stat) (vp, statbuf, flags); |
| 7422 | (*vp->ops->close) (vp); | 7425 | (*vp->ops->close) (vp); |
| 7423 | return rc; | 7426 | return rc; |
| 7424 | } | 7427 | } |