mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-11-05 02:28:55 +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,
|
g_unix_fd_query_path (int fd,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
#if defined (__linux__)
|
#if defined(__linux__) || defined(__sun)
|
||||||
char *path;
|
char *path;
|
||||||
char *proc_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);
|
proc_path = g_strdup_printf ("/proc/self/fd/%d", fd);
|
||||||
|
#endif
|
||||||
path = g_file_read_link (proc_path, error);
|
path = g_file_read_link (proc_path, error);
|
||||||
g_free (proc_path);
|
g_free (proc_path);
|
||||||
|
|
||||||
|
|||||||
@@ -930,7 +930,16 @@ test_fd_query_path (void)
|
|||||||
|
|
||||||
fd_path = g_unix_fd_query_path (fd, &error);
|
fd_path = g_unix_fd_query_path (fd, &error);
|
||||||
g_assert_no_error (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");
|
g_assert_cmpstr (fd_path, ==, "/dev/null");
|
||||||
|
#endif
|
||||||
|
|
||||||
g_clear_fd (&fd, &error);
|
g_clear_fd (&fd, &error);
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
|
|||||||
Reference in New Issue
Block a user