Symbolic link: Difference between revisions

From OSDev.wiki
Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content added Content deleted
(Created page with "{{Filesystems}} <!-- {{In Progress}} --> ==Introduction== A symbolic link is a special type of file that refers to another file or directory and is most often encountered in ...")
 
Line 12: Line 12:
Example:
Example:
On a system substituting the hierarchy (Linux, glibc, shown as shell commands for clarity) :
On a system substituting the hierarchy (Linux, glibc, shown as shell commands for clarity) :
<code>
<code><pre>
$ ln -T /dir1/sdir1 /dir2/sdirlink1
$ ln -T /dir1/sdir1 /dir2/sdirlink1
$ cd /dir2/sdirlink1
$ cd /dir2/sdirlink1
Line 25: Line 25:
$ pwd
$ pwd
/dir1
/dir1
</code>
</pre></code>


On a system substituting the hierarchy (posnk (old version), newlib, shown as shell commands for clarity) :
On a system substituting the hierarchy (posnk (old version), newlib, shown as shell commands for clarity) :
<code>
<code><pre>
$ ln -T /dir1/sdir1 /dir2/sdirlink1
$ ln -T /dir1/sdir1 /dir2/sdirlink1
$ cd /dir2/sdirlink1
$ cd /dir2/sdirlink1
Line 41: Line 41:
$ pwd
$ pwd
/dir2
/dir2
</code>
</pre></code>

Revision as of 12:21, 6 March 2015

Filesystems
Virtual Filesystems

VFS

Disk Filesystems
CD/DVD Filesystems
Network Filesystems
Flash Filesystems

Introduction

A symbolic link is a special type of file that refers to another file or directory and is most often encountered in UNIX derived/inspired operating systems and their file systems. Symbolic links are real files that contain a path which is automatically resolved when the link is accessed.

Path resolution

There are multiple ways of handling symbolic links during path resolution: Some operating systems maintain the hierarchy of the path leading to the symlink while others substitute the entire hierarchy of the path for that of the target. UNIX-like operating systems handle this in a strange way: The kernel and C library do the latter while some shells maintain a history of path changes and resolve the parent of a symlinked directory as the parent of the symlink.

Example: On a system substituting the hierarchy (Linux, glibc, shown as shell commands for clarity) :

$ ln -T /dir1/sdir1 /dir2/sdirlink1
$ cd /dir2/sdirlink1
$ pwd
/dir1/sdir1
$ cd ..
$ pwd
/dir1
$ cd 
/
$ cd /dir2/sdirlink1/..
$ pwd
/dir1

On a system substituting the hierarchy (posnk (old version), newlib, shown as shell commands for clarity) :

$ ln -T /dir1/sdir1 /dir2/sdirlink1
$ cd /dir2/sdirlink1
$ pwd
/dir2/sdirlink1
$ cd ..
$ pwd
/dir2
$ cd 
/
$ cd /dir2/sdirlink1/..
$ pwd
/dir2