Differentiating Directory & Files ?

In pre-create callback, how can i determine the target of this request
is a Directory or a File ?

Thanks,
SivaRaja

FLT_PREOP_CALLBACK_STATUS PreCreateCallback (
PFLT_CALLBACK_DATA Data, PCFLT_RELATED_OBJECTS FltObjects, PVOID
*CompletionContext)

PFLT_IO_PARAMETER_BLOCK IopbPtr = Data->Iopb;
PFLT_PARAMETERS Parameters = &IopbPtr->Parameters;
ULONG CreateOptions;
ULONG DirectoryOperation;

//
// Check for ‘this is a directory’
//
CreateOptions = Parameters->Create.Options & 0x00FFFFFF;
DirectoryOperation = CreateOptions & FILE_DIRECTORY_FILE; // 0 =
FALSE, 1 = TRUE

Mickey.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of SivaRaja
Sent: Tuesday, July 12, 2005 2:17 AM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Differentiating Directory & Files ?

In pre-create callback, how can i determine the target of this request is a
Directory or a File ?

Thanks,
SivaRaja


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

Use FltIsDirectory()

Ken

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of SivaRaja
Sent: Tuesday, July 12, 2005 2:17 AM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Differentiating Directory & Files ?

In pre-create callback, how can i determine the target of this request
is a Directory or a File ?

Thanks,
SivaRaja


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

Mickey, that’s just what I want, works fine & very clear!
thanks a lot.

On 7/12/05, Mickey Lane wrote:
> FLT_PREOP_CALLBACK_STATUS PreCreateCallback (
> PFLT_CALLBACK_DATA Data, PCFLT_RELATED_OBJECTS FltObjects, PVOID
> *CompletionContext)
>
> PFLT_IO_PARAMETER_BLOCK IopbPtr = Data->Iopb;
> PFLT_PARAMETERS Parameters = &IopbPtr->Parameters;
> ULONG CreateOptions;
> ULONG DirectoryOperation;
>
> //
> // Check for ‘this is a directory’
> //
> CreateOptions = Parameters->Create.Options & 0x00FFFFFF;
> DirectoryOperation = CreateOptions & FILE_DIRECTORY_FILE; // 0 =
> FALSE, 1 = TRUE
>
> Mickey.
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of SivaRaja
> Sent: Tuesday, July 12, 2005 2:17 AM
> To: Windows File Systems Devs Interest List
> Subject: [ntfsd] Differentiating Directory & Files ?
>
>
> In pre-create callback, how can i determine the target of this request is a
> Directory or a File ?
>
> Thanks,
> SivaRaja
>
> —
> 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
>
>
> —
> Questions? First check the IFS FAQ at https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@gmail.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>

Unfortunately, this won’t do what you want. It WILL tell you if the caller insisted that what is being opened MUST be a directory (the purpose of FILE_DIRECTORY_FILE) but you will often see calls where this bit is not set but the object being opened IS a directory.

Ken’s suggestion won’t work until after the file has been opened. If you must know BEFORE the user open has proceeded, you can:

  • Open the file/directory yourself and inquire as to its type;
  • Look for the file/directory in the containing directory and examine its attributes.

Once it is opened, you can ask (as Ken’s suggestion does) but before it is opened there’s no way to know. A bit like Schr?dinger’s cat, right? You must open the box first…

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 SivaRaja
Sent: Tuesday, July 12, 2005 7:13 AM
To: ntfsd redirect
Subject: Re: [ntfsd] Differentiating Directory & Files ?

Mickey, that’s just what I want, works fine & very clear!
thanks a lot.

On 7/12/05, Mickey Lane wrote:
> FLT_PREOP_CALLBACK_STATUS PreCreateCallback (
> PFLT_CALLBACK_DATA Data, PCFLT_RELATED_OBJECTS FltObjects, PVOID
> *CompletionContext)
>
> PFLT_IO_PARAMETER_BLOCK IopbPtr = Data->Iopb;
> PFLT_PARAMETERS Parameters = &IopbPtr->Parameters;
> ULONG CreateOptions;
> ULONG DirectoryOperation;
>
> //
> // Check for ‘this is a directory’
> //
> CreateOptions = Parameters->Create.Options & 0x00FFFFFF;
> DirectoryOperation = CreateOptions & FILE_DIRECTORY_FILE; // 0 =
> FALSE, 1 = TRUE
>
> Mickey.
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of SivaRaja
> Sent: Tuesday, July 12, 2005 2:17 AM
> To: Windows File Systems Devs Interest List
> Subject: [ntfsd] Differentiating Directory & Files ?
>
>
> In pre-create callback, how can i determine the target of this request is a
> Directory or a File ?
>
> Thanks,
> SivaRaja
>
> —
> 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
>
>
> —
> Questions? First check the IFS FAQ at https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@gmail.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

