=== modified file 'ChangeLog' --- ChangeLog 2014-01-23 02:48:44 +0000 +++ ChangeLog 2014-01-23 03:11:08 +0000 @@ -1,5 +1,10 @@ 2014-01-23 Paul Eggert + Port better to platforms lacking fchmod. + See the thread starting at: + http://lists.gnu.org/archive/html/emacs-devel/2014-01/msg01899.html + * lib/fnchmod.h: New file. + Merge from gnulib, incorporating: 2014-01-22 qacl: check for fchmod * m4/acl.m4: Update from gnulib. === modified file 'lib-src/ChangeLog' --- lib-src/ChangeLog 2014-01-22 19:38:31 +0000 +++ lib-src/ChangeLog 2014-01-23 03:11:08 +0000 @@ -1,3 +1,13 @@ +2014-01-23 Paul Eggert + + Port better to platforms lacking fchmod. + * Makefile.in (update-game-score${EXEEXT}): + Depend on ${srcdir}/../lib/fnchmod.h. + * update-game-score.c (INLINE): New macro. + Include . + (write_scores): Use fnchmod rather than chmod on WINDOWSNT and + fchmod elsewhere. + 2014-01-22 Eli Zaretskii * update-game-score.c (write_scores) [WINDOWSNT]: Use chmod === modified file 'lib-src/Makefile.in' --- lib-src/Makefile.in 2014-01-05 02:56:08 +0000 +++ lib-src/Makefile.in 2014-01-23 03:11:08 +0000 @@ -372,7 +372,8 @@ hexl${EXEEXT}: ${srcdir}/hexl.c $(NTLIB) $(config_h) $(CC) ${ALL_CFLAGS} ${srcdir}/hexl.c $(LOADLIBES) -o hexl${EXEEXT} -update-game-score${EXEEXT}: ${srcdir}/update-game-score.c $(NTLIB) $(config_h) +update-game-score${EXEEXT}: ${srcdir}/update-game-score.c \ + ${srcdir}/../lib/fnchmod.h $(NTLIB) $(config_h) $(CC) ${ALL_CFLAGS} -DHAVE_SHARED_GAME_DIR="\"$(gamedir)\"" \ ${srcdir}/update-game-score.c $(LOADLIBES) $(NTLIB) \ -o update-game-score${EXEEXT} === modified file 'lib-src/update-game-score.c' --- lib-src/update-game-score.c 2014-01-22 19:38:31 +0000 +++ lib-src/update-game-score.c 2014-01-23 03:11:08 +0000 @@ -31,6 +31,7 @@ Created 2002/03/22. */ +#define INLINE EXTERN_INLINE #include #include @@ -48,6 +49,8 @@ #include #include +#include + #ifdef WINDOWSNT #include "ntlib.h" #endif @@ -443,10 +446,8 @@ fd = mkostemp (tempfile, 0); if (fd < 0) return -1; -#ifndef WINDOWSNT - if (fchmod (fd, 0644) != 0) + if (fnchmod (fd, filename, 0644) != 0) return -1; -#endif f = fdopen (fd, "w"); if (! f) return -1; @@ -459,10 +460,6 @@ return -1; if (rename (tempfile, filename) != 0) return -1; -#ifdef WINDOWSNT - if (chmod (filename, 0644) < 0) - return -1; -#endif return 0; } === added file 'lib/fnchmod.h' --- lib/fnchmod.h 1970-01-01 00:00:00 +0000 +++ lib/fnchmod.h 2014-01-23 03:11:08 +0000 @@ -0,0 +1,45 @@ +/* Set file mode based on a file descriptor or name. + + Copyright 2014 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef FNCHMOD_H +#define FNCHMOD_H + +#include + +#include + +INLINE_HEADER_BEGIN + +/* On systems that have fchmod, use it to change the mode of FD. + On other systems, use chmod on NAME instead; NAME should identify + the same file that FD does. Typically fchmod is preferable, as it + can avoid some races. MODE is the desired mode. Return 0 if + successful. Return -1 and set errno upon failure. */ + +INLINE int +fnchmod (int fd, char const *name, mode_t mode) +{ +#if HAVE_FCHMOD + return fchmod (fd, mode); +#else + return chmod (name, mode); +#endif +} + +INLINE_HEADER_END + +#endif === modified file 'src/ChangeLog' --- src/ChangeLog 2014-01-22 10:29:23 +0000 +++ src/ChangeLog 2014-01-23 03:11:08 +0000 @@ -1,3 +1,10 @@ +2014-01-23 Paul Eggert + + Port better to platforms lacking fchmod. + * fileio.c, filelock.c: Include . + * fileio.c (Fcopy_file): + * filelock.c (create_lock_file): Use fnchmod, not fchmod. + 2014-01-22 Martin Rudalics Fixes in window size functions around Bug#16430 and Bug#16470. === modified file 'src/fileio.c' --- src/fileio.c 2014-01-03 06:47:27 +0000 +++ src/fileio.c 2014-01-23 03:11:08 +0000 @@ -41,6 +41,7 @@ #endif #include +#include #include "lisp.h" #include "intervals.h" @@ -2113,7 +2114,7 @@ : (already_exists || (new_mask & ~realmask) == default_permissions) ? 0 - : fchmod (ofd, default_permissions)) + : fnchmod (ofd, SSDATA (encoded_newname), default_permissions)) { case -2: report_file_error ("Copying permissions from", file); case -1: report_file_error ("Copying permissions to", newname); === modified file 'src/filelock.c' --- src/filelock.c 2014-01-01 07:43:34 +0000 +++ src/filelock.c 2014-01-23 03:11:08 +0000 @@ -39,6 +39,7 @@ #include #include +#include #include "lisp.h" #include "character.h" @@ -424,7 +425,7 @@ /* Use 'write', not 'emacs_write', as garbage collection might signal an error, which would leak FD. */ if (write (fd, lock_info_str, lock_info_len) != lock_info_len - || fchmod (fd, S_IRUSR | S_IRGRP | S_IROTH) != 0) + || fnchmod (fd, nonce, S_IRUSR | S_IRGRP | S_IROTH) != 0) err = errno; /* There is no need to call fsync here, as the contents of the lock file need not survive system crashes. */