[Bug 250872] objcopy (elfcopy, elftoolchain) in-place operation emits output to wrong filesystem
bugzilla-noreply at freebsd.org
bugzilla-noreply at freebsd.org
Thu Nov 5 02:04:54 UTC 2020
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=250872
Bug ID: 250872
Summary: objcopy (elfcopy, elftoolchain) in-place operation
emits output to wrong filesystem
Product: Base System
Version: CURRENT
Hardware: Any
OS: Any
Status: New
Severity: Affects Only Me
Priority: ---
Component: bin
Assignee: bugs at FreeBSD.org
Reporter: cem at freebsd.org
objcopy can fail with 'write failed: No space left on device' when working on a
file in a filesystem with tons of free space. (I.e., no explicit destination
file, dst == src.)
This is because create_tempfile() is completely ignorant of any destination
goal and writes everything to /tmp. Then, for files outside of /tmp,
copy_from_tempfile() cannot rely on rename(2) putting the output in place of
the input file and has to instead do a full read-copy-write from /tmp.
For "temporary" files which are really the work-in-progress output file, they
should be emitted to the destination directory and renamed over the top of the
destination file. I'd suggest:
1. Add an optional destination path parameter to create_tempfile.
create_file() passes src in 'dst == NULL' case near top of function, and
possibly for other consumers in the same file if they are potentially the final
output file.
2. create_tempfile constructs a path adjacent to 'src' (that doesn't exist
already) and opens it, if src is provided. Otherwise, it uses its existing
logic to construct a temporary file in /tmp.
3. The rest of the logic in create_file / copy_from_tempfile should handle this
correctly already.
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the freebsd-bugs
mailing list