[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scp example: file type code instead of permission bits ?
- Subject: scp example: file type code instead of permission bits ?
- From: baptiste marchand <baptistemarchand42@xxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Wed, 3 Aug 2011 20:00:15 +0200
- To: libssh@xxxxxxxxxx
Good Evening, I was playing with the scp example (libssh_scp.c) and when I tried to copy a local file to a remote location ( ie: ./libssh_scp source.txt localhost:destination.txt ) I got the following error: scp status code 1d not valid. I noticed that at line 185: mode = s.st_mode & S_IFMT; "mode" is set to the* file type code * And then we use it in line 210: r=ssh_scp_push_file(dest->scp,src->path, size, mode); However in the documentation of the ssh_scp_push_file (here<http://api.libssh.org/stable/group__libssh__scp.html#ga544f4b9c525071910110ada94148adc6>) it is sais that mode is "The* UNIX permissions* for the new file, e.g. 0644." So I replaced the line 185 with this: mode = s.st_mode & *~*S_IFMT; The only difference is the tild, it inverts the value of S_IFMT so we get the other part of s.st_mode wich is the permission bits. It seems to work. Anyway, I hope that I didn't waste your time with a known issue, Regards, -- Baptiste Marchand - EPITA 2013 06.31.01.87.38
|Re: scp example: file type code instead of permission bits ?||Andreas Schneider <asn@xxxxxxxxxxxxxx>|