Save errno before calling other funcs that potentially alter it. Bug

* gio/gdesktopappinfo.c: (ensure_dir):
	* gio/glocalfile.c: (g_local_file_query_filesystem_info),
	(g_local_file_read), (g_local_file_delete), (g_local_file_trash),
	(g_local_file_move):
	* gio/glocalfileinfo.c: (set_xattr), (_g_local_file_info_get),
	(_g_local_file_info_get_from_fd), (set_unix_mode),
	(set_unix_uid_gid), (set_symlink), (set_mtime_atime):
	* gio/glocalfileinputstream.c: (g_local_file_input_stream_read),
	(g_local_file_input_stream_skip),
	(g_local_file_input_stream_close),
	(g_local_file_input_stream_seek):
	* gio/glocalfileoutputstream.c:
	(g_local_file_output_stream_write),
	(g_local_file_output_stream_close),
	(g_local_file_output_stream_seek),
	(g_local_file_output_stream_truncate), (copy_file_data),
	(handle_overwrite_open):
	* gio/gunixinputstream.c: (g_unix_input_stream_read),
	(g_unix_input_stream_close), (read_async_cb), (close_async_cb):
	* gio/gunixoutputstream.c: (g_unix_output_stream_write),
	(g_unix_output_stream_close), (write_async_cb), (close_async_cb):
	Save
	errno before calling other funcs that potentially alter it. Bug
	#514766.

svn path=/trunk/; revision=6466
This commit is contained in:
Christian Persch
2008-02-06 15:10:08 +00:00
parent d87c1c0af4
commit 37ac644bd1
8 changed files with 232 additions and 112 deletions

View File

@@ -150,13 +150,15 @@ g_local_file_input_stream_read (GInputStream *stream,
res = read (file->priv->fd, buffer, count);
if (res == -1)
{
if (errno == EINTR)
int errsv = errno;
if (errsv == EINTR)
continue;
g_set_error (error, G_IO_ERROR,
g_io_error_from_errno (errno),
g_io_error_from_errno (errsv),
_("Error reading from file: %s"),
g_strerror (errno));
g_strerror (errsv));
}
break;
@@ -182,20 +184,24 @@ g_local_file_input_stream_skip (GInputStream *stream,
start = lseek (file->priv->fd, 0, SEEK_CUR);
if (start == -1)
{
int errsv = errno;
g_set_error (error, G_IO_ERROR,
g_io_error_from_errno (errno),
g_io_error_from_errno (errsv),
_("Error seeking in file: %s"),
g_strerror (errno));
g_strerror (errsv));
return -1;
}
res = lseek (file->priv->fd, count, SEEK_CUR);
if (res == -1)
{
int errsv = errno;
g_set_error (error, G_IO_ERROR,
g_io_error_from_errno (errno),
g_io_error_from_errno (errsv),
_("Error seeking in file: %s"),
g_strerror (errno));
g_strerror (errsv));
return -1;
}
@@ -219,10 +225,14 @@ g_local_file_input_stream_close (GInputStream *stream,
{
res = close (file->priv->fd);
if (res == -1)
g_set_error (error, G_IO_ERROR,
g_io_error_from_errno (errno),
_("Error closing file: %s"),
g_strerror (errno));
{
int errsv = errno;
g_set_error (error, G_IO_ERROR,
g_io_error_from_errno (errsv),
_("Error closing file: %s"),
g_strerror (errsv));
}
break;
}
@@ -295,10 +305,12 @@ g_local_file_input_stream_seek (GFileInputStream *stream,
if (pos == (off_t)-1)
{
int errsv = errno;
g_set_error (error, G_IO_ERROR,
g_io_error_from_errno (errno),
g_io_error_from_errno (errsv),
_("Error seeking in file: %s"),
g_strerror (errno));
g_strerror (errsv));
return FALSE;
}