diff options
| author | Paul Eggert | 2013-03-13 11:42:22 -0700 |
|---|---|---|
| committer | Paul Eggert | 2013-03-13 11:42:22 -0700 |
| commit | 47d7532e093db8a5068a40c587915121ffaaad18 (patch) | |
| tree | a99ea6eca34ea0e9c8d6e8a8d6291833ce27dca5 /lib-src/movemail.c | |
| parent | c7ffccaf17d63cefd34bef0a9becc4e68df3b115 (diff) | |
| download | emacs-47d7532e093db8a5068a40c587915121ffaaad18.tar.gz emacs-47d7532e093db8a5068a40c587915121ffaaad18.zip | |
File synchronization fixes.
* admin/CPP-DEFINES (BSD_SYSTEM, HAVE_FSYNC): Remove.
* admin/merge-gnulib (GNULIB_MODULES): Add fsync, fdatasync.
* configure.ac (BSD_SYSTEM, BSD_SYSTEM_AHB): Remove; no longer needed.
(fsync): Remove check; now done by gnulib.
* lib/fdatasync.c, lib/fsync.c, m4/fdatasync.m4, m4/fsync.m4:
New files, from gnulib.
* lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
* lib-src/Makefile.in (LIB_FDATASYNC): New macro.
(emacsclient${EXEEXT}): Use it.
* lib-src/emacsclient.c (main): Use fdatasync, not fsync, since we don't
care about metadata. Keep trying if interrupted.
* lib-src/movemail.c (main, popmail): Don't worry about BSD_SYSTEM, since
fsync is available everywhere (or there is a substitute). Don't
report an error if fsync returns EINVAL.
* nt/inc/ms-w32.h (fdatasync): New macro, suggested by Eli Zaretskii.
* src/Makefile.in (LIB_FDATASYNC): New macro.
(LIBES): Use it.
* src/conf_post.h (BSD_SYSTEM, BSD_SYSTEM_AHB): Remove; no longer needed.
* src/fileio.c (Fwrite_region, write_region_inhibit_fsync):
Don't worry about HAVE_FSYNC, since a substitute fsync is
available if the system lacks one.
(Fwrite_regin): Retry fsync if interrupted.
Fixes: debbugs:13944
Diffstat (limited to 'lib-src/movemail.c')
| -rw-r--r-- | lib-src/movemail.c | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/lib-src/movemail.c b/lib-src/movemail.c index 190937d762b..81ac8aa187c 100644 --- a/lib-src/movemail.c +++ b/lib-src/movemail.c | |||
| @@ -466,10 +466,8 @@ main (int argc, char **argv) | |||
| 466 | } | 466 | } |
| 467 | } | 467 | } |
| 468 | 468 | ||
| 469 | #ifdef BSD_SYSTEM | 469 | if (fsync (outdesc) != 0 && errno != EINVAL) |
| 470 | if (fsync (outdesc) < 0) | ||
| 471 | pfatal_and_delete (outname); | 470 | pfatal_and_delete (outname); |
| 472 | #endif | ||
| 473 | 471 | ||
| 474 | /* Prevent symlink attacks truncating other users' mailboxes */ | 472 | /* Prevent symlink attacks truncating other users' mailboxes */ |
| 475 | if (setregid (-1, real_gid) < 0) | 473 | if (setregid (-1, real_gid) < 0) |
| @@ -750,21 +748,14 @@ popmail (char *mailbox, char *outfile, int preserve, char *password, int reverse | |||
| 750 | } | 748 | } |
| 751 | } | 749 | } |
| 752 | 750 | ||
| 753 | /* On AFS, a call to write only modifies the file in the local | 751 | if (fsync (mbfi) != 0 && errno != EINVAL) |
| 754 | * workstation's AFS cache. The changes are not written to the server | ||
| 755 | * until a call to fsync or close is made. Users with AFS home | ||
| 756 | * directories have lost mail when over quota because these checks were | ||
| 757 | * not made in previous versions of movemail. */ | ||
| 758 | |||
| 759 | #ifdef BSD_SYSTEM | ||
| 760 | if (fsync (mbfi) < 0) | ||
| 761 | { | 752 | { |
| 762 | error ("Error in fsync: %s", strerror (errno), 0); | 753 | error ("Error in fsync: %s", strerror (errno), 0); |
| 754 | close (mbfi); | ||
| 763 | return EXIT_FAILURE; | 755 | return EXIT_FAILURE; |
| 764 | } | 756 | } |
| 765 | #endif | ||
| 766 | 757 | ||
| 767 | if (close (mbfi) == -1) | 758 | if (close (mbfi) != 0) |
| 768 | { | 759 | { |
| 769 | error ("Error in close: %s", strerror (errno), 0); | 760 | error ("Error in close: %s", strerror (errno), 0); |
| 770 | return EXIT_FAILURE; | 761 | return EXIT_FAILURE; |