Good point, Tony. I’m calling FltIsDirectory() in the pre
IRP_MJ_SET_INFORMATION callback, but it’s valid by that time.

In pre-create, I have to call FltCreateFile() followed by
FltQueryInformationFile().

Sorry for the mis-information.

Ken

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tony Mason
Sent: Tuesday, July 12, 2005 8:07 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Differentiating Directory & Files ?

Unfortunately, this won’t do what you want. It WILL tell you if the caller
insisted that what is being opened MUST be a directory (the purpose of
FILE_DIRECTORY_FILE) but you will often see calls where this bit is not set
but the object being opened IS a directory.

Ken’s suggestion won’t work until after the file has been opened. If you
must know BEFORE the user open has proceeded, you can:

  • Open the file/directory yourself and inquire as to its type;
  • Look for the file/directory in the containing directory and examine its
    attributes.

Once it is opened, you can ask (as Ken’s suggestion does) but before it is
opened there’s no way to know. A bit like Schr?dinger’s cat, right? You
must open the box first…

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 SivaRaja
Sent: Tuesday, July 12, 2005 7:13 AM
To: ntfsd redirect
Subject: Re: [ntfsd] Differentiating Directory & Files ?

Mickey, that’s just what I want, works fine & very clear!
thanks a lot.

On 7/12/05, Mickey Lane wrote:
> FLT_PREOP_CALLBACK_STATUS PreCreateCallback (
> PFLT_CALLBACK_DATA Data, PCFLT_RELATED_OBJECTS FltObjects, PVOID
> *CompletionContext)
>
> PFLT_IO_PARAMETER_BLOCK IopbPtr = Data->Iopb;
> PFLT_PARAMETERS Parameters = &IopbPtr->Parameters;
> ULONG CreateOptions;
> ULONG DirectoryOperation;
>
> //
> // Check for ‘this is a directory’
> //
> CreateOptions = Parameters->Create.Options & 0x00FFFFFF;
> DirectoryOperation = CreateOptions & FILE_DIRECTORY_FILE; // 0 =
> FALSE, 1 = TRUE
>
> Mickey.
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of SivaRaja
> Sent: Tuesday, July 12, 2005 2:17 AM
> To: Windows File Systems Devs Interest List
> Subject: [ntfsd] Differentiating Directory & Files ?
>
>
> In pre-create callback, how can i determine the target of this request is
a
> Directory or a File ?
>
> Thanks,
> SivaRaja
>
> —
> 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
>
>
> —
> Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@gmail.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


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

Do this:

Open the file yourself
If the file isn’t found and it is a create request,
you can trust the create flags about whether it is a
directory or not
If your open succeeds, query with
FileStandardInformation to find out what it is

You cannot trust the open flags on an already existing
file/directory.

— SivaRaja wrote:

> In pre-create callback, how can i determine the
> target of this request
> is a Directory or a File ?
>
> Thanks,
> SivaRaja
>
> —
> 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
>

> You cannot trust the open flags on an already existing

file/directory.

Well, I think you cannot trust the flags only in the case the create flags
don’t
specify either FILE_DIRECTORY_FILE
or FILE_NON_DIRECTORY_FILE.

  • If the flags contained FILE_DIRECTORY_FILE and the file
    has been opened, it is actually a directory.
  • If the flags contained FILE_NON_DIRECTORY_FILE and the file
    has been opened, it is a file.
  • If the flags didn’t contain any of the two flag, you must perform
    additional query for doing it.

L.

Almost…

If someone opens a volume and specifies FILE_NON_DIRECTORY_FILE it will
succeed. Other specialized devices (printers and named pipes come to
mind) also should work with FILE_NON_DIRECTORY_FILE.

In addition, we have cases where the two are defined together:

