Commit Graph

42 Commits

Author SHA1 Message Date
Matthew Barnes
013aa4fead Backport all the GIO object types used by OSTree 2015-05-05 10:26:33 -04:00
Colin Walters
be6bc2d75d lockfile: New code to lock files, massaged from systemd
Will be used by OSTree to lock the sysroot against concurrent
manipulation.  Taken from current systemd git master, tweaked to
GLibify.
2015-05-05 08:49:00 -04:00
Colin Walters
fda8f26625 README.md: Some more rationale 2015-05-04 16:10:28 -04:00
Matthew Barnes
dfe77be2d5 Backport more autocleanup types from GLib
GStrv, GFile, GOutputStream
2015-05-04 11:58:09 -04:00
Colin Walters
90390949f2 fdio: glnx_file_copy_at: If no stbuf passed, do stat internally
There are some cases where we want to copy with just a filename,
so let's be convenient in that case and do stat for the caller.

This will be used by an ostree commit.
2015-04-20 22:10:07 -04:00
Colin Walters
381ca54ee3 dirfd: Add API to get an absolute path from a dfd/relpath
There are a lot of APIs that still only take absolute paths, such as
librpm (and everything above it).  I plan to use this in rpm-ostree to
convert temporary directories that I'm accessing fd-relative back into
absolutes until such time as fd-relative APIs are plumbed through the
stack more.
2015-04-17 09:33:58 -04:00
Colin Walters
c231a3b845 console: Do basic output if we're not on a tty
Doing nothing isn't super useful; if you're using e.g. rpm-ostree in
Jenkins you want to see *something* from the "live tail".

This is a basic line-per-change implementation.

Closes: https://github.com/GNOME/libglnx/pull/6
2015-04-17 08:23:37 -04:00
Colin Walters
371172bcfd fdio: Fix errno handling from posix_fallocate() and loop_write()
For extra fun, both of these functions have different error handling
schemes.  `posix_fallocate` does *not* set `errno` because...  I'm not
sure.  Maybe POSIX was trying a new function design?

