FSUTIL, hardlink not working

  • Thread starter Thread starter Bertoldino
  • Start date Start date
B

Bertoldino

hi,
either in win2000 or in winXP (both NTFS) i've tried FSUTIL hardlink create
newlink_file
source_file


but the new file seems to be only a mere copy and not an hardlink, so if i
modify the newlink_file the source_file remains the same

what's the matter? :-/

sorry for my bad english
 
Pegasus said:

google is not frend as YOU are! :-)
i googled for weeks and i'v never seen that link :)
i'm not used to post without searching in google, sorry you supposed it.


anyway,
my problem remains the same:

let me explain my "experiment" with the following sequence:
(the OS messages are in italian language, but you can simply repeat my
experiment and read your OS messages)

=== TOP ===

C:\test>md a b

C:\test>cd a

C:\test\a>copy con original_file.txt
This is the original file.
^Z
1 file copiati.

C:\test\a>cd ..\b



C:\test\b>fsutil hardlink create hardlinked.txt ..\a\original_file.txt
Collegamento hardware creato per C:\test\b\hardlinked.txt <<===>>
C:\test\a\orig

C:\test\b>edit hardlinked.txt

C:\test\b>type hardlinked.txt
This is the original file.
LINE ADDED USING HARDLINKED.TXT


C:\test\b>cd..\a

C:\test\a>type original_file.txt
This is the original file.

=== BOTTOM ===

as you can see the original file was not updated.
this doesn't seem an hardlink to me.
i've not controlled sizes, but content.

what was wrong? :-/

Thanks for your time and kind attention :-)
 
Bertoldino said:
google is not frend as YOU are! :-)
i googled for weeks and i'v never seen that link :)
i'm not used to post without searching in google, sorry you supposed it.


anyway,
my problem remains the same:

let me explain my "experiment" with the following sequence:
(the OS messages are in italian language, but you can simply repeat my
experiment and read your OS messages)

=== TOP ===

C:\test>md a b

C:\test>cd a

C:\test\a>copy con original_file.txt
This is the original file.
^Z
1 file copiati.

C:\test\a>cd ..\b



C:\test\b>fsutil hardlink create hardlinked.txt ..\a\original_file.txt
Collegamento hardware creato per C:\test\b\hardlinked.txt <<===>>
C:\test\a\orig

C:\test\b>edit hardlinked.txt

C:\test\b>type hardlinked.txt
This is the original file.
LINE ADDED USING HARDLINKED.TXT


C:\test\b>cd..\a

C:\test\a>type original_file.txt
This is the original file.

=== BOTTOM ===

as you can see the original file was not updated.
this doesn't seem an hardlink to me.
i've not controlled sizes, but content.

what was wrong? :-/

Thanks for your time and kind attention :-)

Some of your commands are back to front. Try this little batch file:
@echo off
dir c:\ > c:\original.txt
fsutil hardlink create c:\linked.txt c:\original.txt
echo Viva l'Italia! >> c:\linked.txt
type c:\original.txt
 
Pegasus said:
Some of your commands are back to front. Try this little batch file:
@echo off
dir c:\ > c:\original.txt
fsutil hardlink create c:\linked.txt c:\original.txt
echo Viva l'Italia! >> c:\linked.txt
type c:\original.txt

