          <<< NOTED::DISK$NOTES7:[NOTES$LIBRARY_7OF4]HACKERS.NOTE;1 >>>
                               -< ** Hackers ** >-
================================================================================
Note 1221.12                 Detecting file aliases?                    12 of 16
RANGER::HARRIS "Juggling has its ups and downs"      41 lines  22-APR-1991 09:33
        -< A code fragment - WARNING: Following Reply has 1100+ lines >-
--------------------------------------------------------------------------------
				*** WARNING ***
			    1100+ line reply follows

    The following replies contain a 1100+ line 'C' program to scan a disk
    looking for directory entries which may possibily be alias entries
    (files created using SET FILE/ENTER or equivalent via the XQP).
    
	scan_alias.c	! C program to scan for alias filenames.
	fh2def.h	! include file with file header definitions
	hm2def.h	! include file with home block definitions
	dirdef.h	! include file with directory file definitions
    
    I do not pretend to know for a fact that the files found are realy
    alias entries.  It it at best an avisory service.
    
    The program will claim a file is an alias if the directory backlink
    pointer in the file header is not the directory the filename is found
    in.
    
    The program will also claim a file is an alias if the filename in the
    directory is not the same as the filename in the file header (see QAR
    4865 for how this could cause a false alias claim - or deliberate
    changing of the filename in the file header using the XQP). 
    
    This program reads the INDEXF.SYS file directly and it opens and reads
    directory files in block mode.  This is not the most robust approach but
    I used the discussion in this note as an excuse to learn more about the
    structure of the file system (using the "VMS File System Internals" book
    by Kirby McCoy as my reference).  Besides this is the HACKERS notes
    file.  
    
    A better approach would have been to use directory wildcard processing
    to walk the directory tree, but that wouldn't have been as much fun, and
    besides I think this approach is faster.  If someone wants to try
    this don't use [*...] via RMS because it will run into problems if
    people have used rooted directories to nest deeper then 8 levels.  Use
    either the XQP or just wildcard a single directory at a time opening
    each directory by FID to get around the RMS subdirectory nesting
    limits. 
    
    						Bob Harris
