FsRtlAddToTunnelCache

Dear all,

in a user mode application, I need to copy a file and preserve its short
file name. I came across the “tunneling” APIs such as
FsRtlInitializeTunnelCache, FsRtlAddToTunnelCache etc. Basically, as I
understand it, once a long file name has been added to the tunnel cache,
you can open the file by its short name, copy/rename it, and the long
file name will be dragged along. Is this correct?

However, I checked and the tunneling stuff is only exported by
NTOSKRNL.EXE, which means it is only available to drivers. So the
question is, is there any way, from an user mode application, to tell
the file system that it should use tunneling “for the next copy/rename
operation”?

Thanks!

Ralf.


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Open the destination file with proper disposition.
This will truncate the data, but leave the name + MFT record intact.
Then write to this file.

Max

----- Original Message -----
From: “Ralf Buschmann”
To: “File Systems Developers”
Sent: Monday, February 11, 2002 12:38 PM
Subject: [ntfsd] FsRtlAddToTunnelCache

> Dear all,
>
> in a user mode application, I need to copy a file and preserve its short
> file name. I came across the “tunneling” APIs such as
> FsRtlInitializeTunnelCache, FsRtlAddToTunnelCache etc. Basically, as I
> understand it, once a long file name has been added to the tunnel cache,
> you can open the file by its short name, copy/rename it, and the long
> file name will be dragged along. Is this correct?
>
> However, I checked and the tunneling stuff is only exported by
> NTOSKRNL.EXE, which means it is only available to drivers. So the
> question is, is there any way, from an user mode application, to tell
> the file system that it should use tunneling “for the next copy/rename
> operation”?
>
> Thanks!
>
> Ralf.
>
>
> —
> You are currently subscribed to ntfsd as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Maxim,

you wrote on Monday, February 11, 2002, 13:32:05:

>> in a user mode application, I need to copy a file and preserve its short
>> file name. I came across the “tunneling” APIs such as
>> FsRtlInitializeTunnelCache, FsRtlAddToTunnelCache etc. Basically, as I
>> understand it, once a long file name has been added to the tunnel cache,
>> you can open the file by its short name, copy/rename it, and the long
>> file name will be dragged along. Is this correct?

MSS> Open the destination file with proper disposition.
MSS> This will truncate the data, but leave the name + MFT record intact.
MSS> Then write to this file.

Sorry, looks like I didn’t make myself clear. I understand what you are
saying but that’s not the issue here. My problem is that I’m creating a
new file and need a way to control its short name. For example I have
files

c:\src\Long Name 1.txt
c:\src\Long Name 2.txt

Now I need to copy “c:\src\Long Name 2.txt” to directory c:\dest which
is empty. But in c:\dest, “Long Name 2.txt” will have the short file
name longna~1.txt, not longna~2.txt. I want to keep the original short
file name, if possible.

Ralf.


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Ralf,

The FsRtl tunneling APIs are not what you are looking for – these are
used to help file systems implement tunneling, not to expose the name
tunneling to applications above the file systems.

With Windows XP, there is a new WIN32 API that allows you to set the
short file name for a file, SetFileShortName. This is equivalent to
calling ZwSetFileInformation with the FILE_INFORMATION_CLASS of
FileShortNameInformation.

There are a couple caveats about this – it only works on NTFS and the
user calling this API must have SE_RESTORE_PRIVILEGE in order for this
operation to succeed (this API was added to help out backup-type
applications).

Previous to Windows XP, there is no mechanism for explicitly setting the
short name on a file on any of the file systems that ship with the OS.

Thanks,

Molly Brown
Microsoft Corporation

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

-----Original Message-----
From: Ralf Buschmann [mailto:xxxxx@backmagic.de]
Sent: Monday, February 11, 2002 5:03 AM
To: File Systems Developers
Subject: [ntfsd] Re: FsRtlAddToTunnelCache

Maxim,

you wrote on Monday, February 11, 2002, 13:32:05:

>> in a user mode application, I need to copy a file and preserve its
short
>> file name. I came across the “tunneling” APIs such as
>> FsRtlInitializeTunnelCache, FsRtlAddToTunnelCache etc. Basically, as
I
>> understand it, once a long file name has been added to the tunnel
cache,
>> you can open the file by its short name, copy/rename it, and the
long
>> file name will be dragged along. Is this correct?

MSS> Open the destination file with proper disposition.
MSS> This will truncate the data, but leave the name + MFT record
intact.
MSS> Then write to this file.

Sorry, looks like I didn’t make myself clear. I understand what you are
saying but that’s not the issue here. My problem is that I’m creating a
new file and need a way to control its short name. For example I have
files

c:\src\Long Name 1.txt
c:\src\Long Name 2.txt

Now I need to copy “c:\src\Long Name 2.txt” to directory c:\dest which
is empty. But in c:\dest, “Long Name 2.txt” will have the short file
name longna~1.txt, not longna~2.txt. I want to keep the original short
file name, if possible.

Ralf.


You are currently subscribed to ntfsd as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Daniel,

