diff options
author | Andreas Gruenbacher <agruen@suse.de> | 2006-01-25 17:43:40 +0000 |
---|---|---|
committer | Andreas Gruenbacher <agruen@suse.de> | 2006-01-25 17:43:40 +0000 |
commit | 6a465ef8391b60586307fb465847d16b338237de (patch) | |
tree | d72bd9d0ed573193e4e17d2511ea4892a2f4a1ca | |
parent | fcb7ad34843a4e06f3c45694787c8ac3056a9e68 (diff) | |
download | quilt-6a465ef8391b60586307fb465847d16b338237de.tar.gz |
- lib/backup-files.c: Several fixes from Markus as well.
-rw-r--r-- | lib/backup-files.c | 48 | ||||
-rw-r--r-- | quilt.changes | 3 |
2 files changed, 39 insertions, 12 deletions
diff --git a/lib/backup-files.c b/lib/backup-files.c index 25d2234..fe5b037 100644 --- a/lib/backup-files.c +++ b/lib/backup-files.c @@ -142,14 +142,30 @@ out: static int copy_fd(int from_fd, int to_fd) { - char buffer[4096]; - size_t len; - - while ((len = read(from_fd, buffer, sizeof(buffer))) > 0) { - if ((write(to_fd, buffer, len)) == -1) + char buffer[16384]; + char *wbuf; + ssize_t len, l; + + for ( ;; ) { + len = read(from_fd, buffer, sizeof(buffer)); + if (len == 0) + return 0; + if (len < 0) { + if (errno == EINTR || errno == EAGAIN) + continue; return 1; + } + for (wbuf = buffer; len != 0; ) { + l = write(to_fd, wbuf, len); + if (l < 0) { + if (errno == EINTR || errno == EAGAIN) + continue; + return 1; + } + wbuf += l; + len -= l; + } } - return (len != 0); } static int @@ -162,7 +178,7 @@ copy_file(const char *from, const struct stat *st, const char *to) return 1; } unlink(to); /* make sure we don't inherit this file's mode. */ - if ((to_fd = creat(to, st->st_mode))) { + if ((to_fd = creat(to, st->st_mode)) < 0) { perror(to); close(from_fd); return 1; @@ -285,12 +301,17 @@ process_file(const char *file) printf("Copying %s\n", file); if (link_or_copy_file(file, &st, backup)) goto fail; - if (opt_touch) - utime(backup, NULL); if (opt_nolinks) { if (ensure_nolinks(file)) goto fail; } + if (opt_touch) + (void) utime(backup, NULL); + else { + struct utimbuf ut; + ut.actime = ut.modtime = st.st_mtime; + (void) utime(backup, &ut); + } } } else if (opt_what == what_restore) { struct stat st; @@ -314,12 +335,17 @@ process_file(const char *file) unlink(file); if (link_or_copy_file(backup, &st, file)) goto fail; - if (opt_touch) - utime(file, NULL); if (opt_nolinks) { if (ensure_nolinks(file)) goto fail; } + if (opt_touch) + (void) utime(file, NULL); + else { + struct utimbuf ut; + ut.actime = ut.modtime = st.st_mtime; + (void) utime(file, &ut); + } } unlink(backup); remove_parents(backup); diff --git a/quilt.changes b/quilt.changes index 1ab972b..48ad567 100644 --- a/quilt.changes +++ b/quilt.changes @@ -1,8 +1,9 @@ ------------------------------------------------------------------- -Wed Jan 25 18:20:52 CET 2006 - agruen@suse.de +Wed Jan 25 18:43:38 CET 2006 - agruen@suse.de - lib/backup-files.c: Cleanups by Markus F.X.J. Oberhumer <markus@oberhumer.com>. +- lib/backup-files.c: Several fixes from Markus as well. ------------------------------------------------------------------- Tue Jan 24 03:28:12 CET 2006 - agruen@suse.de |