在 Linux 中编写由多个文件组成的环回设备
Hej,
在 Linux 中使用 losetup
使用文件来模拟块设备相对容易:
任何人都可以给我一个提示,告诉我要寻找什么,以防我想对自己的块设备进行编程,该块设备基于我从中获取内容的多个文件?为了您的理解,我想说从 file1 中取出字节 1-500 和 1.000-3.000,从 file2 中取出字节 501-999 和字节 3.001 到 5.000,将它们作为组合块设备提供。我最喜欢的编程语言是 Python,我希望尽可能在用户空间中编写程序。
对于Windows我找到了这样的实现。它称为 FileDisk 和 HttpDisk,可以在这里找到:
提前致谢并致以问候, 赖纳
Hej,
it is relatively easy to use a file for emulating a block-device using losetup
in Linux:
Can anyone please give me a hint on what to look for in case I want to program my own block-device which is based on several files I'm taking content from? For your understanding, I would like to let's say take bytes 1-500 and 1.000-3.000 from file1 and bytes 501-999 and bytes 3.001 to 5.000 from file2 to offer them as a combined block-device. My prefered programming language is Python and I want to write my program in user-space as much as possible.
For Windows I found such an implementation. It's called FileDisk and HttpDisk and it can be found here:
Thanks in advance and regards,
Rainer
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不需要编写任何程序。您可以使用 Linux 的多设备(又名
md
)子系统为自己构建一个由许多较小设备组成的块设备。为此,您可以使用
mdadm
组装LINEAR
从较小的设备中删除设备。更新
所以这就是我所做的:
请注意,我使用
$
作为提示,以免混淆自动语法突出显示;)就这么简单。
干杯。
PS:现在这确实符合超级用户的资格,不是吗?
You don't need to program anything. You can use Linux's multi-device (a.k.a.
md
) subsystem to build yourself a block device which consists of a number of smaller devices.For this to work you use
mdadm
to assemble aLINEAR
raid device out of smaller devices.Update
So here is what I did:
Note that I used
$
as prompt to not confuse automatic syntax highlighting ;)As easy as that.
Cheers.
PS: Now this really qualifies for superuser, doesn't it?
如果您想完全保留在用户空间中,使用简单的 API,我强烈推荐 FUSE ,这将是 使用 Python 实现相对简单。
If you want to stay completely in userspace, with a simple API, I highly recommend FUSE which would be relatively simple to do with Python.