you wrote on Monday, February 11, 2002, 19:48:52:

[snip]

DL> As Molly says, the FSRTL APIs are only an implementation of a cache
DL> which the filesystems can use to implement tunneling. By themselves
DL> they aren’t anything interesting.

Thank you, I do now understand.

Ralf.


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Molly,

you wrote on Monday, February 11, 2002, 19:30:22:

MB> The FsRtl tunneling APIs are not what you are looking for – these
MB> are used to help file systems implement tunneling, not to expose the
MB> name tunneling to applications above the file systems.

Many thanks for your reply. I understand.

MB> With Windows XP, there is a new WIN32 API that allows you to set the
MB> short file name for a file, SetFileShortName. This is equivalent to
MB> calling ZwSetFileInformation with the FILE_INFORMATION_CLASS of
MB> FileShortNameInformation.

Ah, this API is new to me (OK, I see the November SDK documents it).
Thanks! Could you please provide information on the associated structure
(presumably FILE_SHORTNAME_INFORMATION) and the FILE_INFORMATION_CLASS
enumerated value of FileShortNameInformation? Is it documented in the
Windows XP IFS Kit/DDK? (we already ordered that)

MB> There are a couple caveats about this – it only works on NTFS and
MB> the user calling this API must have SE_RESTORE_PRIVILEGE in order
MB> for this operation to succeed (this API was added to help out
MB> backup-type applications).

The privilege is no problem … but why did you decide to support it
only for NTFS?

MB> Previous to Windows XP, there is no mechanism for explicitly setting
MB> the short name on a file on any of the file systems that ship with
MB> the OS.

Oh well, looks like there is no way around creating temporary files with
8.3 style numerically tailed names prior to copying the file to make
sure the unwanted short file names are already “consumed” and delete
them after copying the file.

Ralf.


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

xcopy supports bulk copying with short file name preservation, I think…
At least, that is what I have always interpreted the /N parameter as
meaning. Since I’ve never tested that assumption, verify it before you
rely on it. If that is correct, perhaps it might lead you to an easier
alternative… Or not, it might be worse than what you propose. =8-0

Phil

Ralf Buschmann @lists.osr.com on 02/11/2002 12:38:41 PM

Please respond to “File Systems Developers”

Sent by: xxxxx@lists.osr.com

To: “File Systems Developers”
cc:

Subject: [ntfsd] Re: FsRtlAddToTunnelCache

Molly,

you wrote on Monday, February 11, 2002, 19:30:22:

MB> The FsRtl tunneling APIs are not what you are looking for – these
MB> are used to help file systems implement tunneling, not to expose the
MB> name tunneling to applications above the file systems.

Many thanks for your reply. I understand.

MB> With Windows XP, there is a new WIN32 API that allows you to set the
MB> short file name for a file, SetFileShortName. This is equivalent to
MB> calling ZwSetFileInformation with the FILE_INFORMATION_CLASS of
MB> FileShortNameInformation.

Ah, this API is new to me (OK, I see the November SDK documents it).
Thanks! Could you please provide information on the associated structure
(presumably FILE_SHORTNAME_INFORMATION) and the FILE_INFORMATION_CLASS
enumerated value of FileShortNameInformation? Is it documented in the
Windows XP IFS Kit/DDK? (we already ordered that)

MB> There are a couple caveats about this – it only works on NTFS and
MB> the user calling this API must have SE_RESTORE_PRIVILEGE in order
MB> for this operation to succeed (this API was added to help out
MB> backup-type applications).

The privilege is no problem … but why did you decide to support it
only for NTFS?

MB> Previous to Windows XP, there is no mechanism for explicitly setting
MB> the short name on a file on any of the file systems that ship with
MB> the OS.

Oh well, looks like there is no way around creating temporary files with
8.3 style numerically tailed names prior to copying the file to make
sure the unwanted short file names are already “consumed” and delete
them after copying the file.

Ralf.


You are currently subscribed to ntfsd as: xxxxx@Seagate.com
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Philip,

you wrote on Monday, February 11, 2002, 20:50:43:

PDB> xcopy supports bulk copying with short file name preservation, I
PDB> think… At least, that is what I have always interpreted the /N
PDB> parameter as meaning.

No, XCOPY /N will copy the files by their short file names only. That
is, the LFN will get lost.

Ralf.


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

That’s a good thing to know. Sorry it wasn’t any help.

Phil

Ralf Buschmann @lists.osr.com on 02/11/2002 11:59:57 PM

Please respond to “File Systems Developers”

Sent by: xxxxx@lists.osr.com

To: “File Systems Developers”
cc:

Subject: [ntfsd] Re: FsRtlAddToTunnelCache

Philip,

you wrote on Monday, February 11, 2002, 20:50:43:

PDB> xcopy supports bulk copying with short file name preservation, I
PDB> think… At least, that is what I have always interpreted the /N
PDB> parameter as meaning.

No, XCOPY /N will copy the files by their short file names only. That
is, the LFN will get lost.

Ralf.


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com