How does GetFileType decide?

Does anyone know how the Win32 API GetFileType decides a file’s type
under Windows 2000? For my installable file system, GetFileType is
returning FILE_TYPE_UNKNOWN for all files, and this is causing various
things to break (e.g., the “open” procedure produces “Invalid argument”
errors). By single-stepping in the debugger I can see that GetFileType
invokes an NT kernel operation, but the kernel doesn’t seem to ask my
file system driver for any information before returning (“filemon” also
indicates that there are no IRP’s being generated).

Any suggestions on how my file system driver can control the value
returned by GetFileType?

-John-

It is determined by the DeviceType parameter specified on IoCreateDevice.

Bruce

-----Original Message-----
From: John Ousterhout [mailto:xxxxx@electric-cloud.com]
Sent: Tuesday, July 23, 2002 2:03 PM
To: File Systems Developers
Subject: [ntfsd] How does GetFileType decide?

Does anyone know how the Win32 API GetFileType decides a file’s type
under Windows 2000? For my installable file system, GetFileType is
returning FILE_TYPE_UNKNOWN for all files, and this is causing various
things to break (e.g., the “open” procedure produces “Invalid argument”
errors). By single-stepping in the debugger I can see that GetFileType
invokes an NT kernel operation, but the kernel doesn’t seem to ask my
file system driver for any information before returning (“filemon” also
indicates that there are no IRP’s being generated).

Any suggestions on how my file system driver can control the value
returned by GetFileType?

-John-


You are currently subscribed to ntfsd as: xxxxx@SERENA.com
To unsubscribe send a blank email to %%email.unsub%%

***********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. Any unauthorized review, use, disclosure or distribution
is prohibited. If you are not the intended recipient, please contact
the sender by reply e-mail and destroy all copies of the original
message.
***********************************************************************

Thanks for the suggestion. My call to IoCreateDevice looked like this:

status = IoCreateDevice(driver , 0, &deviceName,
FILE_DEVICE_FILE_SYSTEM, 0, FALSE, &device);

I tried changing FILE_DEVICE_FILE_SYSTEM to FILE_DEVICE_DISK_FILE_SYSTEM,
which is the same as other file systems such as fastfact, but GetFileType
is still returning FILE_TYPE_UNKNOWN. Any other ideas? I’m wondering if
perhaps the device parameter to IoCreateDevice determines the file type
for devices, but not for files managed by a file system driver.

-John-

It is determined by the DeviceType parameter specified on IoCreateDevice.

Bruce

-----Original Message-----
From: John Ousterhout [mailto:xxxxx@electric-cloud.com]
Sent: Tuesday, July 23, 2002 2:03 PM
To: File Systems Developers
Subject: [ntfsd] How does GetFileType decide?

Does anyone know how the Win32 API GetFileType decides a file’s type
under Windows 2000? For my installable file system, GetFileType is
returning FILE_TYPE_UNKNOWN for all files, and this is causing various
things to break (e.g., the “open” procedure produces “Invalid argument”
errors). By single-stepping in the debugger I can see that GetFileType
invokes an NT kernel operation, but the kernel doesn’t seem to ask my
file system driver for any information before returning (“filemon” also
indicates that there are no IRP’s being generated).

Any suggestions on how my file system driver can control the value
returned by GetFileType?

-John-

Perhaps it needs to be spomething more specific like like
FILE_DEVICE_DISK_FILE_SYSTEM, FILE_DEVICE_CD_ROM_FILE_SYSTEM, or
FILE_DEVICE_NETWORK_FILE_SYSTEM. I had the same problem before, and
changing it to FILE_DEVICE_NETWORK_FILE_SYSTEM corrected my problem (mine is
a network file system).

Bruce

-----Original Message-----
From: John Ousterhout [mailto:xxxxx@electric-cloud.com]
Sent: Wednesday, July 24, 2002 9:03 AM
To: File Systems Developers
Subject: [ntfsd] RE: How does GetFileType decide?

Thanks for the suggestion. My call to IoCreateDevice looked like this:

status = IoCreateDevice(driver , 0, &deviceName,
FILE_DEVICE_FILE_SYSTEM, 0, FALSE, &device);

I tried changing FILE_DEVICE_FILE_SYSTEM to FILE_DEVICE_DISK_FILE_SYSTEM,
which is the same as other file systems such as fastfact, but GetFileType
is still returning FILE_TYPE_UNKNOWN. Any other ideas? I’m wondering if
perhaps the device parameter to IoCreateDevice determines the file type
for devices, but not for files managed by a file system driver.

-John-

It is determined by the DeviceType parameter specified on IoCreateDevice.

Bruce

-----Original Message-----
From: John Ousterhout [mailto:xxxxx@electric-cloud.com]
Sent: Tuesday, July 23, 2002 2:03 PM
To: File Systems Developers
Subject: [ntfsd] How does GetFileType decide?

