Skip to content
Snippets Groups Projects
  1. Oct 16, 2017
  2. Oct 11, 2017
    • Colin Walters's avatar
      fdio: Avoid ?: syntax for fstatat_allow_noent() · e627524a
      Colin Walters authored
      `g-ir-scanner` is unaware of this GNUC extension and complains.
      Saw that while building ostree.
      
      While we're here, fix up a few other things:
      
       - Tell the compiler the stat buffer is unused (I didn't see
         a warning, just doing this on general principle)
       - Return from `glnx_throw_errno_prefix()` directly; we do
         preserve errno there, let's feel free to rely on it.
      e627524a
    • Jonathan Lebon's avatar
      tests: drop unused variable · b923a950
      Jonathan Lebon authored
      b923a950
  3. Oct 06, 2017
    • Jonathan Lebon's avatar
      fdio: allow NULL for fstatat_allow_noent stbuf · 5362f6bc
      Jonathan Lebon authored
      Often, the caller doesn't actually care about the details of the stat
      struct itself, but just whether the entry exists or not. It does work
      to just pass `NULL` directly to glibc in a quick test, but given that
      the argument is tagged as `__nonnull` and that the documentation does
      not explicitly specify this is supported, let's do this safely.
      5362f6bc
    • Colin Walters's avatar
      Add glnx_fd_close() and glnx_autofd · 97cd6a6c
      Colin Walters authored
      I'd like to have the checks for `EBADF` as well as the
      "assign to -1" in more places.  The cleanup function we
      had for `glnx_fd_close` is actually what we want.
      
      Let's rename the cleanup macro to `glnx_autofd` to better match
      other autocleanups like `g_autofree`.
      
      Then we can use `glnx_fd_close()` as a replacement for plain Unix `close()`. I
      left the `glnx_close_fd` macro, but it's obviously confusing now with the
      former. We'll eventually remove it.
      97cd6a6c
  4. Oct 05, 2017
  5. Oct 02, 2017
  6. Oct 01, 2017
    • Colin Walters's avatar
      missing: Sync from latest systemd, add memfd_create() · dd5fd9c1
      Colin Walters authored
      Planning to use memfd_create() in flatpak and rpm-ostree, which both use
      bubblewrap, and want to pass read-only data via file descriptor to the
      container. Passing via `O_TMPFILE` requires `O_RDWR` (read and write),
      and passing via a pipe would require buffering.
      
      The systemd `missing.h` has grown enormously; I only cherry-picked the bits for
      memfd.
      dd5fd9c1
  7. Sep 26, 2017
  8. Sep 25, 2017
  9. Sep 21, 2017
  10. Sep 17, 2017
  11. Sep 13, 2017
    • Colin Walters's avatar
      tests: Add macro for auto-error checking · c2bcca04
      Colin Walters authored
      Having our tests forced into a `goto out` style is seriously annoying
      since we can't write tests like we write production code.  Add
      a macro that checks for the error being NULL.
      
      This doesn't fully solve the problem since the test functions are
      still forced into `void` returns; at some point I may extend
      GLib to have `g_test_add_err_func()`.
      c2bcca04
    • Colin Walters's avatar
      tree-wide: Use our own syscall wrappers or error prefixing · 667d8aa7
      Colin Walters authored
      Followup to similar commits in the ostree stack recently.
      667d8aa7
    • Colin Walters's avatar
      dirfd: Extend tmpdir API to support optional cleaning · 0428fd87
      Colin Walters authored
      We have a use case in libostree's staging dirs where we try to reuse
      them across multiple ostree txns, but we want the fd-relative bits
      here.
      
      Extend the tmpdir API to make deletion optional. While here, also extend the API
      to support checking for errors when deleting for projects like libostree that
      want to do so consistently.
      
      Also while here, add a change to set the fd to `-1` after clearing to be extra
      defensive.
      0428fd87
  12. Sep 12, 2017
    • Colin Walters's avatar
    • Colin Walters's avatar
      fdio: Use O_TMPFILE + rename-overwrite for regfile copies · 673f48f6
      Colin Walters authored
      I was working on rpm-ostree unified core, and hit the fact that
      `glnx_file_copy_at()` had the same bug with `fsetxattr()` and files whose mode
      is <= `0400` (e.g. `000` in the case of `/etc/shadow`) that libostree did a
      while ago.  Basically, Linux currently allows `write()` on non-writable open files
      but not `fsetxattr()`.  This situation is masked for privileged (i.e.
      `CAP_DAC_OVERRIDE`) code.
      
      Looking at this, I think it's cleaner to convert to `O_TMPFILE` here,
      since that code already handles setting the tmpfile to mode `0600`.  Now,
      this *is* a behavior change in the corner case of existing files which
      are symbolic links.  Previously we'd do an `open(O_TRUNC)` which would follow
      the link.
      
      But in the big picture, I think the use cases for `open(O_TRUNC)` are really
      rare - I audited all callers of this in ostree/rpm-ostree/flatpak, and all of
      them will be fine with this behavior change. For example, the ostree `/etc`
      merge code already explicitly unlinks the target beforehand. Other cases like
      supporting `repo/pubring.gpg` in an ostree repo being a symlink...eh, just no.
      
      Making this change allows us to convert to new style, and brings all of the
      general benefits of using `O_TMPFILE` too.
      673f48f6
    • Colin Walters's avatar
      fdio: Support taking ownership of tmpfile fd · 9d995a36
      Colin Walters authored
      While reading a strace I noticed a double close in the tests; this was because
      we were missing an assignment to `-1` in the tests. However, let's make
      supporting this clearer by explicitly supporting the fd being `-1` while still
      setting the `initialized` variable to `FALSE`. We also add the `EBADF` assertion
      checking.
      9d995a36
    • Colin Walters's avatar
      fdio: Use O_EXCL for anonymous tmpfiles · 806bb46e
      Colin Walters authored
      I noticed while reading the manpage for `linkat()` that `O_TMPFILE`
      supports `O_EXCL` to mean exactly what we're doing with the anonymous
      tmpfile API.
      
      Change the code to start using it; this required refactoring the internals since
      we had a check to be sure the caller wasn't passing `O_EXCL` for the
      non-anonymous path which we want to keep.
      
      Presumably the storage system could do smarter things if it knows a file will
      always be anonymous, e.g. it doesn't need to journal its data.
      806bb46e
  13. Sep 07, 2017
    • Colin Walters's avatar
      fdio: Add glnx_fstatat_allow_noent() · 627d4e2f
      Colin Walters authored
      This is a very common pattern in both ostree/rpm-ostree. Make a better API for
      this. I thought a lot about simply zeroing out `struct stat` but that feels
      dangerous; none of the values have seem obviously `cannot be zero`.
      627d4e2f
  14. Aug 25, 2017
  15. Aug 18, 2017
    • Colin Walters's avatar
      dirfd: New tmpdir API · 7100ebbc
      Colin Walters authored
      Basically all of the ostree/rpm-ostree callers want to both create and open, so
      let's merge `glnx_mkdtempat()` and `glnx_mkdtempat_open()`.
      
      Second, all of them want to do `glnx_shutil_rm_rf_at()` on cleanup, so we do the
      same thing we did with `GLnxTmpfile` and create `GLnxTmpDir` that has a cleanup
      attribute.
      
      The cleanup this results in for rpm-ostree is pretty substantial.
      7100ebbc
  16. Aug 15, 2017
  17. Aug 09, 2017
    • Colin Walters's avatar
      fdio: Merge systemd code to use copy_file_range(), use FICLONE · d18f026e
      Colin Walters authored
      FICLONE is the new alias for the formerly btrfs-specific ioctl; XFS
      has experimental patches to support it.
      
      Further, we should use copy_file_range() for the case where we're only doing a
      limited copy. Both NFS and XFS (with reflink enabled) understand it.
      
      Part of the reason I'm doing this is so that ostree's `/etc` merge will start
      using XFS reflinks. But another major reason is to take the next step after and
      copy this code into GLib as well, so that all of the general GLib users will
      benefit; e.g. Nautilus will transparently do server copy offloads with NFS home
      directories.
      
      See also this coreutils thread about `copy_file_range()`:
      <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=24399>. I don't care about file
      holes for our use cases, so it's fine.
      
      Other changes while I'm here:
       - Tweak the sendfile() case to match the newly inlined logic for cfr
       - Add a TEMP_FAILURE_RETRY() around the read()
      d18f026e
  18. Aug 02, 2017
  19. Jul 31, 2017
  20. Jul 26, 2017
  21. Jul 24, 2017
  22. Jul 21, 2017
    • Jonathan Lebon's avatar
      errors: check for an error before prefixing · c820571b
      Jonathan Lebon authored
      Minor tweak to the new `GLNX_AUTO_PREFIX_ERROR`. Since the common case
      is that there's no errors, let's bring down the same check that
      `g_prefix_error` does to avoid a function call most of the time.
      c820571b
  23. Jul 20, 2017
  24. Jul 19, 2017
  25. Jul 17, 2017
    • Colin Walters's avatar
      errors: Add GLNX_AUTO_PREFIX_ERROR · 607f1775
      Colin Walters authored
      In a lot of places in ostree, we end up prefixing errors in the *caller*.
      Often we only have 1-2 callers, and doing the error prefixing isn't
      too duplicative.  But there are definitely cases where it's cleaner
      to do the prefixing in the callee.  We have functions that aren't
      ported to new style for this reason (they still do the prefixing
      in `out:`).
      
      Introduce a cleanup-oriented version of error prefixing so we can port those
      functions too.
      607f1775
    • Colin Walters's avatar
      fdio: Add string prefix for glnx_fstat() · 61ef326a
      Colin Walters authored
      For consistency.
      61ef326a
Loading