From: Miklos S. <mi...@sz...> - 2015-05-21 14:59:16
|
On Wed, Apr 29, 2015 at 2:48 PM, John Salmon <Joh...@de...> wrote: > > The documentation says that the fi argument to the lowlevel getattr > callback is "for future use, currently always NULL". > > But in practice, I see that it is sometimes non-NULL. Is there > documentation describing when it is non-NULL. In the cases I've seen, > it is non-NULL when getattr is called to verify EOF on an open file. > But I'm curious about the details and whether there are other > situations where it is non-NULL. It's used from read, write and lseek to verify EOF. > When I noticed that fi was sometimes non-NULL, I had high hopes that > it would be non-NULL when a process called fstat on an open file > descriptor, and that fi->fh would contain the value set by the > corresponding open. Unfortunately, this seems not to be the case. > The behavior seems to depend on whether whether read was called > between the open and the fstat. For example, this idiom (which seems > to be common in dlopen) results in a call to > lowlevel_ops::getattr(..., fi=NULL). > > fd = open("/file/managed/by/my/fuse_process", O_RDONLY); > read(fd, buf, sz); > fstat(fd, &sb); > > Is there any way I can determine, in the fuse daemon, that the getattr > resulting from the above fstat is associated with a currently open > file? No. The linux VFS doesn't provide that information to filesystems, so fuse can't provide it to userspace filesystems. Thanks, Miklos |