blob: 9ef09edfcdf6c5b36d6a9160e59e641542d39d21 [file] [log] [blame]
<?xml version='1.0'?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
]>
<chapter id="Symbolic_Links">
<title>Symbolic Links</title>
<para>Symbolic links to a file can be stored in one of two formats: "local" and "extents". The length of the symlink contents is always specified by the inode's <command>di_size</command> value.</para>
<section id="Shortform_Symbolic_Links"><title>Shortform Symbolic Links</title>
<para>Symbolic links are stored with the "local" <command>di_format</command> if the symbolic link can fit within the inode's data fork. The link data is an array of characters (<command>di_symlink</command> array in the data fork union).</para>
<para>
<mediaobject>
<imageobject><imagedata fileref="images/61.png" format="PNG" width="100%" scalefit="0"/></imageobject>
<textobject><phrase>61</phrase></textobject>
</mediaobject>
</para>
<bridgehead>xfs_db Example:</bridgehead>
<para>A short symbolic link to a file is created:</para>
<programlisting>
xfs_db&gt; inode &lt;inode#&gt;
xfs_db&gt; p
core.magic = 0x494e
core.mode = 0120777
core.version = 1
core.format = 1 (local)
...
core.size = 12
core.nblocks = 0
core.extsize = 0
core.nextents = 0
...
u.symlink = "small_target"
</programlisting>
<para>Raw on-disk data with the link contents highlighted:</para>
<mediaobject>
<imageobject><imagedata fileref="images/code/61.png" format="PNG" /></imageobject>
<textobject><phrase>code61</phrase></textobject>
</mediaobject>
</section>
<section id="Extent_Symbolic_Links"><title>Extent Symbolic Links</title>
<para>If the length of the symbolic link exceeds the space available in the inode's data fork, the link is moved to a new filesystem block and the inode's <command>di_format</command> is changed to "extents". The location of the block(s) is specified by the data fork's <command>di_bmx[]</command> array. In the significant majority of cases, this will be in one filesystem block as a symlink cannot be longer than 1024 characters.</para>
<para>
<mediaobject>
<imageobject><imagedata fileref="images/62.png" format="PNG" width="100%" scalefit="0"/></imageobject>
<textobject><phrase>62</phrase></textobject>
</mediaobject>
</para>
<bridgehead>xfs_db Example:</bridgehead>
<para>A longer link is created (greater than 156 bytes):</para>
<programlisting>
xfs_db&gt; inode &lt;inode#&gt;
xfs_db&gt; p
core.magic = 0x494e
core.mode = 0120777
core.version = 1
core.format = 2 (extents)
...
core.size = 182
core.nblocks = 1
core.extsize = 0
core.nextents = 1
...
u.bmx[0] = [startoff,startblock,blockcount,extentflag] 0:[0,37530,1,0]
xfs_db&gt; dblock 0
xfs_db&gt; type symlink
xfs_db&gt; p
"symlink contents..."
</programlisting>
</section></chapter>