mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-11-01 08:52:18 +01:00
Merge branch 'g_unix_fd_query_path' into 'main'
glib-unix: Add Solaris implementation of g_unix_fd_query_path See merge request GNOME/glib!4887
This commit is contained in:
@@ -952,11 +952,15 @@ char *
|
||||
g_unix_fd_query_path (int fd,
|
||||
GError **error)
|
||||
{
|
||||
#if defined (__linux__)
|
||||
#if defined(__linux__) || defined(__sun)
|
||||
char *path;
|
||||
char *proc_path;
|
||||
|
||||
#ifdef __sun
|
||||
proc_path = g_strdup_printf ("/proc/self/path/%d", fd);
|
||||
#else
|
||||
proc_path = g_strdup_printf ("/proc/self/fd/%d", fd);
|
||||
#endif
|
||||
path = g_file_read_link (proc_path, error);
|
||||
g_free (proc_path);
|
||||
|
||||
|
||||
@@ -930,7 +930,16 @@ test_fd_query_path (void)
|
||||
|
||||
fd_path = g_unix_fd_query_path (fd, &error);
|
||||
g_assert_no_error (error);
|
||||
#ifdef __sun
|
||||
/* /dev/null is a symlink on Solaris, so follow the link */
|
||||
char *dev_null_path = realpath ("/dev/null", NULL);
|
||||
g_assert_no_errno (errno);
|
||||
g_assert_nonnull (dev_null_path);
|
||||
g_assert_cmpstr (fd_path, ==, dev_null_path);
|
||||
g_free (dev_null_path);
|
||||
#else
|
||||
g_assert_cmpstr (fd_path, ==, "/dev/null");
|
||||
#endif
|
||||
|
||||
g_clear_fd (&fd, &error);
|
||||
g_assert_no_error (error);
|
||||
|
||||
Reference in New Issue
Block a user