mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-02 15:33:39 +02:00
Switch all open() calls to use g_open()
Because it now handles EINTR. And we should do so. While most people use Linux, which tries very hard to avoid propagating EINTR back up into userspace, it can still happen. https://bugzilla.gnome.org/show_bug.cgi?id=682833
This commit is contained in:
@@ -2017,7 +2017,7 @@ g_local_file_trash (GFile *file,
|
||||
infofile = g_build_filename (infodir, infoname, NULL);
|
||||
g_free (infoname);
|
||||
|
||||
fd = open (infofile, O_CREAT | O_EXCL, 0666);
|
||||
fd = g_open (infofile, O_CREAT | O_EXCL, 0666);
|
||||
} while (fd == -1 && errno == EEXIST);
|
||||
|
||||
g_free (basename);
|
||||
|
@@ -1247,10 +1247,10 @@ get_content_type (const char *basename,
|
||||
sniff_length = 4096;
|
||||
|
||||
#ifdef O_NOATIME
|
||||
fd = open (path, O_RDONLY | O_NOATIME);
|
||||
fd = g_open (path, O_RDONLY | O_NOATIME, 0);
|
||||
if (fd < 0 && errno == EPERM)
|
||||
#endif
|
||||
fd = open (path, O_RDONLY);
|
||||
fd = g_open (path, O_RDONLY, 0);
|
||||
|
||||
if (fd != -1)
|
||||
{
|
||||
|
@@ -37,6 +37,7 @@
|
||||
#endif
|
||||
|
||||
#include <gio/gio.h>
|
||||
#include <glib/gstdio.h>
|
||||
#include <gi18n.h>
|
||||
|
||||
/* GResource functions {{{1 */
|
||||
@@ -142,7 +143,7 @@ get_elf (const gchar *file,
|
||||
if (elf_version (EV_CURRENT) == EV_NONE )
|
||||
return NULL;
|
||||
|
||||
*fd = open (file, O_RDONLY);
|
||||
*fd = g_open (file, O_RDONLY, 0);
|
||||
if (*fd < 0)
|
||||
return NULL;
|
||||
|
||||
|
@@ -178,7 +178,7 @@ test_interface_method_call (GDBusConnection *connection,
|
||||
|
||||
error = NULL;
|
||||
|
||||
fd = open (path, O_RDONLY);
|
||||
fd = g_open (path, O_RDONLY, 0);
|
||||
g_unix_fd_list_append (fd_list, fd, &error);
|
||||
g_assert_no_error (error);
|
||||
close (fd);
|
||||
|
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
|
||||
#include <gio/gio.h>
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
#ifdef G_OS_UNIX
|
||||
#include <fcntl.h>
|
||||
@@ -154,7 +155,7 @@ test_pollable_unix (void)
|
||||
g_object_unref (out);
|
||||
|
||||
/* Non-pipe/socket unix streams are not pollable */
|
||||
fd = open ("/dev/null", O_RDWR);
|
||||
fd = g_open ("/dev/null", O_RDWR, 0);
|
||||
g_assert_cmpint (fd, !=, -1);
|
||||
in = G_POLLABLE_INPUT_STREAM (g_unix_input_stream_new (fd, FALSE));
|
||||
out = g_unix_output_stream_new (fd, FALSE);
|
||||
|
Reference in New Issue
Block a user