#define FILE_COPY_STRUCTURED_STORAGE 0x00000041
#define FILE_STRUCTURED_STORAGE 0x00000441

Note that this combines:

#define FILE_DIRECTORY_FILE 0x00000001

And

#define FILE_NON_DIRECTORY_FILE 0x00000040

While at the present time nobody is using FILE_COPY_STRUCTURED_STORAGE
or FILE_STRUCTURED_STORAGE (at least not that I know) you can bet that
this trick will be used the next time someone needs an option - all of
the single bit combinations are exhausted so by using two incompatible
bits together you expand the size of the name space.

So, rely upon these bits at your own peril, and be careful to properly
catch all of these edge condition cases.

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 Ladislav Zezula
Sent: Tuesday, July 12, 2005 1:57 PM
To: ntfsd redirect
Subject: Re: [ntfsd] Differentiating Directory & Files ?

You cannot trust the open flags on an already existing
file/directory.

Well, I think you cannot trust the flags only in the case the create
flags
don’t
specify either FILE_DIRECTORY_FILE
or FILE_NON_DIRECTORY_FILE.

  • If the flags contained FILE_DIRECTORY_FILE and the file
    has been opened, it is actually a directory.
  • If the flags contained FILE_NON_DIRECTORY_FILE and the file
    has been opened, it is a file.
  • If the flags didn’t contain any of the two flag, you must perform
    additional query for doing it.

L.


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

To find Directory or file
In pre-create, I tired to receive the file handle using the
FltCreateFile() but it failed. Can anyone please figure out the
problem in the code ?
then after this i have to call FltQueryInformationFile () to find
Directory or a file ?

Error Code always - c000000d - STATUS_INVALID_PARAMETER

PFLT_FILE_NAME_INFORMATION nameInfo = NULL;
OBJECT_ATTRIBUTES theAttributes;
IO_STATUS_BLOCK IoStatus;
PHANDLE pHandle = NULL;

/* &nameInfo->Name prints correctly
\Device\HarddiskVolume1\WINDOWS\system32\setupapi.dll */

if ( nameInfo != NULL )
{

DbgPrint(“The File name = %wZ\n”,&nameInfo->Name);

InitializeObjectAttributes( &theAttributes,
&nameInfo->Name,
OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE,
NULL,
NULL );

status = FltCreateFile( gFilterHandle, Data->Iopb->TargetInstance,
pHandle, GENERIC_READ | FILE_LIST_DIRECTORY,
&theAttributes, &IoStatus,
NULL,FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ | FILE_SHARE_WRITE,
FILE_OPEN,FILE_NON_DIRECTORY_FILE|FILE_DIRECTORY_FILE,
NULL,0, IO_IGNORE_SHARE_ACCESS_CHECK );

if ( NT_SUCCESS(status) )
{
DbgPrint(“File handle successfully received\n”);
FltClose(pHandle);
}
else
{
DbgPrint (“Failed to recevice file handle= %x\n”,status);
}

FltReleaseFileNameInformation(nameInfo);

}

Thanks,
SivaRaja.

On 7/12/05, Tony Mason wrote:
> Almost…
>
> If someone opens a volume and specifies FILE_NON_DIRECTORY_FILE it will
> succeed. Other specialized devices (printers and named pipes come to
> mind) also should work with FILE_NON_DIRECTORY_FILE.
>
> In addition, we have cases where the two are defined together:
>
> #define FILE_COPY_STRUCTURED_STORAGE 0x00000041
> #define FILE_STRUCTURED_STORAGE 0x00000441
>
> Note that this combines:
>
> #define FILE_DIRECTORY_FILE 0x00000001
>
> And
>
> #define FILE_NON_DIRECTORY_FILE 0x00000040
>
> While at the present time nobody is using FILE_COPY_STRUCTURED_STORAGE
> or FILE_STRUCTURED_STORAGE (at least not that I know) you can bet that
> this trick will be used the next time someone needs an option - all of
> the single bit combinations are exhausted so by using two incompatible
> bits together you expand the size of the name space.
>
> So, rely upon these bits at your own peril, and be careful to properly
> catch all of these edge condition cases.
>
> 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 Ladislav Zezula
> Sent: Tuesday, July 12, 2005 1:57 PM
> To: ntfsd redirect
> Subject: Re: [ntfsd] Differentiating Directory & Files ?
>
> > You cannot trust the open flags on an already existing
> > file/directory.
>
> Well, I think you cannot trust the flags only in the case the create
> flags
> don’t
> specify either FILE_DIRECTORY_FILE
> or FILE_NON_DIRECTORY_FILE.
>
> - If the flags contained FILE_DIRECTORY_FILE and the file
> has been opened, it is actually a directory.
> - If the flags contained FILE_NON_DIRECTORY_FILE and the file
> has been opened, it is a file.
> - If the flags didn’t contain any of the two flag, you must perform
> additional query for doing it.
>
> L.
>
>
> —
> 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
>

