Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 05 Nov 2020 02:04:53 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 250872] objcopy (elfcopy, elftoolchain) in-place operation emits output to wrong filesystem
Message-ID:  <bug-250872-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D250872

            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@FreeBSD.org
          Reporter: cem@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 destinati=
on
file, dst =3D=3D 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, th=
ey
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.=20
create_file() passes src in 'dst =3D=3D NULL' case near top of function, and
possibly for other consumers in the same file if they are potentially the f=
inal
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.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-250872-227>