From: Franco B. <fr...@fu...> - 2006-01-13 10:25:42
|
It does work, that's exactly how I use FUSE. In the open routine do: res = open(path, flags); fi->fh = res; And in the read routine do: int fd = fi->fh; res = pread(fd, buf, size, offset); On Fri, 2006-01-13 at 11:16 +0100, Bjorn Lalin wrote: > Hello, > > I was simply wondering if there is a reason to store the file handle > of > the open() wrapper when making a file system. > > The thing is a wanna make a wrapper filesystem with some logging, > and it seems expensive to do an open() + read() + close() on every > read performed (what is being done in the example filesystem given > with fuse). Or? The thing is I made a small test to log all calls into > the fuse_operations struct to a file, printing all arguments given > etc. and > then simply mounting the fs and doing an > > echo "test" > testfile > > I then took a look at the logfile and the ->fh field of the struct > fuse_file_info > passed into the read call, and discovered that the file handle I > stored in the > open() code is not there anymore. > > However when release is called I get the correct file handle integer > passed > in the struct. > > Can anyone explain to me what is going on here, and how to code the > open(), > read(), write(), and release() correctly? > > best regards, > Bjorn |