File size of virtual file

China☆狼群 提交于 2019-12-12 02:28:40

问题


I'm using FUSE to create an overlay filesystem, where directories are augmented with virtual entities. I am setting the file size of these entities to 0, because I have no way of knowing -- ahead of reading them, which is particularly expensive in my case -- what they should be.

However, there seems to be an obvious optimisation taking place, insofar as zero-length files don't incur any read call (only open and release).

My question therefore is simply, what should I set the file size to? I know symlinks have a size of their filename length; would this work, given it's not a symlink? Otherwise, the best I can do is provide a lower bound for the size... If read only has a file descriptor, chunk size and offset, presumably it reads 'til EOF rather than whatever stat can tell it.


回答1:


The file size must be correct. A lot of code depends on this information, you can't simply omit it.

That means you need to figure out an efficient way to cache/precalculate this information.

Have a look at the sources of cmdfs which runs a command on all files in the filesystem. Linux Magazine has an overview article.



来源:https://stackoverflow.com/questions/31940468/file-size-of-virtual-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!