summaryrefslogtreecommitdiff
path: root/nt/inc
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2013-03-05 14:35:41 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2013-03-05 14:35:41 -0800
commit707431575aef93ac3e9923d450a6cbf18192c933 (patch)
treec81ecb9af767baaea6876c956b6fc921ebb6ac9e /nt/inc
parent05e193f1706f5d9846530e734d0271b15b9a818c (diff)
downloademacs-707431575aef93ac3e9923d450a6cbf18192c933.tar.gz
FILE's lock is now always .#FILE and may be a regular file.
* etc/NEWS: Document this. * nt/inc/unistd.h (O_NOFOLLOW): New macro. * src/filelock.c: Include <c-ctype.h>. (MAX_LFINFO): New top-level constant. (lock_info_type): Remove members pid, boot_time. Add members at, dot, colon. Change user member to be the entire buffer, not a pointer. This allows us to handle the case where a foreign pid or boot time exceeds the local range. All uses changed. (LINKS_MIGHT_NOT_WORK): New constant. (FREE_LOCK_INFO): Remove, as the pieces no longer need freeing. (defined_WINDOWSNT): Remove. (MAKE_LOCK_NAME, file_in_lock_file_name): Always use .#FILE (not .#-FILE) for the file lock, even if it is a regular file. (rename_lock_file): New function. (create_lock_file): Use it. (create_lock_file, read_lock_data): Prefer a symbolic link for the lock file, falling back on a regular file if symlinks don't work. Do not try to create symlinks on MS-Windows, due to security hassles. Stick with POSIXish functions (open, read, write, close, fchmod, readlink, symlink, link, rename, unlink, mkstemp) when creating locks, as a GNUish host may be using a Windowsish file system, and cannot use MS-Windows-only system calls. Fall back on mktemp if mkstemp doesn't work. Don't fail merely because of a symlink-contents length limit in the current file system; fall back on regular files. Increase the symlink contents length limit to 8 KiB, this should be big enough for any real use and doesn't crunch the stack. (create_lock_file, lock_file_1, read_lock_data): Simplify allocation of lock file buffers now that they fit in 8 KiB. (lock_file_1): Return error number, not bool. All callers changed. (ELOOP): New macro, if not already defined. (read_lock_data): Return size of lock file contents, not Lisp object. All callers changed. Handle a race condition if some other process replaces a regular-file lock with a symlink lock or vice versa, while we're trying to read the lock. (current_lock_owner): Parse contents more carefully, to help avoid confusing a regular-file lock with some other application's use of the file. Check for lock file contents being too long, or not parsing correctly. (current_lock_owner, lock_file): Allow foreign pid and boot times that exceed the local range. (current_lock_owner, lock_if_free, lock_file): Simplify allocation of lock file contents. * src/w32.c (sys_rename_replace): New function, containing most of the contents of the old sys_rename. (sys_rename): Use it. (fchmod): New dummy function. * src/w32.h (sys_rename_replace, fchmod): New decls. Fixes: debbugs:13807
Diffstat (limited to 'nt/inc')
-rw-r--r--nt/inc/unistd.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/nt/inc/unistd.h b/nt/inc/unistd.h
index 3fd9289d83d..e07c46533f7 100644
--- a/nt/inc/unistd.h
+++ b/nt/inc/unistd.h
@@ -27,8 +27,9 @@ extern int faccessat (int, char const *, int, int);
#define AT_EACCESS 4
#define AT_SYMLINK_NOFOLLOW 4096
-#define O_NOCTTY 0
#define O_IGNORE_CTTY 0
+#define O_NOCTTY 0
+#define O_NOFOLLOW 0
/* This is normally on stdlib.h, but we don't override that header. */
extern int unsetenv (const char *);