<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: determining filename of unlinked open file in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/determining-filename-of-unlinked-open-file/m-p/4933382#M803208</link>
    <description>By definition, an unlinked file (i.e. the link count has been reduced to zero) does not have a pathname associated with it so your question really has no meaning. The directory entry has already been removed and&lt;BR /&gt;the system is waiting for all processes which had the file open to either close() the file or terminate. When that condition is satisfied the space is actually freed within the filesystem. &lt;BR /&gt;&lt;BR /&gt;So now your question is how does lsof display the file descriptor? Answer: lsof is kernel intrusive and has access to areas that normal system calls like fstat() do not. Moreover, file descriptors are not transportable across processes except in special cases (e.g parent/child). For example, file descriptor 6 in processA might be associated with "myfile" while file descriptor 6 in processB might be associated with "yourfile".&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Thu, 13 Oct 2005 10:53:10 GMT</pubDate>
    <dc:creator>A. Clay Stephenson</dc:creator>
    <dc:date>2005-10-13T10:53:10Z</dc:date>
    <item>
      <title>determining filename of unlinked open file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/determining-filename-of-unlinked-open-file/m-p/4933380#M803206</link>
      <description>Hello, &lt;BR /&gt;&lt;BR /&gt;I am attempting to determine the full pathname of an unlinked open file.  The file is detectable by lsof. I have used "lsof +aL1 /filesystem-name" to display information about my file.&lt;BR /&gt;&lt;BR /&gt;Here is a sanitized version of my lsof output:&lt;BR /&gt;COMMAND   PID USER   FD   TYPE     DEVICE  SIZE/OFF NLINK NODE NAME&lt;BR /&gt;processname 4380 root  197u   REG 64,0x40001 255016960     0 2706 /filesystem-name (/dev/vg4/lvol01)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I would prefer to not re-invent the wheel. I am looking for the full pathname of the open file. I have begun to write a C program that will tell me all the information available about the open file with the fstat command. I have chosen the fstat because I have the file descriptor name available to me. (197)&lt;BR /&gt;&lt;BR /&gt;Well, this is not working. I am receiving an errno of 9. (EBADF - Bad file number)  This is telling me that I must not have access to it any longer since the controlling process must be the only one able to access the open file.  I am puzzled that I am unable to get more information, when lsof was able to determine the existence of it, and report the FD number to me.&lt;BR /&gt;&lt;BR /&gt;Does anyone have any insight for me?&lt;BR /&gt;&lt;BR /&gt;my uname -a:&lt;BR /&gt;&lt;BR /&gt;HP-UX hostname B.11.11 U 9000/800 4254029963 unlimited-user license&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 13 Oct 2005 10:05:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/determining-filename-of-unlinked-open-file/m-p/4933380#M803206</guid>
      <dc:creator>Kevin Shortt</dc:creator>
      <dc:date>2005-10-13T10:05:06Z</dc:date>
    </item>
    <item>
      <title>Re: determining filename of unlinked open file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/determining-filename-of-unlinked-open-file/m-p/4933381#M803207</link>
      <description>If this is an unlinked file, it has no path. Unlinked means that the directory tree does not have an entry pointing to the inode.&lt;BR /&gt; &lt;BR /&gt;If it did, then you could do a-&lt;BR /&gt;find /filesystemname -inum 2706 -print&lt;BR /&gt; &lt;BR /&gt;to find the path.&lt;BR /&gt; &lt;BR /&gt;Rod Hills</description>
      <pubDate>Thu, 13 Oct 2005 10:39:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/determining-filename-of-unlinked-open-file/m-p/4933381#M803207</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2005-10-13T10:39:34Z</dc:date>
    </item>
    <item>
      <title>Re: determining filename of unlinked open file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/determining-filename-of-unlinked-open-file/m-p/4933382#M803208</link>
      <description>By definition, an unlinked file (i.e. the link count has been reduced to zero) does not have a pathname associated with it so your question really has no meaning. The directory entry has already been removed and&lt;BR /&gt;the system is waiting for all processes which had the file open to either close() the file or terminate. When that condition is satisfied the space is actually freed within the filesystem. &lt;BR /&gt;&lt;BR /&gt;So now your question is how does lsof display the file descriptor? Answer: lsof is kernel intrusive and has access to areas that normal system calls like fstat() do not. Moreover, file descriptors are not transportable across processes except in special cases (e.g parent/child). For example, file descriptor 6 in processA might be associated with "myfile" while file descriptor 6 in processB might be associated with "yourfile".&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 13 Oct 2005 10:53:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/determining-filename-of-unlinked-open-file/m-p/4933382#M803208</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-10-13T10:53:10Z</dc:date>
    </item>
    <item>
      <title>Re: determining filename of unlinked open file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/determining-filename-of-unlinked-open-file/m-p/4933383#M803209</link>
      <description>&lt;BR /&gt;Ahh..I see. &lt;BR /&gt;&lt;BR /&gt;This is because the link between the directory and the inode is removed when the file is unlinked. (yes?)&lt;BR /&gt;&lt;BR /&gt;So does that mean once the file has been unlinked there is no trace of actually where the file was created originally?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks for your replies.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 13 Oct 2005 10:58:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/determining-filename-of-unlinked-open-file/m-p/4933383#M803209</guid>
      <dc:creator>Kevin Shortt</dc:creator>
      <dc:date>2005-10-13T10:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: determining filename of unlinked open file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/determining-filename-of-unlinked-open-file/m-p/4933384#M803210</link>
      <description>Yes, you have the essence of it. Man 2 unlink explains the process quite well.&lt;BR /&gt;&lt;BR /&gt;One of the standard UNIX idioms is something like this:&lt;BR /&gt;&lt;BR /&gt;fdes = open("xxx/yyy/mytempfile",O_RDWR | O_CREAT,0600)&lt;BR /&gt;(void) unlink("xxx/yyy/mytempfile");&lt;BR /&gt;...&lt;BR /&gt;...&lt;BR /&gt;...&lt;BR /&gt;close(fdes);&lt;BR /&gt;&lt;BR /&gt;The idea is that a file is created and opened and then immediately unlinked. This process (and perhaps its child processes) have complete access to this otherwise invisible file until all the processes close the fdes or terminate. This is essentially what the tmpfile() function does.&lt;BR /&gt;</description>
      <pubDate>Thu, 13 Oct 2005 11:06:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/determining-filename-of-unlinked-open-file/m-p/4933384#M803210</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-10-13T11:06:48Z</dc:date>
    </item>
    <item>
      <title>Re: determining filename of unlinked open file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/determining-filename-of-unlinked-open-file/m-p/4933385#M803211</link>
      <description>&lt;BR /&gt;Thanks to both responders. You have helped me understand unlinked files and sequence of events around them. &lt;BR /&gt;&lt;BR /&gt;Thank you.</description>
      <pubDate>Thu, 13 Oct 2005 11:32:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/determining-filename-of-unlinked-open-file/m-p/4933385#M803211</guid>
      <dc:creator>Kevin Shortt</dc:creator>
      <dc:date>2005-10-13T11:32:58Z</dc:date>
    </item>
  </channel>
</rss>

