diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-03-26 13:25:51 +0200 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2018-08-24 16:47:08 +0200 |
commit | df15bd49b7c870a13f48f78ae7958380ad01f565 (patch) | |
tree | 25d3b433f8527575849466a1a4e37ab471ec16ba /src/test/test-fs-util.c | |
parent | b9458858b4f6475dd32b83f37c546a9ad2c444b2 (diff) |
fd-util: introduce fd_reopen() helper for reopening an fd
We have the same code for this in place at various locations, let's
unify that. Also, let's repurpose test-fs-util.c as a test for this new
helper cal..
Diffstat (limited to 'src/test/test-fs-util.c')
-rw-r--r-- | src/test/test-fs-util.c | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/src/test/test-fs-util.c b/src/test/test-fs-util.c index ba01eea4e..35bb699c3 100644 --- a/src/test/test-fs-util.c +++ b/src/test/test-fs-util.c @@ -270,17 +270,13 @@ static void test_chase_symlinks(void) { pfd = chase_symlinks(p, NULL, CHASE_OPEN, NULL); if (pfd != -ENOENT) { - char procfs[STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(pfd) + 1]; _cleanup_close_ int fd = -1; sd_id128_t a, b; assert_se(pfd >= 0); - xsprintf(procfs, "/proc/self/fd/%i", pfd); - - fd = open(procfs, O_RDONLY|O_CLOEXEC); + fd = fd_reopen(pfd, O_RDONLY|O_CLOEXEC); assert_se(fd >= 0); - safe_close(pfd); assert_se(id128_read_fd(fd, ID128_PLAIN, &a) >= 0); |