<div>Hi,</div>
<div> </div>
<div>I try to verify my supposition using code segments below.</div>
<div> </div>
<div>(1)</div>
<div>mknod()</div>
<div>open()</div>
<div>close()</div>
<div>unlink()</div>
<div> </div>
<div>(2)</div>
<div>mknod()</div>
<div>open()</div>
<div>unlink()</div>
<div>close()</div>
<div> </div>
<div>IMFS_memfile_remove will be called to free related data structures when deleting an IMFS memory file. I debugged the above code segments. In (1) IMFS_memfile_remove is called; in (2) it is never called...</div>
<div> </div>
<div>Maybe, we can clear the LIBIO_FLAGS_OPEN flag bit of "iop" in memfile_close before memfile_check_rmnod.</div>
<div>And for device_close and imfs_dir_close, add similar checks.</div>
<div> </div>
<div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Looks to me that the generic close should be detecting this<br>condition and (maybe) calling the specific filetype for unlink.</blockquote>
<br>Since link count is recorded in jnode, we may only be able to check in each filesystem.</div>
<div> </div>
<div>Regards,</div>
<div>Wei</div>
<div> </div>
<div><span class="gmail_quote">On 8/22/08, <b class="gmail_sendername">Joel Sherrill</b> <<a href="mailto:joel.sherrill@oarcorp.com">joel.sherrill@oarcorp.com</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><span class="q">Wei Shen wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">I suspect there is a bug with unlink of IMFS files, but I am not certain.<br><br>If a file is still being opened, IMFS_unlink will not really free the<br>
file node, but just decrements its link count and removes it from the<br>parent's chain, and the remaining work is leaved to close.<br>memfile_close calls memfile_check_rmnod to delete the file node with a zero link count when the last user closes the file.<br>
<br>However, in memfile_check_rmnod "rtems_libio_is_file_open" is checked, which it will always be TRUE because the LIBIO_FLAGS_OPEN flag bit has not been cleared yet. Hence, the file node will never be deleted, while it can no more be accessed in the file system.<br>
 <br></blockquote></span>Can you provide a simple test case and let me analyze it?<span class="q"><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">I also wonder why device_close and imfs_dir_close do not do similar rmnod checks as memfile_close.<br> <br>
</blockquote></span>Looks to me that the generic close should be detecting this<br>condition and (maybe) calling the specific filetype for unlink.<br><br>What do you think of that?  Again I think it will take a test<br>case to verify and fix.</blockquote>
</div>