From: Kevin F. <Kev...@pn...> - 2011-06-17 16:40:30
|
On Fri, 2011-06-17 at 04:08 -0700, Sven Utcke wrote: > Hallo Wesley, > > > > I believe getattr's file size is used by fuse. If you are > > > returning zero, the extra stuff in a read past the size wont > > > matter. You might check on that first. > > > > I did some tests and i think you're right. Many smartcards don't > > report the file size so i returned 0 bytes in getattr. I not changed > > it to a static value and that made the hello world read function > > work. > > > > Is there any way to work around this ? As said, many cards don't > > report their file sizes and i'm also planning to return an > > interpreted version of the data instead of the raw data so there > > would be no way to guess that before actually reading the file. > > And pre-reading it, presumably, would be to expensive. > > > Could i for example just report a (relatively) large file size so my > > data will always fit in ? > > Not particularly elegant, but ought to work. After all, read() needs > to be able to deal with files getting truncated while reading anyway. > And, of course, once read you could cache that size :-) This fuse behavior has troubled me for a while now and I'd like to know how to do it properly. Say you have your file stored in a network file system, you return the size known in the getattr, a third party appends some stuff to the end of the file without your knowledge and then a read comes out of your file system. Will fuse truncate the read on the file down to the originally stated size? That would seem wrong. How would you tell fuse to not truncate but to accept the extra data? Kevin > > Sven |