[mythtv-users] INSERT INTO recordedmarkup fails w/duplicate; recording status changes [Workaround]

Jan Ceuleers jan.ceuleers at gmail.com
Sun Apr 16 10:10:53 UTC 2023


On 16/04/2023 04:47, Stephen Worthington wrote:
> Linux allows you to update a running file.  I think it does that by
> pushing all the code in the running file into RAM and then (if
> necessary) out into swap space before it overwrites the old file.

No, this is done by making use of Posix-standardised filesystem features
in the mv and rm commands (and syscalls):

First the package manager writes the new file, giving it a temporary
filename. It has to take care to create the new file within the same
filesystem as the one hosting the file that is about to be replaced.

Then the old file is renamed (by the package manager) using the mv
command. When the destination of the mv command is situated on the same
filesystem the command only modifies the directory entry; the file data
itself remains untouched. The package manager then uses the mv command
to rename the new file from its initial temporary filename to the target
filename. Again, this only involves updating the directory entry.

Finally the package manager deletes the old file using rm. But the rm
command merely unlinks the file's data from the directory entry:
existing users of that data continue having access to it because they
don't need the directory entry to continue using the file. For example,
if the file in question is an executable file then the kernel will have
memory-mapped the file (using the mmap system call), as a side-effect of
which the filesystem knows not yet to recycle the disk space the file
occupies.

> So
> as long as the program using that file keeps running, it keeps using
> the older version.

Correct.

HTH, Jan



More information about the mythtv-users mailing list