|
Lines 76-81
struct sftp_conn {
Link Here
|
| 76 |
#define SFTP_EXT_STATVFS 0x00000002 |
76 |
#define SFTP_EXT_STATVFS 0x00000002 |
| 77 |
#define SFTP_EXT_FSTATVFS 0x00000004 |
77 |
#define SFTP_EXT_FSTATVFS 0x00000004 |
| 78 |
#define SFTP_EXT_HARDLINK 0x00000008 |
78 |
#define SFTP_EXT_HARDLINK 0x00000008 |
|
|
79 |
#define SFTP_EXT_LSETSTAT 0x00000016 |
| 79 |
u_int exts; |
80 |
u_int exts; |
| 80 |
u_int64_t limit_kbps; |
81 |
u_int64_t limit_kbps; |
| 81 |
struct bwlimit bwlimit_in, bwlimit_out; |
82 |
struct bwlimit bwlimit_in, bwlimit_out; |
|
Lines 387-392
do_init(int fd_in, int fd_out, u_int tra
Link Here
|
| 387 |
strcmp(value, "1") == 0) { |
387 |
strcmp(value, "1") == 0) { |
| 388 |
ret->exts |= SFTP_EXT_HARDLINK; |
388 |
ret->exts |= SFTP_EXT_HARDLINK; |
| 389 |
known = 1; |
389 |
known = 1; |
|
|
390 |
} else if (strcmp(name, "lsetstat@openssh.com") == 0 && |
| 391 |
strcmp(value, "1") == 0) { |
| 392 |
ret->exts |= SFTP_EXT_LSETSTAT; |
| 393 |
known = 1; |
| 390 |
} |
394 |
} |
| 391 |
if (known) { |
395 |
if (known) { |
| 392 |
debug2("Server supports extension \"%s\" revision %s", |
396 |
debug2("Server supports extension \"%s\" revision %s", |
|
Lines 833-838
do_hardlink(struct sftp_conn *conn, char
Link Here
|
| 833 |
} |
834 |
} |
| 834 |
|
835 |
|
| 835 |
int |
836 |
int |
|
|
837 |
do_lsetstat(struct sftp_conn *conn, char *path, Attrib *a) |
| 838 |
{ |
| 839 |
Buffer msg; |
| 840 |
u_int status, id; |
| 841 |
|
| 842 |
buffer_init(&msg); |
| 843 |
/* Send link request */ |
| 844 |
id = conn->msg_id++; |
| 845 |
if ((conn->exts & SFTP_EXT_HARDLINK) == 0) { |
| 846 |
error("Server does not support hardlink@openssh.com extension"); |
| 847 |
return -1; |
| 848 |
} |
| 849 |
|
| 850 |
buffer_put_char(&msg, SSH2_FXP_EXTENDED); |
| 851 |
buffer_put_int(&msg, id); |
| 852 |
buffer_put_cstring(&msg, "lsetstat@openssh.com"); |
| 853 |
buffer_put_cstring(&msg, path); |
| 854 |
encode_attrib(&msg, a); |
| 855 |
send_msg(conn, &msg); |
| 856 |
debug3("Sent message lsetstat@openssh.com \"%s\"", |
| 857 |
path); |
| 858 |
buffer_free(&msg); |
| 859 |
|
| 860 |
status = get_status(conn, id); |
| 861 |
if (status != SSH2_FX_OK) |
| 862 |
error("Couldn't lsetstat file \"%s\": %s", |
| 863 |
path, fx2txt(status)); |
| 864 |
|
| 865 |
return(status); |
| 866 |
} |
| 867 |
|
| 868 |
int do_create(struct sftp_conn *conn, char *path, Attrib *a) |
| 869 |
{ |
| 870 |
Buffer msg; |
| 871 |
u_int status, id, handle_len; |
| 872 |
char *handle; |
| 873 |
|
| 874 |
buffer_init(&msg); |
| 875 |
|
| 876 |
/* Send open request */ |
| 877 |
id = conn->msg_id++; |
| 878 |
buffer_put_char(&msg, SSH2_FXP_OPEN); |
| 879 |
buffer_put_int(&msg, id); |
| 880 |
buffer_put_cstring(&msg, path); |
| 881 |
buffer_put_int(&msg, SSH2_FXF_CREAT); |
| 882 |
encode_attrib(&msg, a); |
| 883 |
send_msg(conn, &msg); |
| 884 |
debug3("Sent message SSH2_FXP_OPEN I:%u P:%s", id, path); |
| 885 |
|
| 886 |
/* Get Handle */ |
| 887 |
handle = get_handle(conn, id, &handle_len, |
| 888 |
"remote open(\"%s\")", path); |
| 889 |
if (handle == NULL) { |
| 890 |
buffer_free(&msg); |
| 891 |
return(-1); |
| 892 |
} |
| 893 |
|
| 894 |
/* Send close request */ |
| 895 |
status=do_close(conn, handle, handle_len); |
| 896 |
buffer_free(&msg); |
| 897 |
xfree(handle); |
| 898 |
if (status != SSH2_FX_OK) |
| 899 |
error("Couldn't create file \"%s\": %s", |
| 900 |
path, fx2txt(status)); |
| 901 |
|
| 902 |
return status; |
| 903 |
} |
| 904 |
|
| 905 |
int |
| 836 |
do_symlink(struct sftp_conn *conn, char *oldpath, char *newpath) |
906 |
do_symlink(struct sftp_conn *conn, char *oldpath, char *newpath) |
| 837 |
{ |
907 |
{ |
| 838 |
Buffer msg; |
908 |
Buffer msg; |