IRP_MJ_CREATE

Hi All,

Is there a way that i could know that a FileObject is for file or folder in
IRP_MJ_CREATE dispatch routine.

Regards,
VC

The file object hasn’t been set up by the file system so it contains no
useful information. Further, there’s no guarantee that whatever is
being opened up is a file OR a directory (it could, for example, be a
stream, a volume, a printer, a named pipe, or anything else the file
system wishes to export as part of its abstraction.)

In the general case (ergo sitting on top of FAT or NTFS and you’ve
already filtered out the volume open case) you can either open the
directory and look or open the file and look. Theoretically it should
be possible to call through the fast I/O interface, obtain information
about the file and then allow the original create to proceed. But
that’s not a good technique for newbie to try using.

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

Looking forward to seeing you at the next OSR File Systems class in
Boston, MA April 18-21, 2006.

Tony,

I have a question regarding Create operation. The FileStandardInformation
class has the structure

typedef struct FILE_STANDARD_INFORMATION {
LARGE_INTEGER AllocationSize;
LARGE_INTEGER EndOfFile;
ULONG NumberOfLinks;
BOOLEAN DeletePending;
BOOLEAN Directory;
} FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION;

The AllocationSize field here, does it change everytime I write something to
the file, or is it set once during ZwCreateFile to some constant value
depending on the underlying volume?

amitr0

…actually, by Tony I didnt mean Tony specificaly, anyone who knows, may
please answer this question…

That’s going to depend upon the file system. When you first create you
can provide a hint as to the allocation size. After that, though, the
allocation size is adjusted by the file system as it sees fit.
Normally, you’d see the allocation size grow as the file grows - but
within the constraints of the underlying allocation unit (ergo, if the
volume you are using has 64KB blocks, you’d expect the allocation size
to be a multiple of 64KB. Writing small data units to the end of the
file would grow the EOF, but only periodically would the allocation size
increase.)

Regards,

Tony

Tony Mason

Consulting Partner

OSR Open Systems Resources, Inc.

http://www.osr.com

Looking forward to seeing you at the next OSR File Systems class in
Boston, MA April 18-21, 2006.

tony, (and others)

thanks for the reply. Why I asked this question was because, I am rolling my
own read and write IRPS. However I create the file using zwcreatefile in
driverentry and use the Fo after that.

now when I write to a file certain buffers of say length n, I have to also
adjust the file size also, so the seq of ops are IRP_MJ_WRITE and then
IRP_MJ_SET_INFO. Am I correct in this?

If I am, then I have to correctly set the EndOfFile and AllocationSize for
this. The endofile can be the bufferlength+ the prev end of file, but i am
having problems with allocationsize.

can you please help.

amitr0

PS:- I am using the kfc sample of OSR as reference…

Why would you change the size of the file? The file system will
maintain that for you under normal circumstances so you shouldn’t need
to do that at all. Just write and let the FSD do its job…

Regards,

Tony

Tony Mason

Consulting Partner

OSR Open Systems Resources, Inc.

http://www.osr.com

Looking forward to seeing you at the next OSR File Systems class in
Boston, MA April 18-21, 2006.

> now when I write to a file certain buffers of say length n, I have to also adjust the

file size also, so the seq of ops are IRP_MJ_WRITE and then IRP_MJ_SET_INFO.
Am I correct in this?

No :wink:

If you just create file and throw IRP_MJ_WRITE (cached), the file system
takes care about managing file size. No file set file size call is necessary.

L.

>The AllocationSize field here, does it change everytime I write something to

the file

Yes it does. It is the number of disk clusters really occupied by the file.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com