gosh :-(
i've tried, they work perfectly and the problem is that they seem to be
identical to my instruction sequence (except for the command itself, you
used pipe commands with dir, i used direct input)

:-(

please help me understand ...
the sequence is:

create original file / test content

create hard link to the original file
write to the hard link
test content of the original file ; if content is updated, hardlink is
working, else ... i'm not able to use FSUTUL ! ;-)

sorry if i'm a little blockhead ... but i'm going on reading and reading
your example and mine... and i can't see where is the problem :-(
 
Bertoldino said:
gosh :-(
i've tried, they work perfectly and the problem is that they seem to be
identical to my instruction sequence (except for the command itself, you
used pipe commands with dir, i used direct input)

:-(

please help me understand ...
the sequence is:

create original file / test content

create hard link to the original file
write to the hard link
test content of the original file ; if content is updated, hardlink is
working, else ... i'm not able to use FSUTUL ! ;-)

sorry if i'm a little blockhead ... but i'm going on reading and reading
your example and mine... and i can't see where is the problem :-(

Writing pseudo-code is fine when explaining a general
principle but is of no use when it comes to debugging.
I created a batch file for you that shows how the hardlink
concept works. You now need to create your own batch
file to demonstrate how it does NOT work when you do it.
 
Writing pseudo-code is fine when explaining a general
principle but is of no use when it comes to debugging.
I created a batch file for you that shows how the hardlink
concept works. You now need to create your own batch
file to demonstrate how it does NOT work when you do it.

yes,
i recreated perfectly a batch file with your concept in mind and it worked
fine:

==my sample: ==

time /T >original.txt
fsutil hardlink create hardlink.txt original.txt
date /T >>hardlink.txt
md sample
move hardlink.txt .\sample
type .\sample\hardlink.txt

== end of my sample ==

it works.
but when i do the following in interactive mode (by hand), it doesn't work:

copy con original.txt
{typing something, then ctrl-z, return}
fsutil hardlink create linked.txt original.txt
edit linked.txt
{modify somewhat}
type original.txt

the resulting file is not modified :-(
and the same thing happens if i use notepad (not only "edit")
 
Bertoldino said:
yes,
i recreated perfectly a batch file with your concept in mind and it worked
fine:

==my sample: ==

time /T >original.txt
fsutil hardlink create hardlink.txt original.txt
date /T >>hardlink.txt
md sample
move hardlink.txt .\sample
type .\sample\hardlink.txt

== end of my sample ==

it works.
but when i do the following in interactive mode (by hand), it doesn't
work:

copy con original.txt
{typing something, then ctrl-z, return}
fsutil hardlink create linked.txt original.txt
edit linked.txt
{modify somewhat}
type original.txt

the resulting file is not modified :-(
and the same thing happens if i use notepad (not only "edit")

You are punishing yourself by using a DOS program (edit)
on an NTFS volume with an advanced NTFS command
(fsutil). When you use edit then it destroys part of the link
and you have to rebuild it. Stop using edit - there is no reason
at all for having it!
 
Pegasus (MVP) wrote:

You are punishing yourself by using a DOS program (edit)
on an NTFS volume with an advanced NTFS command
(fsutil). When you use edit then it destroys part of the link
and you have to rebuild it. Stop using edit - there is no reason
at all for having it!

yes!
if i do the test ONLY with notepad all works!!! :)

but... there's no trace of this behavior in the KB ...

**THANKS** Pegasus!!! ;-)

Am I right if i say that "edit" is the only program that destroys an
hardlink?
 
Bertoldino said:
Pegasus (MVP) wrote:



yes!
if i do the test ONLY with notepad all works!!! :)

but... there's no trace of this behavior in the KB ...

**THANKS** Pegasus!!! ;-)

Am I right if i say that "edit" is the only program that destroys an
hardlink?

Yes, that's what I found out in my tests.

You must not expect a KB article on the compatibility of
a 16-bit legacy program with a file system designed for a
32-bit operating system. It works most of the time but you
cannot rely on it. Why would you want to use it, anyway?
It has nothing but drawbacks when compared to notepad.exe!
You might as well use edlin - another leftover from the "good"
old DOS days . . .
 
Pegasus said:
You must not expect a KB article on the compatibility of
a 16-bit legacy program with a file system designed for a
32-bit operating system. It works most of the time but you
cannot rely on it.

ok
i thought that dos calls were emulated by 32 bit OS and 16 or 32 was the
same thing
Why would you want to use it, anyway?

sometimes special characters like òàùèì often used in italian are different
when used in a standard batch and written with a notepad
It has nothing but drawbacks when compared to notepad.exe!

except for the fact that any notepad file with accented characters
mispresent that characters :-(
You might as well use edlin - another leftover from the "good"
old DOS days . . .

LOL i hated edlin ... but sometimes it saved my work ;)
 
Bertoldino said:
ok
i thought that dos calls were emulated by 32 bit OS and 16 or 32 was the
same thing


sometimes special characters like òàùèì often used in italian are
different
when used in a standard batch and written with a notepad


except for the fact that any notepad file with accented characters
mispresent that characters :-(


LOL i hated edlin ... but sometimes it saved my work ;)

This is an intriguing issue you raise, one that has bothered me
on occasion when writing batch files for European clients: That
accented letters appear correctly in notepad but differently in
a Command Prompt that is subject to a non-English code page.
I will now try "edit" in such cases (and notepad in all other cases!)
 
This is an intriguing issue you raise, one that has bothered me
on occasion when writing batch files for European clients: That
accented letters appear correctly in notepad but differently in
a Command Prompt that is subject to a non-English code page.
I will now try "edit" in such cases (and notepad in all other cases!)

wordpad can also do the job, by choosing ms-dos as the format when you
save the file. That way the charset will be correct
 
jorgen said:
wordpad can also do the job, by choosing ms-dos as the format when you
save the file. That way the charset will be correct

thanks to all of you!

I'm thinking the problem with hardlinks is NOT a matter of 16/32 bit ...
calls to the kernel are transparent, right?

it's the way the program(s) writes to the file
in fact you can do the same, identical thing with winzip 11 (or 10, or 9, or
8) ... as "edit" they don't write to the file: they write to a temp file,
then erase the original and move/rename the temp file! :-)
i think this is a "behavior by design" ... a bad behavior ;-)

bye! :)
 
The same thing happens with Excel. If you edit the file and save it the link
still shows the old date and does not have the new data. Hardlink does not
seem to work and only makes a copy of the file. I tried this on a 2003 Server
and XP and both do the same thing.
 
Back
Top