uint32_t sftp_v456_fstat(struct sftpjob *job) { int fd; struct handleid id; struct stat sb; uint32_t rc; pcheck(sftp_parse_handle(job, &id)); D(("sftp_fstat %" PRIu32 " %" PRIu32, id.id, id.tag)); if((rc = sftp_handle_get_fd(&id, &fd, 0))) return rc; return sftp_v456_stat_core(job, fstat(fd, &sb), &sb, 0); }
void queue_serializable_job(struct sftpjob *job) { uint8_t type; uint32_t id; uint64_t offset, len64; uint32_t len; struct handleid hid; unsigned handleflags; struct sqnode *q; job->ptr = job->data; job->left = job->len; if(!sftp_parse_uint8(job, &type) && (type == SSH_FXP_READ || type == SSH_FXP_WRITE) && sftp_parse_uint32(job, &id) == SSH_FX_OK && sftp_parse_handle(job, &hid) == SSH_FX_OK && sftp_parse_uint64(job, &offset) == SSH_FX_OK && sftp_parse_uint32(job, &len) == SSH_FX_OK) { /* This is a well-formed read or write operation */ len64 = len; handleflags = sftp_handle_flags(&hid); } else { /* Anything else has dummy values */ memset(&hid, 0, sizeof hid); offset = 0; len64 = ~(uint64_t)0; handleflags = 0; } ferrcheck(pthread_mutex_lock(&sq_mutex)); q = xmalloc(sizeof *q); q->older = newest; q->job = job; q->type = type; q->hid = hid; q->handleflags = handleflags; q->offset = offset; q->len = len64; newest = q; ferrcheck(pthread_mutex_unlock(&sq_mutex)); }