Boost logo

Boost :

Subject: [boost] [filesystem] proposal: treat reparse files as regular files
From: Paul Harris (harris.pc_at_[hidden])
Date: 2015-07-24 04:03:17

Hi all,

-- Proposal --

tl;dr : I propose that we treat all non-symlink "reparse_files" as

If the boost library user wants to do something special with these plain
reparse files, they should use alternative means. But typically they are
supposed to be treated as regular files.

This means we could drop the "reparse_file" enum, or continue to use it for
a special-case whats_my_real_status() function.

--- Motivation ---

Windows Server 2012 uses reparse points to implement deduplification.
Those files should be treated as regular files in all circumstances.
Currently, they are not classed as "regular" files, so fs::copy() will skip
those files,
and library-user code written to list files based on official examples will
ignore all dedup'd files.

This is causing serious and latent problems at the user end, because
deduping only happens occasionally after X days, and users cannot easily
check if a file is dedup'd (they look just like regular files).

--- Real life example ---

Another example of reparse use is the "Symantec Enterprise Vault" (version
10), which I found running on one site.
It replaces files on the server with reparse-point files.
shows the contents of the reparse buffer, which is a URL to an internal
HTTP server. The url points to a .asp link with a bunch of codes and dates
to identify the file in the server.
Copy-pasting that URL into a webbrowser allows you to directly download the
file via the webbrowser, which is pretty neat I suppose.

In this case, the reparsed-files in Windows Explorer all have grey X
crosses on their file icon. If you "type" them (via cmd) or open them, the
icon loses the grey cross and the file is no longer a reparse point file.

My software refused to read the files because they were "not regular
files". Once I adjusted the boost code (described below), my software saw
them as regular and opened the files. The file icons lost the grey cross.

SO it seems that the file server automatically downloads and replaces the
files with the stored content on demand, and the file reading client
program should really just treat these files as normal files.

--- Short logic ---

reparse files (that are not symlinks) should almost always be treated as
plain files.
They are a mechanism for MS file servers to store files in clever ways, but
the client should not care and just read/write them as if they were normal

This is different to all the other "other" files which can't be treated
like normal files:
block, character, fifo, socket, unknown

So, reparse files should not be grouped with the "other" file types.

They are also NOT symlinks, and should not be treated as symlinks (which
would require special decisions for copying, or querying the status, or
checking if the target still exists).

--- What are reparse files ---

I did some reading, if I understand correctly:

Reparse points give drivers (on the server) a chance to get data through
some other specialised means (eg query from a cluster store).
They are processed by the server, not the client, so clients should treat
reparse data as opaque data.
EXCEPT for symlink reparse files.

quote:"The following reparse tags, with the exception of
IO_REPARSE_TAG_SYMLINK, are processed on the server and are not processed
by a client after transmission over the wire. Clients should treat
associated reparse data as opaque data."

It seems like the rest of the tags are used for connecting files to other
types of storage (eg long term storage, cluster storage).
Clients may need to do something special with SOME reparse point files, IF
the client cares about how long the file read may take.
quote: "Most applications should take special actions for files that have
been moved to long-term storage, if only to notify the user that it may
take a while to retrieve the file."

--- Changes required ---

Option 1: change is_regular_file() to return true where type==reparse_file
I don't like this option, as library-users could be checking the type
directly instead of using is_regular_file().

Option 2:
These functions return reparse_file:

  fs::file_type query_file_type(const path& p, error_code* ec)
  file_status status(const path& p, error_code* ec)
  file_status symlink_status(const path& p, error_code* ec)

They should instead return regular_file instead.

--- How to test with dedup files ---

Creating dedup'd files is a feature only available on Windows Server 2012,
I believe,
although Windows XP/Vista/7/8/10 clients all can read dedup files.

Here is how I created a windows server to test with (for free!) on a demo
Azure cloud server.
I have one working, so if anyone would like to use it for their testing,
let me know.

Step one: follow this blog article:

once the machine was "running" I clicked Connect at the bottom.
That gave me an .rdp file which in theory I could use with rdesktop, but it
uses a DNS name that was only just created, so that didn't work.

When you click the name of the server in the list, it shows the public IP
on the right.. and the port
then you can do this
$ rdesktop that.ip.addr:port

But only if you have the latest rdesktop AND you have set up kerberos

Instead I found a windows computer and used remote desktop from there.

Once inside,
in the "Server Manager --> Dashboard" window on the screen, click "Add
then go next next until "Server Roles"
expand "File and Storage services" , "File and iSCSI" , and tick "Data
Then next next etc and Install.
Wait a bit... and its done.
Continuing on that webpage...
Time to enable dedup.  There is a temp disk D: so lets enable there.
Method 1... I did this and then went to method 2... Start PowerShell, type:
"Enable-DedupVolume D:"
Method 2... in that same Dashboard, hit the 4th button (File and Storage
Then Volumes --> Disks
click Volume 1 at the top, and then right click D: at the bottom -->
Configure Dedup.
To try and accelerate this puppy, I set the "age to dedup" to 0 days.
Time to make something to dedup.  We'll just duplicate the warning.txt file
that exists on D:
In powershell:
PS> D:
PS> $file = Get-Content DATALOSS_WARNING_README.txt
Then, do these 2 commands a bunch of times until "big.txt" gets to say 6MB
PS> Add-Content big.txt $file
PS> $file = Get-Content big.txt
Then use windows explorer (or other) to make a dozen copies of big.txt
Copy c:\windows\explorer.exe to D:
to give it something to dedup
Go to D: and then copy-paste explorer.exe a dozen times.
In PowerShell, type:
PS> Update-DedupStatus -Volume D:
PS> Start-DedupStatus -Type Optimization -Volume D:
and then wait for it to finish.
you can track its progress with:
PS> Get-DedupJob
PS> Get-DedupStatus -Volume D:
So, once its deduped, you check.
you should see that its a reparse point with that 0x800etc0013 code.
Copy-paste big.txt to big2.txt and check it with the query, and it should
tell you big2 is NOT a reparse point.
NOW you have some files to test the boost library...
You can't zip them up (they lose the dedup tag), you have to run boost
binaries ON the computer in the sky.
--- Finish ---
Thanks for reading,

Boost list run by bdawes at, gregod at, cpdaniel at, john at