[glib/2325-symlink-replace-file: 7/7] gioerror: Add conversion from ENXIO to G_IO_ERROR_NOT_REGULAR_FILE




commit 050dfebdd2b6dc3d03e2804b8e1ab184252fdbd7
Author: Philip Withnall <pwithnall endlessos org>
Date:   Fri Feb 26 13:25:50 2021 +0000

    gioerror: Add conversion from ENXIO to G_IO_ERROR_NOT_REGULAR_FILE
    
    `ENXIO` can be returned from `open(2)` for special files (FIFOs, device
    files and domain sockets) which are not backed by anything.
    
    This fixes the error returned by `g_file_replace()` when trying to
    replace such a file, so that it now matches the documentation.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>

 gio/gioerror.c   | 6 ++++++
 gio/tests/file.c | 8 ++++----
 2 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/gio/gioerror.c b/gio/gioerror.c
index 477906c0c..38fc3d83f 100644
--- a/gio/gioerror.c
+++ b/gio/gioerror.c
@@ -107,6 +107,12 @@ g_io_error_from_errno (gint err_no)
       break;
 #endif
 
+#ifdef ENXIO
+    case ENXIO:
+      return G_IO_ERROR_NOT_REGULAR_FILE;
+      break;
+#endif
+
 #ifdef EROFS
     case EROFS:
       return G_IO_ERROR_READ_ONLY;
diff --git a/gio/tests/file.c b/gio/tests/file.c
index c2a139794..d99838d54 100644
--- a/gio/tests/file.c
+++ b/gio/tests/file.c
@@ -1246,7 +1246,7 @@ test_replace (gconstpointer test_data)
         FALSE, G_FILE_CREATE_NONE, NULL,
         FILE_TEST_SETUP_TYPE_SOCKET, default_public_mode,
         FILE_TEST_SETUP_TYPE_REGULAR_NONEMPTY, default_public_mode,
-        FALSE, G_IO_ERROR, G_IO_ERROR_FAILED,  /* FIXME Perhaps this should be G_IO_ERROR_NOT_REGULAR_FILE; 
actually documented as such */
+        FALSE, G_IO_ERROR, G_IO_ERROR_NOT_REGULAR_FILE,
         2, FILE_TEST_SETUP_TYPE_SOCKET, default_public_mode, NULL,
         FILE_TEST_SETUP_TYPE_REGULAR_NONEMPTY, default_public_mode, original_backup_contents,
       },
@@ -1317,7 +1317,7 @@ test_replace (gconstpointer test_data)
         TRUE, G_FILE_CREATE_NONE, NULL,
         FILE_TEST_SETUP_TYPE_SOCKET, default_public_mode,
         FILE_TEST_SETUP_TYPE_REGULAR_NONEMPTY, default_public_mode,
-        FALSE, G_IO_ERROR, G_IO_ERROR_FAILED,  /* FIXME Perhaps this should be G_IO_ERROR_NOT_REGULAR_FILE; 
actually documented as such */
+        FALSE, G_IO_ERROR, G_IO_ERROR_NOT_REGULAR_FILE,
         2, FILE_TEST_SETUP_TYPE_SOCKET, default_public_mode, NULL,
         FILE_TEST_SETUP_TYPE_REGULAR_NONEMPTY, default_public_mode, original_backup_contents,
       },
@@ -1451,7 +1451,7 @@ test_replace (gconstpointer test_data)
         FALSE, G_FILE_CREATE_REPLACE_DESTINATION, NULL,
         FILE_TEST_SETUP_TYPE_SOCKET, default_public_mode,
         FILE_TEST_SETUP_TYPE_REGULAR_NONEMPTY, default_public_mode,
-        FALSE, G_IO_ERROR, G_IO_ERROR_FAILED,  /* FIXME Perhaps this should be G_IO_ERROR_NOT_REGULAR_FILE; 
actually documented as such */
+        FALSE, G_IO_ERROR, G_IO_ERROR_NOT_REGULAR_FILE,
         2, FILE_TEST_SETUP_TYPE_SOCKET, default_public_mode, NULL,
         FILE_TEST_SETUP_TYPE_REGULAR_NONEMPTY, default_public_mode, original_backup_contents,
       },
@@ -1526,7 +1526,7 @@ test_replace (gconstpointer test_data)
         TRUE, G_FILE_CREATE_REPLACE_DESTINATION, NULL,
         FILE_TEST_SETUP_TYPE_SOCKET, default_public_mode,
         FILE_TEST_SETUP_TYPE_REGULAR_NONEMPTY, default_public_mode,
-        FALSE, G_IO_ERROR, G_IO_ERROR_FAILED,  /* FIXME Perhaps this should be G_IO_ERROR_NOT_REGULAR_FILE; 
actually documented as such */
+        FALSE, G_IO_ERROR, G_IO_ERROR_NOT_REGULAR_FILE,
         2, FILE_TEST_SETUP_TYPE_SOCKET, default_public_mode, NULL,
         FILE_TEST_SETUP_TYPE_REGULAR_NONEMPTY, default_public_mode, original_backup_contents,
       },


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]