<div>Hi all,</div>
<div> </div>
<div>I had a problem related with hard link in yaffs2.</div>
<div> </div>
<div>A problem occured in the following two deleted objects.</div>
<div> </div>
<div>yaffs_Object obj1</div>
<div> variantType = YAFFS_OBJECT_TYPE_HARDLINK</div>
<div> objectId = 6036</div>
<div> variant.hardLinkVariant.equivalentObjectId = 6010</div>
<div> deleted = 1</div>
<div> </div>
<div>yaffs_Object obj2</div>
<div> variantType = YAFFS_OBJECT_TYPE_HARDLINK</div>
<div> objectId = 5816</div>
<div> variant.hardLinkVariant.equivalentObjectId = 6036</div>
<div> deleted = 1</div>
<div> </div>
<div>An error took place in the function yaffs_ScanBackwards.</div>
<div> </div>
<div>Line 4896</div>
<div>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="¹ÙÅÁ" size="2">case YAFFS_OBJECT_TYPE_HARDLINK:</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font size="2"><font face="¹ÙÅÁ"><span style="mso-spacerun: yes"> </span>in->variant.hardLinkVariant.equivalentObjectId =</font></font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font size="2"><font face="¹ÙÅÁ"><span style="mso-spacerun: yes"> </span>oh->equivalentObjectId;</font></font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font size="2"><font face="¹ÙÅÁ"><span style="mso-spacerun: yes"> </span>in->hardLinks.next =</font></font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font size="2"><font face="¹ÙÅÁ"><span style="mso-spacerun: yes"> </span>(struct list_head *) hardList;</font></font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font size="2"><font face="¹ÙÅÁ"><span style="mso-spacerun: yes"> </span>hardList = in;</font></font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font size="2"><font face="¹ÙÅÁ"><span style="mso-spacerun: yes"> </span>break;</font></font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="¹ÙÅÁ" size="2"></font></span> </p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="¹ÙÅÁ" size="2">Obj1 was the first object to be executed in the previous code.</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="¹ÙÅÁ" size="2">Therefore, obj1->hardLinks.next = NULL;</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US">Because hardList was initialized to NULL in line 4432.</span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"></span> </p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US">This makes an error in the following code.</span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"></span> </p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US">Line 4953</span></p><span lang="EN-US">
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="¹ÙÅÁ" size="2">if (in) {</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font size="2"><font face="¹ÙÅÁ"><span style="mso-spacerun: yes"> </span>/* Add the hardlink pointers */</font></font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font size="2"><font face="¹ÙÅÁ"><span style="mso-spacerun: yes"> </span>hl->variant.hardLinkVariant.equivalentObject = in;</font></font></span>
</p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font size="2"><font face="¹ÙÅÁ"><span style="mso-spacerun: yes"> </span>list_add(&hl->hardLinks, &in->hardLinks);</font></font></span>
</p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font size="2"><font face="¹ÙÅÁ">} else {</font></font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font size="2"><font face="¹ÙÅÁ"><span style="mso-spacerun: yes"> </span>/* Todo Need to report/handle this better.</font></font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font size="2"><font face="¹ÙÅÁ"><span style="mso-spacerun: yes"> </span>* Got a problem... hardlink to a non-existant object</font></font></span>
</p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font size="2"><font face="¹ÙÅÁ"><span style="mso-spacerun: yes"> </span>*/</font></font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font size="2"><font face="¹ÙÅÁ"><span style="mso-spacerun: yes"> </span>hl->variant.hardLinkVariant.equivalentObject = NULL;</font></font></span>
</p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font size="2"><font face="¹ÙÅÁ"><span style="mso-spacerun: yes"> </span>INIT_LIST_HEAD(&hl->hardLinks);</font></font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="¹ÙÅÁ" size="2"> </font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font size="2"><font face="¹ÙÅÁ">}</font></font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="¹ÙÅÁ" size="2"> </font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">In line 4956, there is list_add(&hl->hardLinks, &in->hardLinks).</p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">In this case, "in" can be obj1 and "hl" can be obj2.</p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">But obj1->hardLinks.next was initialized to NULL in line 4899.</p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">So NULL pointer is referenced in list_add.</p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> </p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">This problem was caused because a deleted hard link referred to</p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">the other deleted hard link.</p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">The other reason is that deleted hard links were set up.</p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> </p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">I solved this problem like this.</p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> </p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="¹ÙÅÁ" size="2">4897,4901c4897,4904</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="¹ÙÅÁ" size="2"><<span style="mso-spacerun: yes"> </span>in->variant.hardLinkVariant.equivalentObjectId =</font></span>
</p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="¹ÙÅÁ" size="2"><<span style="mso-spacerun: yes"> </span>oh->equivalentObjectId;</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="¹ÙÅÁ" size="2"><<span style="mso-spacerun: yes"> </span>in->hardLinks.next =</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="¹ÙÅÁ" size="2"><<span style="mso-spacerun: yes"> </span>(struct list_head *) hardList;</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="¹ÙÅÁ" size="2"><<span style="mso-spacerun: yes"> </span><span style="mso-spacerun: yes"> </span>hardList = in;</font></span>
</p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="¹ÙÅÁ" size="2">---</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="¹ÙÅÁ" size="2">><span style="mso-spacerun: yes"> </span>if (in->deleted == 0)</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="¹ÙÅÁ" size="2">><span style="mso-spacerun: yes"> </span>{</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="¹ÙÅÁ" size="2">><span style="mso-spacerun: yes"> </span>in->variant.hardLinkVariant.equivalentObjectId =</font>
</span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="¹ÙÅÁ" size="2">><span style="mso-spacerun: yes"> </span>oh->equivalentObjectId;</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="¹ÙÅÁ" size="2">><span style="mso-spacerun: yes"> </span>in->hardLinks.next =</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="¹ÙÅÁ" size="2">><span style="mso-spacerun: yes"> </span>(struct list_head *) hardList;</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="¹ÙÅÁ" size="2">><span style="mso-spacerun: yes"> </span>hardList = in;</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="¹ÙÅÁ" size="2">><span style="mso-spacerun: yes"> </span>}</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="¹ÙÅÁ" size="2"></font></span> </p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="¹ÙÅÁ" size="2">Is it necessary to set up hard links about deleted hard links files?</font> </span></p></span></div>