diff options
| author | Po Lu | 2023-10-28 10:02:58 +0800 |
|---|---|---|
| committer | Po Lu | 2023-10-28 10:19:41 +0800 |
| commit | f0d42c5e47eaba2c8ccee0a804965a2b71923d41 (patch) | |
| tree | d49ef9b2e71da47ed4ca845ac341b95eed6ac739 /src | |
| parent | eb6708f0ac129f2faee31b1f5517641ffb38fcdf (diff) | |
| download | emacs-f0d42c5e47eaba2c8ccee0a804965a2b71923d41.tar.gz emacs-f0d42c5e47eaba2c8ccee0a804965a2b71923d41.zip | |
Minor adjustments to Android drag and drop and content URIs
* java/org/gnu/emacs/EmacsWindow.java (EmacsWindow)
<dndXPosition, dndYPosition>: New fields initialized to -1.
(onDragEvent): Remember the position of the previous event to
avoid sending duplicates.
* src/androidvfs.c (EMACS_PATH_MAX): New define.
(android_saf_tree_rename, android_saf_tree_opendir)
(android_name_file, android_fstatat, android_faccessat)
(android_fchmodat, android_readlinkat): Use EMACS_PATH_MAX where
SAF file names might be encountered.
Diffstat (limited to 'src')
| -rw-r--r-- | src/androidvfs.c | 44 |
1 files changed, 27 insertions, 17 deletions
diff --git a/src/androidvfs.c b/src/androidvfs.c index b3d644e21a2..51558d2a375 100644 --- a/src/androidvfs.c +++ b/src/androidvfs.c | |||
| @@ -403,6 +403,16 @@ android_init_fd_class (JNIEnv *env) | |||
| 403 | 403 | ||
| 404 | 404 | ||
| 405 | 405 | ||
| 406 | /* Account for SAF file names two times as large as PATH_MAX; larger | ||
| 407 | values are prohibitively slow, but smaller values can't face up to | ||
| 408 | some long file names within several nested layers of directories. | ||
| 409 | |||
| 410 | Buffers holding components or other similar file name constitutents | ||
| 411 | which don't represent SAF files must continue to use PATH_MAX, for | ||
| 412 | that is the restriction imposed by the Unix file system. */ | ||
| 413 | |||
| 414 | #define EMACS_PATH_MAX (PATH_MAX * 2) | ||
| 415 | |||
| 406 | /* Delete redundant instances of `.' and `..' from NAME in-place. | 416 | /* Delete redundant instances of `.' and `..' from NAME in-place. |
| 407 | NAME must be *LENGTH long, excluding a mandatory trailing NULL | 417 | NAME must be *LENGTH long, excluding a mandatory trailing NULL |
| 408 | byte. | 418 | byte. |
| @@ -4990,7 +5000,7 @@ android_saf_tree_rename (struct android_vnode *src, | |||
| 4990 | { | 5000 | { |
| 4991 | char *last, *dst_last; | 5001 | char *last, *dst_last; |
| 4992 | struct android_saf_tree_vnode *vp, *vdst; | 5002 | struct android_saf_tree_vnode *vp, *vdst; |
| 4993 | char path[PATH_MAX], path1[PATH_MAX]; | 5003 | char path[EMACS_PATH_MAX], path1[EMACS_PATH_MAX]; |
| 4994 | char *fill, *dst_id; | 5004 | char *fill, *dst_id; |
| 4995 | int rc; | 5005 | int rc; |
| 4996 | 5006 | ||
| @@ -5076,8 +5086,8 @@ android_saf_tree_rename (struct android_vnode *src, | |||
| 5076 | /* The names of the source and destination directories will have | 5086 | /* The names of the source and destination directories will have |
| 5077 | to be copied to path. */ | 5087 | to be copied to path. */ |
| 5078 | 5088 | ||
| 5079 | if (last - vp->name >= PATH_MAX | 5089 | if (last - vp->name >= EMACS_PATH_MAX |
| 5080 | || dst_last - vdst->name >= PATH_MAX) | 5090 | || dst_last - vdst->name >= EMACS_PATH_MAX) |
| 5081 | { | 5091 | { |
| 5082 | errno = ENAMETOOLONG; | 5092 | errno = ENAMETOOLONG; |
| 5083 | return -1; | 5093 | return -1; |
| @@ -5191,7 +5201,7 @@ android_saf_tree_rename (struct android_vnode *src, | |||
| 5191 | directory is required, as it provides the directory whose entries | 5201 | directory is required, as it provides the directory whose entries |
| 5192 | will be modified. */ | 5202 | will be modified. */ |
| 5193 | 5203 | ||
| 5194 | if (last - vp->name >= PATH_MAX) | 5204 | if (last - vp->name >= EMACS_PATH_MAX) |
| 5195 | { | 5205 | { |
| 5196 | errno = ENAMETOOLONG; | 5206 | errno = ENAMETOOLONG; |
| 5197 | return -1; | 5207 | return -1; |
| @@ -5480,7 +5490,7 @@ android_saf_tree_opendir (struct android_vnode *vnode) | |||
| 5480 | struct android_saf_tree_vdir *dir; | 5490 | struct android_saf_tree_vdir *dir; |
| 5481 | char *fill, *end; | 5491 | char *fill, *end; |
| 5482 | jobject cursor; | 5492 | jobject cursor; |
| 5483 | char component[PATH_MAX]; | 5493 | char component[EMACS_PATH_MAX]; |
| 5484 | 5494 | ||
| 5485 | vp = (struct android_saf_tree_vnode *) vnode; | 5495 | vp = (struct android_saf_tree_vnode *) vnode; |
| 5486 | 5496 | ||
| @@ -5510,7 +5520,7 @@ android_saf_tree_opendir (struct android_vnode *vnode) | |||
| 5510 | if (!end) | 5520 | if (!end) |
| 5511 | emacs_abort (); | 5521 | emacs_abort (); |
| 5512 | 5522 | ||
| 5513 | if (end - fill >= PATH_MAX) | 5523 | if (end - fill >= EMACS_PATH_MAX) |
| 5514 | { | 5524 | { |
| 5515 | errno = ENAMETOOLONG; | 5525 | errno = ENAMETOOLONG; |
| 5516 | xfree (dir); | 5526 | xfree (dir); |
| @@ -6455,7 +6465,7 @@ android_root_name (struct android_vnode *vnode, char *name, | |||
| 6455 | least N bytes. | 6465 | least N bytes. |
| 6456 | 6466 | ||
| 6457 | NAME may be either an absolute file name or a name relative to the | 6467 | NAME may be either an absolute file name or a name relative to the |
| 6458 | current working directory. It must not be longer than PATH_MAX | 6468 | current working directory. It must not be longer than EMACS_PATH_MAX |
| 6459 | bytes. | 6469 | bytes. |
| 6460 | 6470 | ||
| 6461 | Value is NULL upon failure with errno set accordingly, or the | 6471 | Value is NULL upon failure with errno set accordingly, or the |
| @@ -6464,14 +6474,14 @@ android_root_name (struct android_vnode *vnode, char *name, | |||
| 6464 | static struct android_vnode * | 6474 | static struct android_vnode * |
| 6465 | android_name_file (const char *name) | 6475 | android_name_file (const char *name) |
| 6466 | { | 6476 | { |
| 6467 | char buffer[PATH_MAX + 1], *head; | 6477 | char buffer[EMACS_PATH_MAX + 1], *head; |
| 6468 | const char *end; | 6478 | const char *end; |
| 6469 | size_t len; | 6479 | size_t len; |
| 6470 | int nslash, c; | 6480 | int nslash, c; |
| 6471 | struct android_vnode *vp; | 6481 | struct android_vnode *vp; |
| 6472 | 6482 | ||
| 6473 | len = strlen (name); | 6483 | len = strlen (name); |
| 6474 | if (len > PATH_MAX) | 6484 | if (len > EMACS_PATH_MAX) |
| 6475 | { | 6485 | { |
| 6476 | errno = ENAMETOOLONG; | 6486 | errno = ENAMETOOLONG; |
| 6477 | return NULL; | 6487 | return NULL; |
| @@ -7009,7 +7019,7 @@ int | |||
| 7009 | android_fstatat (int dirfd, const char *restrict pathname, | 7019 | android_fstatat (int dirfd, const char *restrict pathname, |
| 7010 | struct stat *restrict statbuf, int flags) | 7020 | struct stat *restrict statbuf, int flags) |
| 7011 | { | 7021 | { |
| 7012 | char buffer[PATH_MAX + 1]; | 7022 | char buffer[EMACS_PATH_MAX + 1]; |
| 7013 | struct android_vnode *vp; | 7023 | struct android_vnode *vp; |
| 7014 | int rc; | 7024 | int rc; |
| 7015 | 7025 | ||
| @@ -7023,7 +7033,7 @@ android_fstatat (int dirfd, const char *restrict pathname, | |||
| 7023 | /* Now establish whether DIRFD is a file descriptor corresponding to | 7033 | /* Now establish whether DIRFD is a file descriptor corresponding to |
| 7024 | an open VFS directory stream. */ | 7034 | an open VFS directory stream. */ |
| 7025 | 7035 | ||
| 7026 | if (!android_fstatat_1 (dirfd, pathname, buffer, PATH_MAX + 1)) | 7036 | if (!android_fstatat_1 (dirfd, pathname, buffer, EMACS_PATH_MAX + 1)) |
| 7027 | { | 7037 | { |
| 7028 | pathname = buffer; | 7038 | pathname = buffer; |
| 7029 | goto vfs; | 7039 | goto vfs; |
| @@ -7049,7 +7059,7 @@ int | |||
| 7049 | android_faccessat (int dirfd, const char *restrict pathname, | 7059 | android_faccessat (int dirfd, const char *restrict pathname, |
| 7050 | int mode, int flags) | 7060 | int mode, int flags) |
| 7051 | { | 7061 | { |
| 7052 | char buffer[PATH_MAX + 1]; | 7062 | char buffer[EMACS_PATH_MAX + 1]; |
| 7053 | struct android_vnode *vp; | 7063 | struct android_vnode *vp; |
| 7054 | int rc; | 7064 | int rc; |
| 7055 | 7065 | ||
| @@ -7063,7 +7073,7 @@ android_faccessat (int dirfd, const char *restrict pathname, | |||
| 7063 | /* Now establish whether DIRFD is a file descriptor corresponding to | 7073 | /* Now establish whether DIRFD is a file descriptor corresponding to |
| 7064 | an open VFS directory stream. */ | 7074 | an open VFS directory stream. */ |
| 7065 | 7075 | ||
| 7066 | if (!android_fstatat_1 (dirfd, pathname, buffer, PATH_MAX + 1)) | 7076 | if (!android_fstatat_1 (dirfd, pathname, buffer, EMACS_PATH_MAX + 1)) |
| 7067 | { | 7077 | { |
| 7068 | pathname = buffer; | 7078 | pathname = buffer; |
| 7069 | goto vfs; | 7079 | goto vfs; |
| @@ -7089,7 +7099,7 @@ int | |||
| 7089 | android_fchmodat (int dirfd, const char *pathname, mode_t mode, | 7099 | android_fchmodat (int dirfd, const char *pathname, mode_t mode, |
| 7090 | int flags) | 7100 | int flags) |
| 7091 | { | 7101 | { |
| 7092 | char buffer[PATH_MAX + 1]; | 7102 | char buffer[EMACS_PATH_MAX + 1]; |
| 7093 | struct android_vnode *vp; | 7103 | struct android_vnode *vp; |
| 7094 | int rc; | 7104 | int rc; |
| 7095 | 7105 | ||
| @@ -7099,7 +7109,7 @@ android_fchmodat (int dirfd, const char *pathname, mode_t mode, | |||
| 7099 | /* Now establish whether DIRFD is a file descriptor corresponding to | 7109 | /* Now establish whether DIRFD is a file descriptor corresponding to |
| 7100 | an open VFS directory stream. */ | 7110 | an open VFS directory stream. */ |
| 7101 | 7111 | ||
| 7102 | if (!android_fstatat_1 (dirfd, pathname, buffer, PATH_MAX + 1)) | 7112 | if (!android_fstatat_1 (dirfd, pathname, buffer, EMACS_PATH_MAX + 1)) |
| 7103 | { | 7113 | { |
| 7104 | pathname = buffer; | 7114 | pathname = buffer; |
| 7105 | goto vfs; | 7115 | goto vfs; |
| @@ -7125,7 +7135,7 @@ ssize_t | |||
| 7125 | android_readlinkat (int dirfd, const char *restrict pathname, | 7135 | android_readlinkat (int dirfd, const char *restrict pathname, |
| 7126 | char *restrict buf, size_t bufsiz) | 7136 | char *restrict buf, size_t bufsiz) |
| 7127 | { | 7137 | { |
| 7128 | char buffer[PATH_MAX + 1]; | 7138 | char buffer[EMACS_PATH_MAX + 1]; |
| 7129 | struct android_vnode *vp; | 7139 | struct android_vnode *vp; |
| 7130 | ssize_t rc; | 7140 | ssize_t rc; |
| 7131 | 7141 | ||
| @@ -7135,7 +7145,7 @@ android_readlinkat (int dirfd, const char *restrict pathname, | |||
| 7135 | /* Now establish whether DIRFD is a file descriptor corresponding to | 7145 | /* Now establish whether DIRFD is a file descriptor corresponding to |
| 7136 | an open VFS directory stream. */ | 7146 | an open VFS directory stream. */ |
| 7137 | 7147 | ||
| 7138 | if (!android_fstatat_1 (dirfd, pathname, buffer, PATH_MAX + 1)) | 7148 | if (!android_fstatat_1 (dirfd, pathname, buffer, EMACS_PATH_MAX + 1)) |
| 7139 | { | 7149 | { |
| 7140 | pathname = buffer; | 7150 | pathname = buffer; |
| 7141 | goto vfs; | 7151 | goto vfs; |