brasero r634 - in trunk: . po src src/scsi
- From: philippr svn gnome org
- To: svn-commits-list gnome org
- Subject: brasero r634 - in trunk: . po src src/scsi
- Date: Mon, 11 Feb 2008 19:23:04 +0000 (GMT)
Author: philippr
Date: Mon Feb 11 19:23:03 2008
New Revision: 634
URL: http://svn.gnome.org/viewvc/brasero?rev=634&view=rev
Log:
A few changes to support new OS more easily
* configure.in:
* src/Makefile.am:
* src/burn-medium.c: (brasero_medium_get_capacity_CD_RW),
(brasero_medium_get_capacity_DVD_RW),
(brasero_medium_get_capacity_by_type),
(brasero_medium_get_speed_mmc3),
(brasero_medium_get_page_2A_write_speed_desc),
(brasero_medium_get_page_2A_max_speed),
(brasero_medium_get_medium_type), (brasero_medium_get_css_feature),
(brasero_medium_track_volume_size),
(brasero_medium_track_get_info), (brasero_medium_check_BCD_use),
(brasero_medium_get_CD_sessions_info),
(brasero_medium_get_sessions_info), (brasero_medium_get_contents),
(brasero_medium_init_real), (brasero_medium_retry_open),
(brasero_medium_try_open):
* src/scsi-base.h:
* src/scsi-command.h:
* src/scsi-device.h:
* src/scsi-error.c:
* src/scsi-get-configuration.c:
(brasero_mmc2_get_configuration_feature):
* src/scsi-get-performance.c:
(brasero_mmc3_get_performance_wrt_spd_desc):
* src/scsi-mmc1.h:
* src/scsi-mmc2.h:
* src/scsi-mmc3.h:
* src/scsi-mode-pages.h:
* src/scsi-mode-sense.c: (brasero_spc1_mode_sense_get_page):
* src/scsi-read-capacity.c: (brasero_mmc2_read_capacity):
* src/scsi-read-disc-info.c:
(brasero_mmc1_read_disc_information_std),
(brasero_mmc5_read_disc_information_tracks),
(brasero_mmc5_read_disc_information_pows):
* src/scsi-read-disc-structure.c:
(brasero_mmc2_read_generic_structure),
(brasero_mmc2_read_dvd_structure),
(brasero_mmc5_read_bd_structure):
* src/scsi-read-format-capacities.c:
(brasero_mmc2_read_format_capacities):
* src/scsi-read-toc-pma-atip.c: (brasero_mmc1_read_toc_formatted),
(brasero_mmc1_read_toc_raw), (brasero_mmc3_read_cd_text),
(brasero_mmc1_read_atip):
* src/scsi-read-track-information.c:
(brasero_mmc1_read_track_info):
* src/scsi-sg.c: (brasero_sg_command_setup),
(brasero_scsi_command_issue_sync), (brasero_scsi_command_new),
(brasero_scsi_command_free), (brasero_device_handle_open),
(brasero_device_handle_close), (brasero_device_handle_get_fd):
* src/scsi-spc1.h:
* src/scsi/scsi-base.h:
* src/scsi/scsi-command.c:
* src/scsi/scsi-command.h:
* src/scsi/scsi-dvd-structures.h:
* src/scsi/scsi-error.c:
* src/scsi/scsi-error.h:
* src/scsi/scsi-get-configuration.c:
* src/scsi/scsi-get-configuration.h:
* src/scsi/scsi-get-performance.c:
* src/scsi/scsi-get-performance.h:
* src/scsi/scsi-mmc1.h:
* src/scsi/scsi-mmc2.h:
* src/scsi/scsi-mmc3.h:
* src/scsi/scsi-mode-pages.h:
* src/scsi/scsi-mode-sense.c:
* src/scsi/scsi-opcodes.h:
* src/scsi/scsi-q-subchannel.h:
* src/scsi/scsi-read-capacity.c:
* src/scsi/scsi-read-capacity.h:
* src/scsi/scsi-read-disc-info.c:
* src/scsi/scsi-read-disc-info.h:
* src/scsi/scsi-read-disc-structure.c:
* src/scsi/scsi-read-disc-structure.h:
* src/scsi/scsi-read-format-capacities.c:
* src/scsi/scsi-read-format-capacities.h:
* src/scsi/scsi-read-toc-pma-atip.c:
* src/scsi/scsi-read-toc-pma-atip.h:
* src/scsi/scsi-read-track-information.c:
* src/scsi/scsi-read-track-information.h:
* src/scsi/scsi-sense-data.c:
* src/scsi/scsi-sense-data.h:
* src/scsi/scsi-sg.c:
* src/scsi/scsi-sg.h:
* src/scsi/scsi-spc1.h:
* src/scsi/scsi-status-page.h:
* src/scsi/scsi-utils.h:
Added:
trunk/src/scsi-base.h
- copied, changed from r632, /trunk/src/scsi/scsi-base.h
trunk/src/scsi-command.h
- copied, changed from r632, /trunk/src/scsi/scsi-command.h
trunk/src/scsi-device.h
trunk/src/scsi-dvd-structures.h
- copied unchanged from r632, /trunk/src/scsi/scsi-dvd-structures.h
trunk/src/scsi-error.c
- copied, changed from r632, /trunk/src/scsi/scsi-error.c
trunk/src/scsi-error.h
- copied unchanged from r632, /trunk/src/scsi/scsi-error.h
trunk/src/scsi-get-configuration.c
- copied, changed from r632, /trunk/src/scsi/scsi-get-configuration.c
trunk/src/scsi-get-configuration.h
- copied unchanged from r632, /trunk/src/scsi/scsi-get-configuration.h
trunk/src/scsi-get-performance.c
- copied, changed from r632, /trunk/src/scsi/scsi-get-performance.c
trunk/src/scsi-get-performance.h
- copied unchanged from r632, /trunk/src/scsi/scsi-get-performance.h
trunk/src/scsi-mmc1.h
- copied, changed from r632, /trunk/src/scsi/scsi-mmc1.h
trunk/src/scsi-mmc2.h
- copied, changed from r632, /trunk/src/scsi/scsi-mmc2.h
trunk/src/scsi-mmc3.h
- copied, changed from r632, /trunk/src/scsi/scsi-mmc3.h
trunk/src/scsi-mode-pages.h
trunk/src/scsi-mode-sense.c
- copied, changed from r632, /trunk/src/scsi/scsi-mode-sense.c
trunk/src/scsi-opcodes.h
- copied unchanged from r632, /trunk/src/scsi/scsi-opcodes.h
trunk/src/scsi-q-subchannel.h
- copied unchanged from r632, /trunk/src/scsi/scsi-q-subchannel.h
trunk/src/scsi-read-capacity.c
- copied, changed from r632, /trunk/src/scsi/scsi-read-capacity.c
trunk/src/scsi-read-capacity.h
- copied unchanged from r632, /trunk/src/scsi/scsi-read-capacity.h
trunk/src/scsi-read-disc-info.c
- copied, changed from r632, /trunk/src/scsi/scsi-read-disc-info.c
trunk/src/scsi-read-disc-info.h
- copied unchanged from r632, /trunk/src/scsi/scsi-read-disc-info.h
trunk/src/scsi-read-disc-structure.c
- copied, changed from r632, /trunk/src/scsi/scsi-read-disc-structure.c
trunk/src/scsi-read-disc-structure.h
- copied unchanged from r632, /trunk/src/scsi/scsi-read-disc-structure.h
trunk/src/scsi-read-format-capacities.c
- copied, changed from r632, /trunk/src/scsi/scsi-read-format-capacities.c
trunk/src/scsi-read-format-capacities.h
- copied unchanged from r632, /trunk/src/scsi/scsi-read-format-capacities.h
trunk/src/scsi-read-toc-pma-atip.c
- copied, changed from r632, /trunk/src/scsi/scsi-read-toc-pma-atip.c
trunk/src/scsi-read-toc-pma-atip.h
- copied unchanged from r632, /trunk/src/scsi/scsi-read-toc-pma-atip.h
trunk/src/scsi-read-track-information.c
- copied, changed from r632, /trunk/src/scsi/scsi-read-track-information.c
trunk/src/scsi-read-track-information.h
- copied unchanged from r632, /trunk/src/scsi/scsi-read-track-information.h
trunk/src/scsi-sense-data.c
- copied unchanged from r632, /trunk/src/scsi/scsi-sense-data.c
trunk/src/scsi-sense-data.h
- copied unchanged from r632, /trunk/src/scsi/scsi-sense-data.h
trunk/src/scsi-sg.c
- copied, changed from r632, /trunk/src/scsi/scsi-sg.c
trunk/src/scsi-spc1.h
- copied, changed from r632, /trunk/src/scsi/scsi-spc1.h
trunk/src/scsi-status-page.h
- copied unchanged from r632, /trunk/src/scsi/scsi-status-page.h
trunk/src/scsi-utils.h
- copied unchanged from r632, /trunk/src/scsi/scsi-utils.h
Removed:
trunk/src/scsi/
Modified:
trunk/ChangeLog
trunk/configure.in
trunk/po/ChangeLog
trunk/po/POTFILES.in
trunk/src/Makefile.am
trunk/src/burn-medium.c
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Mon Feb 11 19:23:03 2008
@@ -38,6 +38,17 @@
AM_PROG_CC_STDC
AC_HEADER_STDC
+dnl ***************** SCSI related *****************************
+
+dnl ***************** check for linux sg interface *************
+AC_CHECK_TYPES([sg_io_hdr_t],[has_sg="yes"],[has_sg="no"],
+[#include <sys/types.h>
+ #include <scsi/sg.h>])
+
+if test x"$has_sg" = "xno"; then
+ AC_ERROR([Linux sg interface headers could not be found])
+fi
+
dnl ***************** LARGE FILE SUPPORT ***********************
AC_SYS_LARGEFILE
Modified: trunk/po/POTFILES.in
==============================================================================
--- trunk/po/POTFILES.in (original)
+++ trunk/po/POTFILES.in Mon Feb 11 19:23:03 2008
@@ -71,7 +71,7 @@
src/plugins/libburnia/burn-libread-disc.c
src/plugins/local-track/burn-local-image.c
src/plugins/transcode/burn-transcode.c
-src/scsi/scsi-error.c
+src/scsi-error.c
src/brasero-preview.c
src/brasero-split-dialog.c
src/brasero-time-button.c
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Mon Feb 11 19:23:03 2008
@@ -9,8 +9,6 @@
INCLUDES = \
-I$(top_srcdir) \
-I$(top_builddir) \
- -I./scsi \
- -I./md5 \
-DBRASERO_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
-DBRASERO_PREFIX=\"$(prefix)\" \
-DBRASERO_SYSCONFDIR=\"$(sysconfdir)\" \
@@ -136,42 +134,40 @@
burn-iso-field.h \
burn-medium.h \
burn-medium.c \
- scsi/scsi-base.h \
- scsi/scsi-command.c \
- scsi/scsi-command.h \
- scsi/scsi-error.h \
- scsi/scsi-get-configuration.c \
- scsi/scsi-get-configuration.h \
- scsi/scsi-mmc1.h \
- scsi/scsi-mmc2.h \
- scsi/scsi-opcodes.h \
- scsi/scsi-read-disc-info.c \
- scsi/scsi-read-disc-info.h \
- scsi/scsi-read-toc-pma-atip.c \
- scsi/scsi-read-toc-pma-atip.h \
- scsi/scsi-sense-data.c \
- scsi/scsi-sense-data.h \
- scsi/scsi-sg.c \
- scsi/scsi-sg.h \
- scsi/scsi-utils.h \
- scsi/scsi-q-subchannel.h \
- scsi/scsi-error.c \
- scsi/scsi-read-track-information.c \
- scsi/scsi-read-track-information.h \
- scsi/scsi-get-performance.c \
- scsi/scsi-get-performance.h \
- scsi/scsi-mmc3.h \
- scsi/scsi-mode-pages.h \
- scsi/scsi-mode-sense.c \
- scsi/scsi-status-page.h \
- scsi/scsi-spc1.h \
- scsi/scsi-read-capacity.c \
- scsi/scsi-read-capacity.h \
- scsi/scsi-read-disc-structure.c \
- scsi/scsi-read-disc-structure.h \
- scsi/scsi-dvd-structures.h \
- scsi/scsi-read-format-capacities.c \
- scsi/scsi-read-format-capacities.h \
+ scsi-base.h \
+ scsi-command.h \
+ scsi-error.h \
+ scsi-get-configuration.c \
+ scsi-get-configuration.h \
+ scsi-mmc1.h \
+ scsi-mmc2.h \
+ scsi-opcodes.h \
+ scsi-read-disc-info.c \
+ scsi-read-disc-info.h \
+ scsi-read-toc-pma-atip.c \
+ scsi-read-toc-pma-atip.h \
+ scsi-sense-data.c \
+ scsi-sense-data.h \
+ scsi-sg.c \
+ scsi-utils.h \
+ scsi-q-subchannel.h \
+ scsi-error.c \
+ scsi-read-track-information.c \
+ scsi-read-track-information.h \
+ scsi-get-performance.c \
+ scsi-get-performance.h \
+ scsi-mmc3.h \
+ scsi-mode-pages.h \
+ scsi-mode-sense.c \
+ scsi-status-page.h \
+ scsi-spc1.h \
+ scsi-read-capacity.c \
+ scsi-read-capacity.h \
+ scsi-read-disc-structure.c \
+ scsi-read-disc-structure.h \
+ scsi-dvd-structures.h \
+ scsi-read-format-capacities.c \
+ scsi-read-format-capacities.h \
burn-debug.c \
burn-debug.h \
burn-track.h \
@@ -237,9 +233,11 @@
brasero-disc-message.h \
brasero-disc-message.c \
baobab-cell-renderer-progress.c \
- baobab-cell-renderer-progress.h
+ baobab-cell-renderer-progress.h \
+ scsi-device.h
-brasero_LDADD = $(BRASERO_LIBS)
+brasero_LDADD = \
+ $(BRASERO_LIBS)
Modified: trunk/src/burn-medium.c
==============================================================================
--- trunk/src/burn-medium.c (original)
+++ trunk/src/burn-medium.c Mon Feb 11 19:23:03 2008
@@ -39,6 +39,8 @@
#include "burn-basics.h"
#include "burn-debug.h"
#include "burn-medium.h"
+
+#include "scsi-device.h"
#include "scsi-mmc1.h"
#include "scsi-mmc2.h"
#include "scsi-mmc3.h"
@@ -113,7 +115,6 @@
* No exclusive at the moment since when the medium is mounted we can't use excl
*/
-#define OPEN_FLAGS O_RDONLY /*|O_EXCL */|O_NONBLOCK
#define BUSY_RETRY_TIME 1000
enum
@@ -511,7 +512,7 @@
static BraseroBurnResult
brasero_medium_get_capacity_CD_RW (BraseroMedium *self,
- int fd,
+ BraseroDeviceHandle *handle,
BraseroScsiErrCode *code)
{
BraseroScsiAtipData *atip_data = NULL;
@@ -523,7 +524,7 @@
BRASERO_BURN_LOG ("Retrieving capacity from atip");
- result = brasero_mmc1_read_atip (fd,
+ result = brasero_mmc1_read_atip (handle,
&atip_data,
&size,
NULL);
@@ -556,7 +557,7 @@
static BraseroBurnResult
brasero_medium_get_capacity_DVD_RW (BraseroMedium *self,
- int fd,
+ BraseroDeviceHandle *handle,
BraseroScsiErrCode *code)
{
BraseroScsiFormatCapacitiesHdr *hdr = NULL;
@@ -568,7 +569,7 @@
BRASERO_BURN_LOG ("Retrieving format capacity");
priv = BRASERO_MEDIUM_PRIVATE (self);
- result = brasero_mmc2_read_format_capacities (fd,
+ result = brasero_mmc2_read_format_capacities (handle,
&hdr,
&size,
code);
@@ -626,7 +627,7 @@
static BraseroBurnResult
brasero_medium_get_capacity_by_type (BraseroMedium *self,
- int fd,
+ BraseroDeviceHandle *handle,
BraseroScsiErrCode *code)
{
BraseroMediumPrivate *priv;
@@ -639,9 +640,9 @@
return BRASERO_BURN_OK;
if (priv->info & BRASERO_MEDIUM_CD)
- brasero_medium_get_capacity_CD_RW (self, fd, code);
+ brasero_medium_get_capacity_CD_RW (self, handle, code);
else
- brasero_medium_get_capacity_DVD_RW (self, fd, code);
+ brasero_medium_get_capacity_DVD_RW (self, handle, code);
return BRASERO_BURN_OK;
}
@@ -652,7 +653,7 @@
static BraseroBurnResult
brasero_medium_get_speed_mmc3 (BraseroMedium *self,
- int fd,
+ BraseroDeviceHandle *handle,
BraseroScsiErrCode *code)
{
int size;
@@ -668,7 +669,7 @@
/* NOTE: this only work if there is RT streaming feature with
* wspd bit set to 1. At least an MMC3 drive. */
priv = BRASERO_MEDIUM_PRIVATE (self);
- result = brasero_mmc3_get_performance_wrt_spd_desc (fd,
+ result = brasero_mmc3_get_performance_wrt_spd_desc (handle,
&wrt_perf,
&size,
code);
@@ -719,7 +720,7 @@
static BraseroBurnResult
brasero_medium_get_page_2A_write_speed_desc (BraseroMedium *self,
- int fd,
+ BraseroDeviceHandle *handle,
BraseroScsiErrCode *code)
{
BraseroScsiStatusPage *page_2A = NULL;
@@ -735,7 +736,7 @@
BRASERO_BURN_LOG ("Retrieving speed (2A speeds)");
priv = BRASERO_MEDIUM_PRIVATE (self);
- result = brasero_spc1_mode_sense_get_page (fd,
+ result = brasero_spc1_mode_sense_get_page (handle,
BRASERO_SPC_PAGE_STATUS,
&data,
&size,
@@ -789,7 +790,7 @@
static BraseroBurnResult
brasero_medium_get_page_2A_max_speed (BraseroMedium *self,
- int fd,
+ BraseroDeviceHandle *handle,
BraseroScsiErrCode *code)
{
BraseroScsiStatusPage *page_2A = NULL;
@@ -802,7 +803,7 @@
priv = BRASERO_MEDIUM_PRIVATE (self);
- result = brasero_spc1_mode_sense_get_page (fd,
+ result = brasero_spc1_mode_sense_get_page (handle,
BRASERO_SPC_PAGE_STATUS,
&data,
&size,
@@ -832,7 +833,7 @@
static BraseroBurnResult
brasero_medium_get_medium_type (BraseroMedium *self,
- int fd,
+ BraseroDeviceHandle *handle,
BraseroScsiErrCode *code)
{
BraseroScsiGetConfigHdr *hdr = NULL;
@@ -843,7 +844,7 @@
BRASERO_BURN_LOG ("Retrieving media profile");
priv = BRASERO_MEDIUM_PRIVATE (self);
- result = brasero_mmc2_get_configuration_feature (fd,
+ result = brasero_mmc2_get_configuration_feature (handle,
BRASERO_SCSI_FEAT_REAL_TIME_STREAM,
&hdr,
&size,
@@ -864,7 +865,7 @@
* read TocPmaAtip. It if fails that's a ROM, if it succeeds.
* No need to set error code since we consider that it's a ROM
* if a failure happens. */
- result = brasero_mmc1_read_atip (fd,
+ result = brasero_mmc1_read_atip (handle,
&data,
&size,
NULL);
@@ -902,7 +903,7 @@
/* retrieve the speed */
result = brasero_medium_get_page_2A_max_speed (self,
- fd,
+ handle,
code);
return result;
}
@@ -1041,20 +1042,20 @@
/* means it's at least an MMC3 drive */
stream = (BraseroScsiRTStreamDesc *) hdr->desc->data;
if (stream->wrt_spd) {
- result = brasero_medium_get_speed_mmc3 (self, fd, code);
+ result = brasero_medium_get_speed_mmc3 (self, handle, code);
if (result == BRASERO_BURN_OK)
goto end;
}
if (stream->mp2a) {
- result = brasero_medium_get_page_2A_write_speed_desc (self, fd, code);
+ result = brasero_medium_get_page_2A_write_speed_desc (self, handle, code);
if (result == BRASERO_BURN_OK)
goto end;
}
}
/* fallback for speeds */
- result = brasero_medium_get_page_2A_max_speed (self, fd, code);
+ result = brasero_medium_get_page_2A_max_speed (self, handle, code);
end:
@@ -1068,7 +1069,7 @@
static BraseroBurnResult
brasero_medium_get_css_feature (BraseroMedium *self,
- int fd,
+ BraseroDeviceHandle *handle,
BraseroScsiErrCode *code)
{
BraseroScsiGetConfigHdr *hdr = NULL;
@@ -1079,7 +1080,7 @@
priv = BRASERO_MEDIUM_PRIVATE (self);
BRASERO_BURN_LOG ("Testing for Css encrypted media");
- result = brasero_mmc2_get_configuration_feature (fd,
+ result = brasero_mmc2_get_configuration_feature (handle,
BRASERO_SCSI_FEAT_DVD_CSS,
&hdr,
&size,
@@ -1144,7 +1145,7 @@
static BraseroBurnResult
brasero_medium_track_volume_size (BraseroMedium *self,
BraseroMediumTrack *track,
- int fd)
+ BraseroDeviceHandle *handle)
{
BraseroMediumPrivate *priv;
BraseroBurnResult res;
@@ -1165,7 +1166,7 @@
* So we check if their first and only volume is valid.
* That's also used when the track size is reported a 300 Kio
* see below */
- res = brasero_volume_get_size_fd (fd,
+ res = brasero_volume_get_size_fd (brasero_device_handle_get_fd (handle),
track->start,
&nb_blocks,
NULL);
@@ -1187,7 +1188,7 @@
brasero_medium_track_get_info (BraseroMedium *self,
BraseroMediumTrack *track,
int track_num,
- int fd,
+ BraseroDeviceHandle *handle,
BraseroScsiErrCode *code)
{
BraseroScsiTrackInfo track_info;
@@ -1209,7 +1210,7 @@
else
size = 36;
- result = brasero_mmc1_read_track_info (fd,
+ result = brasero_mmc1_read_track_info (handle,
track_num,
&track_info,
&size,
@@ -1233,7 +1234,7 @@
* data size. */
if (track->blocks_num <= 300) {
BRASERO_BURN_LOG ("300 sectors size. Checking for real size");
- brasero_medium_track_volume_size (self, track, fd);
+ brasero_medium_track_volume_size (self, track, handle);
}
if (track_info.next_wrt_address_valid)
@@ -1256,7 +1257,7 @@
* 1 for HEX */
static guint
brasero_medium_check_BCD_use (BraseroMedium *self,
- int fd,
+ BraseroDeviceHandle *handle,
BraseroScsiRawTocDesc *desc,
guint num,
BraseroScsiErrCode *code)
@@ -1348,7 +1349,7 @@
start_LBA -= 150;
start_BCD -= 150;
- result = brasero_mmc1_read_track_info (fd,
+ result = brasero_mmc1_read_track_info (handle,
track_num,
&track_info,
&size,
@@ -1387,7 +1388,7 @@
size = 36;
/* leadout number is number of tracks + 1 */
- result = brasero_mmc1_read_track_info (fd,
+ result = brasero_mmc1_read_track_info (handle,
track_num + 1,
&track_info,
&size,
@@ -1421,7 +1422,7 @@
* this one. */
static BraseroBurnResult
brasero_medium_get_CD_sessions_info (BraseroMedium *self,
- int fd,
+ BraseroDeviceHandle *handle,
BraseroScsiErrCode *code)
{
gint use_bcd;
@@ -1438,7 +1439,7 @@
priv = BRASERO_MEDIUM_PRIVATE (self);
size = 0;
- result = brasero_mmc1_read_toc_raw (fd,
+ result = brasero_mmc1_read_toc_raw (handle,
0,
&toc,
&size,
@@ -1454,7 +1455,7 @@
BRASERO_BURN_LOG ("%i track(s) found", num);
desc = toc->desc;
- use_bcd = brasero_medium_check_BCD_use (self, fd, desc, num, code);
+ use_bcd = brasero_medium_check_BCD_use (self, handle, desc, num, code);
if (!use_bcd) {
g_free (toc);
@@ -1547,7 +1548,7 @@
track->start = leadout_start;
track->type = BRASERO_MEDIUM_TRACK_LEADOUT;
- brasero_medium_track_get_info (self, track, g_slist_length (priv->tracks), fd, code);
+ brasero_medium_track_get_info (self, track, g_slist_length (priv->tracks), handle, code);
}
priv->tracks = g_slist_reverse (priv->tracks);
@@ -1560,7 +1561,7 @@
/* check for tracks less that 300 sectors */
if (track->blocks_num <= 300 && track->type != BRASERO_MEDIUM_TRACK_LEADOUT) {
BRASERO_BURN_LOG ("300 sectors size. Checking for real size");
- brasero_medium_track_volume_size (self, track, fd);
+ brasero_medium_track_volume_size (self, track, handle);
}
BRASERO_BURN_LOG ("Track %i: type = %i start = %llu size = %llu",
@@ -1617,7 +1618,7 @@
static BraseroBurnResult
brasero_medium_get_sessions_info (BraseroMedium *self,
- int fd,
+ BraseroDeviceHandle *handle,
BraseroScsiErrCode *code)
{
int num, i, size;
@@ -1629,7 +1630,7 @@
BRASERO_BURN_LOG ("Reading Toc");
priv = BRASERO_MEDIUM_PRIVATE (self);
- result = brasero_mmc1_read_toc_formatted (fd,
+ result = brasero_mmc1_read_toc_formatted (handle,
0,
&toc,
&size,
@@ -1661,7 +1662,7 @@
brasero_medium_track_get_info (self,
track,
g_slist_length (priv->tracks),
- fd,
+ handle,
code);
if (desc->control & BRASERO_SCSI_TRACK_COPY)
@@ -1685,7 +1686,7 @@
* which have only one track: the first. */
result = brasero_medium_track_volume_size (self,
track,
- fd);
+ handle);
if (result == BRASERO_BURN_OK) {
track->type |= BRASERO_MEDIUM_TRACK_DATA;
priv->info |= BRASERO_MEDIUM_HAS_DATA;
@@ -1731,7 +1732,7 @@
brasero_medium_track_get_info (self,
track,
g_slist_length (priv->tracks),
- fd,
+ handle,
code);
}
@@ -1742,7 +1743,7 @@
static BraseroBurnResult
brasero_medium_get_contents (BraseroMedium *self,
- int fd,
+ BraseroDeviceHandle *handle,
BraseroScsiErrCode *code)
{
int size;
@@ -1754,7 +1755,7 @@
priv = BRASERO_MEDIUM_PRIVATE (self);
- result = brasero_mmc1_read_disc_information_std (fd,
+ result = brasero_mmc1_read_disc_information_std (handle,
&info,
&size,
code);
@@ -1788,7 +1789,7 @@
brasero_medium_track_get_info (self,
track,
1,
- fd,
+ handle,
code);
}
goto end;
@@ -1804,12 +1805,12 @@
}
if (priv->info & BRASERO_MEDIUM_CD) {
- result = brasero_medium_get_CD_sessions_info (self, fd, code);
+ result = brasero_medium_get_CD_sessions_info (self, handle, code);
if (result != BRASERO_BURN_OK)
- result = brasero_medium_get_sessions_info (self, fd, code);
+ result = brasero_medium_get_sessions_info (self, handle, code);
}
else
- result = brasero_medium_get_sessions_info (self, fd, code);
+ result = brasero_medium_get_sessions_info (self, handle, code);
if (result != BRASERO_BURN_OK)
goto end;
@@ -1821,7 +1822,8 @@
}
static void
-brasero_medium_init_real (BraseroMedium *object, int fd)
+brasero_medium_init_real (BraseroMedium *object,
+ BraseroDeviceHandle *handle)
{
gchar *name;
BraseroBurnResult result;
@@ -1834,20 +1836,20 @@
BRASERO_BURN_LOG ("Initializing information for medium in %s", name);
g_free (name);
- result = brasero_medium_get_medium_type (object, fd, &code);
+ result = brasero_medium_get_medium_type (object, handle, &code);
if (result != BRASERO_BURN_OK)
return;
- brasero_medium_get_capacity_by_type (object, fd, &code);
+ brasero_medium_get_capacity_by_type (object, handle, &code);
- result = brasero_medium_get_contents (object, fd, &code);
+ result = brasero_medium_get_contents (object, handle, &code);
if (result != BRASERO_BURN_OK)
return;
/* assume that css feature is only for DVD-ROM which might be wrong but
* some drives wrongly reports that css is enabled for blank DVD+R/W */
if (BRASERO_MEDIUM_IS (priv->info, (BRASERO_MEDIUM_DVD|BRASERO_MEDIUM_ROM)))
- brasero_medium_get_css_feature (object, fd, &code);
+ brasero_medium_get_css_feature (object, handle, &code);
BRASERO_BURN_LOG_DISC_TYPE (priv->info, "media is ");
}
@@ -1855,21 +1857,20 @@
static gboolean
brasero_medium_retry_open (gpointer object)
{
- int fd;
const gchar *path;
BraseroMedium *self;
+ BraseroScsiErrCode code;
BraseroMediumPrivate *priv;
+ BraseroDeviceHandle *handle;
self = BRASERO_MEDIUM (object);
priv = BRASERO_MEDIUM_PRIVATE (object);
path = nautilus_burn_drive_get_device (priv->drive);
BRASERO_BURN_LOG ("Retrying to open device %s", path);
- fd = open (path, OPEN_FLAGS);
- if (fd < 0) {
- if (errno == EBUSY
- || errno == EAGAIN
- || errno == EWOULDBLOCK) {
+ handle = brasero_device_handle_open (path, &code);
+ if (!handle) {
+ if (code == BRASERO_SCSI_NOT_READY) {
BRASERO_BURN_LOG ("Device busy");
/* we'll retry in a second */
return TRUE;
@@ -1887,8 +1888,8 @@
priv->retry_id = 0;
- brasero_medium_init_real (self, fd);
- close (fd);
+ brasero_medium_init_real (self, handle);
+ brasero_device_handle_close (handle);
return FALSE;
}
@@ -1896,9 +1897,10 @@
static void
brasero_medium_try_open (BraseroMedium *self)
{
- int fd;
const gchar *path;
+ BraseroScsiErrCode code;
BraseroMediumPrivate *priv;
+ BraseroDeviceHandle *handle;
priv = BRASERO_MEDIUM_PRIVATE (self);
path = nautilus_burn_drive_get_device (priv->drive);
@@ -1906,11 +1908,9 @@
/* the drive might be busy (a burning is going on) so we don't block
* but we re-try to open it every second */
BRASERO_BURN_LOG ("Trying to open device %s", path);
- fd = open (path, OPEN_FLAGS);
- if (fd < 0) {
- if (errno == EAGAIN
- || errno == EWOULDBLOCK
- || errno == EBUSY) {
+ handle = brasero_device_handle_open (path, &code);
+ if (!handle) {
+ if (code == BRASERO_SCSI_NOT_READY) {
BRASERO_BURN_LOG ("Device busy");
priv->info = BRASERO_MEDIUM_BUSY;
priv->icon = icons [0];
@@ -1925,8 +1925,8 @@
}
BRASERO_BURN_LOG ("Open () succeeded");
- brasero_medium_init_real (self, fd);
- close (fd);
+ brasero_medium_init_real (self, handle);
+ brasero_device_handle_close (handle);
}
static void
Copied: trunk/src/scsi-base.h (from r632, /trunk/src/scsi/scsi-base.h)
==============================================================================
--- /trunk/src/scsi/scsi-base.h (original)
+++ trunk/src/scsi-base.h Mon Feb 11 19:23:03 2008
@@ -22,11 +22,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA
*/
-#ifndef _SCSI_BASE_H
-#define _SCSI_BASE_H
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
#include <glib.h>
+#ifndef _SCSI_BASE_H
+#define _SCSI_BASE_H
+
G_BEGIN_DECLS
typedef unsigned char uchar;
Copied: trunk/src/scsi-command.h (from r632, /trunk/src/scsi/scsi-command.h)
==============================================================================
--- /trunk/src/scsi/scsi-command.h (original)
+++ trunk/src/scsi-command.h Mon Feb 11 19:23:03 2008
@@ -24,6 +24,7 @@
#include <glib.h>
+#include "scsi-device.h"
#include "scsi-error.h"
#include "scsi-utils.h"
#include "scsi-base.h"
@@ -31,10 +32,7 @@
#ifndef _BURN_SCSI_COMMAND_H
#define _BURN_SCSI_COMMAND_H
-#ifdef __cplusplus
-extern "C"
-{
-#endif
+G_BEGIN_DECLS
/* Most scsi commands are <= 16 (apparently some of the new mmc can be longer) */
#define BRASERO_SCSI_CMD_MAX_LEN 16
@@ -53,6 +51,8 @@
};
typedef struct _BraseroScsiCmdInfo BraseroScsiCmdInfo;
+typedef struct _BraseroScsiCmd BraseroScsiCmd;
+
#define BRASERO_SCSI_COMMAND_DEFINE(cdb, name, fd_flags, direction) \
static const BraseroScsiCmdInfo info = \
{ /* SCSI commands always end by 1 byte of ctl */ \
@@ -63,7 +63,8 @@
}
gpointer
-brasero_scsi_command_new (const BraseroScsiCmdInfo *info, int fd);
+brasero_scsi_command_new (const BraseroScsiCmdInfo *info,
+ BraseroDeviceHandle *handle);
BraseroScsiResult
brasero_scsi_command_free (gpointer command);
@@ -73,14 +74,7 @@
gpointer buffer,
int size,
BraseroScsiErrCode *error);
-BraseroScsiResult
-brasero_scsi_command_issue_immediate (gpointer command,
- gpointer buffer,
- int size,
- BraseroScsiErrCode *error);
-#ifdef __cplusplus
-}
-#endif
+G_END_DECLS
#endif /* _BURN_SCSI_COMMAND_H */
Added: trunk/src/scsi-device.h
==============================================================================
--- (empty file)
+++ trunk/src/scsi-device.h Mon Feb 11 19:23:03 2008
@@ -0,0 +1,49 @@
+/***************************************************************************
+ * scsi-device.h
+ *
+ * Mon Feb 11 16:55:05 2008
+ * Copyright 2008 Philippe Rouquier
+ * <bonfire-app wanadoo fr>
+ ****************************************************************************/
+
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA
+ */
+
+#ifndef _SCSI_DEVICE_H
+#define _SCSI_DEVICE_H
+
+#include <glib.h>
+
+#include "scsi-error.h"
+
+G_BEGIN_DECLS
+
+typedef struct _BraseroDeviceHandle BraseroDeviceHandle;
+
+BraseroDeviceHandle *
+brasero_device_handle_open (const gchar *path, BraseroScsiErrCode *error);
+
+void
+brasero_device_handle_close (BraseroDeviceHandle *handle);
+
+int
+brasero_device_handle_get_fd (BraseroDeviceHandle *handle);
+
+G_END_DECLS
+
+#endif /* _SCSI_DEVICE_H */
+
+
Copied: trunk/src/scsi-error.c (from r632, /trunk/src/scsi/scsi-error.c)
==============================================================================
--- /trunk/src/scsi/scsi-error.c (original)
+++ trunk/src/scsi-error.c Mon Feb 11 19:23:03 2008
@@ -24,7 +24,7 @@
#include <glib/gi18n-lib.h>
#include "burn-basics.h"
-#include "scsi/scsi-error.h"
+#include "scsi-error.h"
static const gchar *error_string [] = { N_("unknown error"),
N_("size mismatch"),
Copied: trunk/src/scsi-get-configuration.c (from r632, /trunk/src/scsi/scsi-get-configuration.c)
==============================================================================
--- /trunk/src/scsi/scsi-get-configuration.c (original)
+++ trunk/src/scsi-get-configuration.c Mon Feb 11 19:23:03 2008
@@ -149,7 +149,7 @@
}
BraseroScsiResult
-brasero_mmc2_get_configuration_feature (int fd,
+brasero_mmc2_get_configuration_feature (BraseroDeviceHandle *handle,
BraseroScsiFeatureType type,
BraseroScsiGetConfigHdr **data,
int *size,
@@ -161,7 +161,7 @@
g_return_val_if_fail (data != NULL, BRASERO_SCSI_FAILURE);
g_return_val_if_fail (size != NULL, BRASERO_SCSI_FAILURE);
- cdb = brasero_scsi_command_new (&info, fd);
+ cdb = brasero_scsi_command_new (&info, handle);
BRASERO_SET_16 (cdb->feature_num, type);
cdb->returned_data = BRASERO_GET_CONFIG_RETURN_ONLY_FEATURE;
Copied: trunk/src/scsi-get-performance.c (from r632, /trunk/src/scsi/scsi-get-performance.c)
==============================================================================
--- /trunk/src/scsi/scsi-get-performance.c (original)
+++ trunk/src/scsi-get-performance.c Mon Feb 11 19:23:03 2008
@@ -172,7 +172,7 @@
*/
BraseroScsiResult
-brasero_mmc3_get_performance_wrt_spd_desc (int fd,
+brasero_mmc3_get_performance_wrt_spd_desc (BraseroDeviceHandle *handle,
BraseroScsiGetPerfData **data,
int *size,
BraseroScsiErrCode *error)
@@ -180,7 +180,7 @@
BraseroGetPerformanceCDB *cdb;
BraseroScsiResult res;
- cdb = brasero_scsi_command_new (&info, fd);
+ cdb = brasero_scsi_command_new (&info, handle);
cdb->type = BRASERO_GET_PERFORMANCE_WR_SPEED_TYPE;
res = brasero_get_performance (cdb, sizeof (BraseroScsiWrtSpdDesc), data, size, error);
Copied: trunk/src/scsi-mmc1.h (from r632, /trunk/src/scsi/scsi-mmc1.h)
==============================================================================
--- /trunk/src/scsi/scsi-mmc1.h (original)
+++ trunk/src/scsi-mmc1.h Mon Feb 11 19:23:03 2008
@@ -22,6 +22,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA
*/
+#include <glib.h>
+
+#include "scsi-base.h"
+#include "scsi-device.h"
#include "scsi-error.h"
#include "scsi-read-disc-info.h"
#include "scsi-read-toc-pma-atip.h"
@@ -34,31 +38,31 @@
G_BEGIN_DECLS
BraseroScsiResult
-brasero_mmc1_read_disc_information_std (int fd,
+brasero_mmc1_read_disc_information_std (BraseroDeviceHandle *handle,
BraseroScsiDiscInfoStd **info_return,
int *size,
BraseroScsiErrCode *error);
BraseroScsiResult
-brasero_mmc1_read_toc_formatted (int fd,
+brasero_mmc1_read_toc_formatted (BraseroDeviceHandle *handle,
int track_num,
BraseroScsiFormattedTocData **data,
int *size,
BraseroScsiErrCode *error);
BraseroScsiResult
-brasero_mmc1_read_toc_raw (int fd,
+brasero_mmc1_read_toc_raw (BraseroDeviceHandle *handle,
int session_num,
BraseroScsiRawTocData **data,
int *size,
BraseroScsiErrCode *error);
BraseroScsiResult
-brasero_mmc1_read_atip (int fd,
+brasero_mmc1_read_atip (BraseroDeviceHandle *handle,
BraseroScsiAtipData **data,
int *size,
BraseroScsiErrCode *error);
BraseroScsiResult
-brasero_mmc1_read_track_info (int fd,
+brasero_mmc1_read_track_info (BraseroDeviceHandle *handle,
int track_num,
BraseroScsiTrackInfo *track_info,
int *size,
Copied: trunk/src/scsi-mmc2.h (from r632, /trunk/src/scsi/scsi-mmc2.h)
==============================================================================
--- /trunk/src/scsi/scsi-mmc2.h (original)
+++ trunk/src/scsi-mmc2.h Mon Feb 11 19:23:03 2008
@@ -22,6 +22,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA
*/
+#include <glib.h>
+
+#include "scsi-base.h"
#include "scsi-error.h"
#include "scsi-read-capacity.h"
#include "scsi-get-configuration.h"
@@ -34,27 +37,27 @@
G_BEGIN_DECLS
BraseroScsiResult
-brasero_mmc2_read_capacity (int fd,
+brasero_mmc2_read_capacity (BraseroDeviceHandle *handle,
BraseroScsiReadCapacityData *data,
int size,
BraseroScsiErrCode *error);
BraseroScsiResult
-brasero_mmc2_get_configuration_feature (int fd,
+brasero_mmc2_get_configuration_feature (BraseroDeviceHandle *handle,
BraseroScsiFeatureType type,
BraseroScsiGetConfigHdr **data,
int *size,
BraseroScsiErrCode *error);
BraseroScsiResult
-brasero_mmc2_read_generic_structure (int fd,
+brasero_mmc2_read_generic_structure (BraseroDeviceHandle *handle,
BraseroScsiGenericFormatType type,
BraseroScsiReadDiscStructureHdr **data,
int *size,
BraseroScsiErrCode *error);
BraseroScsiResult
-brasero_mmc2_read_format_capacities (int fd,
+brasero_mmc2_read_format_capacities (BraseroDeviceHandle *handle,
BraseroScsiFormatCapacitiesHdr **data,
int *size,
BraseroScsiErrCode *error);
Copied: trunk/src/scsi-mmc3.h (from r632, /trunk/src/scsi/scsi-mmc3.h)
==============================================================================
--- /trunk/src/scsi/scsi-mmc3.h (original)
+++ trunk/src/scsi-mmc3.h Mon Feb 11 19:23:03 2008
@@ -22,6 +22,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA
*/
+#include <glib.h>
+
+#include "scsi-base.h"
#include "scsi-error.h"
#include "scsi-get-performance.h"
#include "scsi-read-toc-pma-atip.h"
@@ -29,26 +32,21 @@
#ifndef _BURN_MMC3_H
#define _BURN_MMC3_H
-#ifdef __cplusplus
-extern "C"
-{
-#endif
+G_BEGIN_DECLS
BraseroScsiResult
-brasero_mmc3_read_cd_text (int fd,
+brasero_mmc3_read_cd_text (BraseroDeviceHandle *handle,
BraseroScsiCDTextData **data,
int *size,
BraseroScsiErrCode *error);
BraseroScsiResult
-brasero_mmc3_get_performance_wrt_spd_desc (int fd,
+brasero_mmc3_get_performance_wrt_spd_desc (BraseroDeviceHandle *handle,
BraseroScsiGetPerfData **data,
int *data_size,
BraseroScsiErrCode *error);
-#ifdef __cplusplus
-}
-#endif
+G_END_DECLS
#endif /* _BURN_MMC3_H */
Added: trunk/src/scsi-mode-pages.h
==============================================================================
--- (empty file)
+++ trunk/src/scsi-mode-pages.h Mon Feb 11 19:23:03 2008
@@ -0,0 +1,91 @@
+/***************************************************************************
+ * scsi-mode-pages.h
+ *
+ * Sat Oct 21 19:11:53 2006
+ * Copyright 2006 algernon
+ * <algernon localhost localdomain>
+ ****************************************************************************/
+
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA
+ */
+
+#include <glib.h>
+
+#include "scsi-base.h"
+
+#ifndef _SCSI_MODE_PAGES_H
+#define _SCSI_MODE_PAGES_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+
+struct _BraseroScsiModePage {
+ uchar code :6;
+ uchar reserved :1;
+ uchar ps :1;
+
+ uchar len;
+};
+
+#else
+
+struct _BraseroScsiModePage {
+ uchar ps :1;
+ uchar reserved :1;
+ uchar code :6;
+
+ uchar len;
+};
+
+#endif
+
+typedef struct _BraseroScsiModePage BraseroScsiModePage;
+
+struct _BraseroScsiModeHdr {
+ uchar len [2];
+ uchar medium_type :8;
+ uchar device_param :8;
+ uchar reserved [2];
+ uchar bdlen [2];
+};
+typedef struct _BraseroScsiModeHdr BraseroScsiModeHdr;
+
+struct _BraseroScsiModeData {
+ BraseroScsiModeHdr hdr;
+ BraseroScsiModePage page;
+};
+typedef struct _BraseroScsiModeData BraseroScsiModeData;
+
+/**
+ * Pages codes
+ */
+
+typedef enum {
+ BRASERO_SPC_PAGE_NULL = 0x00,
+ BRASERO_SPC_PAGE_STATUS = 0x2a,
+} BraseroSPCPageType;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SCSI_MODE-PAGES_H */
+
+
Copied: trunk/src/scsi-mode-sense.c (from r632, /trunk/src/scsi/scsi-mode-sense.c)
==============================================================================
--- /trunk/src/scsi/scsi-mode-sense.c (original)
+++ trunk/src/scsi-mode-sense.c Mon Feb 11 19:23:03 2008
@@ -89,7 +89,7 @@
#define BRASERO_MODE_DATA(data) ((BraseroScsiModeData *) (data))
BraseroScsiResult
-brasero_spc1_mode_sense_get_page (int fd,
+brasero_spc1_mode_sense_get_page (BraseroDeviceHandle *handle,
BraseroSPCPageType num,
BraseroScsiModeData **data,
int *data_size,
@@ -109,7 +109,7 @@
}
/* issue a first command to get the size of the page ... */
- cdb = brasero_scsi_command_new (&info, fd);
+ cdb = brasero_scsi_command_new (&info, handle);
cdb->dbd = 1;
cdb->page_code = num;
BRASERO_SET_16 (cdb->alloc_len, sizeof (header));
Copied: trunk/src/scsi-read-capacity.c (from r632, /trunk/src/scsi/scsi-read-capacity.c)
==============================================================================
--- /trunk/src/scsi/scsi-read-capacity.c (original)
+++ trunk/src/scsi-read-capacity.c Mon Feb 11 19:23:03 2008
@@ -76,7 +76,7 @@
BRASERO_SCSI_READ);
BraseroScsiResult
-brasero_mmc2_read_capacity (int fd,
+brasero_mmc2_read_capacity (BraseroDeviceHandle *handle,
BraseroScsiReadCapacityData *data,
int size,
BraseroScsiErrCode *error)
@@ -85,7 +85,7 @@
BraseroScsiResult res;
/* NOTE: all the fields are ignored by MM drives */
- cdb = brasero_scsi_command_new (&info, fd);
+ cdb = brasero_scsi_command_new (&info, handle);
memset (data, 0, size);
res = brasero_scsi_command_issue_sync (cdb, data, size, error);
Copied: trunk/src/scsi-read-disc-info.c (from r632, /trunk/src/scsi/scsi-read-disc-info.c)
==============================================================================
--- /trunk/src/scsi/scsi-read-disc-info.c (original)
+++ trunk/src/scsi-read-disc-info.c Mon Feb 11 19:23:03 2008
@@ -85,7 +85,7 @@
BraseroScsiResult
-brasero_mmc1_read_disc_information_std (int fd,
+brasero_mmc1_read_disc_information_std (BraseroDeviceHandle *handle,
BraseroScsiDiscInfoStd **info_return,
int *size,
BraseroScsiErrCode *error)
@@ -102,7 +102,7 @@
return BRASERO_SCSI_FAILURE;
}
- cdb = brasero_scsi_command_new (&info, fd);
+ cdb = brasero_scsi_command_new (&info, handle);
cdb->data_type = BRASERO_DISC_INFO_STD;
BRASERO_SET_16 (cdb->alloc_len, sizeof (BraseroScsiDiscInfoStd));
@@ -144,7 +144,7 @@
}
BraseroScsiResult
-brasero_mmc5_read_disc_information_tracks (int fd,
+brasero_mmc5_read_disc_information_tracks (BraseroDeviceHandle *handle,
BraseroScsiTrackResInfo *info_return,
int size,
BraseroScsiErrCode *error)
@@ -152,7 +152,7 @@
BraseroRdDiscInfoCDB *cdb;
BraseroScsiResult res;
- cdb = brasero_scsi_command_new (&info, fd);
+ cdb = brasero_scsi_command_new (&info, handle);
cdb->data_type = BRASERO_DISC_INFO_TRACK_RES;
BRASERO_SET_16 (cdb->alloc_len, size);
@@ -163,7 +163,7 @@
}
BraseroScsiResult
-brasero_mmc5_read_disc_information_pows (int fd,
+brasero_mmc5_read_disc_information_pows (BraseroDeviceHandle *handle,
BraseroScsiPOWResInfo *info_return,
int size,
BraseroScsiErrCode *error)
@@ -171,7 +171,7 @@
BraseroRdDiscInfoCDB *cdb;
BraseroScsiResult res;
- cdb = brasero_scsi_command_new (&info, fd);
+ cdb = brasero_scsi_command_new (&info, handle);
cdb->data_type = BRASERO_DISC_INFO_POW_RES;
BRASERO_SET_16 (cdb->alloc_len, size);
Copied: trunk/src/scsi-read-disc-structure.c (from r632, /trunk/src/scsi/scsi-read-disc-structure.c)
==============================================================================
--- /trunk/src/scsi/scsi-read-disc-structure.c (original)
+++ trunk/src/scsi-read-disc-structure.c Mon Feb 11 19:23:03 2008
@@ -139,7 +139,7 @@
}
BraseroScsiResult
-brasero_mmc2_read_generic_structure (int fd,
+brasero_mmc2_read_generic_structure (BraseroDeviceHandle *handle,
BraseroScsiGenericFormatType type,
BraseroScsiReadDiscStructureHdr **data,
int *size,
@@ -148,7 +148,7 @@
BraseroReadDiscStructureCDB *cdb;
BraseroScsiResult res;
- cdb = brasero_scsi_command_new (&info, fd);
+ cdb = brasero_scsi_command_new (&info, handle);
cdb->format = type;
res = brasero_read_disc_structure (cdb, data, size, error);
@@ -157,7 +157,7 @@
}
BraseroScsiResult
-brasero_mmc2_read_dvd_structure (int fd,
+brasero_mmc2_read_dvd_structure (BraseroDeviceHandle *handle,
int address,
BraseroScsiDVDFormatType type,
BraseroScsiReadDiscStructureHdr **data,
@@ -167,7 +167,7 @@
BraseroReadDiscStructureCDB *cdb;
BraseroScsiResult res;
- cdb = brasero_scsi_command_new (&info, fd);
+ cdb = brasero_scsi_command_new (&info, handle);
cdb->format = type;
cdb->media_type = BRASERO_MEDIA_DVD_HD_DVD;
BRASERO_SET_32 (cdb->address, address);
@@ -178,7 +178,7 @@
}
BraseroScsiResult
-brasero_mmc5_read_bd_structure (int fd,
+brasero_mmc5_read_bd_structure (BraseroDeviceHandle *handle,
BraseroScsiBDFormatType type,
BraseroScsiReadDiscStructureHdr **data,
int *size,
@@ -187,7 +187,7 @@
BraseroReadDiscStructureCDB *cdb;
BraseroScsiResult res;
- cdb = brasero_scsi_command_new (&info, fd);
+ cdb = brasero_scsi_command_new (&info, handle);
cdb->format = type;
cdb->media_type = BRASERO_MEDIA_BD;
Copied: trunk/src/scsi-read-format-capacities.c (from r632, /trunk/src/scsi/scsi-read-format-capacities.c)
==============================================================================
--- /trunk/src/scsi/scsi-read-format-capacities.c (original)
+++ trunk/src/scsi-read-format-capacities.c Mon Feb 11 19:23:03 2008
@@ -48,7 +48,7 @@
BRASERO_SCSI_READ);
BraseroScsiResult
-brasero_mmc2_read_format_capacities (int fd,
+brasero_mmc2_read_format_capacities (BraseroDeviceHandle *handle,
BraseroScsiFormatCapacitiesHdr **data,
int *size,
BraseroScsiErrCode *error)
@@ -64,7 +64,7 @@
return BRASERO_SCSI_FAILURE;
}
- cdb = brasero_scsi_command_new (&info, fd);
+ cdb = brasero_scsi_command_new (&info, handle);
BRASERO_SET_16 (cdb->alloc_len, sizeof (BraseroScsiFormatCapacitiesHdr));
memset (&hdr, 0, sizeof (BraseroScsiFormatCapacitiesHdr));
Copied: trunk/src/scsi-read-toc-pma-atip.c (from r632, /trunk/src/scsi/scsi-read-toc-pma-atip.c)
==============================================================================
--- /trunk/src/scsi/scsi-read-toc-pma-atip.c (original)
+++ trunk/src/scsi-read-toc-pma-atip.c Mon Feb 11 19:23:03 2008
@@ -154,7 +154,7 @@
*/
BraseroScsiResult
-brasero_mmc1_read_toc_formatted (int fd,
+brasero_mmc1_read_toc_formatted (BraseroDeviceHandle *handle,
int track_num,
BraseroScsiFormattedTocData **data,
int *size,
@@ -163,7 +163,7 @@
BraseroRdTocPmaAtipCDB *cdb;
BraseroScsiResult res;
- cdb = brasero_scsi_command_new (&info, fd);
+ cdb = brasero_scsi_command_new (&info, handle);
cdb->format = BRASERO_RD_TAP_FORMATTED_TOC;
/* first track for which this function will return information */
@@ -183,7 +183,7 @@
*/
BraseroScsiResult
-brasero_mmc1_read_toc_raw (int fd,
+brasero_mmc1_read_toc_raw (BraseroDeviceHandle *handle,
int session_num,
BraseroScsiRawTocData **data,
int *size,
@@ -192,7 +192,7 @@
BraseroRdTocPmaAtipCDB *cdb;
BraseroScsiResult res;
- cdb = brasero_scsi_command_new (&info, fd);
+ cdb = brasero_scsi_command_new (&info, handle);
cdb->format = BRASERO_RD_TAP_RAW_TOC;
/* first session for which this function will return information */
@@ -212,7 +212,7 @@
*/
BraseroScsiResult
-brasero_mmc3_read_cd_text (int fd,
+brasero_mmc3_read_cd_text (BraseroDeviceHandle *handle,
BraseroScsiCDTextData **data,
int *size,
BraseroScsiErrCode *error)
@@ -220,7 +220,7 @@
BraseroRdTocPmaAtipCDB *cdb;
BraseroScsiResult res;
- cdb = brasero_scsi_command_new (&info, fd);
+ cdb = brasero_scsi_command_new (&info, handle);
cdb->format = BRASERO_RD_TAP_CD_TEXT;
res = brasero_read_toc_pma_atip (cdb,
@@ -237,7 +237,7 @@
*/
BraseroScsiResult
-brasero_mmc1_read_atip (int fd,
+brasero_mmc1_read_atip (BraseroDeviceHandle *handle,
BraseroScsiAtipData **data,
int *size,
BraseroScsiErrCode *error)
@@ -248,7 +248,7 @@
/* In here we have to ask how many bytes the drive wants to return first
* indeed there is a difference in the descriptor size between MMC1/MMC2
* and MMC3. */
- cdb = brasero_scsi_command_new (&info, fd);
+ cdb = brasero_scsi_command_new (&info, handle);
cdb->format = BRASERO_RD_TAP_ATIP;
cdb->msf = 1; /* specs says it's compulsory */
Copied: trunk/src/scsi-read-track-information.c (from r632, /trunk/src/scsi/scsi-read-track-information.c)
==============================================================================
--- /trunk/src/scsi/scsi-read-track-information.c (original)
+++ trunk/src/scsi-read-track-information.c Mon Feb 11 19:23:03 2008
@@ -153,7 +153,7 @@
*/
BraseroScsiResult
-brasero_mmc1_read_track_info (int fd,
+brasero_mmc1_read_track_info (BraseroDeviceHandle *handle,
int track_num,
BraseroScsiTrackInfo *track_info,
int *size,
@@ -162,7 +162,7 @@
BraseroRdTrackInfoCDB *cdb;
BraseroScsiResult res;
- cdb = brasero_scsi_command_new (&info, fd);
+ cdb = brasero_scsi_command_new (&info, handle);
cdb->addr_num_type = BRASERO_FIELD_TRACK_NUM;
BRASERO_SET_32 (cdb->blk_addr_trk_ses_num, track_num);
Copied: trunk/src/scsi-sg.c (from r632, /trunk/src/scsi/scsi-sg.c)
==============================================================================
--- /trunk/src/scsi/scsi-sg.c (original)
+++ trunk/src/scsi-sg.c Mon Feb 11 19:23:03 2008
@@ -22,47 +22,179 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA
*/
-#include <string.h>
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <errno.h>
#include <unistd.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
#include <sys/ioctl.h>
#include <scsi/scsi.h>
-#include <scsi/sg.h>
-#include "scsi-sg.h"
+#include "scsi-command.h"
+#include "burn-debug.h"
#include "scsi-utils.h"
#include "scsi-error.h"
#include "scsi-sense-data.h"
-BraseroScsiResult
-brasero_sg_send_command (int fd, struct sg_io_hdr *command, BraseroScsiErrCode *error)
-{
- unsigned char sense_buffer [32];
- BraseroScsiErrCode res;
+/* Only work for linux when it has the SG interface */
+#if HAVE_SG_IO_HDR_T
+
+#include <scsi/sg.h>
+
+struct _BraseroDeviceHandle {
+ int fd;
+};
+
+struct _BraseroScsiCmd {
+ uchar cmd [BRASERO_SCSI_CMD_MAX_LEN];
+ BraseroDeviceHandle *handle;
+
+ const BraseroScsiCmdInfo *info;
+};
+
+#define BRASERO_SCSI_CMD_OPCODE_OFF 0
+#define BRASERO_SCSI_CMD_SET_OPCODE(command) (command->cmd [BRASERO_SCSI_CMD_OPCODE_OFF] = command->info->opcode)
- /* NOTE: the sense buffer is the result of the first write command
- * (REQUEST SENSE usually) since SG_IO is both write and read. */
- memset (&sense_buffer, 0, sizeof (sense_buffer));
+#define OPEN_FLAGS O_RDONLY /*|O_EXCL */|O_NONBLOCK
- command->interface_id = 'S'; /* mandatory */
- command->flags = SG_FLAG_LUN_INHIBIT|SG_FLAG_DIRECT_IO;
+/**
+ * This is to send a command
+ */
+
+static void
+brasero_sg_command_setup (struct sg_io_hdr *transport,
+ uchar *sense_data,
+ BraseroScsiCmd *cmd,
+ uchar *buffer,
+ int size)
+{
+ memset (sense_data, 0, BRASERO_SENSE_DATA_SIZE);
+ memset (transport, 0, sizeof (struct sg_io_hdr));
+
+ transport->interface_id = 'S'; /* mandatory */
+// transport->flags = SG_FLAG_LUN_INHIBIT|SG_FLAG_DIRECT_IO;
+ transport->cmdp = cmd->cmd;
+ transport->cmd_len = cmd->info->size;
+ transport->dxferp = buffer;
+ transport->dxfer_len = size;
/* where to output the scsi sense buffer */
- command->sbp = sense_buffer;
- command->mx_sb_len = sizeof (sense_buffer);
+ transport->sbp = sense_data;
+ transport->mx_sb_len = BRASERO_SENSE_DATA_SIZE;
+
+ if (cmd->info->direction & BRASERO_SCSI_READ)
+ transport->dxfer_direction = SG_DXFER_FROM_DEV;
+ else if (cmd->info->direction & BRASERO_SCSI_WRITE)
+ transport->dxfer_direction = SG_DXFER_TO_DEV;
+}
+
+BraseroScsiResult
+brasero_scsi_command_issue_sync (gpointer command,
+ gpointer buffer,
+ int size,
+ BraseroScsiErrCode *error)
+{
+ uchar sense_buffer [BRASERO_SENSE_DATA_SIZE];
+ struct sg_io_hdr transport;
+ BraseroScsiResult res;
+ BraseroScsiCmd *cmd;
+
+ cmd = command;
+ brasero_sg_command_setup (&transport,
+ sense_buffer,
+ cmd,
+ buffer,
+ size);
+
+ /* for the time being only sg driver is supported */
/* NOTE on SG_IO: only for TEST UNIT READY, REQUEST/MODE SENSE, INQUIRY,
* READ CAPACITY, READ BUFFER, READ and LOG SENSE are allowed with it */
- res = ioctl (fd, SG_IO, command);
+ res = ioctl (cmd->handle->fd, SG_IO, &transport);
if (res) {
BRASERO_SCSI_SET_ERRCODE (error, BRASERO_SCSI_ERRNO);
return BRASERO_SCSI_FAILURE;
}
- if ((command->info & SG_INFO_OK_MASK) == SG_INFO_OK)
+ if ((transport.info & SG_INFO_OK_MASK) == SG_INFO_OK)
return BRASERO_SCSI_OK;
- if ((command->masked_status & CHECK_CONDITION) && command->sb_len_wr)
- return brasero_sense_data_process (sense_buffer, &res);
+ if ((transport.masked_status & CHECK_CONDITION) && transport.sb_len_wr)
+ return brasero_sense_data_process (sense_buffer, error);
return BRASERO_SCSI_FAILURE;
}
+
+gpointer
+brasero_scsi_command_new (const BraseroScsiCmdInfo *info,
+ BraseroDeviceHandle *handle)
+{
+ BraseroScsiCmd *cmd;
+
+ /* make sure we can set the flags of the descriptor */
+
+ /* allocate the command */
+ cmd = g_new0 (BraseroScsiCmd, 1);
+ cmd->info = info;
+ cmd->handle = handle;
+
+ BRASERO_SCSI_CMD_SET_OPCODE (cmd);
+ return cmd;
+}
+
+BraseroScsiResult
+brasero_scsi_command_free (gpointer cmd)
+{
+ g_free (cmd);
+ return BRASERO_SCSI_OK;
+}
+
+/**
+ * This is to open a device
+ */
+
+BraseroDeviceHandle *
+brasero_device_handle_open (const gchar *path,
+ BraseroScsiErrCode *code)
+{
+ int fd;
+ BraseroDeviceHandle *handle;
+
+ fd = open (path, OPEN_FLAGS);
+ if (fd < 0) {
+ if (errno == EAGAIN
+ || errno == EWOULDBLOCK
+ || errno == EBUSY)
+ *code = BRASERO_SCSI_NOT_READY;
+ else
+ *code = BRASERO_SCSI_ERRNO;
+
+ return NULL;
+ }
+
+ handle = g_new (BraseroDeviceHandle, 1);
+ handle->fd = fd;
+
+ return handle;
+}
+
+void
+brasero_device_handle_close (BraseroDeviceHandle *handle)
+{
+ close (handle->fd);
+ g_free (handle);
+}
+
+int
+brasero_device_handle_get_fd (BraseroDeviceHandle *handle)
+{
+ return handle->fd;
+}
+
+#endif /* HAVE_SG_IO_HDR_T */
Copied: trunk/src/scsi-spc1.h (from r632, /trunk/src/scsi/scsi-spc1.h)
==============================================================================
--- /trunk/src/scsi/scsi-spc1.h (original)
+++ trunk/src/scsi-spc1.h Mon Feb 11 19:23:03 2008
@@ -22,6 +22,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA
*/
+#include <glib.h>
+
+#include "scsi-base.h"
+
#include "scsi-error.h"
#include "scsi-mode-pages.h"
@@ -34,7 +38,7 @@
#endif
BraseroScsiResult
-brasero_spc1_mode_sense_get_page (int fd,
+brasero_spc1_mode_sense_get_page (BraseroDeviceHandle *handle,
BraseroSPCPageType num,
BraseroScsiModeData **data,
int *data_size,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]