Lines Matching refs:conn

85 get_handle(struct sftp_conn *conn, u_int expected_id, u_int *len,
99 send_msg(struct sftp_conn *conn, Buffer *m)
114 if (atomiciov6(writev, conn->fd_out, iov, 2,
115 conn->limit_kbps > 0 ? sftpio : NULL, &conn->bwlimit_out) !=
123 get_msg(struct sftp_conn *conn, Buffer *m)
128 if (atomicio6(read, conn->fd_in, buffer_ptr(m), 4,
129 conn->limit_kbps > 0 ? sftpio : NULL, &conn->bwlimit_in) != 4) {
141 if (atomicio6(read, conn->fd_in, buffer_ptr(m), msg_len,
142 conn->limit_kbps > 0 ? sftpio : NULL, &conn->bwlimit_in)
152 send_string_request(struct sftp_conn *conn, u_int id, u_int code, char *s,
161 send_msg(conn, &msg);
162 debug3("Sent message fd %d T:%u I:%u", conn->fd_out, code, id);
167 send_string_attrs_request(struct sftp_conn *conn, u_int id, u_int code,
177 send_msg(conn, &msg);
178 debug3("Sent message fd %d T:%u I:%u", conn->fd_out, code, id);
183 get_status(struct sftp_conn *conn, u_int expected_id)
189 get_msg(conn, &msg);
208 get_handle(struct sftp_conn *conn, u_int expected_id, u_int *len,
223 get_msg(conn, &msg);
247 get_decode_stat(struct sftp_conn *conn, u_int expected_id, int quiet)
254 get_msg(conn, &msg);
282 get_decode_statvfs(struct sftp_conn *conn, struct sftp_statvfs *st,
289 get_msg(conn, &msg);
419 sftp_proto_version(struct sftp_conn *conn)
421 return conn->version;
425 do_close(struct sftp_conn *conn, char *handle, u_int handle_len)
432 id = conn->msg_id++;
436 send_msg(conn, &msg);
439 status = get_status(conn, id);
450 do_lsreaddir(struct sftp_conn *conn, char *path, int printflag,
457 id = conn->msg_id++;
463 send_msg(conn, &msg);
467 handle = get_handle(conn, id, &handle_len,
479 id = expected_id = conn->msg_id++;
487 send_msg(conn, &msg);
491 get_msg(conn, &msg);
511 do_close(conn, handle, handle_len);
560 do_close(conn, handle, handle_len);
574 do_readdir(struct sftp_conn *conn, char *path, SFTP_DIRENT ***dir)
576 return(do_lsreaddir(conn, path, 0, dir));
592 do_rm(struct sftp_conn *conn, char *path)
598 id = conn->msg_id++;
599 send_string_request(conn, id, SSH2_FXP_REMOVE, path, strlen(path));
600 status = get_status(conn, id);
607 do_mkdir(struct sftp_conn *conn, char *path, Attrib *a, int printflag)
611 id = conn->msg_id++;
612 send_string_attrs_request(conn, id, SSH2_FXP_MKDIR, path,
615 status = get_status(conn, id);
623 do_rmdir(struct sftp_conn *conn, char *path)
627 id = conn->msg_id++;
628 send_string_request(conn, id, SSH2_FXP_RMDIR, path,
631 status = get_status(conn, id);
639 do_stat(struct sftp_conn *conn, char *path, int quiet)
643 id = conn->msg_id++;
645 send_string_request(conn, id,
646 conn->version == 0 ? SSH2_FXP_STAT_VERSION_0 : SSH2_FXP_STAT,
649 return(get_decode_stat(conn, id, quiet));
653 do_lstat(struct sftp_conn *conn, char *path, int quiet)
657 if (conn->version == 0) {
662 return(do_stat(conn, path, quiet));
665 id = conn->msg_id++;
666 send_string_request(conn, id, SSH2_FXP_LSTAT, path,
669 return(get_decode_stat(conn, id, quiet));
674 do_fstat(struct sftp_conn *conn, char *handle, u_int handle_len, int quiet)
678 id = conn->msg_id++;
679 send_string_request(conn, id, SSH2_FXP_FSTAT, handle,
682 return(get_decode_stat(conn, id, quiet));
687 do_setstat(struct sftp_conn *conn, char *path, Attrib *a)
691 id = conn->msg_id++;
692 send_string_attrs_request(conn, id, SSH2_FXP_SETSTAT, path,
695 status = get_status(conn, id);
704 do_fsetstat(struct sftp_conn *conn, char *handle, u_int handle_len,
709 id = conn->msg_id++;
710 send_string_attrs_request(conn, id, SSH2_FXP_FSETSTAT, handle,
713 status = get_status(conn, id);
721 do_realpath(struct sftp_conn *conn, char *path)
728 expected_id = id = conn->msg_id++;
729 send_string_request(conn, id, SSH2_FXP_REALPATH, path,
734 get_msg(conn, &msg);
769 do_rename(struct sftp_conn *conn, char *oldpath, char *newpath)
777 id = conn->msg_id++;
778 if ((conn->exts & SFTP_EXT_POSIX_RENAME)) {
788 send_msg(conn, &msg);
790 (conn->exts & SFTP_EXT_POSIX_RENAME) ? "posix-rename@openssh.com" :
794 status = get_status(conn, id);
803 do_hardlink(struct sftp_conn *conn, char *oldpath, char *newpath)
811 id = conn->msg_id++;
812 if ((conn->exts & SFTP_EXT_HARDLINK) == 0) {
822 send_msg(conn, &msg);
827 status = get_status(conn, id);
836 do_symlink(struct sftp_conn *conn, char *oldpath, char *newpath)
841 if (conn->version < 3) {
849 id = conn->msg_id++;
854 send_msg(conn, &msg);
859 status = get_status(conn, id);
869 do_readlink(struct sftp_conn *conn, char *path)
876 expected_id = id = conn->msg_id++;
877 send_string_request(conn, id, SSH2_FXP_READLINK, path, strlen(path));
881 get_msg(conn, &msg);
916 do_statvfs(struct sftp_conn *conn, const char *path, struct sftp_statvfs *st,
922 if ((conn->exts & SFTP_EXT_STATVFS) == 0) {
927 id = conn->msg_id++;
935 send_msg(conn, &msg);
938 return get_decode_statvfs(conn, st, id, quiet);
943 do_fstatvfs(struct sftp_conn *conn, const char *handle, u_int handle_len,
949 if ((conn->exts & SFTP_EXT_FSTATVFS) == 0) {
954 id = conn->msg_id++;
962 send_msg(conn, &msg);
965 return get_decode_statvfs(conn, st, id, quiet);
970 send_read_request(struct sftp_conn *conn, u_int id, u_int64_t offset,
982 send_msg(conn, &msg);
987 do_download(struct sftp_conn *conn, char *remote_path, char *local_path,
1009 if (a == NULL && (a = do_stat(conn, remote_path, 0)) == NULL)
1029 buflen = conn->transfer_buflen;
1033 id = conn->msg_id++;
1040 send_msg(conn, &msg);
1043 handle = get_handle(conn, id, &handle_len,
1055 do_close(conn, handle, handle_len);
1090 req->id = conn->msg_id++;
1096 send_read_request(conn, req->id, req->offset,
1101 get_msg(conn, &msg);
1153 req->id = conn->msg_id++;
1156 send_read_request(conn, req->id,
1170 } else if (max_req <= conn->num_requests) {
1191 do_close(conn, handle, handle_len);
1196 do_close(conn, handle, handle_len);
1198 status = do_close(conn, handle, handle_len);
1226 download_dir_internal(struct sftp_conn *conn, char *src, char *dst,
1240 (dirattrib = do_stat(conn, src, 1)) == NULL) {
1263 if (do_readdir(conn, src, &dir_entries) == -1) {
1278 if (download_dir_internal(conn, new_src, new_dst,
1283 if (do_download(conn, new_src, new_dst,
1316 download_dir(struct sftp_conn *conn, char *src, char *dst,
1322 if ((src_canon = do_realpath(conn, src)) == NULL) {
1327 ret = download_dir_internal(conn, src_canon, dst,
1334 do_upload(struct sftp_conn *conn, char *local_path, char *remote_path,
1385 id = conn->msg_id++;
1391 send_msg(conn, &msg);
1396 handle = get_handle(conn, id, &handle_len,
1405 data = xmalloc(conn->transfer_buflen);
1424 len = read(local_fd, data, conn->transfer_buflen);
1445 send_msg(conn, &msg);
1455 id - ackid >= conn->num_requests) {
1459 get_msg(conn, &msg);
1507 do_fsetstat(conn, handle, handle_len, &a);
1509 if (do_close(conn, handle, handle_len) != SSH2_FX_OK)
1517 upload_dir_internal(struct sftp_conn *conn, char *src, char *dst,
1552 status = do_mkdir(conn, dst, &a, 0);
1561 if (do_stat(conn, dst, 0) == NULL)
1586 if (upload_dir_internal(conn, new_src, new_dst,
1590 if (do_upload(conn, new_src, new_dst, pflag) == -1) {
1601 do_setstat(conn, dst, &a);
1608 upload_dir(struct sftp_conn *conn, char *src, char *dst, int printflag,
1614 if ((dst_canon = do_realpath(conn, dst)) == NULL) {
1619 ret = upload_dir_internal(conn, src, dst_canon, pflag, printflag, 0);