`loop_write` uses the systemd error handling style which returns
`-errno`, so we need to set errno back so that the macro can propagate
it into the `GError`.
2015-04-14 10:08:41 -04:00
Colin Walters
c36ea3ea80 fdio: Honor umask by default for glnx_file_replace_contents_at()
By default (with `-1) use the Unix traditional default of
`0666 - umask`.  But do support forcing a mode.
2015-04-14 10:08:41 -04:00
Matthew Barnes
02af92ffef fdio: Fix default mode in glnx_file_replace_contents_with_perms_at()
mkostemp() defaults to 0600.  Use 0644 instead unless a mode is
explicitly provided.

https://bugzilla.gnome.org/747813
2015-04-14 08:45:51 -04:00
Colin Walters
20fc302df5 fdio: Canonicalize dfd for replace contents API
Just noticed while inspecting the code.
2015-04-13 13:35:32 -04:00
Colin Walters
376219a9c2 fdio: Also add a replace variant that takes mode/uid/gid
This will be used for OSTree too.
2015-04-08 21:31:43 -04:00
Colin Walters
dc47528f51 fdio: Add glnx_file_replace_contents_at()
Sort of similar to `g_file_replace_contents()` but `*at()`.  Will be
used for further conversion of OSTree to `*at()`.
2015-04-08 21:13:05 -04:00
Colin Walters
55220bdbf2 shutil: Drop unnecessary new block scope 2015-04-08 05:59:16 -04:00
Colin Walters
16f02afb2b build: Drop leftover -lattr
See previous commits to drop libattr dependency.
2015-04-08 05:58:31 -04:00
Colin Walters
e72bbdebb0 fdio: Include <string.h> for basename
Most callers already included `string.h` which is why I didn't see
this earlier.
2015-04-07 12:34:30 -04:00
Colin Walters
19885b8a20 shutil: Add mkdir -p API
I looked at the systemd code but it didn't have a variant of
mkdir_parents that used `*at()`.  This is a fresh implementation, with
the risk that entails.

However I am changing libgsystem to call it now for testing, and
libgsystem APIs are covered by ostree usage at least.
2015-04-07 12:29:07 -04:00
Colin Walters
d59a63e3e6 Switch to using glibc xattrs
See https://github.com/GNOME/ostree/pull/78
2015-04-01 05:42:26 -04:00
Colin Walters
d8a3d3b821 README.md: Add some porting bits 2015-03-20 11:53:57 -04:00
Colin Walters
08d1339f9a console: Make glnx_console_lines and columns public
They'll be used by rpm-ostree at least.
2015-03-19 20:49:11 -04:00
Colin Walters
cf2a89f506 Add glnx_dirfd_canonicalize()
We want to honor `-1 == AT_FDCWD`.
2015-03-17 13:41:57 -04:00
Colin Walters
c92adab47a fdio: Add missing mode argument
Spotted by fortify-source.
2015-03-09 21:22:38 -04:00
Colin Walters
175502e5be Add glnx_basename()
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.
2015-03-05 09:02:48 -05:00
Colin Walters
a11b2eb20a Import libcontainer code from rpm-ostree
Now that this module is Linux specific, we can more cleanly depend on
it here.
2015-03-04 18:29:14 -05:00
Colin Walters
162d1f6b58 fdio: Add glnx_file_copy_at()
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.
2015-03-03 11:30:41 -05:00
Colin Walters
9a7277889a dfditer: Unset initialized variable when cleared
This allows reusing an iterator struct.
2015-03-03 08:43:15 -05:00
Giuseppe Scrivano
39c6393876 Makefile-libglnx.am: use README.md not README
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2015-03-02 10:05:37 -05:00
Colin Walters
37082ed867 backports: g_autofree 2015-02-25 21:44:54 -05:00
Colin Walters
1288bd8508 xattrs: Migrate some code from ostree here
This also uses GBytes and avoids malloc where possible.
2015-02-20 13:44:29 -05:00
Colin Walters
1ebfefa565 fdio: New APIs to read/write on fds, fd-relative
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().
2015-02-20 12:17:04 -05:00
Colin Walters
08d68d16cc Add cleanups for array types 2015-02-19 17:53:46 -05:00
Colin Walters
d469ad2a9c Include autocleanups - it has the definitions which we want 2015-02-19 15:35:35 -05:00
Colin Walters
ffac03f49c .gitignore: New file
This comes into play with subdir-objects.
2015-02-19 15:35:35 -05:00
Matthew Barnes
fa43744c05 Fix includes when relying on backported g_autoptr() 2015-02-18 16:45:45 -05:00
Colin Walters
64936b6700 Import console from rpm-ostree
This contains some basic progress bar drawing code for now.
2015-02-17 16:52:49 -05:00
Colin Walters
70b070b5ea dirfd: Fix two typos 2015-02-17 16:03:36 -05:00
Colin Walters
0885d6735a dirfd: Add some gtk-doc 2015-02-15 17:49:58 -05:00
Colin Walters
a90e1c3423 Import xattr setting code from libgsystem 2015-02-15 17:36:32 -05:00
Colin Walters
f5399c8348 Import xattr reading code from libgsystem 2015-02-15 17:26:47 -05:00
Colin Walters
ba67dd39a7 Update README 2015-02-15 11:57:15 -05:00
Colin Walters
8e9a171ec4 Import directory iteration, errno handling, and shutil from libgsystem 2015-02-15 11:53:34 -05:00
Colin Walters
5ac3f4a119 Initial commit; backport of GLib autoptr code
This module is a new successor to libgsystem.  It currently contains a
backport of the GLib cleanup macros, but soon more Linux-specific code
will be added.
2015-02-14 13:41:51 -05:00