From 6d67568da36960482a0182f36f6af32398582060 Mon Sep 17 00:00:00 2001 From: Gleb Popov <6yearold@gmail.com> Date: Wed, 13 Nov 2024 13:29:01 +0000 Subject: [PATCH] Replace procfs linuxism with kinfo freebsdism --- gio/tests/fake-desktop-portal.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/gio/tests/fake-desktop-portal.c b/gio/tests/fake-desktop-portal.c index 50b4555b0..4cba067d3 100644 --- a/gio/tests/fake-desktop-portal.c +++ b/gio/tests/fake-desktop-portal.c @@ -22,6 +22,12 @@ /* A stub implementation of xdg-desktop-portal */ +#ifdef __FreeBSD__ +#include +#include +#include +#endif /* __FreeBSD__ */ + #include #include #include @@ -206,7 +212,7 @@ handle_to_uri (GVariant *handle, { int fd = -1; int fd_id; - char *proc_path; + char *proc_path = NULL; char *path; char *uri; @@ -216,8 +222,17 @@ handle_to_uri (GVariant *handle, if (fd == -1) return NULL; +#ifdef __FreeBSD__ + struct kinfo_file kf; + kf.kf_structsize = sizeof (kf); + if (fcntl (fd, F_KINFO, &kf) == -1) + return NULL; + path = g_strdup (kf.kf_path); + +#else proc_path = g_strdup_printf ("/proc/self/fd/%d", fd); path = g_file_read_link (proc_path, NULL); +#endif g_assert_nonnull (path); uri = g_filename_to_uri (path, NULL, NULL);