From: Miklos S. <mi...@sz...> - 2006-05-03 13:08:24
|
> The problem is in the fact that the function pointers in fuse_operations > can only be set to point to *static* members of a C++ object, so in the > case of the init function we would have something like: > > class c_t { > static void *op_init(void) { > } > > void set_fuse_ops() { > struct fuse_operations fuse_ops = {.... > op_init, > ... }; > } > }; > > But op_init is static and hence it cannot get any information about the > object pointer for the instance of c_t from which set_fuse_ops is being > called. Hence I cannot define op_init such that it returns the object > pointer. You can set a global (or static member) variable to the c_t instance. Currently it doesn't make any sense to create multiple fuse objects per process, so this is not a serious limitation. In the next fuse version you will be able to pass a pointer to fuse_new()/fuse_main() which you can use in the init() method. > Then to get the object pointer I do: > > fuse_context *fc = fuse_get_context(); > if (fc) return static_cast<c_t*>(fc->fuse->user_data); Instead you can do: return static_cast<c_t*>(fuse_get_context()->private_data); Miklos |