Hi Pawel,

On Wednesday 09 May 2007 23:40:53 Pawel Jakub Dawidek wrote:
> Simple test that does open(O_CREAT)/fstat()/unlink()/fstat() seems to
> work fine on both FreeBSD and Solaris. Maybe your problem is somewhere
> else?

I understand that, but the FUSE low-level API doesn't use vnodes to identify 
files, it uses the inode number.

So when a program calls fstat() it generates a GETATTR event in FUSE that must 
be handled by a function with this prototype:

--
int zfsfuse_getattr(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info 
*fi);
--

So the file is identified by the "ino" parameter (the inode number). If you're 
wondering what the "fi" parameter is for - in this handler it's reserved for 
future use and is always NULL.

So in order to get the associated vnode I must call zfs_zget() first, at the 
top of almost every FUSE handler:

...

vfs_t *vfs = (vfs_t *) fuse_req_userdata(req);
zfsvfs_t *zfsvfs = vfs->vfs_data;

ZFS_ENTER(zfsvfs);
znode_t *znode;

int error = zfs_zget(zfsvfs, ino, &znode, B_TRUE);
...

The problem is that zfs_zget() will return ENOENT if the inode has been 
unlinked, so that's why I had to add that boolean parameter.

Reply via email to