MINIX内部碎片2 [英] MINIX Internal Fragmentation 2

查看:137
本文介绍了MINIX内部碎片2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C语言编写一些软件,递归列出所有文件在指定的目录,现在我需要制定出内部碎片的中间。

I am in the middle of writing some software in C that recursively lists all files in a given directory and now I need to work out the internal fragmentation.

我已经花了很长时间研究这一点,并发现,在ext2的内部碎片只是发生在最后一个块。我知道,从理论上一个索引节点号,你应该能够得到第一个和最后一个块地址,但我不知道怎么样。

I have spent a long time researching this and have found out that the internal fragmentation on ext2 only occurs in the last block. I know that from an inode number in theory you should be able to get the first and last block addresses but I have no idea how.

我已经调查 STAT()的fcntl()和各种方式。我如何从一个inode编号的最后一个块地址?

I have looked into stat(), fcntl() and all sorts of ways. How do I get the last block address from an inode number?

我也想通了,一旦我有最后一个块,我可以测试一下,看看有多少可用空间是在该块,这会给我的内部碎片。

I have also figured out that once I have the address of the last block that I can test to see how much free space is in that block and this will give me the internal fragmentation.

我知道有一个 get_inode get_block 命令,但不知道除此之外!

I know that there is a get_inode and a get_block command but have no idea apart from that!

推荐答案

也许你想的太复杂,但大致的内部碎片应该可以,如果你除以块大小的文件大小,并利用模计算。

Maybe you think too complicated, but roughly the internal fragmentation should be able to calculated if you divide the file size by the block size and take the modulo.

但是,如果该文件是一个经典一这是唯一有效的 - 与稀疏文件或文件持有多少等信息(如巨大的ACL或扩展属性),可能会有差异。 (我不知道他们的存储位置,但我能想象,有可能是将它们存储在最后的块,有效(但unnoticedly)减少了内部碎片的文件系统。)

But this is only valid if the file is a "classic one" - with sparse files or files holding much "other information" (such as huge ACLs or extended attributes), there might be a difference. (I don't know where they are stored, but I could imagine that there could be file systems storing them in the last block, effectively (but unnoticedly) reducing the internal fragmentation.)

这篇关于MINIX内部碎片2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