Does anyone know how the Win32 API GetFileType decides a file’s type
under Windows 2000? For my installable file system, GetFileType is
returning FILE_TYPE_UNKNOWN for all files, and this is causing various
things to break (e.g., the “open” procedure produces “Invalid argument”
errors). By single-stepping in the debugger I can see that GetFileType
invokes an NT kernel operation, but the kernel doesn’t seem to ask my
file system driver for any information before returning (“filemon” also
indicates that there are no IRP’s being generated).

Any suggestions on how my file system driver can control the value
returned by GetFileType?

-John-


You are currently subscribed to ntfsd as: xxxxx@SERENA.com
To unsubscribe send a blank email to %%email.unsub%%

***********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. Any unauthorized review, use, disclosure or distribution
is prohibited. If you are not the intended recipient, please contact
the sender by reply e-mail and destroy all copies of the original
message.
***********************************************************************

John,
What is the value of GetLastError() upon calling GetFileType()? - Eric

This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
From: John Ousterhout [mailto:xxxxx@electric-cloud.com]
Sent: Wednesday, July 24, 2002 9:03 AM
To: File Systems Developers
Subject: [ntfsd] RE: How does GetFileType decide?

Thanks for the suggestion. My call to IoCreateDevice looked like this:

status = IoCreateDevice(driver , 0, &deviceName,
FILE_DEVICE_FILE_SYSTEM, 0, FALSE, &device);

I tried changing FILE_DEVICE_FILE_SYSTEM to
FILE_DEVICE_DISK_FILE_SYSTEM, which is the same as other file systems
such as fastfact, but GetFileType is still returning FILE_TYPE_UNKNOWN.
Any other ideas? I’m wondering if perhaps the device parameter to
IoCreateDevice determines the file type for devices, but not for files
managed by a file system driver.

-John-

It is determined by the DeviceType parameter specified on
IoCreateDevice.

Bruce

-----Original Message-----
From: John Ousterhout [mailto:xxxxx@electric-cloud.com]
Sent: Tuesday, July 23, 2002 2:03 PM
To: File Systems Developers
Subject: [ntfsd] How does GetFileType decide?

Does anyone know how the Win32 API GetFileType decides a file’s type
under Windows 2000? For my installable file system, GetFileType is
returning FILE_TYPE_UNKNOWN for all files, and this is causing various

things to break (e.g., the “open” procedure produces “Invalid
argument” errors). By single-stepping in the debugger I can see that
GetFileType invokes an NT kernel operation, but the kernel doesn’t
seem to ask my file system driver for any information before returning

(“filemon” also indicates that there are no IRP’s being generated).

Any suggestions on how my file system driver can control the value
returned by GetFileType?

-John-


You are currently subscribed to ntfsd as: xxxxx@MICROSOFT.com To
unsubscribe send a blank email to %%email.unsub%%

There is a twist to GetFileType if the handle is to a storage device object.
In this case the the type is actually the physical device object that’s in
the fileobject. Essentially the type is based on the device type of the
device object that’s in FileObject->DeviceObject. So for mounted on devices,
you will get the type of the storage device object. This obviously applies
only to local storage. Remote filesystems don’t have VPBs. Typically
FileObject->DeviceObject should have FILE_DEVICE_DISK or some other type
which carries a VPB.

So debug this further you should tell what’s the type of device that the
handle points to (if you have the kernel debugger you can find the
fileobject using the !handle extension and then dump the fileobject to find
the deviceobject).


Nar Ganapathy
Windows Core OS group
This posting is provided “AS IS” with no warranties, and confers no rights.
“Eric W Hanson” wrote in message news:xxxxx@ntfsd…

John,
What is the value of GetLastError() upon calling GetFileType()? - Eric

This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
From: John Ousterhout [mailto:xxxxx@electric-cloud.com]
Sent: Wednesday, July 24, 2002 9:03 AM
To: File Systems Developers
Subject: [ntfsd] RE: How does GetFileType decide?

Thanks for the suggestion. My call to IoCreateDevice looked like this:

status = IoCreateDevice(driver , 0, &deviceName,
FILE_DEVICE_FILE_SYSTEM, 0, FALSE, &device);

I tried changing FILE_DEVICE_FILE_SYSTEM to
FILE_DEVICE_DISK_FILE_SYSTEM, which is the same as other file systems
such as fastfact, but GetFileType is still returning FILE_TYPE_UNKNOWN.
Any other ideas? I’m wondering if perhaps the device parameter to
IoCreateDevice determines the file type for devices, but not for files
managed by a file system driver.

-John-

