Skip to content
Snippets Groups Projects
  1. Oct 25, 2016
    • Colin Walters's avatar
      fdio: Make GLnxFileCopyFlags actually flags · 7d2f577d
      Colin Walters authored
      I wanted to add a new one, and realized it was wrong.  Luckily,
      I think we were safe until now, since the set of bits for `(0, 1, 2)`
      is actually distinct.
      
      Although, hm, callers specifying `GLNX_FILE_COPY_OVERWRITE` may
      have not actually been getting that.
      7d2f577d
  2. Jul 01, 2016
    • Colin Walters's avatar
      fdio: Add open_tmpfile_linkable() and link_tmpfile_at() · 113c770d
      Colin Walters authored
      We had a bug previously where we failed to clean up a temporary file
      in an error path.  This is a classic case where the new `O_TMPFILE`
      API in Linux is nicer.
      
      To implement this, as usual we start with some original bits from
      systemd.  But in this case I ended up having to heavily modify it
      because systemd doesn't support "link into place and overwrite".  They
      don't actually use their tempfile code much at all in fact - as far as
      I can tell, just in the coredump code.
      
      Whereas in many apps, ostree included, a very common use case is
      atomically updating an existing file, which is
      `glnx_file_replace_contents_at()`, including subtleties like doing an
      `fdatasync()` if the file already existed.
      
      Implementing this then is slightly weird since we need to link() the
      file into place, then rename() after.
      
      It's still better though because if we e.g. hit `ENOSPC` halfway
      through, we'll clean up the file automatically.
      
      We still do keep the mode where we error out if the file exists.
      Finally, the ostree core though does have a more unusual case where we
      want to ignore EEXIST (allow concurrent object writers), so add
      support for that now.
      
      Note: One really confusing bug I had here was that `O_TMPFILE` ignores
      the provided mode, and this caused ostree to write refs that weren't
      world readable.
      
      Rework things so we always call `fchmod()`, but as a consequence we're
      no longer honoring umask in the default case.  I doubt anyone will
      care, and if they do we should probably fix ostree to consistently use
      a mode inherited from the repo or something.
      113c770d
  3. May 03, 2016
  4. Jan 11, 2016
    • Colin Walters's avatar
      fdio: Export loop_write · 3c470803
      Colin Walters authored
      I plan to use this in rpm-ostree.  Sad how many times this gets
      reinvented.  Should probably stick a copy in `glib-unix.h` or so.
      3c470803
  5. Apr 09, 2015
  6. Apr 07, 2015
  7. Apr 01, 2015
  8. Mar 05, 2015
    • Colin Walters's avatar
      Add glnx_basename() · 175502e5
      Colin Walters authored
      We have to wrap the glibc version to ensure we get the right version,
      otherwise depending on the variance of includes we may end up crashing
      if we get the POSIX version.
      175502e5
  9. Mar 03, 2015
    • Colin Walters's avatar
      fdio: Add glnx_file_copy_at() · 162d1f6b
      Colin Walters authored
      This will allow deleting some code from OSTree for the config file
      merging.  We're reusing some code from systemd, which a nice modern
      clean codebase, and among other things this gets us BTRFS reflinking
      (if available) again.
      162d1f6b
  10. Feb 20, 2015
    • Colin Walters's avatar
      fdio: New APIs to read/write on fds, fd-relative · 1ebfefa5
      Colin Walters authored
      We don't have this really in GLib, unfortunately.  We do want
      GCancellable, but we also want to operate on raw fds where possible.
      
      The "read a file and validate as UTF-8" is a common use case of mine,
      and this combines that with openat().
      1ebfefa5
  11. Feb 15, 2015
  12. Feb 14, 2015
Loading