I tried to simulate the same open with FileTest tool
It returns STATUS_INVALID_PARAMETER too,
certainly because of the combination of
FILE_NON_DIRECTORY_FILE|FILE_DIRECTORY_FILE.
If I removed the FILE_NON_DIRECTORY_FILE flag, it succeeded.
You may not specify both the flags.

I recommend you to get FileTest from osronline.com.
It’s been written exactly for such experiments, it is faster than
compile, load and install a driver and reboot between every trying.

L.

Thanks Ladislav, i downloaded FileTest & really very cool utilit. I
removed the FILE_NON_DIRECTORY_FILE flag but failed - After removing
the FILE_DIRECTORY_FILE flag it worked perfectly using FileTest tool.

Well, sorry for bugging again. I tried the same in the Pre-Create
callback but failed.

Error code : c0000005 - STATUS_ACCESS_VIOLATION

RtlInitUnicodeString(&testString,L"\??\C:\1.txt");

InitializeObjectAttributes(&theAttributes, &testString,
OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE,
NULL,NULL );

status = FltCreateFile( gFilterHandle,
Data->Iopb->TargetInstance,
pHandle, GENERIC_READ, &theAttributes,
&IoStatus,
NULL,FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ,FILE_OPEN,FILE_NON_DIRECTORY_FILE,
NULL,0,0 );

if ( NT_SUCCESS(status) )
{
DbgPrint(“File handle successfully received\n”);
FltClose(pHandle);
}
else
DbgPrint (“Failed to recevice file handle= %x\n”,status);

Can anyone please tell me what is wrong with this code ?

Thanks,
SivaRaja.

On 7/13/05, Ladislav Zezula wrote:
> I tried to simulate the same open with FileTest tool
> It returns STATUS_INVALID_PARAMETER too,
> certainly because of the combination of
> FILE_NON_DIRECTORY_FILE|FILE_DIRECTORY_FILE.
> If I removed the FILE_NON_DIRECTORY_FILE flag, it succeeded.
> You may not specify both the flags.
>
> I recommend you to get FileTest from osronline.com.
> It’s been written exactly for such experiments, it is faster than
> compile, load and install a driver and reboot between every trying.
>
> L.
>
>
> —
> Questions? First check the IFS FAQ at https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@gmail.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>

Greetings mortal, SivaRaja!
You wrote on Mon, 11 Jul 2005 23:17:01 -0700:

S> In pre-create callback, how can i determine the target of this
S> request is a Directory or a File ?

If you not playing with mini-filter model, try to use that algorithm:

  1. Check Parameters.Create.Options with FILE_DIRECTORY_FILE - caller want to create/open a
    directory, if your interest in files only skip this request.
  2. If lower file system is a network file system (FILE_DEVICE_NETWORK_FILE_SYSTEM) try to
    open target yourself (we must use ZwCreateFile to handle no access condition):

Status = ZwCreateFile(&hFile,
FILE_READ_ATTRIBUTES | SYNCHRONIZE,
&oba,
&IoBlock,
NULL,
0,
0,
FILE_OPEN,
FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT | FILE_COMPLETE_IF_OPLOCKED,
NULL,
0);

if (STATUS_SUCCESS == Status)
{
ZwClose(hFile);
}

  1. If lower file system is a local file system try to use
    IoCreateFileSpecifyDeviceObjectHint() (for w2k you must install security update(s) with
    new kernel that contain this function) like above.

  2. Check Status:

if (STATUS_SUCCESS == Status)
{
// It’s a directory
break;
}
else
{
// check an error
if (STATUS_NOT_A_DIRECTORY == Status)
{
// it’s a file and it’s exist
Status = STATUS_SUCCESS;
}
else if (STATUS_OBJECT_NAME_NOT_FOUND == Status)
{
// It’s a file and it’s not exist
Status = STATUS_SUCCESS;
}
else
{
// other error, skip request
Status = STATUS_SUCCESS;
break;
}
}

