Hi all,
A while back, Ted Hess posted the following:
Win32 CreateFile does not use all of the Nt/Zw/IoCreateFile allowable
values. They are mapped as follows:
OPEN_EXISTING FILE_OPEN
CREATE_NEW FILE_CREATE
OPEN_ALWAYS FILE_OPEN_IF
CREATE_ALWAYS FILE_OVERWRITE_IF
TRUNCATE_EXISTING FILE_OPEN, followed by a SetInformation IRP
specifying zero allocation.
.My own experimentation backs this up.
This leads me to wonder why the designers of CreateFile chose to do that
instead of the following:
First 3 same as above.
CREATE_ALWAYS FILE_SUPERSEDE
TRUNCATE_EXISTING FILE_OVERWRITE.
Since CreateFile does what it does, that leads to several questions about
proper file system behavior.
-
It appears that NTFS destroys all named streams when it gets a file
open of FILE_OVERWRITE_IF. I would expect this for FILE_SUPERSEDE, but not
for FILE_OVERWRITE_IF. Does this mean that a file system should destroy all
named streams for all three variants (FILE_SUPERSEDE, FILE_OVERWRITE, and
FILE_OVERWRITE_IF).
-
According to the FastFat source code, FILE_SUPERSEDE has an “implied”
DELETE access, where as FILE_OVERWRITE and FILE_OVERWRITE_IF have “implied”
WRITE access. This seems to be consistent with NTFS as well. However when a
named stream is opened, then the name stream must have DELETE shared if a
FILE_OVERWRITE_IF is to succeed on the base file. So I guess
FILE_OVERWRITE_IF implies WRITE access for the main stream and DELETE access
for any named streams (I guess this is correct, they are being deleted).
-
Does anyone know why CreateFile uses the mappings it does instead of
the obvious ones? I am very curious about this.
Thanks for any input.
Don Edvalson
Well, ZwCreateFile also allows to specify AllocationSize, and CreateFile
does not.
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
----- Original Message -----
From: “Don”
Newsgroups: ntfsd
To: “Windows File Systems Devs Interest List”
Sent: Thursday, May 06, 2004 7:27 PM
Subject: [ntfsd] Unusual behavior of NTFS Disposition values.
> Hi all,
>
> A while back, Ted Hess posted the following:
>
> Win32 CreateFile does not use all of the Nt/Zw/IoCreateFile allowable
> values. They are mapped as follows:
>
> OPEN_EXISTING FILE_OPEN
> CREATE_NEW FILE_CREATE
> OPEN_ALWAYS FILE_OPEN_IF
> CREATE_ALWAYS FILE_OVERWRITE_IF
> TRUNCATE_EXISTING FILE_OPEN, followed by a SetInformation IRP
> specifying zero allocation.
>
> .My own experimentation backs this up.
>
> This leads me to wonder why the designers of CreateFile chose to do that
> instead of the following:
>
> First 3 same as above.
> CREATE_ALWAYS FILE_SUPERSEDE
> TRUNCATE_EXISTING FILE_OVERWRITE.
>
> Since CreateFile does what it does, that leads to several questions about
> proper file system behavior.
>
> 1. It appears that NTFS destroys all named streams when it gets a file
> open of FILE_OVERWRITE_IF. I would expect this for FILE_SUPERSEDE, but not
> for FILE_OVERWRITE_IF. Does this mean that a file system should destroy all
> named streams for all three variants (FILE_SUPERSEDE, FILE_OVERWRITE, and
> FILE_OVERWRITE_IF).
>
> 2. According to the FastFat source code, FILE_SUPERSEDE has an “implied”
> DELETE access, where as FILE_OVERWRITE and FILE_OVERWRITE_IF have “implied”
> WRITE access. This seems to be consistent with NTFS as well. However when a
> named stream is opened, then the name stream must have DELETE shared if a
> FILE_OVERWRITE_IF is to succeed on the base file. So I guess
> FILE_OVERWRITE_IF implies WRITE access for the main stream and DELETE access
> for any named streams (I guess this is correct, they are being deleted).
>
> 3. Does anyone know why CreateFile uses the mappings it does instead of
> the obvious ones? I am very curious about this.
>
> Thanks for any input.
>
> Don Edvalson
>
>
>
>
> —
> Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
It also allows choice of case-sensitivity and serveral other open/create
options that Win32 does not expose.
/ted
-----Original Message-----
From: Maxim S. Shatskih [mailto:xxxxx@storagecraft.com]
Sent: Thursday, May 06, 2004 4:43 PM
To: Windows File Systems Devs Interest List
Subject: Re: [ntfsd] Unusual behavior of NTFS Disposition values.
Well, ZwCreateFile also allows to specify AllocationSize, and CreateFile
does not.
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
----- Original Message -----
From: “Don”
Newsgroups: ntfsd
To: “Windows File Systems Devs Interest List”
Sent: Thursday, May 06, 2004 7:27 PM
Subject: [ntfsd] Unusual behavior of NTFS Disposition values.
> Hi all,
>
> A while back, Ted Hess posted the following:
>
> Win32 CreateFile does not use all of the Nt/Zw/IoCreateFile allowable
> values. They are mapped as follows:
>
> OPEN_EXISTING FILE_OPEN
> CREATE_NEW FILE_CREATE
> OPEN_ALWAYS FILE_OPEN_IF
> CREATE_ALWAYS FILE_OVERWRITE_IF
> TRUNCATE_EXISTING FILE_OPEN, followed by a SetInformation IRP
> specifying zero allocation.
>
> .My own experimentation backs this up.
>
> This leads me to wonder why the designers of CreateFile chose to do
> that instead of the following:
>
> First 3 same as above.
> CREATE_ALWAYS FILE_SUPERSEDE
> TRUNCATE_EXISTING FILE_OVERWRITE.
>
> Since CreateFile does what it does, that leads to several questions
> about proper file system behavior.
>
> 1. It appears that NTFS destroys all named streams when it gets a file
> open of FILE_OVERWRITE_IF. I would expect this for FILE_SUPERSEDE, but
> not for FILE_OVERWRITE_IF. Does this mean that a file system should
> destroy all named streams for all three variants (FILE_SUPERSEDE,
> FILE_OVERWRITE, and FILE_OVERWRITE_IF).
>
> 2. According to the FastFat source code, FILE_SUPERSEDE has an
“implied”
> DELETE access, where as FILE_OVERWRITE and FILE_OVERWRITE_IF have
> “implied” WRITE access. This seems to be consistent with NTFS as well.
> However when a named stream is opened, then the name stream must have
> DELETE shared if a FILE_OVERWRITE_IF is to succeed on the base file.
> So I guess FILE_OVERWRITE_IF implies WRITE access for the main stream
> and DELETE access for any named streams (I guess this is correct, they
> are being deleted).
>
> 3. Does anyone know why CreateFile uses the mappings it does instead of
> the obvious ones? I am very curious about this.
>
> Thanks for any input.
>
> Don Edvalson
>
>
>
>
> —
> Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@storagecraft.com To
> unsubscribe send a blank email to xxxxx@lists.osr.com
—
Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
You are currently subscribed to ntfsd as: xxxxx@livevault.com To unsubscribe
send a blank email to xxxxx@lists.osr.com