=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/cvs/file.c,v retrieving revision 1.196 retrieving revision 1.197 diff -c -r1.196 -r1.197 *** src/usr.bin/cvs/file.c 2007/09/09 20:24:06 1.196 --- src/usr.bin/cvs/file.c 2007/09/17 10:07:21 1.197 *************** *** 1,4 **** ! /* $OpenBSD: file.c,v 1.196 2007/09/09 20:24:06 tobias Exp $ */ /* * Copyright (c) 2006 Joris Vink * Copyright (c) 2004 Jean-Francois Brousseau --- 1,4 ---- ! /* $OpenBSD: file.c,v 1.197 2007/09/17 10:07:21 tobias Exp $ */ /* * Copyright (c) 2006 Joris Vink * Copyright (c) 2004 Jean-Francois Brousseau *************** *** 36,41 **** --- 36,42 ---- #include #include + #include "atomicio.h" #include "cvs.h" #define CVS_IGN_STATIC 0x01 /* pattern is static, no need to glob */ *************** *** 935,943 **** mtime = st.st_mtimespec.tv_sec; if (S_ISREG(st.st_mode)) { ! size_t sz; ! ssize_t nw; ! char *p, *buf; int saved_errno; if (st.st_size > (off_t)SIZE_MAX) { --- 936,942 ---- mtime = st.st_mtimespec.tv_sec; if (S_ISREG(st.st_mode)) { ! char *p; int saved_errno; if (st.st_size > (off_t)SIZE_MAX) { *************** *** 959,976 **** madvise(p, st.st_size, MADV_SEQUENTIAL); ! sz = st.st_size; ! buf = p; ! ! while (sz > 0) { ! if ((nw = write(dst, p, sz)) == -1) { ! saved_errno = errno; ! (void)unlink(to); ! fatal("cvs_file_copy: `%s': %s", ! from, strerror(saved_errno)); ! } ! buf += nw; ! sz -= nw; } (void)munmap(p, st.st_size); --- 958,968 ---- madvise(p, st.st_size, MADV_SEQUENTIAL); ! if (atomicio(vwrite, dst, p, st.st_size) != st.st_size) { ! saved_errno = errno; ! (void)unlink(to); ! fatal("cvs_file_copy: `%s': %s", from, ! strerror(saved_errno)); } (void)munmap(p, st.st_size);