zopencommunity / rsyncport

A file synchronization utility
Apache License 2.0
0 stars 1 forks source link

rsync local copy does not seem to work #2

Closed MikeFultonDev closed 2 years ago

MikeFultonDev commented 2 years ago

Given a $HOME directory with a sub1 and sub2 directory, with file1.txt in sub1, then:

rsync -v $HOME/sub1/file1.txt $HOME/sub2/

should work. Instead it prints out:

skipping non-regular file "file1.txt"

sent 39 bytes  received 54 bytes  186.00 bytes/sec
total size is 0  speedup is 0.00
MikeFultonDev commented 2 years ago

Running on my Mac with -vvvv I get:

rsync -vvvv ./src/f1.txt ./dst/
cmd= machine= user= path=./dst/
cmd[0]=. cmd[1]=./dst/ 
(Server) Protocol versions: remote=29, negotiated=29
(Client) Protocol versions: remote=29, negotiated=29
[sender] make_file(f1.txt,*,2)
server_recv(2) starting pid=23311
[sender] i=0 ./src f1.txt mode=0100644 len=10 flags=0
send_file_list done
file list sent
send_files starting
recv_file_name(f1.txt)
received 1 names
[receiver] i=0 1 f1.txt mode=0100644 len=10 flags=0
recv_file_list done
get_local_name count=1 ./dst/
generator starting pid=23311 count=1
delta-transmission disabled for local transfer or --whole-file
recv_generator(f1.txt,0)
send_files(0, ./src/f1.txt)
count=0 n=0 rem=0
send_files mapped ./src/f1.txt of size 10
calling match_sums ./src/f1.txt
f1.txt
sending file_sum
false_alarms=0 hash_hits=0 matches=0
sender finished ./src/f1.txt
generate_files phase=1
send_files phase=1
recv_files(1) starting
recv_files(f1.txt)
data recv 10 at 0
got file_sum
renaming .f1.txt.95sVrN to f1.txt
recv_files phase=1
generate_files phase=2
send_files phase=2
send files finished
total: matches=0  hash_hits=0  false_alarms=0 data=10
recv_files phase=2
recv_files finished
generate_files phase=3
generate_files finished
client_run waiting on 23311

sent 97 bytes  received 42 bytes  278.00 bytes/sec
total size is 10  speedup is 0.07
_exit_cleanup(code=0, file=/AppleInternal/Library/BuildRoots/20d6c351-ee94-11ec-bcaf-7247572f23b4/Library/Caches/com.apple.xbs/Sources/rsync/rsync/main.c, line=996): entered
_exit_cleanup(code=0, file=/AppleInternal/Library/BuildRoots/20d6c351-ee94-11ec-bcaf-7247572f23b4/Library/Caches/com.apple.xbs/Sources/rsync/rsync/main.c, line=996): about to call exit(0)
MikeFultonDev commented 2 years ago

Running on z/OS:

cmd=<NULL> machine=<NULL> user=<NULL> path=./dst/
cmd[0]=. cmd[1]=./dst/ 
msg checking charset: ISO8859-1
(Client) Protocol versions: remote=31, negotiated=31
(Server) Protocol versions: remote=31, negotiated=31
[sender] make_file(f1.txt,*,0)
[sender] flist start=0, used=1, low=0, high=0
[sender] i=0 ./src f1.txt mode=0644 len=10 flags=0
send_file_list done
[sender] flist_eof=1
file list sent
send_files starting
server_recv(2) starting pid=351
recv_file_name(f1.txt)
received 1 names
[Receiver] flist_eof=1
[Receiver] flist start=0, used=1, low=0, high=0
[Receiver] i=0 1 f1.txt mode=0644 len=10 flags=0
recv_file_list done
get_local_name count=1 ./dst/
generator starting pid=351
delta-transmission disabled for local transfer or --whole-file
recv_generator(f1.txt,0)
skipping non-regular file "f1.txt"
generate_files phase=1
send_files phase=1
recv_files(1) starting
recv_files phase=1
generate_files phase=2
send_files phase=2
send files finished
total: matches=0  hash_hits=0  false_alarms=0 data=0
recv_files phase=2
recv_files finished
generate_files phase=3
generate_files finished
client_run waiting on 351

sent 36 bytes  received 556 bytes  1,184.00 bytes/sec
total size is 0  speedup is 0.00
[sender] _exit_cleanup(code=0, file=main.c, line=1327): entered
[sender] _exit_cleanup(code=0, file=./main.c, line=1327): about to call exit(0)
MikeFultonDev commented 2 years ago

