Linux File System, Process and Open File Table [closed]












0














I'm a little bit confused about process and open file tables.



I know that if 2 processes try to open the same file, there will be 2 entries in the open file table. I am trying to find out the reason for this.



Why there are 2 entries created in the open file table when 2 different processes try to reach the same file? Why it can't be done with 1 entry?










share|improve this question















closed as primarily opinion-based by shellter, Pearly Spencer, Michael Dodd, E_net4 wishes happy holidays, Paul Roub Nov 12 at 15:48


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.




















    0














    I'm a little bit confused about process and open file tables.



    I know that if 2 processes try to open the same file, there will be 2 entries in the open file table. I am trying to find out the reason for this.



    Why there are 2 entries created in the open file table when 2 different processes try to reach the same file? Why it can't be done with 1 entry?










    share|improve this question















    closed as primarily opinion-based by shellter, Pearly Spencer, Michael Dodd, E_net4 wishes happy holidays, Paul Roub Nov 12 at 15:48


    Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.


















      0












      0








      0







      I'm a little bit confused about process and open file tables.



      I know that if 2 processes try to open the same file, there will be 2 entries in the open file table. I am trying to find out the reason for this.



      Why there are 2 entries created in the open file table when 2 different processes try to reach the same file? Why it can't be done with 1 entry?










      share|improve this question















      I'm a little bit confused about process and open file tables.



      I know that if 2 processes try to open the same file, there will be 2 entries in the open file table. I am trying to find out the reason for this.



      Why there are 2 entries created in the open file table when 2 different processes try to reach the same file? Why it can't be done with 1 entry?







      unix process filesystems kernel






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 12 at 13:14

























      asked Nov 12 at 8:33









      G.Baysec

      43




      43




      closed as primarily opinion-based by shellter, Pearly Spencer, Michael Dodd, E_net4 wishes happy holidays, Paul Roub Nov 12 at 15:48


      Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.






      closed as primarily opinion-based by shellter, Pearly Spencer, Michael Dodd, E_net4 wishes happy holidays, Paul Roub Nov 12 at 15:48


      Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.


























          1 Answer
          1






          active

          oldest

          votes


















          1














          I'm not quite clear what you mean by "file tables". There are no common structures in the Linux kernel referred to as "file tables".



          There is /etc/fstab, which stands for "filesystem table", which lists filesystems which are automatically mounted when the system is booted.



          The "filetable" Stack Overflow tag that you included in this question is for SQL Server and not directly connected with Linux.



          What it sounds like you are referring to when you talk about open files is links. See Hard and soft link mechanism. When a file is open in Linux, the kernel maintains what is basically another hard link to the file. That is why you can actually delete a file that is open and the system will continue running normally. Only when the application closes the file will the space on the disk actually be marked as free.



          So for each inode on a filesystem (an inode is generally what we think of as a file), there are often multiple links--one for each entry in a directory, and one for each time an application opens the file.



          Update: Here is a quote from the web page that inspired this question:




          Each file table entry contains information about the current file. Foremost, is the status of the file, such as the file read or write status and other status information. Additionally, the file table entry maintains an offset which describes how many bytes have been read from (or written to) the file indicating where to read/write from next.




          So, to directly answer the question, "Why there are 2 entries created in the open file table when 2 different processes try to reach the same file?", 2 entries are required because they may contain different information. One process may open the file read-only while the other read-write. And the file offset (position within the file) for each process will almost certainly be different.






          share|improve this answer























          • I mean" open file table" with "file tables" . I have done some research from "usna.edu/Users/cs/wcbrown/courses/IC221/classes/L09/Class.html" and "usna.edu/Users/cs/aviv/classes/ic221/s16/lec/21/lec.html". In these posts and as well as others, it says if 2 process try to open a file, than there will be 2 entries in the open file tables. Im asking the reason of that
            – G.Baysec
            Nov 12 at 10:30












          • @G.Baysec Thanks for the links; I have updated my answer.
            – bitinerant
            Nov 12 at 12:33










          • Thanks for answer @bitinerant.
            – G.Baysec
            Nov 12 at 13:05












          • @G.Baysec - you are welcome. If it answers your question, could you mark it as the accepted answer in Stack Overflow?
            – bitinerant
            Nov 12 at 15:14


















          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          I'm not quite clear what you mean by "file tables". There are no common structures in the Linux kernel referred to as "file tables".



          There is /etc/fstab, which stands for "filesystem table", which lists filesystems which are automatically mounted when the system is booted.



          The "filetable" Stack Overflow tag that you included in this question is for SQL Server and not directly connected with Linux.



          What it sounds like you are referring to when you talk about open files is links. See Hard and soft link mechanism. When a file is open in Linux, the kernel maintains what is basically another hard link to the file. That is why you can actually delete a file that is open and the system will continue running normally. Only when the application closes the file will the space on the disk actually be marked as free.



          So for each inode on a filesystem (an inode is generally what we think of as a file), there are often multiple links--one for each entry in a directory, and one for each time an application opens the file.



          Update: Here is a quote from the web page that inspired this question:




          Each file table entry contains information about the current file. Foremost, is the status of the file, such as the file read or write status and other status information. Additionally, the file table entry maintains an offset which describes how many bytes have been read from (or written to) the file indicating where to read/write from next.




          So, to directly answer the question, "Why there are 2 entries created in the open file table when 2 different processes try to reach the same file?", 2 entries are required because they may contain different information. One process may open the file read-only while the other read-write. And the file offset (position within the file) for each process will almost certainly be different.






          share|improve this answer























          • I mean" open file table" with "file tables" . I have done some research from "usna.edu/Users/cs/wcbrown/courses/IC221/classes/L09/Class.html" and "usna.edu/Users/cs/aviv/classes/ic221/s16/lec/21/lec.html". In these posts and as well as others, it says if 2 process try to open a file, than there will be 2 entries in the open file tables. Im asking the reason of that
            – G.Baysec
            Nov 12 at 10:30












          • @G.Baysec Thanks for the links; I have updated my answer.
            – bitinerant
            Nov 12 at 12:33










          • Thanks for answer @bitinerant.
            – G.Baysec
            Nov 12 at 13:05












          • @G.Baysec - you are welcome. If it answers your question, could you mark it as the accepted answer in Stack Overflow?
            – bitinerant
            Nov 12 at 15:14
















          1














          I'm not quite clear what you mean by "file tables". There are no common structures in the Linux kernel referred to as "file tables".



          There is /etc/fstab, which stands for "filesystem table", which lists filesystems which are automatically mounted when the system is booted.



          The "filetable" Stack Overflow tag that you included in this question is for SQL Server and not directly connected with Linux.



          What it sounds like you are referring to when you talk about open files is links. See Hard and soft link mechanism. When a file is open in Linux, the kernel maintains what is basically another hard link to the file. That is why you can actually delete a file that is open and the system will continue running normally. Only when the application closes the file will the space on the disk actually be marked as free.



          So for each inode on a filesystem (an inode is generally what we think of as a file), there are often multiple links--one for each entry in a directory, and one for each time an application opens the file.



          Update: Here is a quote from the web page that inspired this question:




          Each file table entry contains information about the current file. Foremost, is the status of the file, such as the file read or write status and other status information. Additionally, the file table entry maintains an offset which describes how many bytes have been read from (or written to) the file indicating where to read/write from next.




          So, to directly answer the question, "Why there are 2 entries created in the open file table when 2 different processes try to reach the same file?", 2 entries are required because they may contain different information. One process may open the file read-only while the other read-write. And the file offset (position within the file) for each process will almost certainly be different.






          share|improve this answer























          • I mean" open file table" with "file tables" . I have done some research from "usna.edu/Users/cs/wcbrown/courses/IC221/classes/L09/Class.html" and "usna.edu/Users/cs/aviv/classes/ic221/s16/lec/21/lec.html". In these posts and as well as others, it says if 2 process try to open a file, than there will be 2 entries in the open file tables. Im asking the reason of that
            – G.Baysec
            Nov 12 at 10:30












          • @G.Baysec Thanks for the links; I have updated my answer.
            – bitinerant
            Nov 12 at 12:33










          • Thanks for answer @bitinerant.
            – G.Baysec
            Nov 12 at 13:05












          • @G.Baysec - you are welcome. If it answers your question, could you mark it as the accepted answer in Stack Overflow?
            – bitinerant
            Nov 12 at 15:14














          1












          1








          1






          I'm not quite clear what you mean by "file tables". There are no common structures in the Linux kernel referred to as "file tables".



          There is /etc/fstab, which stands for "filesystem table", which lists filesystems which are automatically mounted when the system is booted.



          The "filetable" Stack Overflow tag that you included in this question is for SQL Server and not directly connected with Linux.



          What it sounds like you are referring to when you talk about open files is links. See Hard and soft link mechanism. When a file is open in Linux, the kernel maintains what is basically another hard link to the file. That is why you can actually delete a file that is open and the system will continue running normally. Only when the application closes the file will the space on the disk actually be marked as free.



          So for each inode on a filesystem (an inode is generally what we think of as a file), there are often multiple links--one for each entry in a directory, and one for each time an application opens the file.



          Update: Here is a quote from the web page that inspired this question:




          Each file table entry contains information about the current file. Foremost, is the status of the file, such as the file read or write status and other status information. Additionally, the file table entry maintains an offset which describes how many bytes have been read from (or written to) the file indicating where to read/write from next.




          So, to directly answer the question, "Why there are 2 entries created in the open file table when 2 different processes try to reach the same file?", 2 entries are required because they may contain different information. One process may open the file read-only while the other read-write. And the file offset (position within the file) for each process will almost certainly be different.






          share|improve this answer














          I'm not quite clear what you mean by "file tables". There are no common structures in the Linux kernel referred to as "file tables".



          There is /etc/fstab, which stands for "filesystem table", which lists filesystems which are automatically mounted when the system is booted.



          The "filetable" Stack Overflow tag that you included in this question is for SQL Server and not directly connected with Linux.



          What it sounds like you are referring to when you talk about open files is links. See Hard and soft link mechanism. When a file is open in Linux, the kernel maintains what is basically another hard link to the file. That is why you can actually delete a file that is open and the system will continue running normally. Only when the application closes the file will the space on the disk actually be marked as free.



          So for each inode on a filesystem (an inode is generally what we think of as a file), there are often multiple links--one for each entry in a directory, and one for each time an application opens the file.



          Update: Here is a quote from the web page that inspired this question:




          Each file table entry contains information about the current file. Foremost, is the status of the file, such as the file read or write status and other status information. Additionally, the file table entry maintains an offset which describes how many bytes have been read from (or written to) the file indicating where to read/write from next.




          So, to directly answer the question, "Why there are 2 entries created in the open file table when 2 different processes try to reach the same file?", 2 entries are required because they may contain different information. One process may open the file read-only while the other read-write. And the file offset (position within the file) for each process will almost certainly be different.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 12 at 12:32

























          answered Nov 12 at 9:13









          bitinerant

          564




          564












          • I mean" open file table" with "file tables" . I have done some research from "usna.edu/Users/cs/wcbrown/courses/IC221/classes/L09/Class.html" and "usna.edu/Users/cs/aviv/classes/ic221/s16/lec/21/lec.html". In these posts and as well as others, it says if 2 process try to open a file, than there will be 2 entries in the open file tables. Im asking the reason of that
            – G.Baysec
            Nov 12 at 10:30












          • @G.Baysec Thanks for the links; I have updated my answer.
            – bitinerant
            Nov 12 at 12:33










          • Thanks for answer @bitinerant.
            – G.Baysec
            Nov 12 at 13:05












          • @G.Baysec - you are welcome. If it answers your question, could you mark it as the accepted answer in Stack Overflow?
            – bitinerant
            Nov 12 at 15:14


















          • I mean" open file table" with "file tables" . I have done some research from "usna.edu/Users/cs/wcbrown/courses/IC221/classes/L09/Class.html" and "usna.edu/Users/cs/aviv/classes/ic221/s16/lec/21/lec.html". In these posts and as well as others, it says if 2 process try to open a file, than there will be 2 entries in the open file tables. Im asking the reason of that
            – G.Baysec
            Nov 12 at 10:30












          • @G.Baysec Thanks for the links; I have updated my answer.
            – bitinerant
            Nov 12 at 12:33










          • Thanks for answer @bitinerant.
            – G.Baysec
            Nov 12 at 13:05












          • @G.Baysec - you are welcome. If it answers your question, could you mark it as the accepted answer in Stack Overflow?
            – bitinerant
            Nov 12 at 15:14
















          I mean" open file table" with "file tables" . I have done some research from "usna.edu/Users/cs/wcbrown/courses/IC221/classes/L09/Class.html" and "usna.edu/Users/cs/aviv/classes/ic221/s16/lec/21/lec.html". In these posts and as well as others, it says if 2 process try to open a file, than there will be 2 entries in the open file tables. Im asking the reason of that
          – G.Baysec
          Nov 12 at 10:30






          I mean" open file table" with "file tables" . I have done some research from "usna.edu/Users/cs/wcbrown/courses/IC221/classes/L09/Class.html" and "usna.edu/Users/cs/aviv/classes/ic221/s16/lec/21/lec.html". In these posts and as well as others, it says if 2 process try to open a file, than there will be 2 entries in the open file tables. Im asking the reason of that
          – G.Baysec
          Nov 12 at 10:30














          @G.Baysec Thanks for the links; I have updated my answer.
          – bitinerant
          Nov 12 at 12:33




          @G.Baysec Thanks for the links; I have updated my answer.
          – bitinerant
          Nov 12 at 12:33












          Thanks for answer @bitinerant.
          – G.Baysec
          Nov 12 at 13:05






          Thanks for answer @bitinerant.
          – G.Baysec
          Nov 12 at 13:05














          @G.Baysec - you are welcome. If it answers your question, could you mark it as the accepted answer in Stack Overflow?
          – bitinerant
          Nov 12 at 15:14




          @G.Baysec - you are welcome. If it answers your question, could you mark it as the accepted answer in Stack Overflow?
          – bitinerant
          Nov 12 at 15:14



          Popular posts from this blog

          Florida Star v. B. J. F.

          Error while running script in elastic search , gateway timeout

          Adding quotations to stringified JSON object values