Working with links

ccb

Jul 13, 2009
47
0
TCC 15.01.51 x64 Windows 7 [Version 6.1.7601]

Hello,
I create a link like this:
MKLNK c:\skydrive\bin\msbld12.bat c:\bin\msbld12.bat

- In c:\bin, is there a way to list all the links? 'dir' doesn't seem to be able to do it.
- Once I know that c:\bin\msbld12.bat is a link, is there a way to determine what it is linked to?

Thanks for any insights...

(I found reference to INODE in another thread, but that seemed to be used to compare two objects to see if they are the same. @links[<file>] returns the number of links to the <file>, but nothing else.)

UPDATE:
'dir' identifies soft links ('<SYMLINK>') and their target, but not hard links.
 
May 20, 2008
11,401
99
Syracuse, NY, USA
Hard links? I wrote a LISTLINKS.EXE a long time ago and recently have been working on a version of DU.EXE (which doesn't count bytes/allocation for more than one link to the same thing). It's pretty easy to determine if a file has more than one link but, as far as I know, the only way to determine what other files may be linked to a file with multiple links is to search for them starting with the name of one of them (which is slow).

I read the SysInternals blurb. I don't think that program deals with hard links (but rather with junctions, reparse points).
 
May 20, 2008
11,401
99
Syracuse, NY, USA
P.S. There are thousands of hard links on the Win7 system drive. Just for example, here's a file with 7 links.
Code:
l:\projects\mydu\release> mydu.exe c:\ | grep 00065536:00011061
00065536:00011061 (7)    c:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\prc.nlp::$DATA
00065536:00011061 (7)    c:\Windows\Microsoft.NET\Framework\v2.0.50727\prc.nlp::$DATA
00065536:00011061 (7)    c:\Windows\winsxs\x86_mscorlib_b77a5c561934e089_6.1.7601.17514_none_9c12e14f7dfecaf8\prc.nlp::$DATA
00065536:00011061 (7)    c:\Windows\winsxs\x86_mscorlib_b77a5c561934e089_6.1.7601.17587_none_9c199efd7df8c93c\prc.nlp::$DATA
00065536:00011061 (7)    c:\Windows\winsxs\x86_mscorlib_b77a5c561934e089_6.1.7601.17648_none_9c1586e97dfc7dd2\prc.nlp::$DATA
00065536:00011061 (7)    c:\Windows\winsxs\x86_mscorlib_b77a5c561934e089_6.1.7601.21693_none_854d53a7979edc15\prc.nlp::$DATA
00065536:00011061 (7)    c:\Windows\winsxs\x86_mscorlib_b77a5c561934e089_6.1.7601.21768_none_8549e0bd97a21086\prc.nlp::$DATA
It took about 25 seconds to do that (but it got **all** the multiple link info).
 
May 20, 2008
11,401
99
Syracuse, NY, USA
MYDU.EXE is very much a work in progress, requires >= Vista, and so far only exists in a 32-bit version. But it might be fun to play with. I added an option to send inode/link info to a file. If a file has more than one hard link you'll only find all of them if you specify a high enough starting directory.
When I do "mydu.exe /l vlinks.txt v:\" and sort the resulting file, I see the one hard link I made as a test.
Code:
(snip)
00A30000:00006376 1 v:\4utilcopy\dynalink\oniguruma.obj
00A50000:00000FBF 2 v:\linkbg.cpp
00A50000:00000FBF 2 v:\4utilcopy\bg.cpp
00A50000:00002401 1 v:\tcsh\tcsh-6.18.01\config.rpath
(snip)
FWIW, I'm attaching a ZIP of it. It works like this.
Code:
l:\projects\mydu\release> mydu.exe /?
Show size/allocation; requires NTFS
 
MYDU [/S(treams)] [/D(ebug)] [/V(erbose)] [/E(xplorer)] [/L(inks) file] dirname
 
  /S  show non-default streams
  /D  show Failures (stderr)
  /V  show (recursive) byte/alloc for each directory
  /E  use Explorer style byte counts
  /L  send inode/link info to file
      *quote dirnames containing whitespace
      *hard-linked files counted only once
      *junctions/reparse points are not followed
 

Attachments

  • mydu.zip
    33.2 KB · Views: 53

samintz

Scott Mintz
May 20, 2008
1,503
16
Solon, OH, USA
P.S. There are thousands of hard links on the Win7 system drive. Just for example, here's a file with 7 links.
Code:
l:\projects\mydu\release> mydu.exe c:\ | grep 00065536:00011061
00065536:00011061 (7)    c:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\prc.nlp::$DATA
00065536:00011061 (7)    c:\Windows\Microsoft.NET\Framework\v2.0.50727\prc.nlp::$DATA
00065536:00011061 (7)    c:\Windows\winsxs\x86_mscorlib_b77a5c561934e089_6.1.7601.17514_none_9c12e14f7dfecaf8\prc.nlp::$DATA
00065536:00011061 (7)    c:\Windows\winsxs\x86_mscorlib_b77a5c561934e089_6.1.7601.17587_none_9c199efd7df8c93c\prc.nlp::$DATA
00065536:00011061 (7)    c:\Windows\winsxs\x86_mscorlib_b77a5c561934e089_6.1.7601.17648_none_9c1586e97dfc7dd2\prc.nlp::$DATA
00065536:00011061 (7)    c:\Windows\winsxs\x86_mscorlib_b77a5c561934e089_6.1.7601.21693_none_854d53a7979edc15\prc.nlp::$DATA
00065536:00011061 (7)    c:\Windows\winsxs\x86_mscorlib_b77a5c561934e089_6.1.7601.21768_none_8549e0bd97a21086\prc.nlp::$DATA
It took about 25 seconds to do that (but it got **all** the multiple link info).

Does that mean all those files have their streams hard linked? Is a stream actually a separate file? Aside from the fact that streams are normally hidden is there any difference between a stream a regular file?

-Scott
 
May 20, 2008
11,401
99
Syracuse, NY, USA
Does that mean all those files have their streams hard linked? Is a stream actually a separate file? Aside from the fact that streams are normally hidden is there any difference between a stream a regular file?

-Scott
You can't make a hard link to a stream per se. When you make a hard link to a file the hard link has the same streams. A stream is not "separate"; by that I mean all the streams of all links to the same thing have the same inode (file index). As for the actual storage of the data, I haven't figured it all out. For small streams (small files (default stream) and small alternate streams) on NTFS the APIs say that allocation is less than one cluster. I take that to mean the data is small enough to fit in the file's MFT entry. An MFT entry is typically 1024 bytes and must include the file's attributes, times, name, and info about where it can be found ("runs" of clusters). I have read that sufficiently fragmented files can require additional 1024-byte chunks in the MFT to accommodate all the necessary "run" info. I don't know how to tell when that happens.
I'm trying to figure out how to accurately compute "allocation". I have not found two tools that agree. The 8,192 below is almost certainly wrong on NTFS.
Code:
2009-06-10  17:42              24  autoexec.bat
2009-06-10  17:42              10  config.sys
                34 bytes in 2 files and 7 dirs    8,192 bytes allocated
For these files, GetFileInformationByHandleEx (requires Vista+) reports allocations of only a few bytes more than their sizes. I suspect that no 4096-byte clusters are used and that the data is contained in the MFT record. I'm not complaining. Utilities should work on various file systems and on various OSs.
 
Similar threads
Thread starter Title Forum Replies Date
twaterloo FolderMonitor for the 1st time not working Support 5
Tim Rowe NTFS Descriptions not working Support 13
J Batcomp still not working for me in TCMD27 Support 1
M Oracle batch OPatch.bat.bat not working in TCC but correctly in CMD Support 5
M Why did BEEP just quit working? Support 12
cgunhouse SETLOCAL not working in BDEBUGGER Support 9
nickles ANSI Colors Windows 7 no longer working Support 6
K ANSI Not Working Support 8
thorntonpg option /u not working The directory name is invalid Support 5
Charles Dye Is the "File Associations" installer dialog working? Support 4
H @ceiling @floor @int not working version 21.01.63 Support 9
K Command Line Selection Not Working Support 12
G Extended directory search not working Support 4
B %@fileseek is not working ? Support 2
C "Take Command has stopped working" Support 1
H New command not working well in Windows 7 Support 4
C "TakeCommand has stopped working" Support 3
N ping DNS lookup not working Support 1
N Updater/silentall not working? Support 1
K Help Not Working Support 11
R Fixed set /r has stopped working in build 35 Support 4
U Keys and IDX not working Support 11
Jesse Heines How to? Everything Tool Not Working After Version 20 Installation Support 8
WavSlave Fixed LIST /U not working in TCC v19 Support 5
Jay Sage %_selected no longer working Support 15
S iftp copying pgp files from ftp is not working Support 11
fishman@panix.com Extended Directory Searches are not working for me in CDD Support 9
J How to set working directory Support 10
vefatica Fixed LEAVE N not working Support 7
P %date5 not working Support 6
M WAD PDir not working correctly... Support 5
Detlef Fixed ParameterChar in TCMD.INI no longer working Support 35
Jay Sage WAD Variable _LOGFILE Not Working Support 2
I v16 - Shortcuts not working Support 6
rps Fixed Win "set /p" not working in V17 build 53 Support 3
Jay Sage Toolbar Update to INI File Not Working Support 10
Jay Sage Ctrl-C Not Working Reliably to Copy Screen Content Support 4
Jay Sage Unknown_CMD Not Working Support 4
fromano Fixed /E not working in TCMD 17.0.40 while doing one way synch Support 1
R WAD Copy's command dialogue not working Support 2
C WAD @index not working in v16 x64 Support 14
Dan Glynhampton Fixed @version "force" flag not working, and unable to set separator Support 3
C RSS feed subscription not working Support 9
M @Index not working like I thought it would... Support 2
C Move /MD not always working Support 1
C Startup folder not working on v15 Support 6
T Documentation Comspec not working Support 3
T view command not working Support 5
J Extended directory search has stopped working Support 9
vefatica WAD TPIPE.EXE has stopped working Support 13

Similar threads