mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-19 10:22:27 +00:00
707431575a
* 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
38 lines
1.2 KiB
C
38 lines
1.2 KiB
C
/* Fake unistd.h: config.h already provides most of the relevant things. */
|
|
|
|
#ifndef _UNISTD_H
|
|
#define _UNISTD_H
|
|
|
|
/* On Microsoft platforms, <stdlib.h> declares 'environ'; on POSIX
|
|
platforms, <unistd.h> does. Every file in Emacs that includes
|
|
<unistd.h> also includes <stdlib.h>, so there's no need to declare
|
|
'environ' here. */
|
|
|
|
/* Provide prototypes of library functions that are emulated on w32
|
|
and whose prototypes are usually found in unistd.h on POSIX
|
|
platforms. */
|
|
extern ssize_t readlink (const char *, char *, size_t);
|
|
extern ssize_t readlinkat (int, const char *, char *, size_t);
|
|
extern int symlink (char const *, char const *);
|
|
extern int setpgid (pid_t, pid_t);
|
|
extern pid_t getpgrp (void);
|
|
extern pid_t setsid (void);
|
|
extern pid_t tcgetpgrp (int);
|
|
|
|
extern int faccessat (int, char const *, int, int);
|
|
|
|
/* These are normally on fcntl.h, but we don't override that header. */
|
|
/* Use values compatible with gnulib, as there's no reason to differ. */
|
|
#define AT_FDCWD (-3041965)
|
|
#define AT_EACCESS 4
|
|
#define AT_SYMLINK_NOFOLLOW 4096
|
|
|
|
#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 *);
|
|
|
|
#endif /* _UNISTD_H */
|