All,

I tried using the write-devices patch from rsync-patches.  Thanks for creating 
it.  I hope that and copy-devices become part of mainline.


When I tried to copy from a regular file to a device, with a command like
   rsync -write-devices -inplace rsync://10.10.10.1/share/drive.img /dev/sdb3
I used to get a 'rsync: ftruncate failed on "/dev/sdb3": Invalid argument (22)' 
error.

The problem seems to be rooted in line 135 of write-devices.diff (from the 
rsync-patches repo).
Namely, I believe
   !IS_DEVICE(file->mode)
is checking the mode of the source file, not the destination, which is what it 
should check.  I wrote a hack to check if fd corresponds to a device instead 
(simple code changes below), which seemed to make things work although it 
should be coded more cleanly.  Thanks.

Ryan



Informal description of changes from receiver.c line 369:



Original code (after applying write-devices patch):

#ifdef HAVE_TRUNCATE
                If((inplace
#ifdef PREALLOCATE_NEEDS_TRUNCATE
|| preallocated_len > offset
#endif
                ) && fd != -1 && !IS_DEVICE(file->mode) && do_ftruncate(fd, 
offset) < 0) {




Code after change:

#ifdef HAVE_TRUNCATE
{
                STRUCT_STAT st;
                Do_fstat(fd, &st);
                If((inplace
#ifdef PREALLOCATE_NEEDS_TRUNCATE
|| preallocated_len > offset
#endif
                ) && fd != -1 && !IS_DEVICE(st.st_mode) && do_ftruncate(fd, 
offset) < 0) {


-- 
Please use reply-all for most replies to avoid omitting the mailing list.
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html

Reply via email to