ntcreatefile 分配大小 [英] Ntcreatefile allocationsize

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

问题描述

AllocationSize 参数的用途是什么在函数 Ntcreatefile 中?

what is the purpose of AllocationSize parameter in the function Ntcreatefile ?

AllocationSize 使用非零值并使用 NtClose 关闭文件时,实际文件大小不等于 AllocationSize.

When using a non zero value for AllocationSize and closing the file with NtClose, the real file size is not equal to AllocationSize.

为什么?

这个参数好像没什么用.

This parameter seems to have no use.

谢谢

推荐答案

NtCreateFile() 不会对参数做任何特殊处理,它只是将参数传递给 MJ_CREATE 请求中的文件系统驱动程序.您将需要 WDK 来查看它的使用情况.值得一看的是 FAT 驱动程序,您会在 src/filesys/fastfat/w2k/create.c 中找到 AllocationSize.按照调用链进入 allocsup.c,FatAllocateDiskSpace().

NtCreateFile() doesn't do anything special with the argument, it simply passes it on to the file system driver in the MJ_CREATE request. You'll need the WDK to see how it is getting used. A good one to look at is the FAT driver, you'll find the AllocationSize used in src/filesys/fastfat/w2k/create.c. Follow the call chain into allocsup.c, FatAllocateDiskSpace().

预先知道预期分配大小的机会比比皆是.它可以在磁盘驱动器头已经在正确位置的情况下预先分配簇来更新文件分配表.当卷在使用每个可用集群之前空间不足时,它可能会导致创建调用失败.相反,让它不会失败将确保您可以写入文件而不会耗尽磁盘空间.只要你写的不超过你要求的.

Opportunities abound with knowing the expected allocation size up front. It can allocate the clusters up front with the disk drive head is already in the right spot to update the file allocation table. And it can fail the create call when the volume is running low on space before consuming every available cluster. Conversely, having it not fail will ensure that you can write to the file without running out of disk space. As long as you don't write more than you asked for anyway.

当然,当您关闭文件时,文件大小将更新为实际写入的字节数.AllocationSize 只是一个提示.

And sure, when you close the file then the file size will be updated to the actual number of bytes written. AllocationSize is merely a hint.

这篇关于ntcreatefile 分配大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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