version 1.1, 2000/08/31 21:52:23 |
version 1.2, 2000/09/01 22:29:32 |
|
|
}; |
}; |
|
|
int |
int |
errno_to_portable(int errno) |
errno_to_portable(int unixerrno) |
{ |
{ |
int ret = 0; |
int ret = 0; |
switch (errno) { |
switch (unixerrno) { |
case 0: |
case 0: |
ret = SSH_FX_OK; |
ret = SSH_FX_OK; |
break; |
break; |
|
|
if (a.flags & SSH_FXA_HAVE_SIZE) { |
if (a.flags & SSH_FXA_HAVE_SIZE) { |
a.size_high = get_int(); |
a.size_high = get_int(); |
a.size_low = get_int(); |
a.size_low = get_int(); |
a.size = a.size_high; |
a.size = (u_int64_t) a.size_high << 32 + a.size_low; |
a.size <<= 32; |
|
a.size += a.size_low; |
|
} |
} |
if (a.flags & SSH_FXA_HAVE_UGID) { |
if (a.flags & SSH_FXA_HAVE_UGID) { |
a.uid = get_int(); |
a.uid = get_int(); |
|
|
a.flags = 0; |
a.flags = 0; |
a.flags |= SSH_FXA_HAVE_SIZE; |
a.flags |= SSH_FXA_HAVE_SIZE; |
a.size = st->st_size; |
a.size = st->st_size; |
a.size_low = st->st_size; |
a.size_low = a.size; |
a.size_high = st->st_size >> 32; |
a.size_high = (u_int32_t) a.size >> 32; |
a.flags |= SSH_FXA_HAVE_UGID; |
a.flags |= SSH_FXA_HAVE_UGID; |
a.uid = st->st_uid; |
a.uid = st->st_uid; |
a.gid = st->st_gid; |
a.gid = st->st_gid; |
|
|
int version = buffer_get_int(&iqueue); |
int version = buffer_get_int(&iqueue); |
|
|
TRACE("client version %d", version); |
TRACE("client version %d", version); |
if (version != SSH_FILEXFER_VERSION) |
|
exit(1); |
|
buffer_init(&msg); |
buffer_init(&msg); |
buffer_put_char(&msg, SSH_FXP_VERSION); |
buffer_put_char(&msg, SSH_FXP_VERSION); |
buffer_put_int(&msg, SSH_FILEXFER_VERSION); |
buffer_put_int(&msg, SSH_FILEXFER_VERSION); |
|
|
off_low = get_int(); |
off_low = get_int(); |
len = get_int(); |
len = get_int(); |
|
|
off = off_high; |
off = (u_int64_t) off_high << 32 + off_low; |
off <<= 32; |
|
off += off_low; |
|
TRACE("read id %d handle %d off %qd len %d", id, handle, off, len); |
TRACE("read id %d handle %d off %qd len %d", id, handle, off, len); |
if (len > sizeof buf) { |
if (len > sizeof buf) { |
len = sizeof buf; |
len = sizeof buf; |
|
|
off_low = get_int(); |
off_low = get_int(); |
data = get_string(&len); |
data = get_string(&len); |
|
|
off = off_high; |
off = (u_int64_t) off_high << 32 + off_low; |
off <<= 32; |
|
off += off_low; |
|
TRACE("write id %d handle %d off %qd len %d", id, handle, off, len); |
TRACE("write id %d handle %d off %qd len %d", id, handle, off, len); |
fd = handle_to_fd(handle); |
fd = handle_to_fd(handle); |
if (fd >= 0) { |
if (fd >= 0) { |
|
|
{ |
{ |
u_int32_t id; |
u_int32_t id; |
char *oldpath, *newpath; |
char *oldpath, *newpath; |
int ret; |
int ret, status; |
int status = SSH_FX_FAILURE; |
|
|
|
id = get_int(); |
id = get_int(); |
oldpath = get_string(NULL); |
oldpath = get_string(NULL); |
newpath = get_string(NULL); |
newpath = get_string(NULL); |
TRACE("rename id %d old %s new %s", id, oldpath, newpath); |
TRACE("rename id %d old %s new %s", id, oldpath, newpath); |
ret = rename(oldpath, newpath); |
ret = rename(oldpath, newpath); |
if (ret != -1) |
status = (ret == -1) ? errno_to_portable(errno) : SSH_FX_OK; |
status = SSH_FX_OK; |
|
send_status(id, status); |
send_status(id, status); |
xfree(oldpath); |
xfree(oldpath); |
xfree(newpath); |
xfree(newpath); |