From 0f1f3e6f4bfdd17e799533a67b62ed1fff1a15a6 Mon Sep 17 00:00:00 2001 From: Phillip Whelan Date: Wed, 20 Sep 2023 07:48:13 -0700 Subject: [PATCH] in_calyptia_fleet: add readlink equivalent for windows. Signed-off-by: Phillip Whelan --- plugins/in_calyptia_fleet/in_calyptia_fleet.c | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/plugins/in_calyptia_fleet/in_calyptia_fleet.c b/plugins/in_calyptia_fleet/in_calyptia_fleet.c index 3e2df36fff0..3175b5645c1 100644 --- a/plugins/in_calyptia_fleet/in_calyptia_fleet.c +++ b/plugins/in_calyptia_fleet/in_calyptia_fleet.c @@ -695,6 +695,29 @@ static int get_calyptia_fleet_id_by_name(struct flb_in_calyptia_fleet_config *ct #ifdef FLB_SYSTEM_WINDOWS #define link(a, b) CreateHardLinkA(b, a, 0) + +ssize_t readlink(const char *path, char *realpath, size_t srealpath) { + HANDLE hFile; + DWORD ret; + + hFile = CreateFile(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, NULL); + + if (hFile == INVALID_HANDLE_VALUE) { + return -1; + } + + ret = GetFinalPathNameByHandleA(hFile, realpath, srealpath, VOLUME_NAME_NT); + + if (ret < srealpath) { + CloseHandle(hFile); + return -1; + } + + CloseHandle(hFile); + return ret; +} + #endif /* cb_collect callback */