Function recv_generator (starts at line 1204) prints out the 'skipping non-regular file' message at line 1684 1226 computest the 'ftype' enum filetype stype, ftype = get_file_type(file->mode); which is pretty straight-forward and defined at line 601 and uses the 'mode_t mode' to return the 'enum filetype' So - S_ISREG(mode) doesn't appear to be true... and since the file doesn't exist yet, presumably this is determined from whatever is sent over the 'wire'

MikeFultonDev commented 2 years ago

So - next question is 'How is the 'struct file_struct *file' being computed and transmitted?

MikeFultonDev commented 2 years ago

Differences:

MikeFultonDev commented 2 years ago

dir_flist->files is the global variable (and field) that has the files in it.

define S_ISREG(m) ( ( (m) & S_IFMT)==S_IFREG ) is defined in sys/stats.h

define S_IFMT 0xFF000000

define S_IFREG 0x03000000

Since the '0x03' isn't in the 'mode' I am thinking that could be the problem?

On the Mac, S_IFREG is indeed 0100000: ./sys/_types/_s_ifmt.h:#define S_IFREG 0100000 / [XSI] regular /

So not having the 'full' mode passed through does seem to be the issue

MikeFultonDev commented 2 years ago

rsync.h is defining _S_IFMT and _S_IFLNK but S_IFMT and S_IFLNK are defined (differently) on z/OS and I expect those should be used, so changed rsync.h to be:

#ifndef _S_IFMT
  #ifdef S_IFMT
    #define _S_IFMT S_IFMT
  #else
    #define _S_IFMT        0170000
  #endif
#endif

#ifndef _S_IFLNK
  #ifdef S_IFLNK
    #define _S_IFLNK S_IFLNK
  #else
    #define _S_IFLNK  0120000
  #endif
#endif
MikeFultonDev commented 2 years ago

rsync.h also has:

struct file_struct {
  const char *dirname;  /* The dir info inside the transfer */
  time_t modtime;   /* When the item was last modified */
  uint32 len32;   /* Lowest 32 bits of the file's length */
  uint16 mode;    /* The item's type and permissions */
  uint16 flags;   /* The FLAG_* bits for this item */
#ifdef USE_FLEXIBLE_ARRAY
  const char basename[];  /* The basename (AKA filename) follows */
#else
  const char basename[1]; /* A kluge that should work like a flexible array */
#endif
};
MikeFultonDev commented 2 years ago

Changing the size to uint32, I now run 'successfully', but the file isn't actually copied:

rsync -vvvv /tmp/src/f1.txt /tmp/dst/      
cmd=<NULL> machine=<NULL> user=<NULL> path=/tmp/dst/
cmd[0]=. cmd[1]=/tmp/dst/ 
msg checking charset: ISO8859-1
(Server) Protocol versions: remote=31, negotiated=31
(Client) Protocol versions: remote=31, negotiated=31
[sender] make_file(f1.txt,*,0)
[sender] flist start=0, used=1, low=0, high=0
[sender] i=0   mode=0300000644 len=10 flags=0
send_file_list done
[sender] flist_eof=1
file list sent
send_files starting
server_recv(2) starting pid=16777550
recv_file_name(<NULL>)
received 1 names
[Receiver] flist_eof=1
[Receiver] flist start=0, used=1, low=0, high=0
[Receiver] i=0   mode=0300000644 len=10 flags=0
recv_file_list done
get_local_name count=1 /tmp/dst/
generator starting pid=16777550
delta-transmission disabled for local transfer or --whole-file
generate_files phase=1
send_files phase=1
recv_files(1) starting
recv_files phase=1
generate_files phase=2
send_files phase=2
send files finished
total: matches=0  hash_hits=0  false_alarms=0 data=0
recv_files phase=2
recv_files finished
generate_files phase=3
generate_files finished
client_run waiting on 16777550

sent 30 bytes  received 500 bytes  1,060.00 bytes/sec
total size is 10  speedup is 0.02
[sender] _exit_cleanup(code=0, file=main.c, line=1327): entered
[sender] _exit_cleanup(code=0, file=./main.c, line=1327): about to call exit(0)
FULTONM@zopen bash /tmp >ls -rtl src dst
src:
total 8
-rw-r--r--   1 FULTONM  ZOTGRP        10 Sep  4 18:18 f1.txt

dst:
total 0