From 1a048dc5e2c463f2eaf1b8975983185fee080b37 Mon Sep 17 00:00:00 2001 From: Ruediger Meier Date: Mon, 29 Feb 2016 12:49:13 +0100 Subject: lib: move fopen_at() to fileutils.h, remove at.h Signed-off-by: Ruediger Meier --- include/fileutils.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include/fileutils.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; -- cgit v1.2.3-55-g7522