summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2017-05-19 11:26:55 +0200
committerAlexander Larsson <alexl@redhat.com>2017-05-19 11:26:55 +0200
commitafffc256a09f86e1bcfde08d2b5081558ffe0816 (patch)
tree6a5e7a258d286a7dd3a9bd02b96d37c1f75d4adc
parent4fbd48fb88906b3eaa9de31c6c798c4f15ee05a4 (diff)
downloadlibglnx-wip/alexl/fix-tmpfiles.tar.gz
fdio: Allow using AT_FDCWD with GlnxTmpfilewip/alexl/fix-tmpfiles
We use fd >= 0 to check for validity instead of src_dfd >= 0 because everything works just fine with src_dfd == AT_FDCWD, except that is negative so the checks break. This fixes flatpak which uses AT_FDCWD.
-rw-r--r--glnx-fdio.c4
-rw-r--r--glnx-fdio.h2
2 files changed, 2 insertions, 4 deletions
diff --git a/glnx-fdio.c b/glnx-fdio.c
index ac62a5e..c05b62f 100644
--- a/glnx-fdio.c
+++ b/glnx-fdio.c
@@ -150,8 +150,6 @@ glnx_renameat2_exchange (int olddirfd, const char *oldpath,
void
glnx_tmpfile_clear (GLnxTmpfile *tmpf)
{
- if (tmpf->src_dfd == -1)
- return;
if (tmpf->fd == -1)
return;
(void) close (tmpf->fd);
@@ -247,7 +245,7 @@ glnx_link_tmpfile_at (GLnxTmpfile *tmpf,
const gboolean replace = (mode == GLNX_LINK_TMPFILE_REPLACE);
const gboolean ignore_eexist = (mode == GLNX_LINK_TMPFILE_NOREPLACE_IGNORE_EXIST);
- g_return_val_if_fail (tmpf->src_dfd >= 0, FALSE);
+ g_return_val_if_fail (tmpf->fd >= 0, FALSE);
/* Unlike the original systemd code, this function also supports
* replacing existing files.
diff --git a/glnx-fdio.h b/glnx-fdio.h
index cc36ca4..cccad57 100644
--- a/glnx-fdio.h
+++ b/glnx-fdio.h
@@ -53,7 +53,7 @@ typedef struct {
int fd;
char *path;
} GLnxTmpfile;
-#define GLNX_TMPFILE_INIT { .src_dfd = -1 };
+#define GLNX_TMPFILE_INIT { .fd = -1 };
void glnx_tmpfile_clear (GLnxTmpfile *tmpf);
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GLnxTmpfile, glnx_tmpfile_clear);