How do open files act on linux systems?

I simply relabelled a log documents to "foo.log.old", and also thought that the application will certainly start creating a new logfile at "foo.log". I was stunned to uncover that it tracked the logfile to its new name, and also maintained adding lines to "foo.log.old".

In Windows, I'm not accustomed to this sort of actions - I do not recognize if it is also feasible to implement it. Just how specifically is this actions applied in linux? Where can I discover more concerning it?

0
2019-05-18 23:22:41
Source Share
Answers: 2

To actually see just how this actions is applied you can consider some Unix shows publications. Mathepic is appropriate because it relates to an inode. The real pathname is just made use of to open the documents, as soon as that is done the program referrals it by its opened up documents descriptor. The documents descriptor subsequently referrals the inode, which in this instance does not care if the underlying files name has actually transformed.

Regarding applying this in Windows, that is an inquiry for an additional website.

To find out more concerning this without striking guides simply look around for linux filesystems and also inodes. There could not be a clear solution, yet you'll have the ability to recognize why.

0
2019-05-21 08:21:25
Source

Programs connect to files via a number kept by the filesystem (called an inode on typical unix filesystems), to which the name is simply a reference (and also perhaps not an one-of-a-kind reference at that).

So numerous points to be knowledgeable about:

  1. Moving a documents making use of mv does not transform that underling number unless you relocate throughout filesystems (which amounts making use of cp after that rm on the initial).
  2. Due to the fact that greater than one name can connect to a file (i.e. we have tough web links), the information in "removed" files does not vanish till all referrals to the servant documents vanish.
  3. Probably crucial: when a program opens a documents it makes a reference to it that is (for the objectives of when the information will certainly be removed) equal to a having a documents name attached to it.

This generates numerous actions like:

  • A program can open an apply for analysis, yet not in fact read it till after the customer as rmed it at the command line, and also the program will certainly still have accessibility to the information .
  • The one you ran into: mving a documents does not disconnect the partnership in between the documents and also any kind of programs that have it open (unless you cross filesystem borders, in which instance the program still have a variation of the initial to work with).
  • If a program has actually opened an apply for creating, and also the customer rms it is last filename at the command line, the program can maintain exactly on placing things right into the documents, yet as quickly as it shuts there will certainly disappear reference to that information and also it will certainly vanish.
  • 2 programs that connect via several files can get a crude, partial security by getting rid of the documents (s) after they are ended up opening. (This is not real security mind, it simply changes an open opening right into a race problem.)
0
2019-05-21 08:17:35
Source