Copyright (c) Hyperion Entertainment and contributors.

Difference between revisions of "Hard and Soft Links"

From AmigaOS Documentation Wiki
Jump to navigation Jump to search
(Created page with "Hard and soft links allow an AmigaDOS user to refer to a single file or directory by more than one name. A '''hard link''' associates a new name with a file or directory by li...")
 
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
Hard and soft links allow an AmigaDOS user to refer to a single file or directory by more than one name. A '''hard link''' associates a new name with a file or directory by linking to its physical location on disk. A '''soft link''' associates a new name with a file or directory by linking to its path name. Hard and soft links are implemented in the filesystem as modified file header blocks. A new file header block is added for each link
+
Hard and soft links allow an AmigaDOS user to refer to a single file or directory by more than one name. A '''hard link''' associates a new name with a file or directory by linking to its physical location on disk. A '''soft link''' associates a new name with a file or directory by linking to its path name. Hard and soft links are implemented in the file system as modified file header blocks. A new file header block is added for each link
 
created.
 
created.
   
Line 12: Line 12:
   
 
Soft links have type T.SHORT and secondary type of ST_SOFTLINK (3). In this kind of link, the hash table area is used to store a BCPL string representing the path and name of the object being linked to, for example,
 
Soft links have type T.SHORT and secondary type of ST_SOFTLINK (3). In this kind of link, the hash table area is used to store a BCPL string representing the path and name of the object being linked to, for example,
work:foo/bar/cap. The filesystem does not attempt to access work:foo/bar/cap but tells the caller that the file they are trying to access is a soft link. The caller must then execute the correct DOS call, ReadLink(), to find out what file should really be opened.
+
work:foo/bar/cap. The file system does not attempt to access work:foo/bar/cap but tells the caller that the file they are trying to access is a soft link. The caller must then execute the correct DOS call, ReadLink(), to find out what file should really be opened.
   
If a soft link is deleted then its file header block is free. If the object a soft link points to is deleted then the soft link is left pointing at a nonexistent file. Subsequent references to the soft link will return the "object not found" error from AmigaDOS. Note that, although soft links are implemented in the filesystem, they are not supported by the MAKELINK command at the time of this writing.
+
If a soft link is deleted then its file header block is free. If the object a soft link points to is deleted then the soft link is left pointing at a nonexistent file. Subsequent references to the soft link will return the "object not found" error from AmigaDOS.
  +
  +
Note that since Makelink 53.3, "Soft" option is the default and you need to specify the "Hard" option to make a hard link.

Latest revision as of 20:42, 2 October 2015

Hard and soft links allow an AmigaDOS user to refer to a single file or directory by more than one name. A hard link associates a new name with a file or directory by linking to its physical location on disk. A soft link associates a new name with a file or directory by linking to its path name. Hard and soft links are implemented in the file system as modified file header blocks. A new file header block is added for each link created.

The header block for a hard link has a type of T.SHORT (2) and a secondary type of ST_LINKFILE (-4) or ST_LINKDIR (4) depending on whether it is linked to a file or directory. Hard links point to their object via a block number pointer stored at size - 11.

Any AmigaDOS object which has a hard link pointing at it will get a new field at size - 10 that is a pointer back to the hard link. In addition, the hard link header block has this new file at size - 10 which is used to chain together multiple hard links pointing at the same object.

If a hard link is deleted, it is first removed from the chain of hard links and then its file header block is freed. If the object a hard link points to is deleted, then the first hard link in the chain is altered so that it becomes the new file header block. The original file header block is then freed.

Soft links have type T.SHORT and secondary type of ST_SOFTLINK (3). In this kind of link, the hash table area is used to store a BCPL string representing the path and name of the object being linked to, for example, work:foo/bar/cap. The file system does not attempt to access work:foo/bar/cap but tells the caller that the file they are trying to access is a soft link. The caller must then execute the correct DOS call, ReadLink(), to find out what file should really be opened.

If a soft link is deleted then its file header block is free. If the object a soft link points to is deleted then the soft link is left pointing at a nonexistent file. Subsequent references to the soft link will return the "object not found" error from AmigaDOS.

Note that since Makelink 53.3, "Soft" option is the default and you need to specify the "Hard" option to make a hard link.