From: Michael Albinus <michael.albinus@gmx.de>
To: emacs-devel@gnu.org
Cc: Po Lu <luangruo@yahoo.com>
Subject: Re: feature/android b91e8ada70e 3/5: Fix auto-revert-mode on Android
Date: Sat, 25 Feb 2023 11:27:11 +0100 [thread overview]
Message-ID: <87k006vy4g.fsf@gmx.de> (raw)
In-Reply-To: <20230224132344.40927C1391F@vcs2.savannah.gnu.org> (Po Lu via Mailing list for Emacs changes's message of "Fri, 24 Feb 2023 08:23:44 -0500 (EST)")
Po Lu via Mailing list for Emacs changes <emacs-diffs@gnu.org> writes:
Hi,
> Fix auto-revert-mode on Android
>
> * src/inotify.c (Finotify_add_watch): Handle asset files.
> ---
> src/inotify.c | 19 ++++++++++++++++++-
> 1 file changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/src/inotify.c b/src/inotify.c
> index 7562ffb1701..b2a48884efa 100644
> --- a/src/inotify.c
> +++ b/src/inotify.c
> @@ -419,6 +419,7 @@ IN_ONESHOT */)
> int wd = -1;
> uint32_t imask = aspect_to_inotifymask (aspect);
> uint32_t mask = imask | IN_MASK_ADD | IN_EXCL_UNLINK;
> + char *name;
>
> CHECK_STRING (filename);
>
> @@ -432,7 +433,23 @@ IN_ONESHOT */)
> }
>
> encoded_file_name = ENCODE_FILE (filename);
> - wd = inotify_add_watch (inotifyfd, SSDATA (encoded_file_name), mask);
> + name = SSDATA (encoded_file_name);
> +
> +#if defined HAVE_ANDROID && !defined ANDROID_STUBIFY
> + /* If FILENAME actually lies in a special directory, return now
> + instead of letting inotify fail. These directories cannot
> + receive file notifications as they are read only. */
> +
> + if (strcmp (name, "/assets")
> + || strcmp (name, "/assets/")
> + || strcmp (name, "/content")
> + || strcmp (name, "/content/")
> + || strncmp (name, "/assets/", sizeof "/assets")
> + || strncmp (name, "/content", sizeof "/content"))
> + return Qnil;
> +#endif
> +
> + wd = inotify_add_watch (inotifyfd, name, mask);
> if (wd < 0)
> report_file_notify_error ("Could not add watch for file", filename);
I have two problems with this patch. First, nil is not defined as return
value of *-add-watch functions. If we want to allow this, we must extend
the interface.
Second, do we really want to have such a hard coded list in inotify.c?
What about other directories on other systems, like "/proc"? Shouldn't
we add rather a common interface for excluding directories from being
watched, say file-notify-excluded-directories (a list of strings)? This
could be modified on Lisp level, no need to do it in the notification
backends.
Best regards, Michael.
next parent reply other threads:[~2023-02-25 10:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <167724502313.15669.16640007729364817665@vcs2.savannah.gnu.org>
[not found] ` <20230224132344.40927C1391F@vcs2.savannah.gnu.org>
2023-02-25 10:27 ` Michael Albinus [this message]
2023-02-25 10:41 ` feature/android b91e8ada70e 3/5: Fix auto-revert-mode on Android Po Lu
2023-02-25 10:49 ` Michael Albinus
2023-02-25 11:13 ` Po Lu
2023-02-25 11:51 ` Michael Albinus
2023-02-25 12:19 ` Po Lu
2023-02-25 12:28 ` Michael Albinus
2023-02-26 0:49 ` chad
2023-02-26 2:40 ` Po Lu
2023-02-27 3:03 ` chad
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87k006vy4g.fsf@gmx.de \
--to=michael.albinus@gmx.de \
--cc=emacs-devel@gnu.org \
--cc=luangruo@yahoo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).