Eugene.

Sort of a sanity check on this subject…

My objective is to ignore anything to do with directories in the pre-create
mini-filter routine.
I do other stuff before/between/after these steps to justify ignoring the
operation based on
other criteria - this bit just deals with the directories.

Step 1:
Isolate create options and test for FILE_DIRECTORY_FILE. If true, ignore
the operation.

Step 2:
FltGetFileNameInformation()

Step 3:
InitializeObjectAttributes w/returned name
If no name returned then it’s not possible to determine if it’s a
directory

Step 4:
FltCreateFile()
If NT_SUCCESS == FALSE, ignore because it’s not a legit anything.

Step 5:
ObReferenceObjectByHandle()

Step 6:
FltQueryInformationFile(… FileStandardInformation …)

Step 7:
Test BOOLEAN in returned struct, if true ignore the operation.

I’ve noticed the notes re: FltCreateFile + ObReferenceObjectByHandle on XP
and
FltCreateFileEx on Server 2003 SP1 () but I’ll deal with that
later.

I’ve also noticed with very limited testing that in cases where the name is
NOT a
legitimate path + file name [+ extension]…

If the name string ends in a backslash, the FltCreateFile works and I
eventually
get the BOOLEAN that tells me it’s a directory. If name string does not end
that
Way - say it’s just “\device\harddiskvolume4” - then FltCreateFile fails
with
invalid parameter.

Is my invalid parameter due to something other than the
“\device\harddiskvolume4” syntax?
(Actually, it’s not my syntax - it’s what FltGetFileNameInformation() gave
me.)

My call:

NtStatus = FltCreateFile (
Filter, // 1 filter
Data->Iopb->TargetInstance, // 2 instance
&Handle, // 3 requested handle
FILE_READ_ATTRIBUTES, // 4 desired access
&Attributes, // 5 object attributes
&IoStatus, // 6 return status
0, // 7 allocation size
FILE_ATTRIBUTE_NORMAL, // 8 attributes
0, // 9 share access (ignored because
of IO_IGNORE_SHARE_ACCESS_CHECK)
FILE_OPEN, // 10 create disposition
FILE_COMPLETE_IF_OPLOCKED, // 11 create option
NULL, // 12 ea buffer
0, // 13 ea length
IO_IGNORE_SHARE_ACCESS_CHECK); // 14 flags

Mickey.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tony Mason
Sent: Tuesday, July 12, 2005 3:01 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Differentiating Directory & Files ?

Almost…

If someone opens a volume and specifies FILE_NON_DIRECTORY_FILE it will
succeed. Other specialized devices (printers and named pipes come to
mind) also should work with FILE_NON_DIRECTORY_FILE.

In addition, we have cases where the two are defined together:

#define FILE_COPY_STRUCTURED_STORAGE 0x00000041
#define FILE_STRUCTURED_STORAGE 0x00000441

Note that this combines:

#define FILE_DIRECTORY_FILE 0x00000001

And

#define FILE_NON_DIRECTORY_FILE 0x00000040

While at the present time nobody is using FILE_COPY_STRUCTURED_STORAGE or
FILE_STRUCTURED_STORAGE (at least not that I know) you can bet that this
trick will be used the next time someone needs an option - all of the single
bit combinations are exhausted so by using two incompatible bits together
you expand the size of the name space.

So, rely upon these bits at your own peril, and be careful to properly catch
all of these edge condition cases.

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 Ladislav Zezula
Sent: Tuesday, July 12, 2005 1:57 PM
To: ntfsd redirect
Subject: Re: [ntfsd] Differentiating Directory & Files ?

> You cannot trust the open flags on an already existing file/directory.

Well, I think you cannot trust the flags only in the case the create flags
don’t
specify either FILE_DIRECTORY_FILE
or FILE_NON_DIRECTORY_FILE.

- If the flags contained FILE_DIRECTORY_FILE and the file
has been opened, it is actually a directory.
- If the flags contained FILE_NON_DIRECTORY_FILE and the file
has been opened, it is a file.
- If the flags didn’t contain any of the two flag, you must perform
additional query for doing it.

L.


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