aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2024-06-19 16:41:59 +0800
committerPo Lu2024-06-19 16:41:59 +0800
commitdb18613c962ea4db42aa9bdd4c211f6b8312bd49 (patch)
treeb7b2e47967c5a75fe33c8ecc78770c7ca0a6bad8 /src
parent5fceb53856583384e7adeab52494d1afc6eae666 (diff)
downloademacs-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.c41
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 *);
649static int android_unix_rmdir (struct android_vnode *); 650static int android_unix_rmdir (struct android_vnode *);
650static int android_unix_rename (struct android_vnode *, 651static int android_unix_rename (struct android_vnode *,
651 struct android_vnode *, bool); 652 struct android_vnode *, bool);
652static int android_unix_stat (struct android_vnode *, struct stat *); 653static int android_unix_stat (struct android_vnode *, struct stat *, int);
653static int android_unix_access (struct android_vnode *, int); 654static int android_unix_access (struct android_vnode *, int);
654static int android_unix_mkdir (struct android_vnode *, mode_t); 655static int android_unix_mkdir (struct android_vnode *, mode_t);
655static int android_unix_chmod (struct android_vnode *, mode_t, int); 656static 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
898static int 899static int
899android_unix_stat (struct android_vnode *vnode, struct stat *statb) 900android_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
907static int 909static int
@@ -1669,7 +1671,7 @@ static int android_afs_symlink (const char *, struct android_vnode *);
1669static int android_afs_rmdir (struct android_vnode *); 1671static int android_afs_rmdir (struct android_vnode *);
1670static int android_afs_rename (struct android_vnode *, 1672static int android_afs_rename (struct android_vnode *,
1671 struct android_vnode *, bool); 1673 struct android_vnode *, bool);
1672static int android_afs_stat (struct android_vnode *, struct stat *); 1674static int android_afs_stat (struct android_vnode *, struct stat *, int);
1673static int android_afs_access (struct android_vnode *, int); 1675static int android_afs_access (struct android_vnode *, int);
1674static int android_afs_mkdir (struct android_vnode *, mode_t); 1676static int android_afs_mkdir (struct android_vnode *, mode_t);
1675static int android_afs_chmod (struct android_vnode *, mode_t, int); 1677static 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
2092static int 2094static int
2093android_afs_stat (struct android_vnode *vnode, struct stat *statb) 2095android_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 *);
2506static int android_content_rmdir (struct android_vnode *); 2509static int android_content_rmdir (struct android_vnode *);
2507static int android_content_rename (struct android_vnode *, 2510static int android_content_rename (struct android_vnode *,
2508 struct android_vnode *, bool); 2511 struct android_vnode *, bool);
2509static int android_content_stat (struct android_vnode *, struct stat *); 2512static int android_content_stat (struct android_vnode *, struct stat *, int);
2510static int android_content_access (struct android_vnode *, int); 2513static int android_content_access (struct android_vnode *, int);
2511static int android_content_mkdir (struct android_vnode *, mode_t); 2514static int android_content_mkdir (struct android_vnode *, mode_t);
2512static int android_content_chmod (struct android_vnode *, mode_t, int); 2515static int android_content_chmod (struct android_vnode *, mode_t, int);
@@ -2696,7 +2699,7 @@ android_content_rename (struct android_vnode *src,
2696 2699
2697static int 2700static int
2698android_content_stat (struct android_vnode *vnode, 2701android_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 *);
3190static int android_authority_rmdir (struct android_vnode *); 3193static int android_authority_rmdir (struct android_vnode *);
3191static int android_authority_rename (struct android_vnode *, 3194static int android_authority_rename (struct android_vnode *,
3192 struct android_vnode *, bool); 3195 struct android_vnode *, bool);
3193static int android_authority_stat (struct android_vnode *, struct stat *); 3196static int android_authority_stat (struct android_vnode *, struct stat *, int);
3194static int android_authority_access (struct android_vnode *, int); 3197static int android_authority_access (struct android_vnode *, int);
3195static int android_authority_mkdir (struct android_vnode *, mode_t); 3198static int android_authority_mkdir (struct android_vnode *, mode_t);
3196static int android_authority_chmod (struct android_vnode *, mode_t, int); 3199static int android_authority_chmod (struct android_vnode *, mode_t, int);
@@ -3415,7 +3418,7 @@ android_authority_rename (struct android_vnode *src,
3415 3418
3416static int 3419static int
3417android_authority_stat (struct android_vnode *vnode, 3420android_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 *);
3642static int android_saf_root_rmdir (struct android_vnode *); 3645static int android_saf_root_rmdir (struct android_vnode *);
3643static int android_saf_root_rename (struct android_vnode *, 3646static int android_saf_root_rename (struct android_vnode *,
3644 struct android_vnode *, bool); 3647 struct android_vnode *, bool);
3645static int android_saf_root_stat (struct android_vnode *, struct stat *); 3648static int android_saf_root_stat (struct android_vnode *, struct stat *, int);
3646static int android_saf_root_access (struct android_vnode *, int); 3649static int android_saf_root_access (struct android_vnode *, int);
3647static int android_saf_root_mkdir (struct android_vnode *, mode_t); 3650static int android_saf_root_mkdir (struct android_vnode *, mode_t);
3648static int android_saf_root_chmod (struct android_vnode *, mode_t, int); 3651static 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
3871static int 3874static int
3872android_saf_root_stat (struct android_vnode *vnode, 3875android_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 *);
4706static int android_saf_tree_rmdir (struct android_vnode *); 4709static int android_saf_tree_rmdir (struct android_vnode *);
4707static int android_saf_tree_rename (struct android_vnode *, 4710static int android_saf_tree_rename (struct android_vnode *,
4708 struct android_vnode *, bool); 4711 struct android_vnode *, bool);
4709static int android_saf_tree_stat (struct android_vnode *, struct stat *); 4712static int android_saf_tree_stat (struct android_vnode *, struct stat *, int);
4710static int android_saf_tree_access (struct android_vnode *, int); 4713static int android_saf_tree_access (struct android_vnode *, int);
4711static int android_saf_tree_mkdir (struct android_vnode *, mode_t); 4714static int android_saf_tree_mkdir (struct android_vnode *, mode_t);
4712static int android_saf_tree_chmod (struct android_vnode *, mode_t, int); 4715static 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
5370static int 5373static int
5371android_saf_tree_stat (struct android_vnode *vnode, 5374android_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 *);
6156static int android_saf_new_rmdir (struct android_vnode *); 6159static int android_saf_new_rmdir (struct android_vnode *);
6157static int android_saf_new_rename (struct android_vnode *, 6160static int android_saf_new_rename (struct android_vnode *,
6158 struct android_vnode *, bool); 6161 struct android_vnode *, bool);
6159static int android_saf_new_stat (struct android_vnode *, struct stat *); 6162static int android_saf_new_stat (struct android_vnode *, struct stat *, int);
6160static int android_saf_new_access (struct android_vnode *, int); 6163static int android_saf_new_access (struct android_vnode *, int);
6161static int android_saf_new_mkdir (struct android_vnode *, mode_t); 6164static int android_saf_new_mkdir (struct android_vnode *, mode_t);
6162static int android_saf_new_chmod (struct android_vnode *, mode_t, int); 6165static 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
6336static int 6339static int
6337android_saf_new_stat (struct android_vnode *vnode, 6340android_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}