[brasero] Fix OpenSolaris support after recent move to GIO instead of HAL



commit b0d969eb4ef0445fd7ca675541441ec39c61b7a2
Author: Philippe Rouquier <bonfire-app wanadoo fr>
Date:   Thu Aug 13 13:36:12 2009 +0200

    Fix OpenSolaris support after recent move to GIO instead of HAL
    Patch by Lin Ma <Lin Ma Sun COM>

 libbrasero-burn/brasero-data-session.c |    2 +-
 libbrasero-burn/burn-basics.c          |   10 ++++++++++
 libbrasero-media/brasero-drive.c       |   31 ++++++++++++++++++++++---------
 libbrasero-media/brasero-medium.c      |    2 +-
 libbrasero-media/brasero-volume.c      |    7 +++----
 libbrasero-media/scsi-uscsi.c          |   11 +++++++++--
 plugins/checksum/burn-checksum-files.c |    4 ++--
 7 files changed, 48 insertions(+), 19 deletions(-)
---
diff --git a/libbrasero-burn/brasero-data-session.c b/libbrasero-burn/brasero-data-session.c
index 9bcff5e..c2d6b95 100644
--- a/libbrasero-burn/brasero-data-session.c
+++ b/libbrasero-burn/brasero-data-session.c
@@ -324,7 +324,7 @@ brasero_data_session_load_directory_contents_real (BraseroDataSession *self,
 		return TRUE;
 
 	priv = BRASERO_DATA_SESSION_PRIVATE (self);
-	device = brasero_drive_get_block_device (brasero_medium_get_drive (priv->loaded));
+	device = brasero_drive_get_device (brasero_medium_get_drive (priv->loaded));
 	brasero_medium_get_last_data_track_address (priv->loaded,
 						    NULL,
 						    &session_block);
diff --git a/libbrasero-burn/burn-basics.c b/libbrasero-burn/burn-basics.c
index b61b499..0da2fd8 100644
--- a/libbrasero-burn/burn-basics.c
+++ b/libbrasero-burn/burn-basics.c
@@ -214,6 +214,16 @@ brasero_burn_library_start (int *argc,
 			  BRASERO_MINOR_VERSION,
 			  BRASERO_SUB);
 
+#if defined(HAVE_STRUCT_USCSI_CMD)
+	/* Work around: because on OpenSolaris brasero posiblely be run
+	 * as root for a user with 'Primary Administrator' profile,
+	 * a root dbus session will be autospawned at that time.
+	 * This fix is to work around
+	 * http://bugzilla.gnome.org/show_bug.cgi?id=526454
+	 */
+	g_setenv ("DBUS_SESSION_BUS_ADDRESS", "autolaunch:", TRUE);
+#endif
+
 	/* Initialize external libraries (threads... */
 	if (!g_thread_supported ())
 		g_thread_init (NULL);
diff --git a/libbrasero-media/brasero-drive.c b/libbrasero-media/brasero-drive.c
index a5bb8c6..09118b2 100644
--- a/libbrasero-media/brasero-drive.c
+++ b/libbrasero-media/brasero-drive.c
@@ -332,7 +332,7 @@ brasero_drive_is_door_open (BraseroDrive *drive)
 	if (!priv->device)
 		return FALSE;
 
-	device = brasero_drive_get_block_device (drive);
+	device = brasero_drive_get_device (drive);
 	handle = brasero_device_handle_open (device, FALSE, NULL);
 	if (!handle)
 		return FALSE;
@@ -364,7 +364,7 @@ brasero_drive_can_use_exclusively (BraseroDrive *drive)
 	g_return_val_if_fail (drive != NULL, FALSE);
 	g_return_val_if_fail (BRASERO_IS_DRIVE (drive), FALSE);
 
-	device = brasero_drive_get_block_device (drive);
+	device = brasero_drive_get_device (drive);
 	handle = brasero_device_handle_open (device, TRUE, NULL);
 	if (!handle)
 		return FALSE;
@@ -400,7 +400,7 @@ brasero_drive_lock (BraseroDrive *drive,
 	if (!priv->device)
 		return FALSE;
 
-	device = brasero_drive_get_block_device (drive);
+	device = brasero_drive_get_device (drive);
 	handle = brasero_device_handle_open (device, FALSE, NULL);
 	if (!handle)
 		return FALSE;
@@ -439,7 +439,7 @@ brasero_drive_unlock (BraseroDrive *drive)
 	if (!!priv->device)
 		return FALSE;
 
-	device = brasero_drive_get_block_device (drive);
+	device = brasero_drive_get_device (drive);
 	handle = brasero_device_handle_open (device, FALSE, NULL);
 	if (!handle)
 		return FALSE;
@@ -492,7 +492,8 @@ brasero_drive_get_display_name (BraseroDrive *drive)
  *
  * Gets a string holding the device path for the drive.
  *
- * Return value: a string holding the device path
+ * Return value: a string holding the device path.
+ * On Solaris returns raw device.
  **/
 const gchar *
 brasero_drive_get_device (BraseroDrive *drive)
@@ -511,9 +512,13 @@ brasero_drive_get_device (BraseroDrive *drive)
  * @drive: a #BraseroDrive
  *
  * Gets a string holding the block device path for the drive. This can be used on
- * some other OSes, like Solaris, for burning operations instead of the device
+ * some other OSes, like Solaris, for GIO operations instead of the device
  * path.
  *
+ * Solaris uses block device for GIO operations and
+ * uses raw device for system calls and backends
+ * like cdrtool.
+ *
  * If such a path is not available, it returns the device path.
  *
  * Return value: a string holding the block device path
@@ -1012,7 +1017,7 @@ brasero_drive_probe_thread (gpointer data)
 
 	/* the drive might be busy (a burning is going on) so we don't block
 	 * but we re-try to open it every second */
-	device = brasero_drive_get_block_device (drive);
+	device = brasero_drive_get_device (drive);
 	BRASERO_MEDIA_LOG ("Trying to open device %s", device);
 
 	handle = brasero_device_handle_open (device, FALSE, &code);
@@ -1049,8 +1054,8 @@ brasero_drive_probe_thread (gpointer data)
 			gchar *model;
 			gchar *name;
 
-			vendor = strndup ((gchar *) hdr.vendor, sizeof (hdr.vendor));
-			model = strndup ((gchar *) hdr.name, sizeof (hdr.name));
+			vendor = g_strndup ((gchar *) hdr.vendor, sizeof (hdr.vendor));
+			model = g_strndup ((gchar *) hdr.name, sizeof (hdr.name));
 			name = g_strdup_printf ("%s %s", g_strstrip (vendor), g_strstrip (model));
 			g_free (vendor);
 			g_free (model);
@@ -1092,7 +1097,15 @@ brasero_drive_init_real_device (BraseroDrive *drive,
 
 	priv = BRASERO_DRIVE_PRIVATE (drive);
 
+#if defined(HAVE_STRUCT_USCSI_CMD)
+	/* On Solaris path points to raw device, block_path points to the block device. */
+	g_assert(g_str_has_prefix(device, "/dev/dsk/"));
+	priv->device = g_strdup_printf ("/dev/rdsk/%s", device + 9);
+	priv->block_device = g_strdup (device);
+	BRASERO_MEDIA_LOG ("Initializing block drive %s", priv->block_device);
+#else
 	priv->device = g_strdup (device);
+#endif
 
 	BRASERO_MEDIA_LOG ("Initializing drive %s from device", priv->device);
 
diff --git a/libbrasero-media/brasero-medium.c b/libbrasero-media/brasero-medium.c
index 53dbb09..de8873f 100644
--- a/libbrasero-media/brasero-medium.c
+++ b/libbrasero-media/brasero-medium.c
@@ -2934,7 +2934,7 @@ brasero_medium_probe_thread (gpointer self)
 
 	/* the drive might be busy (a burning is going on) so we don't block
 	 * but we re-try to open it every second */
-	device = brasero_drive_get_block_device (priv->drive);
+	device = brasero_drive_get_device (priv->drive);
 	BRASERO_MEDIA_LOG ("Trying to open device %s", device);
 
 	handle = brasero_device_handle_open (device, FALSE, &code);
diff --git a/libbrasero-media/brasero-volume.c b/libbrasero-media/brasero-volume.c
index 6953f34..3cd84c4 100644
--- a/libbrasero-media/brasero-volume.c
+++ b/libbrasero-media/brasero-volume.c
@@ -80,11 +80,10 @@ brasero_volume_get_gvolume (BraseroVolume *volume)
 
 	drive = brasero_medium_get_drive (BRASERO_MEDIUM (volume));
 
-#if defined(HAVE_STRUCT_USCSI_CMD)
+	/* This returns the block device which is the
+	 * same as the device for all OSes except
+	 * Solaris where the device is the raw device. */
 	volume_path = brasero_drive_get_block_device (drive);
-#else
-	volume_path = brasero_drive_get_device (drive);
-#endif
 
 	/* NOTE: medium-monitor already holds a reference for GVolumeMonitor */
 	monitor = g_volume_monitor_get ();
diff --git a/libbrasero-media/scsi-uscsi.c b/libbrasero-media/scsi-uscsi.c
index b1f409a..e784007 100644
--- a/libbrasero-media/scsi-uscsi.c
+++ b/libbrasero-media/scsi-uscsi.c
@@ -203,12 +203,19 @@ brasero_device_handle_open (const gchar *path,
 	int fd;
 	int flags = OPEN_FLAGS;
 	BraseroDeviceHandle *handle;
-	gchar *rawdisk = NULL;
 
 /* 	if (exclusive) */
 /* 		flags |= O_EXCL; */
 
-	fd = open (path, flags);
+	if (g_str_has_prefix(path, "/dev/dsk/")) {
+		gchar *rawdisk;
+		rawdisk = g_strdup_printf ("/dev/rdsk/%s", path + 9);
+		fd = open (rawdisk, flags);
+		g_free(rawdisk);
+	} else {
+		fd = open (path, flags);
+	}
+
 	if (fd < 0) {
 		if (code) {
 			if (errno == EAGAIN
diff --git a/plugins/checksum/burn-checksum-files.c b/plugins/checksum/burn-checksum-files.c
index 38dc140..5474aff 100644
--- a/plugins/checksum/burn-checksum-files.c
+++ b/plugins/checksum/burn-checksum-files.c
@@ -412,7 +412,7 @@ brasero_checksum_files_merge_with_former_session (BraseroChecksumFiles *self,
 	medium = NULL;
 	brasero_job_get_medium (BRASERO_JOB (self), &medium);
 	burner = brasero_medium_get_drive (medium);
-	device = brasero_drive_get_block_device (burner);
+	device = brasero_drive_get_device (burner);
 	dev_handle = brasero_device_handle_open (device, FALSE, NULL);
 
 	vol = brasero_volume_source_open_device_handle (dev_handle, error);
@@ -832,7 +832,7 @@ brasero_checksum_files_check_files (BraseroChecksumFiles *self,
 	if (!brasero_medium_get_last_data_track_address (medium, NULL, &start_block))
 		return BRASERO_BURN_ERR;
 
-	device = brasero_drive_get_block_device (brasero_medium_get_drive (medium));
+	device = brasero_drive_get_device (brasero_medium_get_drive (medium));
 	dev_handle = brasero_device_handle_open (device, FALSE, NULL);
 	vol = brasero_volume_source_open_device_handle (dev_handle, error);
 



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