diff options
| author | Po Lu | 2023-03-05 14:53:12 +0800 |
|---|---|---|
| committer | Po Lu | 2023-03-05 14:53:12 +0800 |
| commit | 0760d5cc985e449555a9b3879707e91f0d04111c (patch) | |
| tree | 585bf9414cc45b22bb32e6cb86a8ff82360e9de8 /src | |
| parent | e0f400216121508632625701b60a50525bd34e9f (diff) | |
| download | emacs-0760d5cc985e449555a9b3879707e91f0d04111c.tar.gz emacs-0760d5cc985e449555a9b3879707e91f0d04111c.zip | |
Update Android port
* etc/PROBLEMS: Document problem with default monospace font.
* src/fileio.c (check_mutable_filename): Check /content as well.
(Fcopy_file, Fdelete_directory_internal, Fdelete_file)
(Frename_file, Fadd_name_to_file, Fmake_symbolic_link)
(Fset_file_modes, Fset_file_times, Ffile_newer_than_file_p)
(write_region): Adjust accordingly.
(Fset_visited_file_modtime): Remove unnecessary restriction.
* src/filelock.c (make_lock_file_name): Don't interlock files
under /assets and /content.
* src/inotify.c (Finotify_add_watch): Fix typo.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fileio.c | 47 | ||||
| -rw-r--r-- | src/filelock.c | 27 | ||||
| -rw-r--r-- | src/inotify.c | 2 |
3 files changed, 56 insertions, 20 deletions
diff --git a/src/fileio.c b/src/fileio.c index 375019c6fb6..7bc9800aaf8 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -147,18 +147,31 @@ static bool e_write (int, Lisp_Object, ptrdiff_t, ptrdiff_t, | |||
| 147 | 147 | ||
| 148 | 148 | ||
| 149 | /* Check that ENCODED does not lie on any special directory whose | 149 | /* Check that ENCODED does not lie on any special directory whose |
| 150 | contents are read only. Signal a `file-error' if it does. */ | 150 | contents are read only. Signal a `file-error' if it does. |
| 151 | |||
| 152 | If WRITE, then don't check that the file lies on `/content' on | ||
| 153 | Android. This special exception allows writing to content | ||
| 154 | provider-supplied files. */ | ||
| 151 | 155 | ||
| 152 | static void | 156 | static void |
| 153 | check_mutable_filename (Lisp_Object encoded) | 157 | check_mutable_filename (Lisp_Object encoded, bool write) |
| 154 | { | 158 | { |
| 155 | #if defined HAVE_ANDROID && !defined ANDROID_STUBIFY | 159 | #if defined HAVE_ANDROID && !defined ANDROID_STUBIFY |
| 156 | if (!strcmp (SSDATA (encoded), "/assets") | 160 | if (!strcmp (SSDATA (encoded), "/assets") |
| 157 | || !strncmp (SSDATA (encoded), "/assets/", | 161 | || !strncmp (SSDATA (encoded), "/assets/", |
| 158 | sizeof "/assets/" - 1)) | 162 | sizeof "/assets/" - 1)) |
| 159 | xsignal2 (Qfile_error, | 163 | xsignal2 (Qfile_error, |
| 160 | build_string ("File lies on read-" | 164 | build_string ("File lies on read-only directory"), |
| 161 | "only directory"), | 165 | encoded); |
| 166 | |||
| 167 | if (write) | ||
| 168 | return; | ||
| 169 | |||
| 170 | if (!strcmp (SSDATA (encoded), "/content") | ||
| 171 | || !strncmp (SSDATA (encoded), "/content/", | ||
| 172 | sizeof "/content/" - 1)) | ||
| 173 | xsignal2 (Qfile_error, | ||
| 174 | build_string ("File lies on read-only directory"), | ||
| 162 | encoded); | 175 | encoded); |
| 163 | #endif | 176 | #endif |
| 164 | } | 177 | } |
| @@ -2228,7 +2241,7 @@ permissions. */) | |||
| 2228 | 2241 | ||
| 2229 | encoded_file = ENCODE_FILE (file); | 2242 | encoded_file = ENCODE_FILE (file); |
| 2230 | encoded_newname = ENCODE_FILE (newname); | 2243 | encoded_newname = ENCODE_FILE (newname); |
| 2231 | check_mutable_filename (encoded_newname); | 2244 | check_mutable_filename (encoded_newname, true); |
| 2232 | 2245 | ||
| 2233 | #ifdef WINDOWSNT | 2246 | #ifdef WINDOWSNT |
| 2234 | if (NILP (ok_if_already_exists) | 2247 | if (NILP (ok_if_already_exists) |
| @@ -2488,7 +2501,7 @@ DEFUN ("delete-directory-internal", Fdelete_directory_internal, | |||
| 2488 | encoded_dir = ENCODE_FILE (directory); | 2501 | encoded_dir = ENCODE_FILE (directory); |
| 2489 | dir = SSDATA (encoded_dir); | 2502 | dir = SSDATA (encoded_dir); |
| 2490 | 2503 | ||
| 2491 | check_mutable_filename (encoded_dir); | 2504 | check_mutable_filename (encoded_dir, false); |
| 2492 | 2505 | ||
| 2493 | if (rmdir (dir) != 0) | 2506 | if (rmdir (dir) != 0) |
| 2494 | report_file_error ("Removing directory", directory); | 2507 | report_file_error ("Removing directory", directory); |
| @@ -2529,7 +2542,7 @@ With a prefix argument, TRASH is nil. */) | |||
| 2529 | return call1 (Qmove_file_to_trash, filename); | 2542 | return call1 (Qmove_file_to_trash, filename); |
| 2530 | 2543 | ||
| 2531 | encoded_file = ENCODE_FILE (filename); | 2544 | encoded_file = ENCODE_FILE (filename); |
| 2532 | check_mutable_filename (encoded_file); | 2545 | check_mutable_filename (encoded_file, false); |
| 2533 | 2546 | ||
| 2534 | if (unlink (SSDATA (encoded_file)) != 0 && errno != ENOENT) | 2547 | if (unlink (SSDATA (encoded_file)) != 0 && errno != ENOENT) |
| 2535 | report_file_error ("Removing old name", filename); | 2548 | report_file_error ("Removing old name", filename); |
| @@ -2687,8 +2700,8 @@ This is what happens in interactive use with M-x. */) | |||
| 2687 | 2700 | ||
| 2688 | encoded_file = ENCODE_FILE (file); | 2701 | encoded_file = ENCODE_FILE (file); |
| 2689 | encoded_newname = ENCODE_FILE (newname); | 2702 | encoded_newname = ENCODE_FILE (newname); |
| 2690 | check_mutable_filename (encoded_file); | 2703 | check_mutable_filename (encoded_file, false); |
| 2691 | check_mutable_filename (encoded_newname); | 2704 | check_mutable_filename (encoded_newname, false); |
| 2692 | 2705 | ||
| 2693 | bool plain_rename = (case_only_rename | 2706 | bool plain_rename = (case_only_rename |
| 2694 | || (!NILP (ok_if_already_exists) | 2707 | || (!NILP (ok_if_already_exists) |
| @@ -2800,8 +2813,8 @@ This is what happens in interactive use with M-x. */) | |||
| 2800 | 2813 | ||
| 2801 | encoded_file = ENCODE_FILE (file); | 2814 | encoded_file = ENCODE_FILE (file); |
| 2802 | encoded_newname = ENCODE_FILE (newname); | 2815 | encoded_newname = ENCODE_FILE (newname); |
| 2803 | check_mutable_filename (encoded_file); | 2816 | check_mutable_filename (encoded_file, false); |
| 2804 | check_mutable_filename (encoded_newname); | 2817 | check_mutable_filename (encoded_newname, false); |
| 2805 | 2818 | ||
| 2806 | if (link (SSDATA (encoded_file), SSDATA (encoded_newname)) == 0) | 2819 | if (link (SSDATA (encoded_file), SSDATA (encoded_newname)) == 0) |
| 2807 | return Qnil; | 2820 | return Qnil; |
| @@ -2855,8 +2868,8 @@ This happens for interactive use with M-x. */) | |||
| 2855 | 2868 | ||
| 2856 | encoded_target = ENCODE_FILE (target); | 2869 | encoded_target = ENCODE_FILE (target); |
| 2857 | encoded_linkname = ENCODE_FILE (linkname); | 2870 | encoded_linkname = ENCODE_FILE (linkname); |
| 2858 | check_mutable_filename (encoded_target); | 2871 | check_mutable_filename (encoded_target, false); |
| 2859 | check_mutable_filename (encoded_linkname); | 2872 | check_mutable_filename (encoded_linkname, false); |
| 2860 | 2873 | ||
| 2861 | if (symlink (SSDATA (encoded_target), SSDATA (encoded_linkname)) == 0) | 2874 | if (symlink (SSDATA (encoded_target), SSDATA (encoded_linkname)) == 0) |
| 2862 | return Qnil; | 2875 | return Qnil; |
| @@ -3598,7 +3611,7 @@ command from GNU Coreutils. */) | |||
| 3598 | return call4 (handler, Qset_file_modes, absname, mode, flag); | 3611 | return call4 (handler, Qset_file_modes, absname, mode, flag); |
| 3599 | 3612 | ||
| 3600 | encoded = ENCODE_FILE (absname); | 3613 | encoded = ENCODE_FILE (absname); |
| 3601 | check_mutable_filename (encoded); | 3614 | check_mutable_filename (encoded, false); |
| 3602 | char *fname = SSDATA (encoded); | 3615 | char *fname = SSDATA (encoded); |
| 3603 | mode_t imode = XFIXNUM (mode) & 07777; | 3616 | mode_t imode = XFIXNUM (mode) & 07777; |
| 3604 | if (fchmodat (AT_FDCWD, fname, imode, nofollow) != 0) | 3617 | if (fchmodat (AT_FDCWD, fname, imode, nofollow) != 0) |
| @@ -3671,7 +3684,7 @@ TIMESTAMP is in the format of `current-time'. */) | |||
| 3671 | return call4 (handler, Qset_file_times, absname, timestamp, flag); | 3684 | return call4 (handler, Qset_file_times, absname, timestamp, flag); |
| 3672 | 3685 | ||
| 3673 | Lisp_Object encoded_absname = ENCODE_FILE (absname); | 3686 | Lisp_Object encoded_absname = ENCODE_FILE (absname); |
| 3674 | check_mutable_filename (encoded_absname); | 3687 | check_mutable_filename (encoded_absname, false); |
| 3675 | 3688 | ||
| 3676 | if (utimensat (AT_FDCWD, SSDATA (encoded_absname), ts, nofollow) != 0) | 3689 | if (utimensat (AT_FDCWD, SSDATA (encoded_absname), ts, nofollow) != 0) |
| 3677 | { | 3690 | { |
| @@ -3722,7 +3735,6 @@ otherwise, if FILE2 does not exist, the answer is t. */) | |||
| 3722 | return call3 (handler, Qfile_newer_than_file_p, absname1, absname2); | 3735 | return call3 (handler, Qfile_newer_than_file_p, absname1, absname2); |
| 3723 | 3736 | ||
| 3724 | encoded = ENCODE_FILE (absname1); | 3737 | encoded = ENCODE_FILE (absname1); |
| 3725 | check_mutable_filename (encoded); | ||
| 3726 | 3738 | ||
| 3727 | int err1; | 3739 | int err1; |
| 3728 | if (emacs_fstatat (AT_FDCWD, SSDATA (encoded), &st1, 0) == 0) | 3740 | if (emacs_fstatat (AT_FDCWD, SSDATA (encoded), &st1, 0) == 0) |
| @@ -5368,6 +5380,8 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename, | |||
| 5368 | } | 5380 | } |
| 5369 | 5381 | ||
| 5370 | encoded_filename = ENCODE_FILE (filename); | 5382 | encoded_filename = ENCODE_FILE (filename); |
| 5383 | check_mutable_filename (encoded_filename, false); | ||
| 5384 | |||
| 5371 | fn = SSDATA (encoded_filename); | 5385 | fn = SSDATA (encoded_filename); |
| 5372 | open_flags = O_WRONLY | O_CREAT; | 5386 | open_flags = O_WRONLY | O_CREAT; |
| 5373 | open_flags |= EQ (mustbenew, Qexcl) ? O_EXCL : !NILP (append) ? 0 : O_TRUNC; | 5387 | open_flags |= EQ (mustbenew, Qexcl) ? O_EXCL : !NILP (append) ? 0 : O_TRUNC; |
| @@ -5942,7 +5956,6 @@ in `current-time' or an integer flag as returned by `visited-file-modtime'. */) | |||
| 5942 | return call2 (handler, Qset_visited_file_modtime, Qnil); | 5956 | return call2 (handler, Qset_visited_file_modtime, Qnil); |
| 5943 | 5957 | ||
| 5944 | encoded = ENCODE_FILE (filename); | 5958 | encoded = ENCODE_FILE (filename); |
| 5945 | check_mutable_filename (encoded); | ||
| 5946 | 5959 | ||
| 5947 | if (emacs_fstatat (AT_FDCWD, SSDATA (encoded), &st, 0) | 5960 | if (emacs_fstatat (AT_FDCWD, SSDATA (encoded), &st, 0) |
| 5948 | == 0) | 5961 | == 0) |
diff --git a/src/filelock.c b/src/filelock.c index 45eac5a19a1..be551fc876f 100644 --- a/src/filelock.c +++ b/src/filelock.c | |||
| @@ -659,8 +659,31 @@ lock_if_free (lock_info_type *clasher, Lisp_Object lfname) | |||
| 659 | static Lisp_Object | 659 | static Lisp_Object |
| 660 | make_lock_file_name (Lisp_Object fn) | 660 | make_lock_file_name (Lisp_Object fn) |
| 661 | { | 661 | { |
| 662 | Lisp_Object lock_file_name = call1 (Qmake_lock_file_name, | 662 | Lisp_Object lock_file_name; |
| 663 | Fexpand_file_name (fn, Qnil)); | 663 | #if defined HAVE_ANDROID && !defined ANDROID_STUBIFY |
| 664 | char *name; | ||
| 665 | #endif | ||
| 666 | |||
| 667 | fn = Fexpand_file_name (fn, Qnil); | ||
| 668 | |||
| 669 | #if defined HAVE_ANDROID && !defined ANDROID_STUBIFY | ||
| 670 | /* Files in /assets and /contents can't have lock files on Android | ||
| 671 | as these directories are fabrications of android.c, and backed by | ||
| 672 | read only data. */ | ||
| 673 | |||
| 674 | name = SSDATA (fn); | ||
| 675 | |||
| 676 | if (strcmp (name, "/assets") | ||
| 677 | || strcmp (name, "/assets/") | ||
| 678 | || strcmp (name, "/content") | ||
| 679 | || strcmp (name, "/content/") | ||
| 680 | || strncmp (name, "/assets/", sizeof "/assets") | ||
| 681 | || strncmp (name, "/content/", sizeof "/content")) | ||
| 682 | return Qnil; | ||
| 683 | #endif | ||
| 684 | |||
| 685 | lock_file_name = call1 (Qmake_lock_file_name, fn); | ||
| 686 | |||
| 664 | return !NILP (lock_file_name) ? ENCODE_FILE (lock_file_name) : Qnil; | 687 | return !NILP (lock_file_name) ? ENCODE_FILE (lock_file_name) : Qnil; |
| 665 | } | 688 | } |
| 666 | 689 | ||
diff --git a/src/inotify.c b/src/inotify.c index b2a48884efa..844bf54105c 100644 --- a/src/inotify.c +++ b/src/inotify.c | |||
| @@ -445,7 +445,7 @@ IN_ONESHOT */) | |||
| 445 | || strcmp (name, "/content") | 445 | || strcmp (name, "/content") |
| 446 | || strcmp (name, "/content/") | 446 | || strcmp (name, "/content/") |
| 447 | || strncmp (name, "/assets/", sizeof "/assets") | 447 | || strncmp (name, "/assets/", sizeof "/assets") |
| 448 | || strncmp (name, "/content", sizeof "/content")) | 448 | || strncmp (name, "/content/", sizeof "/content")) |
| 449 | return Qnil; | 449 | return Qnil; |
| 450 | #endif | 450 | #endif |
| 451 | 451 | ||