虚拟文件的文件大小 [英] File size of virtual file
问题描述
我使用FUSE来创建一个覆盖文件系统,其中目录增加虚拟实体。我设置了这些实体的文件大小为0,因为我没有办法知道 - 阅读他们提前,这是在我的情况下,特别是昂贵的 - 他们应该是什么
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
).
因此,我的问题很简单,我应该怎么设置文件的大小?我知道,符号链接的大小的文件名长度的;将这项工作,因为它不是一个符号链接?否则,我所能做的最好是大小提供一个下界......如果读
只有一个文件描述符,块大小和偏移,presumably它读取'直到EOF,而不是任何统计
可以告诉它。
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.
推荐答案
文件大小必须正确。很多code取决于这些信息,你不能简单地忽略它。
The file size must be correct. A lot of code depends on this information, you can't simply omit it.
这意味着你需要找出一个有效的方法来缓存/ precalculate此信息。
That means you need to figure out an efficient way to cache/precalculate this information.
看一看的来源 cmdfs 运行在文件系统中的所有文件的命令。 Linux杂志有一个概述文章。
Have a look at the sources of cmdfs which runs a command on all files in the filesystem. Linux Magazine has an overview article.
这篇关于虚拟文件的文件大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!