Skip to content
Snippets Groups Projects
  1. Nov 12, 2019
  2. Nov 11, 2019
  3. Sep 12, 2019
  4. Aug 22, 2019
  5. Aug 16, 2019
  6. Aug 15, 2019
  7. Aug 09, 2019
  8. Jun 24, 2019
  9. May 02, 2019
  10. Mar 28, 2019
  11. Oct 16, 2017
  12. Oct 11, 2017
  13. 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
  14. Sep 26, 2017
  15. Sep 25, 2017
    • Colin Walters's avatar
      fdio: Open target dirname for glnx_file_copy_at() · 5ee2f1be
      Colin Walters authored
      Particularly if `AT_FDCWD` is used, we need to open
      in the target dir, otherwise we can get `EXDEV` when trying
      to do the final link.
      
      (Theoretically we can cross a mountpoint even with fd-relative
       though this is a lot less likely)
      5ee2f1be
  16. 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
  17. Sep 12, 2017
    • 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
  18. 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
  19. Aug 25, 2017
  20. 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
  21. Jul 24, 2017
  22. Jul 19, 2017
    • Colin Walters's avatar
      fdio: Introduce glnx_openat_read() · 268ae488
      Colin Walters authored
      This is kind of long overdue. Reasons are the same as the other wrappers. I
      debated adding `O_NOFOLLOW` support but the use cases for that are pretty
      obscure, callers who want that can just use the syscall directly for now.
      268ae488
  23. 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 cleanup+flush API for FILE* · e30a773f
      Colin Walters authored
      Mostly in ostree/rpm-ostree, we work in either raw `int fd`, or
      `G{Input,Output}Stream`.  One exception is the rpm-ostree `/etc/passwd`
      handling, which uses `FILE*` since that's what glibc exposes.
      
      And in general, there are use cases for `FILE*`; the raw `GUnixOutputStream` for
      example isn't buffered, and doing so via e.g. `GBufferedOutputStream` means
      allocating *two* GObjects and even worse going through multiple vfuncs for every
      write.
      
      `FILE*` is used heavily in systemd, and provides buffering. It is a bit cheaper
      than gobjects, but has its own trap; by default every operation locks a mutex.
      For more information on that, see `unlocked_stdio(3)`. However, callers can
      avoid that by using e.g. `fwrite_unlocked`, which I plan to do for most users of
      `FILE*` that aren't writing to one of the standard streams like `stdout` etc.
      e30a773f
  24. Jul 10, 2017
  25. Jun 28, 2017
  26. Jun 26, 2017
  27. Jun 17, 2017
  28. Jun 14, 2017
    • Colin Walters's avatar
      Add G_IN_SET, patch our internal users via spatch · 9a1b77ef
      Colin Walters authored
      I originally tried to get this into GLib:
      https://bugzilla.gnome.org/show_bug.cgi?id=783751
      
      But that looks like it's going to fail due to MSVC. Let's add it here at least
      so I can start using it tomorrow and not wait for the MSVC team to catch up.
      
      I renamed `glnx-alloca.h` to `glnx-macros.h` as a more natural collective
      home for things from systemd's `macro.h`.
      
      Finally, I used a Coccinelle spatch similar to the one referenced
      in the above BZ to patch our uses.
      9a1b77ef
  29. May 11, 2017
  30. Apr 21, 2017
  31. Mar 24, 2017
  32. Mar 23, 2017
    • Jonathan Lebon's avatar
      glnx-errors.h: add glnx_null_throw[_*] variants · 0c52d85e
      Jonathan Lebon authored
      These are equivalent to the non-null throw, except that the returned
      value is a NULL pointer. They can be used in functions where one wants
      to return a pointer. E.g.:
      
      	GKeyFile *foo(GError **error) {
      		return glnx_null_throw (error, "foobar");
      	}
      
      The function call redirections are wrapped around a compound statement
      expression[1] so that they represent a single top-level expression. This
      allows us to avoid -Wunused-value warnings vs using a comma operator if
      the return value isn't used.
      
      I made the 'args...' absorb the fmt argument as well so that callers can
      still use it without always having to specify at least one additional
      variadic argument. I had to check to be sure that the expansion is all
      done by the preprocessor, so we don't need to worry about stack
      intricacies.
      
      [1] https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
      0c52d85e
Loading