brasero r1439 - in trunk: . src src/plugins/checksum
- From: philippr svn gnome org
- To: svn-commits-list gnome org
- Subject: brasero r1439 - in trunk: . src src/plugins/checksum
- Date: Wed, 29 Oct 2008 14:44:26 +0000 (UTC)
Author: philippr
Date: Wed Oct 29 14:44:26 2008
New Revision: 1439
URL: http://svn.gnome.org/viewvc/brasero?rev=1439&view=rev
Log:
Sometimes after simulation HAL reprobes drive; so check if we can use
the drive exclusively before starting to burn
Also reprobe medium after blanking
* src/brasero-io.c (brasero_io_image_directory_contents_thread):
* src/burn-drive.c (brasero_drive_is_door_open),
(brasero_drive_can_use_exclusively):
* src/burn-drive.h:
* src/burn-medium.c (brasero_medium_probe_thread):
* src/burn.c (brasero_burn_reprobe),
(brasero_burn_can_use_drive_exclusively),
(brasero_burn_run_recorder), (brasero_burn_run_tasks),
(brasero_burn_record_session):
* src/plugins/checksum/burn-checksum-files.c
(brasero_checksum_files_merge_with_former_session):
* src/scsi-cam.c (brasero_device_handle_open):
* src/scsi-device.h:
* src/scsi-sg.c (brasero_device_handle_open):
* src/scsi-uscsi.c (brasero_device_handle_open):
Modified:
trunk/ChangeLog
trunk/src/brasero-io.c
trunk/src/burn-drive.c
trunk/src/burn-drive.h
trunk/src/burn-medium.c
trunk/src/burn.c
trunk/src/plugins/checksum/burn-checksum-files.c
trunk/src/scsi-cam.c
trunk/src/scsi-device.h
trunk/src/scsi-sg.c
trunk/src/scsi-uscsi.c
Modified: trunk/src/brasero-io.c
==============================================================================
--- trunk/src/brasero-io.c (original)
+++ trunk/src/brasero-io.c Wed Oct 29 14:44:26 2008
@@ -2031,7 +2031,7 @@
GError *error = NULL;
BraseroVolSrc *vol;
- handle = brasero_device_handle_open (data->job.uri, NULL);
+ handle = brasero_device_handle_open (data->job.uri, FALSE, NULL);
vol = brasero_volume_source_open_device_handle (handle, &error);
if (!vol) {
brasero_device_handle_close (handle);
Modified: trunk/src/burn-drive.c
==============================================================================
--- trunk/src/burn-drive.c (original)
+++ trunk/src/burn-drive.c Wed Oct 29 14:44:26 2008
@@ -148,7 +148,7 @@
if (!priv->udi)
return FALSE;
- handle = brasero_device_handle_open (priv->path, NULL);
+ handle = brasero_device_handle_open (priv->path, FALSE, NULL);
if (!handle)
return FALSE;
@@ -162,6 +162,27 @@
}
gboolean
+brasero_drive_can_use_exclusively (BraseroDrive *self)
+{
+ BraseroDeviceHandle *handle;
+ BraseroScsiErrCode code = 0;
+ const gchar *device;
+
+#if defined(HAVE_STRUCT_USCSI_CMD)
+ device = brasero_drive_get_block_device (self);
+#else
+ device = brasero_drive_get_device (self);
+#endif
+
+ handle = brasero_device_handle_open (device, TRUE, NULL);
+ if (!handle)
+ return FALSE;
+
+ brasero_device_handle_close (handle);
+ return TRUE;
+}
+
+gboolean
brasero_drive_lock (BraseroDrive *self,
const gchar *reason,
gchar **reason_for_failure)
Modified: trunk/src/burn-drive.h
==============================================================================
--- trunk/src/burn-drive.h (original)
+++ trunk/src/burn-drive.h Wed Oct 29 14:44:26 2008
@@ -107,6 +107,9 @@
brasero_drive_is_door_open (BraseroDrive *drive);
gboolean
+brasero_drive_can_use_exclusively (BraseroDrive *drive);;
+
+gboolean
brasero_drive_lock (BraseroDrive *drive,
const gchar *reason,
gchar **reason_for_failure);
Modified: trunk/src/burn-medium.c
==============================================================================
--- trunk/src/burn-medium.c (original)
+++ trunk/src/burn-medium.c Wed Oct 29 14:44:26 2008
@@ -2937,7 +2937,7 @@
* but we re-try to open it every second */
BRASERO_BURN_LOG ("Trying to open device %s", path);
- handle = brasero_device_handle_open (path, &code);
+ handle = brasero_device_handle_open (path, FALSE, &code);
while (!handle && counter <= BRASERO_MEDIUM_OPEN_ATTEMPTS) {
sleep (1);
@@ -2947,7 +2947,7 @@
}
counter ++;
- handle = brasero_device_handle_open (path, &code);
+ handle = brasero_device_handle_open (path, FALSE, &code);
}
if (priv->probe_cancelled) {
Modified: trunk/src/burn.c
==============================================================================
--- trunk/src/burn.c (original)
+++ trunk/src/burn.c Wed Oct 29 14:44:26 2008
@@ -32,6 +32,10 @@
#include <stdio.h>
#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
#include <glib.h>
#include <glib-object.h>
#include <glib/gi18n-lib.h>
@@ -239,64 +243,20 @@
}
static BraseroBurnResult
-brasero_burn_wait_for_dest_insertion (BraseroBurn *burn,
- GError **error)
+brasero_burn_reprobe (BraseroBurn *burn)
{
- BraseroBurnPrivate *priv = BRASERO_BURN_PRIVATE (burn);
BraseroMedium *medium;
- guint attempt = 0;
- gchar *failure;
-
- BRASERO_BURN_LOG ("Waiting for destination disc");
- if (!priv->dest)
- return BRASERO_BURN_OK;
-
- /* we need to release our lock */
- if (priv->dest_locked) {
- priv->dest_locked = 0;
- if (!brasero_drive_unlock (priv->dest)) {
- gchar *name;
-
- name = brasero_drive_get_display_name (priv->dest);
- g_set_error (error,
- BRASERO_BURN_ERROR,
- BRASERO_BURN_ERROR_GENERAL,
- _("\"%s\" can't be unlocked"),
- name);
- g_free (name);
- return BRASERO_BURN_ERR;
- }
- }
-
- medium = brasero_drive_get_medium (priv->dest);
- while (brasero_medium_get_status (medium) == BRASERO_MEDIUM_NONE) {
- brasero_burn_sleep (burn, LOAD_TIMEOUT);
-
- attempt ++;
- if (attempt > MAX_LOAD_ATTEMPTS) {
- g_set_error (error,
- BRASERO_BURN_ERROR,
- BRASERO_BURN_ERROR_GENERAL,
- _("the disc could not be reloaded (max attemps reached)"));
- return BRASERO_BURN_ERR;
- }
+ BraseroBurnPrivate *priv;
+ BraseroBurnResult result = BRASERO_BURN_OK;
- medium = brasero_drive_get_medium (priv->dest);
- }
+ priv = BRASERO_BURN_PRIVATE (burn);
- /* Re-add the lock */
- if (!priv->dest_locked
- && !brasero_drive_lock (priv->dest, _("ongoing burning process"), &failure)) {
- g_set_error (error,
- BRASERO_BURN_ERROR,
- BRASERO_BURN_ERROR_GENERAL,
- _("the drive can't be locked (%s)"),
- failure);
- return BRASERO_BURN_ERR;
- }
- priv->dest_locked = 1;
+ /* reprobe the medium and wait for it to be probed */
+ brasero_drive_reprobe (priv->dest);
+ while (!(medium = brasero_drive_get_medium (priv->dest)))
+ result = brasero_burn_sleep (burn, 250);
- return BRASERO_BURN_OK;
+ return result;
}
static BraseroBurnResult
@@ -1462,6 +1422,25 @@
}
static BraseroBurnResult
+brasero_burn_can_use_drive_exclusively (BraseroBurn *burn,
+ BraseroDrive *drive)
+{
+ BraseroBurnResult result;
+
+ if (!drive)
+ return BRASERO_BURN_OK;
+
+ while (!brasero_drive_can_use_exclusively (drive)) {
+ BRASERO_BURN_LOG ("Device busy, retrying in 250 ms");
+ result = brasero_burn_sleep (burn, 250);
+ if (result == BRASERO_BURN_CANCEL)
+ return result;
+ }
+
+ return BRASERO_BURN_OK;
+}
+
+static BraseroBurnResult
brasero_burn_run_recorder (BraseroBurn *burn, GError **error)
{
gint error_code;
@@ -1475,11 +1454,23 @@
BraseroBurnPrivate *priv = BRASERO_BURN_PRIVATE (burn);
has_slept = FALSE;
+
src = brasero_burn_session_get_src_drive (priv->session);
src_medium = brasero_drive_get_medium (src);
+
burner = brasero_burn_session_get_burner (priv->session);
burnt_medium = brasero_drive_get_medium (burner);
+ /* before we start let's see if that drive can be used exclusively.
+ * Of course, it's not really safe since a process could take a lock
+ * just after us but at least it'll give some time to HAL and friends
+ * to finish what they're doing.
+ * This was done because more than often backends wouldn't be able to
+ * get a lock on a medium after a simulation. */
+ result = brasero_burn_can_use_drive_exclusively (burn, burner);
+ if (result != BRASERO_BURN_OK)
+ return result;
+
start:
/* this is just in case */
@@ -1706,10 +1697,15 @@
priv->task = NULL;
priv->tasks_done ++;
- /* Now it can happen (like with dvd+rw-format) that for
- * the whole OS, the disc doesn't exist during the
+ /* Reprobe. It can happen (like with dvd+rw-format) that
+ * for the whole OS, the disc doesn't exist during the
* formatting. Wait for the disc to reappear */
- result = brasero_burn_wait_for_dest_insertion (burn, error);
+ /* Likewise, this is necessary when we do a
+ * simulation before blanking since it blanked the disc
+ * and then to create all tasks necessary for the real
+ * burning operation, we'll need the real medium status
+ * not to include a blanking job again. */
+ result = brasero_burn_reprobe (burn);
if (result != BRASERO_BURN_OK)
break;
@@ -2133,9 +2129,9 @@
return result;
/* reprobe the medium and wait for it to be probed */
- brasero_drive_reprobe (priv->dest);
- while (!(medium = brasero_drive_get_medium (priv->dest)))
- brasero_burn_sleep (burn, 1000);
+ result = brasero_burn_reprobe (burn);
+ if (result != BRASERO_BURN_OK)
+ return result;
if (type == BRASERO_CHECKSUM_MD5
|| type == BRASERO_CHECKSUM_SHA1
Modified: trunk/src/plugins/checksum/burn-checksum-files.c
==============================================================================
--- trunk/src/plugins/checksum/burn-checksum-files.c (original)
+++ trunk/src/plugins/checksum/burn-checksum-files.c Wed Oct 29 14:44:26 2008
@@ -380,7 +380,7 @@
/* try every file and make sure they are of the same type */
brasero_job_get_device (BRASERO_JOB (self), &device);
- dev_handle = brasero_device_handle_open (device, NULL);
+ dev_handle = brasero_device_handle_open (device, FALSE, NULL);
g_free (device);
vol = brasero_volume_source_open_device_handle (dev_handle, error);
Modified: trunk/src/scsi-cam.c
==============================================================================
--- trunk/src/scsi-cam.c (original)
+++ trunk/src/scsi-cam.c Wed Oct 29 14:44:26 2008
@@ -148,22 +148,39 @@
BraseroDeviceHandle *
brasero_device_handle_open (const gchar *path,
+ gboolean exclusive,
BraseroScsiErrCode *code)
{
int fd;
+ int flags = OPEN_FLAGS;
BraseroDeviceHandle *handle;
struct cam_device *cam;
g_assert (path != NULL);
+ if (exclusive)
+ flags |= O_EXCL;
+
/* cam_open_device() fails unless we use O_RDWR */
cam = cam_open_device (path, O_RDWR);
- fd = open (path, OPEN_FLAGS);
+ fd = open (path, flags);
if (cam && fd > -1) {
handle = g_new0 (BraseroDeviceHandle, 1);
handle->cam = cam;
handle->fd = fd;
}
+ else {
+ if (code) {
+ if (errno == EAGAIN
+ || errno == EWOULDBLOCK
+ || errno == EBUSY)
+ *code = BRASERO_SCSI_NOT_READY;
+ else
+ *code = BRASERO_SCSI_ERRNO;
+ }
+
+ return NULL;
+ }
return handle;
}
Modified: trunk/src/scsi-device.h
==============================================================================
--- trunk/src/scsi-device.h (original)
+++ trunk/src/scsi-device.h Wed Oct 29 14:44:26 2008
@@ -34,7 +34,9 @@
typedef struct _BraseroDeviceHandle BraseroDeviceHandle;
BraseroDeviceHandle *
-brasero_device_handle_open (const gchar *path, BraseroScsiErrCode *error);
+brasero_device_handle_open (const gchar *path,
+ gboolean exclusive,
+ BraseroScsiErrCode *error);
void
brasero_device_handle_close (BraseroDeviceHandle *handle);
Modified: trunk/src/scsi-sg.c
==============================================================================
--- trunk/src/scsi-sg.c (original)
+++ trunk/src/scsi-sg.c Wed Oct 29 14:44:26 2008
@@ -157,19 +157,26 @@
BraseroDeviceHandle *
brasero_device_handle_open (const gchar *path,
+ gboolean exclusive,
BraseroScsiErrCode *code)
{
int fd;
+ int flags = OPEN_FLAGS;
BraseroDeviceHandle *handle;
- fd = open (path, OPEN_FLAGS);
+ if (exclusive)
+ flags |= O_EXCL;
+
+ fd = open (path, flags);
if (fd < 0) {
- if (errno == EAGAIN
- || errno == EWOULDBLOCK
- || errno == EBUSY)
- *code = BRASERO_SCSI_NOT_READY;
- else
- *code = BRASERO_SCSI_ERRNO;
+ if (code) {
+ if (errno == EAGAIN
+ || errno == EWOULDBLOCK
+ || errno == EBUSY)
+ *code = BRASERO_SCSI_NOT_READY;
+ else
+ *code = BRASERO_SCSI_ERRNO;
+ }
return NULL;
}
Modified: trunk/src/scsi-uscsi.c
==============================================================================
--- trunk/src/scsi-uscsi.c (original)
+++ trunk/src/scsi-uscsi.c Wed Oct 29 14:44:26 2008
@@ -191,20 +191,27 @@
BraseroDeviceHandle *
brasero_device_handle_open (const gchar *path,
+ gboolean exclusive,
BraseroScsiErrCode *code)
{
int fd;
+ int flags = OPEN_FLAGS;
BraseroDeviceHandle *handle;
gchar *rawdisk = NULL;
- fd = open (path, OPEN_FLAGS);
+ if (exclusive)
+ flags |= O_EXCL;
+
+ fd = open (path, flags);
if (fd < 0) {
- if (errno == EAGAIN
- || errno == EWOULDBLOCK
- || errno == EBUSY)
- *code = BRASERO_SCSI_NOT_READY;
- else
- *code = BRASERO_SCSI_ERRNO;
+ if (code) {
+ if (errno == EAGAIN
+ || errno == EWOULDBLOCK
+ || errno == EBUSY)
+ *code = BRASERO_SCSI_NOT_READY;
+ else
+ *code = BRASERO_SCSI_ERRNO;
+ }
DEBUG("open ERR: %s\n", g_strerror(errno));
return NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]