Hello community, here is the log from the commit of package snapper for openSUSE:Factory checked in at 2013-02-22 17:02:09 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/snapper (Old) and /work/SRC/openSUSE:Factory/.snapper.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "snapper", Maintainer is "ASchnell@suse.com" Changes: -------- --- /work/SRC/openSUSE:Factory/snapper/snapper.changes 2013-02-21 15:37:26.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.snapper.new/snapper.changes 2013-02-22 17:02:10.000000000 +0100 @@ -1,0 +2,5 @@ +Fri Feb 22 11:49:23 CET 2013 - aschnell@suse.de + +- use sendfile system-call instead of read/write loop + +------------------------------------------------------------------- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ snapper-0.1.2.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/snapper-0.1.2/snapper/AppUtil.cc new/snapper-0.1.2/snapper/AppUtil.cc --- old/snapper-0.1.2/snapper/AppUtil.cc 2013-02-08 10:51:31.000000000 +0100 +++ new/snapper-0.1.2/snapper/AppUtil.cc 2013-02-22 14:31:31.000000000 +0100 @@ -30,6 +30,7 @@ #include <sys/utsname.h> #include <sys/ioctl.h> #include <sys/types.h> +#include <sys/sendfile.h> #include <pwd.h> #include <dirent.h> #include <mntent.h> @@ -90,45 +91,19 @@ bool copyfile(int src_fd, int dest_fd) { - struct stat src_stat; - int r1 = fstat(src_fd, &src_stat); - if (r1 != 0) - { - y2err("fstat failed errno:" << errno << " (" << stringerror(errno) << ")"); - return false; - } - - posix_fadvise(src_fd, 0, src_stat.st_size, POSIX_FADV_SEQUENTIAL); - - static_assert(sizeof(off_t) >= 8, "off_t is too small"); - - const off_t block_size = 4096; - - char block[block_size]; - - off_t length = src_stat.st_size; - while (length > 0) + while (true) { - off_t t = min(block_size, length); + // use small value for count to make function better interruptible + ssize_t r1 = sendfile(dest_fd, src_fd, NULL, 0xffff); + if (r1 == 0) + return true; - int r2 = read(src_fd, block, t); - if (r2 != t) + if (r1 < 0) { - y2err("read failed errno:" << errno << " (" << stringerror(errno) << ")"); + y2err("sendfile failed errno:" << errno << " (" << stringerror(errno) << ")"); return false; } - - int r3 = write(dest_fd, block, t); - if (r3 != t) - { - y2err("write failed errno:" << errno << " (" << stringerror(errno) << ")"); - return false; - } - - length -= t; } - - return true; } -- To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-commit+help@opensuse.org