From 2b7e009257a40ef1dcad9845fe61764fea08cdea Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 25 Aug 2017 12:44:52 -0700 Subject: Fix file-attributes race on GNU hosts * doc/lispref/files.texi (File Attributes): Document file-attributes atomicity. * etc/NEWS: Document the fix. * src/dired.c (file_attributes): New args DIRNAME and FILENAME, for diagnostics. All callers changed. On platforms like GNU/Linux that support O_PATH, fix a race condition in file-attributes and similar functions, so that these functions do not return nonsense if a directory entry is replaced while getting its attributes. On non-GNU platforms, do a better (though not perfect) job of detecting the race, and return nil if detected. --- src/kqueue.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/kqueue.c') diff --git a/src/kqueue.c b/src/kqueue.c index a8eb4cb797c..30922ef28b1 100644 --- a/src/kqueue.c +++ b/src/kqueue.c @@ -130,7 +130,7 @@ kqueue_compare_dir_list (Lisp_Object watch_object) return; } new_directory_files = - directory_files_internal (dir, Qnil, Qnil, Qnil, 1, Qnil); + directory_files_internal (dir, Qnil, Qnil, Qnil, true, Qnil); new_dl = kqueue_directory_listing (new_directory_files); /* Parse through the old list. */ @@ -453,7 +453,7 @@ only when the upper directory of the renamed file is watched. */) if (NILP (Ffile_directory_p (file))) watch_object = list4 (watch_descriptor, file, flags, callback); else { - dir_list = directory_files_internal (file, Qnil, Qnil, Qnil, 1, Qnil); + dir_list = directory_files_internal (file, Qnil, Qnil, Qnil, true, Qnil); watch_object = list5 (watch_descriptor, file, flags, callback, dir_list); } watch_list = Fcons (watch_object, watch_list); -- cgit v1.2.3