Open verbosemode opened 7 years ago
Yes this is documented here.
I'm afraid there's no good solution to this problem but not use these functions and handle this yourself in these cases, using for example bos' support for temporary files and Bos.OS.File.move
.
The problem is that bos wants to guarantee you atomicity which only rename(2)
gives you. However many Linux setup have the default temporary directory on another file system which leads to EXDEV
errors when you rename(2)
.
Or maybe an atomic
optional argument could be added which defaults to true
.
Thank you very much for the clarification. Having an atomic argument sounds like a good solution, if it doesn't clutter the code too much. Since this is really just a corner case. Actually, example 2 was just made up and I would have only needed it for writing to /sys recently.
Actually, example 2 was just made up and I would have only needed it for writing to /sys recently.
Note that I guess example1 could be solved by stat
ing the file and avoid doing this on non-regular files. This could also solve the problem for writing to /dev/stdout
and /dev/stderr
.
/cc @rizo
OS.File.write functions use with_oc, which creates temporary files in the directory of the target file. This however fails if the user has just permissions to write to the file, but not for the directory itself.
Maybe this could be fixed by making the directory for the temp files configurable for these functions. But in this case special caution might be required by the user to not use a world-readable directory if the files contain sensitive information.
Here are two examples where the write functions fail.
Example 1: Writing to files in /sys on GNU/Linux
Example 2: Writing to a file in a root-owned directory in /tmp, where the user has only write permission to this single file