summaryrefslogtreecommitdiff
path: root/src/basic
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-04-29 09:16:45 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-04-29 09:16:45 -0400
commit3e39355a96f615f2cb1e805c7d74efbc272de1cd (patch)
treea31b20b819e007d959db412c8d18ee1bf37bed8d /src/basic
parent427a28ecbe0eb170e651e0530ab58d6e6f6c498c (diff)
parent1fcefd8815455e416c1eda3c8c1220831a2f82e9 (diff)
Merge pull request #3126 from poettering/small-fixes
fsync directory when creating or rotating journal files and other small fixes, most importantly for the DHCP DUID code.
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/fd-util.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/basic/fd-util.c b/src/basic/fd-util.c
index 9130d023d7..8b466cff15 100644
--- a/src/basic/fd-util.c
+++ b/src/basic/fd-util.c
@@ -361,8 +361,14 @@ bool fdname_is_valid(const char *s) {
int fd_get_path(int fd, char **ret) {
char procfs_path[strlen("/proc/self/fd/") + DECIMAL_STR_MAX(int)];
+ int r;
xsprintf(procfs_path, "/proc/self/fd/%i", fd);
- return readlink_malloc(procfs_path, ret);
+ r = readlink_malloc(procfs_path, ret);
+
+ if (r == -ENOENT) /* If the file doesn't exist the fd is invalid */
+ return -EBADF;
+
+ return r;
}