summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* fileutils: Add gs_file_open_dir_fd_at()submoduleColin Walters2014-02-272-0/+34
| | | | | This will be used in the OSTree checkout code, where we want to mkdir() and then open it.
* fileutil: Add API to set xattrs of a filename relative to a dir fdColin Walters2014-02-262-19/+49
| | | | This is a Linux-specific way to work around the missing lsetxattrat().
* Include gsystem-glib-compat.h for compatibility with GLib 2.32Jiří Klimeš2014-01-161-0/+1
| | | | | | Needed for g_clear_pointer(). Signed-off-by: Jiří Klimeš <jklimes@redhat.com>
* COPYING: Update to latest FSF with current addressColin Walters2014-01-161-10/+9
| | | | Hooray for rpmlint.
* console: Print a newline when starting a status line the first timeColin Walters2014-01-151-1/+1
| | | | This ensures we're not overwriting any earlier output.
* fileutil: Squash some unused-variable etc. warnings without CONFIG_XATTRColin Walters2014-01-031-29/+47
| | | | | A bit tricky; we have to move the implementation into an internal helper.
* README: Note where to report bugsColin Walters2013-12-081-0/+3
|
* Only use fdatasync() on LinuxRyan Lortie2013-12-081-4/+10
| | | | | | This function is not universally available, and since we don't have our own autoconf script to check for it, just assume that we have it iff we're on Linux.
* Import xattr code from OSTree, use it to make gs_shutil_cp_a() copy xattrsColin Walters2013-11-283-90/+425
| | | | | | | | | | | | | | | | | | | | | For SELinux, it's crucial that we actually copy the "security.selinux" xattr which provides the security context. the "cp_a" name kind of strongly implies that we do what coreutils "cp -a" does, and this patch moves us a lot closer to what it says on the tin. Concretely, we now match directory modes (and ownership), and we copy all xattrs for directories. We're not (yet) copying xattrs for files, but sadly this is a GLib bug. This patch will allow OSTree to simply use gs_shutil_cp_a() for merging configuration. Still TODO: * Timestamps https://bugzilla.gnome.org/show_bug.cgi?id=711058
* GSSubprocess: remove unnecessary NULL check (trivial)Thomas Haller2013-11-061-2/+1
| | | | | | | | | | | This fixes a warning found during Coverity scan. Error: REVERSE_INULL (CWE-476): [#def5] libgsystem/gsystem-subprocess.c:949: deref_ptr_in_call: Dereferencing pointer "context". libgsystem/gsystem-subprocess-context.c:330:3: deref_parm: Directly dereferencing parameter "self". libgsystem/gsystem-subprocess.c:960: check_after_deref: Null-checking "context" suggests that it may be null, but it has already been dereferenced on all paths leading to the check. Signed-off-by: Thomas Haller <thaller@redhat.com>
* shutil: Make gs_shutil_cp_a copy ownership as wellSjoerd Simons2013-11-031-1/+11
| | | | | | | | Like cp -a gs_shutil_cp_a should really copy all directory metadata. This adds support for at least copying the ownership metadata (user/group). https://bugzilla.gnome.org/show_bug.cgi?id=711057
* file-utils: fix wrong condition in open_nointr (open returns -1 on error)Thomas Haller2013-10-311-1/+1
| | | | | | This error was found by running Coverity. Signed-off-by: Thomas Haller <thaller@redhat.com>
* file-utils: Don't leaking fd on error path in gs_file_create()Thomas Haller2013-10-311-0/+1
| | | | | | This error was found by running Coverity. Signed-off-by: Thomas Haller <thaller@redhat.com>
* file-utils: gs_file_open_in_tmpdir_at did never retryThomas Haller2013-10-311-1/+2
| | | | | | | | | | In case of creating an existing file name, gs_file_open_in_tmpdir_at did not retry and failed to create the temporary file (while signalling success). This error was found by running Coverity. Signed-off-by: Thomas Haller <thaller@redhat.com>
* localalloc: Declare the cleanup functions inline in the headerChristian Persch2013-10-232-96/+26
| | | | | This enables gcc with -Wuninitialized to warn if the cleanup function is used on an uninitialised variable.
* Fix signed/unsigned comparision warningsChristian Persch2013-10-213-5/+5
|
* localalloc: Add gs_free_errorChristian Persch2013-10-212-0/+14
|
* Fix introspection warningsJasper St. Pierre2013-10-092-4/+4
|
* file-utils: Rename a functionJasper St. Pierre2013-10-092-7/+7
| | | | The proper prefix is gsystem_, not gs_
* gs_file_get_path_cached: Unlock mutex on errorAlexander Larsson2013-09-301-1/+4
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=708824
* fileutil: Close fd if passed NULL for output streamColin Walters2013-09-291-0/+2
| | | | So we don't leak it.
* fileutil: Handle recent: and trash: URIsBastien Nocera2013-09-201-2/+24
| | | | | | | | | | | | The gs_file_get_path_cached() was rather brittle in its handling of URIs. It would assert() when a GFile didn't have a backing path (such as when handling trash: or recent: URIs), and didn't know how to get the target URI for those items either. Make sure that we do not assert() when a backing path cannot be found, and handle recent: and trash: URIs. https://bugzilla.gnome.org/show_bug.cgi?id=708435
* fileutil: Drop gs_file_create_with_uidgid()Colin Walters2013-09-132-84/+0
| | | | | This was only used by OSTree as far as I know, and it now has a better solution.
* fileutils: Avoid crash if g_set_prgname() has not been calledColin Walters2013-09-131-4/+16
| | | | While we're here, also squash spaces in the filename to '_'.
* shutil: Treat ELOOP like ENOTDIRColin Walters2013-09-101-1/+1
| | | | | We can apparently get this if we try to open with O_NOFOLLOW a chain of symlinks. Just treat it like it's not a directory so we unlink.
* shutil: Use at-relative walking for gs_shutil_rm_rf()Colin Walters2013-09-091-62/+167
| | | | | This is safer against concurrent modification, as well as being more efficient.
* fileutil: Add gs_file_openat_noatime()Colin Walters2013-09-072-31/+54
| | | | | | | While porting relevant parts of OSTree to use openat()/renameat() and friends, it commonly occurs that I wanted to do gs_file_read_noatime(). Make a variant of that API, named differently because the _noatime implies reading.
* fileutil: Add initial directory-relative APIColin Walters2013-09-062-22/+101
| | | | | | | | | | | | | | | | | | | | | | | | Modern UNIX come with a variety of filesystem API suffixed with "at", like openat(), linkat(), etc. The reason for their existence is multiple. First, if you're doing a lot of file operations in a directory, it's simply more efficient to avoid having the kernel traverse potentially long pathnames constantly. Second, this avoids a problem where if a user does e.g.: rm -rf somedir & mv somedir othername mkdir somedir touch somedir/otherfile We won't end up deleting otherfile, because all of our operations are relative to the original "somedir". The second rationale is unlikely to matter for OSTree since we'll assume the user isn't going to move a repository around while we're committing to it, but anyways, it's just better to use fd-relative pathnames.
* fileutil: Add lock around pathname cachingColin Walters2013-09-061-0/+12
| | | | | | | | | | | | | | | | | | | If two threads both call gs_file_get_path_cached() on the same GFile, then it's possible that both threads see the pathname isn't cached, and set the qdata. The second one will end up freeing the cached qdata from the first, causing it to read freed memory. Fix this by just slapping a lock around the whole business. This was observed in the real world in ostree where two threads were calling gs_file_get_path_cached() on the shared repo->tmp_dir. But really, what we want to do is two things: 1) Upstream this into gio 2) Stop using gs_file_get_path_cached() so much; instead, we should be using openat() and friends. This will also avoid malloc, and help us earn our UNIX merit badge.
* gs_file_read_noatime: Always return errorsBastien Nocera2013-09-051-1/+8
| | | | | | | When passed an invalid GFile, or one that's not FUSE backed, we should error out properly instead of not returning an error. https://bugzilla.gnome.org/show_bug.cgi?id=699252
* fileutil: New gs_file_lchown() APIColin Walters2013-08-302-18/+60
| | | | Needed for ostree to chown symbolic links.
* localalloc: Fix extra indirection on gs_strfrev implementationColin Walters2013-08-291-10/+10
| | | | | | This was tripping a compiler warning in NetworkManager; the right way to fix it is actually to be less magical in the macro and lose our synthesized *. Instead add it explicitly for each type.
* localalloc: Add gs_strfreevColin Walters2013-08-292-0/+14
| | | | NetworkManager uses strvs quite a lot.
* fileutil: Fix -Wshadow warning with "index"Colin Walters2013-08-261-4/+4
| | | | Reported-by: Pavel Šimerda <psimerda@redhat.com>
* gsystem-log: Correctly suppress systemd journal code locationColin Walters2013-08-201-2/+1
| | | | It's not useful since we're wrapping the API.
* gsystem-log: Fix double-logging on non-systemd systemsColin Walters2013-08-161-0/+2
| | | | I was getting duplicated output on RHEL6.
* fileutils: Add API to fstat() a streamColin Walters2013-08-142-0/+47
| | | | | | | | | Will be used by ostree. Since libgsystem will return raw GUnix{Input,Output}Stream, we need a way to fstat() them. Maybe we should also have an API to synthesize a #GFileInfo, but that's hard without duplicating all the complex stuff in GIO. https://bugzilla.gnome.org/show_bug.cgi?id=706031
* localalloc: Add gs_unref_bytes()Colin Walters2013-08-142-0/+16
| | | | Since I'm using these more now in ostree, and let's be comprehensive.
* localalloc: Fix variant builder unrefColin Walters2013-08-142-5/+5
| | | | | | I will test my code before pushing. I will test my code before pushing. I will test my code before pushing.
* local-alloc: Fix previous commitColin Walters2013-08-141-1/+1
|
* localalloc: Add cleanup functions for checksum and variant buildersColin Walters2013-08-142-0/+31
| | | | Used in ostree.
* fileutils: Fix fd leakColin Walters2013-08-071-2/+3
|
* fileutil: Add new API to open a temporary file in a particular directoryColin Walters2013-08-062-0/+77
| | | | This is useful for ostree to write to repo/tmp.
* localalloc: Add gs_unref_array()Colin Walters2013-08-022-0/+17
| | | | Requested by NetworkManager team.
* gsystem-log: Add public API to determine whether stdout is journalColin Walters2013-07-242-15/+29
| | | | | Will be used by gnome-desktop-testing to determine whether or not it should set up the journal for its children.
* fileutils: Add gs_file_create_with_uidgid()Colin Walters2013-07-182-0/+84
| | | | | | | | If the provided mode includes S_ISUID or S_ISGID, we will successfully invoke fchmod(), but then a subsequent chown() will undo any setuid bits, even if we're just calling chown for the already extant uid. This API can reliably create a file with the provided mode and owner.
* fileutils: Override umask for gs_file_create()Colin Walters2013-07-171-0/+6
| | | | | | | | | The entire point of this API is to atomically create a file with the given mode; we need to fchmod() in order to get exactly what is specified. This fixes gnome-ostree which uses ostree to check out trees; we were losing the g-w bit on checked out files.
* fileutils: Handles return value of realpath in case of errorsAlberto Ruiz2013-07-181-2/+8
| | | | Signed-off-by: Alberto Ruiz <aruiz@gnome.org>
* fileutil: Make API to generate temporary name publicColin Walters2013-07-162-4/+16
| | | | It's used by ostree core too.
* gs_file_create: New APIColin Walters2013-07-162-0/+45
| | | | | | | This allows ostree core to drop an invocation of chmod() after creating the file. See https://bugzilla.gnome.org/show_bug.cgi?id=699959