summaryrefslogtreecommitdiffstats
path: root/XFS_Filesystem_Structure/en-US/Symbolic_Links.xml
blob: 76c69a536d5c8d0654e19c3080514576fc37aa19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?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"/></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"/></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"/></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>