rem: struct buffer *handle = &sf->handle; (void) path; buf_init(&buf, 0); buf_add_buf(&buf, handle); buf_add_uint64(&buf, offset); buf_add_uint32(&buf, size); err = sftp_request(SSH_FXP_READ, &buf, SSH_FXP_DATA, &data); if (!err) { uint32_t retsize; err = -EPROTO; if (buf_get_uint32(&data, &retsize) != -1) { if (retsize > size) fprintf(stderr, "long read\n"); else { buf_get_mem(&data, rbuf, retsize); err = retsize; } } buf_free(&data); } else if (err == MY_EOF) err = 0; buf_free(&buf); return err;
add: if (sync_read) res = sshfs_sync_read(sf, rbuf, size, offset); else { struct read_chunk *chunk; (void) path;  pthread_mutex_lock(&lock); chunk = search_read_chunk(sf, size, offset); pthread_mutex_unlock(&lock); if (!chunk) res = submit_read(sf, size, offset, &chunk); if (!res) submit_read(sf, size, offset + size, &sf->readahead); if (!res) res = wait_chunk(chunk, rbuf); }  return res;
context: static int sshfs_read(const char *path, char *rbuf, size_t size, off_t offset,                      struct fuse_file_info *fi){    int err;    struct buffer buf;    struct buffer data;    struct sshfs_file *sf = (struct sshfs_file *) fi->fh;    struct buffer *handle = &sf->handle;    (void) path;    buf_init(&buf, 0);    buf_add_buf(&buf, handle);    buf_add_uint64(&buf, offset);    buf_add_uint32(&buf, size);    err = sftp_request(SSH_FXP_READ, &buf, SSH_FXP_DATA, &data);    if (!err) {        uint32_t retsize;        err = -EPROTO;        if (buf_get_uint32(&data, &retsize) != -1) {            if (retsize > size)                fprintf(stderr, "long read\n");            else {                buf_get_mem(&data, rbuf, retsize);                err = retsize;            }        }        buf_free(&data);    } else if (err == MY_EOF)        err = 0;    buf_free(&buf);    return err;    }