static int iconv_read_buf(const char *path, struct fuse_bufvec **bufp, size_t size, off_t offset, struct fuse_file_info *fi) { struct iconv *ic = iconv_get(); char *newpath; int err = iconv_convpath(ic, path, &newpath, 0); if (!err) { err = fuse_fs_read_buf(ic->next, newpath, bufp, size, offset, fi); free(newpath); } return err; }
static int subdir_read_buf(const char *path, struct fuse_bufvec **bufp, size_t size, off_t offset, struct fuse_file_info *fi) { struct subdir *d = subdir_get(); char *newpath; int err = subdir_addpath(d, path, &newpath); if (!err) { err = fuse_fs_read_buf(d->next, newpath, bufp, size, offset, fi); free(newpath); } return err; }
static int volicon_read_buf(const char *path, struct fuse_bufvec **bufp, size_t size, off_t offset, struct fuse_file_info *fi) { int res = 0; if (volicon_is_icon_magic_file(path)) { struct fuse_bufvec *buf; void *mem; size_t a_size; buf = malloc(sizeof(struct fuse_bufvec)); if (buf == NULL) { return -ENOMEM; } if ((offset + size) <= volicon_get()->volicon_size) { a_size = size; } else if (offset < volicon_get()->volicon_size) { a_size = volicon_get()->volicon_size - offset; } else { a_size = 0; } mem = malloc(a_size); if (mem == NULL) { free(buf); return -ENOMEM; } memcpy(mem, (char *)(volicon_get()->volicon_data) + offset, a_size); *buf = FUSE_BUFVEC_INIT(size); buf->buf[0].mem = mem; buf->buf[0].size = a_size; *bufp = buf; } else { res = fuse_fs_read_buf(volicon_get()->next, path, bufp, size, offset, fi); } return res; }