The first part of what Mark said is not correct.
On XP and later, if you do an IRP_MJ_QUERY_INFORMATION on either NTFS and FAT they will return to you the name that was used by the user to open this file object. If the user opened the file with the short name, you get the short name; if the user opened the file with the long name, you get the long name.
NTFS has always behaved like this, but FAT was less consistent. You need this behavior to properly handle name tunneling when files are renamed.
The second part of what Mark said is correct – on all OS versions, the steps Mark outlines for getting the long name by quering the parent is what you need to do. You can bypass this work if you know the file name is not a valid short name format – more than 12 characters or has an extention longer than 3 characters. It is not correct to assume that all short names contain a ‘~’ character and only expand those. If you have a large number of files with the similar names, the file systems end up running out of unique patterns using the typical “~[number]” short name format and will start creating short names which don’t contain a ‘~’.
Thanks,
Molly Brown
Microsoft Corporation
This posting is provided “AS IS” with no warranties and confers no rights.
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Mark Cariddi
Sent: Thursday, September 18, 2003 6:04 AM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Re: Long name vs. Short name on NTFS
As far as I know on XP and Later you can do IRP_MJ_QUERY_INFORMATION looking for FileNameInformation and you will get returned the Long Name of the File.
On W2k, this will not work. You have to open up the parent directory and
do a IRP_MJ_DIRECTORY_CONTROL/IRP_MN_QUERY_DIRECTORY call and pass in the filename of the object that you require the long name for.
–Mark
–
Mark Cariddi
Consulting Associate
OSR, Open Systems Resources, Inc.
http://www.osr.com/
“Ladislav Zezula” wrote in message news:xxxxx@ntfsd…
Hi, all,
There is a feature (maybe bug ?) on NTFS file system.
If you open a file using short name, then query the name using ObQueryNameString, NTFS will return short name to you.
If you open a file using long name and then query the name, NTFS will return the long name.
The question is:
Is it possible to make NTFS return ALWAYS the long name ?
I saw some trick in FILEMON sources - Clearing the FsContext2 in the file object (setting to NULL), then calling IRJ_MJ_QUERY_INFORMATION, then restoring the FsContext2 back to the original value. But this seems as dirty hack to me, and I would like to avoid this method. Does anyone know how to do it ?
Ladislav Zezula
–
Vyhraj Ford Fiesta s klimatizac? a dal?? ceny!
V?ce na http://soutez.volny.cz
—
You are currently subscribed to ntfsd as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com