> It is determined by the DeviceType parameter specified on
> IoCreateDevice.
>
> Bruce
>
> -----Original Message-----
> From: John Ousterhout [mailto:xxxxx@electric-cloud.com]
> Sent: Tuesday, July 23, 2002 2:03 PM
> To: File Systems Developers
> Subject: [ntfsd] How does GetFileType decide?
>
>
> Does anyone know how the Win32 API GetFileType decides a file’s type
> under Windows 2000? For my installable file system, GetFileType is
> returning FILE_TYPE_UNKNOWN for all files, and this is causing various

> things to break (e.g., the “open” procedure produces “Invalid
> argument” errors). By single-stepping in the debugger I can see that
> GetFileType invokes an NT kernel operation, but the kernel doesn’t
> seem to ask my file system driver for any information before returning

> (“filemon” also indicates that there are no IRP’s being generated).
>
> Any suggestions on how my file system driver can control the value
> returned by GetFileType?
>
> -John-


You are currently subscribed to ntfsd as: xxxxx@MICROSOFT.com To
unsubscribe send a blank email to %%email.unsub%%

Oops: my last message was incorrect: changing the device type from
FILE_DEVICE_FILE_SYSTEM to FILE_DEVICE_DISK_FILE_SYSTEM really did fix
the problem. I got fooled because the system immediately hit another
bug that generated the same error message as the file type problem.

Anyhow, everything works great now. Thanks a million!

-John-

Perhaps it needs to be spomething more specific like like
FILE_DEVICE_DISK_FILE_SYSTEM, FILE_DEVICE_CD_ROM_FILE_SYSTEM, or
FILE_DEVICE_NETWORK_FILE_SYSTEM. I had the same problem before, and
changing it to FILE_DEVICE_NETWORK_FILE_SYSTEM corrected my problem (mine is
a network file system).

Bruce

-----Original Message-----
From: John Ousterhout [mailto:xxxxx@electric-cloud.com]
Sent: Wednesday, July 24, 2002 9:03 AM
To: File Systems Developers
Subject: [ntfsd] RE: How does GetFileType decide?

Thanks for the suggestion. My call to IoCreateDevice looked like this:

status = IoCreateDevice(driver , 0, &deviceName,
FILE_DEVICE_FILE_SYSTEM, 0, FALSE, &device);

I tried changing FILE_DEVICE_FILE_SYSTEM to FILE_DEVICE_DISK_FILE_SYSTEM,
which is the same as other file systems such as fastfact, but GetFileType
is still returning FILE_TYPE_UNKNOWN. Any other ideas? I’m wondering if
perhaps the device parameter to IoCreateDevice determines the file type
for devices, but not for files managed by a file system driver.

-John-

> It is determined by the DeviceType parameter specified on IoCreateDevice.
>
> Bruce
>
> -----Original Message-----
> From: John Ousterhout [mailto:xxxxx@electric-cloud.com]
> Sent: Tuesday, July 23, 2002 2:03 PM
> To: File Systems Developers
> Subject: [ntfsd] How does GetFileType decide?
>
>
> Does anyone know how the Win32 API GetFileType decides a file’s type
> under Windows 2000? For my installable file system, GetFileType is
> returning FILE_TYPE_UNKNOWN for all files, and this is causing various
> things to break (e.g., the “open” procedure produces “Invalid argument”
> errors). By single-stepping in the debugger I can see that GetFileType
> invokes an NT kernel operation, but the kernel doesn’t seem to ask my
> file system driver for any information before returning (“filemon” also
> indicates that there are no IRP’s being generated).
>
> Any suggestions on how my file system driver can control the value
> returned by GetFileType?
>
> -John-


You are currently subscribed to ntfsd as: xxxxx@SERENA.com
To unsubscribe send a blank email to %%email.unsub%%

***********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. Any unauthorized review, use, disclosure or distribution
is prohibited. If you are not the intended recipient, please contact
the sender by reply e-mail and destroy all copies of the original
message.
***********************************************************************

In some cases (and maybe all ones), DeviceObject->DeviceType field is
used.

At least the GetFileType path used by isatty() invoked
NtQueryInformationFile which extracts the DeviceObject->DeviceType
field.

Max

----- Original Message -----
From: “John Ousterhout”
To: “File Systems Developers”
Sent: Wednesday, July 24, 2002 1:02 AM
Subject: [ntfsd] How does GetFileType decide?

> Does anyone know how the Win32 API GetFileType decides a file’s type
> under Windows 2000? For my installable file system, GetFileType is
> returning FILE_TYPE_UNKNOWN for all files, and this is causing
various
> things to break (e.g., the “open” procedure produces “Invalid
argument”
> errors). By single-stepping in the debugger I can see that
GetFileType
> invokes an NT kernel operation, but the kernel doesn’t seem to ask
my
> file system driver for any information before returning (“filemon”
also
> indicates that there are no IRP’s being generated).
>
> Any suggestions on how my file system driver can control the value
> returned by GetFileType?
>
> -John-
>
>
>
>
> —
> You are currently subscribed to ntfsd as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to %%email.unsub%%
>