|
From: Joachim S. <js...@la...> - 2013-07-22 08:55:50
|
this one is actually quite simple:
when creating:
struct fuse_operations fusefs_oper;
just use NULL where no functionality should be present, this works
perfectly as read_buf is now not used anymore.
QFuse::QFuse(QObject* parent) : QObject(parent) {
fusefs_oper.getattr = wrap_getattr;
fusefs_oper.readlink = wrap_readlink;
fusefs_oper.getdir = NULL;
fusefs_oper.mknod = wrap_mknod;
fusefs_oper.mkdir = wrap_mkdir;
fusefs_oper.unlink = wrap_unlink;
fusefs_oper.rmdir = wrap_rmdir;
fusefs_oper.symlink = wrap_symlink;
fusefs_oper.rename = wrap_rename;
fusefs_oper.link = wrap_link;
fusefs_oper.chmod = wrap_chmod;
fusefs_oper.chown = wrap_chown;
fusefs_oper.truncate = wrap_truncate;
fusefs_oper.utime = wrap_utime;
fusefs_oper.open = wrap_open;
fusefs_oper.read = wrap_read;
fusefs_oper.read_buf = NULL;
fusefs_oper.write = wrap_write;
fusefs_oper.statfs = wrap_statfs;
fusefs_oper.flush = wrap_flush;
fusefs_oper.release = wrap_release;
fusefs_oper.fsync = wrap_fsync;
fusefs_oper.setxattr = wrap_setxattr;
fusefs_oper.getxattr = wrap_getxattr;
fusefs_oper.listxattr = wrap_listxattr;
fusefs_oper.removexattr = wrap_removexattr;
fusefs_oper.opendir = wrap_opendir;
fusefs_oper.readdir = wrap_readdir;
fusefs_oper.releasedir = wrap_releasedir;
fusefs_oper.fsyncdir = wrap_fsyncdir;
fusefs_oper.init = wrap_init;
fusefs_oper.access = wrap_access;
fusefs_oper.fgetattr = wrap_fgetattr;
fusefs_oper.ftruncate = NULL;
fusefs_oper.fgetattr = NULL;
fusefs_oper.lock = NULL;
fusefs_oper.utimens = NULL;
fusefs_oper.bmap = NULL;
fusefs_oper.flag_nullpath_ok = NULL;
fusefs_oper.flag_nopath = NULL;
fusefs_oper.flag_utime_omit_ok = NULL;
fusefs_oper.flag_reserved = NULL;
fusefs_oper.ioctl = NULL;
fusefs_oper.poll = NULL;
fusefs_oper.write_buf = NULL;
fusefs_oper.read_buf = NULL;
fusefs_oper.flock = NULL;
}
except for some minor things the QFuse example, mixing Qt and FUSE is
now final and can be seen at:
https://github.com/qknight/qfuse
i hope this is of help for others.
best wishes,
joachim schiele
On 07/21/2013 06:17 PM, Joachim Schiele wrote:
> new findings:
>
> ============= fuse.c ================================
> int fuse_fs_read_buf(struct fuse_fs *fs, const char *path,
> struct fuse_bufvec **bufp, size_t size, off_t off,
> struct fuse_file_info *fi)
> {
> fuse_get_context()->private_data = fs->user_data;
> if (fs->op.read || fs->op.read_buf) {
> int res;
>
> if (fs->debug)
> fprintf(stderr,
> "read[%llu] %zu bytes from %llu flags: 0x%x\n",
> (unsigned long long) fi->fh,
> size, (unsigned long long) off, fi->flags);
>
> if (fs->op.read_buf) {
> res = fs->op.read_buf(path, bufp, size, off, fi);
> } else {
> struct fuse_bufvec *buf;
> ...
>
> =====================================================================
>
> the fuse library checks if fs->op.read_buf is implemented. if not it
> simply uses fs->op.read instead. that solved one issue i was about to
> report, that FUSE here would segfault when wanting to use read(..) after
> a while i implemented all possible callbacks just to see that it was not
> segfaulting then... ;-)
>
> now i have to find a way to mix my c++ with that c struct which is a bit
> complicated to say the least.
>
> ===== fuseexmp.c =====
> static struct fuse_operations xmp_oper = {
> .getattr = xmp_getattr,
> .access = xmp_access,
> ...
> };
> ======================
>
> ==== QFuse ====
> my c++ implementation:
>
> ====== QFuse.h ======
> class QFuse : public QObject {
> ...
> private:
> struct fuse_operations fusefs_oper;
> int fuse_stat;
> };
> ====== QFuse.cpp ======
> fusefs_oper.getattr = wrap_getattr;
> fusefs_oper.readlink = wrap_readlink;
> ...
> fusefs_oper.read_buf = wrap_read_buf;
> =======================
>
> the problem seems to be that:
> if (fs->op.read_buf)
>
> returns true no matter if i listed read_buf or not resulting in an
> segfault when it wants to call the read_buf callback - which is not there.
>
> anyone an idea?
>
>
>
> On 07/19/2013 11:37 AM, Joachim Schiele wrote:
>> dear fuse-developers,
>>
>> === what is read_buf(..) and how is it supposed to be working ===
>> i was looking at the fuse.h source code documentation and the
>> fusexmp_fh.c implementation. but still i don't understand what
>> read_buf(..) is supposed to be doing.
>>
>> is there another example for how to use read_buf(..)?
>>
>>
>> === my client wants read_buf(..) but i want to use read(..) ===
>> my current FUSE client implementation wants to use read_buf(..) and not
>> read(..). why is that?
>>
>> i really don't understand why hello.c uses read(..) and my
>> implementation, which is basically a 1:1 copy of hello.c, wants to use
>> read_buf(..) instead.
>>
>> i hope someone can help me!
>>
>> best wishes,
>> joachim
>>
>>
>>
>>
>>
>> === function signatures of read(..) and read_buf(..) ===
>>
>> int read(const char *path, char *buf, size_t size, off_t offset, struct
>> fuse_file_info *fileInfo) {
>> ...
>> }
>>
>> /** Store data from an open file in a buffer
>> *
>> * Similar to the read() method, but data is stored and
>> * returned in a generic buffer.
>> *
>> * No actual copying of data has to take place, the source
>> * file descriptor may simply be stored in the buffer for
>> * later data transfer.
>> *
>> * The buffer must be allocated dynamically and stored at the
>> * location pointed to by bufp. If the buffer contains memory
>> * regions, they too must be allocated using malloc(). The
>> * allocated memory will be freed by the caller.
>> *
>> * Introduced in version 2.9
>> */
>> int read_buf(const char *path, struct fuse_bufvec **bufp, size_t size,
>> off_t off, struct fuse_file_info *fileInfo) {
>> ...
>> }
|