New upstream version 2019.1

This commit is contained in:
Simon McVittie committed 2019-01-14 08:01:21 +00:00
commit 72f5087561
73 files changed
+3173 -1997

No files matched your search

+3 -5
View File
@@ -44,9 +44,7 @@ APIs not defined in GLib yet, such as `glnx_autofd`.
Contributing
------------
Currently there is not a Bugzilla product - one may be created
in the future. You can submit PRs against the Github mirror:
Development happens in GNOME Gitlab: https://gitlab.gnome.org/GNOME/libglnx
https://github.com/GNOME/libglnx/pulls
Or alternatively, email one of the maintainers directly.
(If you're seeing this on the Github mirror, we used to do development
on Github but that was before GNOME deployed Gitlab.)
+2 -3
View File
@@ -1002,8 +1002,7 @@ glnx_file_copy_at (int src_dfd,
* contents. This and other behavior can be controlled via @flags.
*
* Note that no metadata from the existing file is preserved, such as
* uid/gid or extended attributes. The default mode will be `0666`,
* modified by umask.
* uid/gid or extended attributes. The default mode will be `0644`.
*/
gboolean
glnx_file_replace_contents_at (int dfd,
@@ -1025,7 +1024,7 @@ glnx_file_replace_contents_at (int dfd,
* @subpath: Subpath
* @buf: (array len=len) (element-type guint8): File contents
* @len: Length (if `-1`, assume @buf is `NUL` terminated)
* @mode: File mode; if `-1`, use `0666 - umask`
* @mode: File mode; if `-1`, use `0644`
* @flags: Flags
* @cancellable: Cancellable
* @error: Error
+24 -16
View File
@@ -24,8 +24,23 @@
#include <glnx-shutil.h>
#include <glnx-errors.h>
#include <glnx-fdio.h>
#include <glnx-local-alloc.h>
static gboolean
unlinkat_allow_noent (int dfd,
const char *path,
int flags,
GError **error)
{
if (unlinkat (dfd, path, flags) == -1)
{
if (errno != ENOENT)
return glnx_throw_errno_prefix (error, "unlinkat(%s)", path);
}
return TRUE;
}
static gboolean
glnx_shutil_rm_rf_children (GLnxDirFdIterator *dfd_iter,
GCancellable *cancellable,
@@ -51,16 +66,13 @@ glnx_shutil_rm_rf_children (GLnxDirFdIterator *dfd_iter,
if (!glnx_shutil_rm_rf_children (&child_dfd_iter, cancellable, error))
return FALSE;
if (unlinkat (dfd_iter->fd, dent->d_name, AT_REMOVEDIR) == -1)
return glnx_throw_errno_prefix (error, "unlinkat");
if (!glnx_unlinkat (dfd_iter->fd, dent->d_name, AT_REMOVEDIR, error))
return FALSE;
}
else
{
if (unlinkat (dfd_iter->fd, dent->d_name, 0) == -1)
{
if (errno != ENOENT)
return glnx_throw_errno_prefix (error, "unlinkat");
}
if (!unlinkat_allow_noent (dfd_iter->fd, dent->d_name, 0, error))
return FALSE;
}
}
@@ -86,7 +98,6 @@ glnx_shutil_rm_rf_at (int dfd,
{
dfd = glnx_dirfd_canonicalize (dfd);
/* With O_NOFOLLOW first */
glnx_autofd int target_dfd =
openat (dfd, path, O_RDONLY | O_NONBLOCK | O_DIRECTORY | O_CLOEXEC | O_NOFOLLOW);
@@ -100,8 +111,8 @@ glnx_shutil_rm_rf_at (int dfd,
}
else if (errsv == ENOTDIR || errsv == ELOOP)
{
if (unlinkat (dfd, path, 0) != 0)
return glnx_throw_errno_prefix (error, "unlinkat");
if (!glnx_unlinkat (dfd, path, 0, error))
return FALSE;
}
else
return glnx_throw_errno_prefix (error, "open(%s)", path);
@@ -113,13 +124,10 @@ glnx_shutil_rm_rf_at (int dfd,
return FALSE;
if (!glnx_shutil_rm_rf_children (&dfd_iter, cancellable, error))
return FALSE;
return glnx_prefix_error (error, "Removing %s", path);
if (unlinkat (dfd, path, AT_REMOVEDIR) == -1)
{
if (errno != ENOENT)
return glnx_throw_errno_prefix (error, "unlinkat");
}
if (!unlinkat_allow_noent (dfd, path, AT_REMOVEDIR, error))
return FALSE;
}
return TRUE;