summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorRuediger Meier2016-02-29 12:49:13 +0100
committerKarel Zak2016-03-07 15:36:00 +0100
commit1a048dc5e2c463f2eaf1b8975983185fee080b37 (patch)
tree56be241832a0478709d7451a38041bacc2c14609 /include
parentlib: remove openat fallback functions (include/at.h) (diff)
downloadkernel-qcow2-util-linux-1a048dc5e2c463f2eaf1b8975983185fee080b37.tar.gz
kernel-qcow2-util-linux-1a048dc5e2c463f2eaf1b8975983185fee080b37.tar.xz
kernel-qcow2-util-linux-1a048dc5e2c463f2eaf1b8975983185fee080b37.zip
lib: move fopen_at() to fileutils.h, remove at.h
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Diffstat (limited to 'include')
-rw-r--r--include/Makemodule.am1
-rw-r--r--include/at.h22
-rw-r--r--include/fileutils.h10
3 files changed, 10 insertions, 23 deletions
diff --git a/include/Makemodule.am b/include/Makemodule.am
index 0a41a9433..5cdf29a5b 100644
--- a/include/Makemodule.am
+++ b/include/Makemodule.am
@@ -1,7 +1,6 @@
dist_noinst_HEADERS += \
include/all-io.h \
- include/at.h \
include/bitops.h \
include/blkdev.h \
include/canonicalize.h \
diff --git a/include/at.h b/include/at.h
deleted file mode 100644
index a1c6a8b66..000000000
--- a/include/at.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * wrappers for "at" functions.
- *
- * Copyright (C) 2010 Karel Zak <kzak@redhat.com>
- *
- * This file may be redistributed under the terms of the
- * GNU Lesser General Public License.
- */
-#ifndef UTIL_LINUX_AT_H
-#define UTIL_LINUX_AT_H
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
-#include "c.h"
-
-extern FILE *fopen_at(int dir, const char *filename,
- int flags, const char *mode);
-
-#endif /* UTIL_LINUX_AT_H */
diff --git a/include/fileutils.h b/include/fileutils.h
index 79dd01237..1cc007c76 100644
--- a/include/fileutils.h
+++ b/include/fileutils.h
@@ -28,6 +28,16 @@ static inline FILE *xfmkstemp(char **tmpname, const char *dir, const char *prefi
return ret;
}
+static inline FILE *fopen_at(int dir, const char *filename,
+ int flags, const char *mode)
+{
+ int fd = openat(dir, filename, flags);
+ if (fd < 0)
+ return NULL;
+
+ return fdopen(fd, mode);
+}
+
static inline int is_same_inode(const int fd, const struct stat *st)
{
struct stat f;