Re:Japan HP accidentally deleted 77TB data in Kyoto U. super...
by pjmlp on Thursday December 30, 2021 @09:45AM
(#29737087)
Files in use can be shadow updated and then will be actually replaced when possible.
Naturally no one reads MSDN docs.
Also to note that other non-UNIX clones follow similar approach to file locking.
Re:Japan HP accidentally deleted 77TB data in Kyoto U. super...
by justsomehnguy on Friday December 31, 2021 @06:00AM
(#29746838)
>and rename tricks don't work because locks apply to files, not inodes
My experience is opposite, you can rename a locked file and place a new file with the name of the former one.
Depends on the lock type, I suppose.
Re:Japan HP accidentally deleted 77TB data in Kyoto U. super...
by formerly_proven on Thursday December 30, 2021 @10:53AM
(#29737711)
On Unix/Linux you can't update a file mmaped for execution either - text files are busy.
Re:Japan HP accidentally deleted 77TB data in Kyoto U. super...
by toast0 on Thursday December 30, 2021 @03:41PM
(#29741193)
I've updated .so files on FreeBSD while they're running. They weren't busy and a program which had it mmaped to run promptly crashed (my update wasn't intended to be hot loaded and wasn't crafted to be safe, although, it could have been if I knew it was possible). And now I won't forget why I should use install instead of cp (install unlinks before writing, by default, cp opens and overwrites the existing file)
That's the route chosen by Windows for binary executables (exe/dll) and various other systems. Locking a file against writes, delete/rename or even read is just another flag in the windows equivalent of fopen [1]. This makes for software that's quite easy to reason about, but hard to update. The reason why you have to restart Windows to install Windows updates or even install some software is largely due to this locking mechanism: you can't update files that are open (and rename tricks don't work because locks apply to files, not inodes).
With about three decades of hindsight I'm not sure if it's a good tradeoff. It makes it easy to prevent the race conditions that are an endless source of security bugs on unix-like systems; but otoh most software doesn't use the mechanism because it's not in the lowest-common-denominator File APIs of most programming languages; and MS is paying for it with users refusing to install updates because they don't want to restart their PC.
1: Search for FILE_SHARE_DELETE in https://docs.microsoft.com/en-us/windows/win32/api/fileapi/n...