CreateDisposition meaning...

The documentation seems a little vague on the
differences between some of the create dispositions.

I was hoping someone could help me make sure I understand
these correctly.

FILE_SUPERSEDE

I’m not quite sure how this is different than
FILE_OVERWRITE_IF ?

Does this have a WIN32 equivelant?

FILE_OVERWRITE
Does this actually create a new file, or just overwrite the
contents?

In otherwords, does this reset the file attributes? Does the
new file get a new object id?

Thanks,

Joseph

Supersede destroys the attributes AND data of the file, while overwrite
only destroys the data. For example, you can supersede a file and have
it be a directory when the operation is done.

There is no Win32 equivalent for this.

Regards,

Tony

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

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Joseph Galbraith
Sent: Wednesday, November 17, 2004 8:44 PM
To: ntfsd redirect
Subject: [ntfsd] CreateDisposition meaning…

The documentation seems a little vague on the
differences between some of the create dispositions.

I was hoping someone could help me make sure I understand
these correctly.

FILE_SUPERSEDE

I’m not quite sure how this is different than
FILE_OVERWRITE_IF ?

Does this have a WIN32 equivelant?

FILE_OVERWRITE
Does this actually create a new file, or just overwrite the
contents?

In otherwords, does this reset the file attributes? Does the
new file get a new object id?

Thanks,

Joseph


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@osr.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Wow!

That wasn’t what I was guessing. That means since Win32
CREATE_ALWAYS maps to OVERWRITE_IF that CREATE_ALWAYS
doesn’t actually always create… it either creates the
file or truncates an existing file.

Talk about a misnomer…

Well, let me make double sure I understand what my behavior
should be… now that I’ve thought about it this would be
a better way to ask the question in the first place:

FILE_SUPERSEDE
use AllocationSize, FileAttributes, FILE_DIRECTORY_FILE,
FILE_NON_DIRECTORY_FILE. The file is a new file.

FILE_OPEN
Never uses AllocationSize, etc. The file is an existing
file.

FILE_CREATE
use AllocationSize, etc.

FILE_OPEN_IF
use AllocationSize, etc. only if the file doesn’t previously
exist.

FILE_OVERWRITE
Always use AllocationSize, but do not apply FileAttributes
and FILE_DIRECTORY_FILE/FILE_NON_DIRECTORY_FILE must match
existing file. The file is not a new file, and the object-id
of the file does not change.

Or wait… can you OVERWRITE a directory? How about an
empty directory?

Or should FileAttributes be applied also?

FILE_OVERWRITE_IF
If the file exists, same as FILE_OVERWRITE; else same as
FILE_CREATE.

Thanks,

  • Joseph

Tony Mason wrote:

Supersede destroys the attributes AND data of the file, while overwrite
only destroys the data. For example, you can supersede a file and have
it be a directory when the operation is done.

There is no Win32 equivalent for this.

Regards,

Tony

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

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Joseph Galbraith
Sent: Wednesday, November 17, 2004 8:44 PM
To: ntfsd redirect
Subject: [ntfsd] CreateDisposition meaning…

The documentation seems a little vague on the
differences between some of the create dispositions.

I was hoping someone could help me make sure I understand
these correctly.

FILE_SUPERSEDE

I’m not quite sure how this is different than
FILE_OVERWRITE_IF ?

Does this have a WIN32 equivelant?

FILE_OVERWRITE
Does this actually create a new file, or just overwrite the
contents?

In otherwords, does this reset the file attributes? Does the
new file get a new object id?

Thanks,

Joseph


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@osr.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: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Sorry to push a little bit on this, but I’m writing a draft
for the IETF, and I’ve promised it for today, and I want to make
sure the draft supports the semantics I need.

So…

Can FILE_SUPERSED supersede a directory with a FILE?

How about if the directory is empty?

Can a directory (empty or otherwise) be the target
of a OVERWRITE operation if the new file is a
DIRECTORY?

Does FILE_OVERWRITE apply the FileAttributes to the new
file?

Thanks,

Joseph

Tony Mason wrote:

Supersede destroys the attributes AND data of the file, while overwrite
only destroys the data. For example, you can supersede a file and have
it be a directory when the operation is done.

There is no Win32 equivalent for this.

Okay… I’ve been doing some experimenting with this
calling NtCreateFile() against NTFS.

I can create a directory using FILE_CREATE and
FILE_DIRECTORY_FILE.

But, if I use FILE_SUPERSEDE with FILE_DIRECTORY_FILE,
I get STATUS_INVALID_PARAMETER. Same using FILE_OVERWRITE
or FILE_OVERWRITE_IF.

Are you sure SUPERSEDE can change a file to a directory?

Is there a way to create a directory other than specifying
FILE_DIRECTORY_FILE?

Here’s the code snippet:

OBJECT_ATTRIBUTES attr;
InitializeObjectAttributes(&attr, &wcFilename, OBJ_CASE_INSENSITIVE, 0, 0);

HANDLE hFile;
IO_STATUS_BLOCK iosb;
NTSTATUS Status = NtCreateFile(&hFile,
FILE_LIST_DIRECTORY|FILE_ADD_FILE|SYNCHRONIZE,
&attr,
&iosb,
0,
0,
0,
FILE_SUPERSEDE,
FILE_DIRECTORY_FILE|FILE_SYNCHRONOUS_IO_NONALERT,
0,
0);

Still more testing reveals that neither SUPERSEDE nor
OVERWRITE replaces the ACL on the file, and that both
SUPERSEDE and OVERWRITE destroy all alternate data streams,
and neither changes the OBJECT_ID of the file.

I’m definitely still confused about the difference
between the two… so far, I haven’t been able to
find one.

Thanks,

Joseph