[Bug 13317] rsync returns success when target filesystem is full
samba-bugs at samba.org
samba-bugs at samba.org
Tue Mar 6 17:19:15 UTC 2018
https://bugzilla.samba.org/show_bug.cgi?id=13317
--- Comment #18 from Rui DeSousa <rui.desousa at icloud.com> ---
I also wrote a little util as well; I get the correct error in write spot.
[postgres at hades ~]$ cat 000000010000005E00000017 | ./fwrite/fwrite
arch/000000010000005E00000017
fwrite: write: Disc quota exceeded
[postgres at hades ~]$ echo $?
1
[postgres at hades ~]$ du -h arch/000000010000005E00000017.GghJVR
1.9M arch/000000010000005E00000017.GghJVR
Here's the code:
#include <sys/stat.h>
#include <err.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#define BUFSIZE 131072
int
main(int argc, char *argv[])
{
int fd, r, w;
char *buf;
char *name;
if (argc != 2) {
fprintf(stderr, "usage: fwrite [file]\n");
exit(1);
}
if ((buf = malloc(BUFSIZE)) == NULL)
err(1, "malloc");
++argv;
if ((name = (char *) malloc(strlen(*argv) + 10)) == NULL)
err(1, "malloc");
strcat(strcpy(name, *argv), ".XXXXXX");
if ((fd = mkstemp(name)) < 0)
err(1, "mkstemp");
while ((r = read(STDIN_FILENO, buf, BUFSIZE)) > 0)
if ((w = write(fd, buf, r)) == -1)
err(1, "write");
if (r < 0)
err(1, "read");
if (fsync(fd) != 0)
err(1, "fsync");
if (close(fd) != 0)
err(1, "close");
if (rename(name, *argv) != 0)
err(1, "rename");
free(name);
exit(0);
}
--
You are receiving this mail because:
You are the QA Contact for the bug.
More information about the rsync
mailing list