1
/***************************************************************************
2
* scsi-read-disc-info.c
4
* Thu Oct 26 16:51:36 2006
5
* Copyright 2006 Rouquier Philippe
6
* <bonfire-app@wanadoo.fr>
7
****************************************************************************/
10
* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU Library General Public License for more details.
20
* You should have received a copy of the GNU General Public License
21
* along with this program; if not, write to the Free Software
22
* Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA
33
#include "scsi-error.h"
34
#include "scsi-utils.h"
35
#include "scsi-base.h"
36
#include "scsi-command.h"
37
#include "scsi-opcodes.h"
38
#include "scsi-read-disc-info.h"
40
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
42
struct _BraseroRdDiscInfoCDB {
56
struct _BraseroRdDiscInfoCDB {
70
typedef struct _BraseroRdDiscInfoCDB BraseroRdDiscInfoCDB;
72
BRASERO_SCSI_COMMAND_DEFINE (BraseroRdDiscInfoCDB,
73
READ_DISC_INFORMATION,
78
BRASERO_DISC_INFO_STD = 0x00,
79
BRASERO_DISC_INFO_TRACK_RES = 0x01,
80
BRASERO_DISC_INFO_POW_RES = 0x02,
82
} BraseroDiscInfoType;
86
brasero_mmc1_read_disc_information_std (int fd,
87
BraseroScsiDiscInfoStd **info_return,
89
BraseroScsiErrCode *error)
91
BraseroScsiDiscInfoStd std_info;
92
BraseroScsiDiscInfoStd *buffer;
93
BraseroRdDiscInfoCDB *cdb;
94
BraseroScsiResult res;
97
if (!info_return || !size) {
98
BRASERO_SCSI_SET_ERRCODE (error, BRASERO_SCSI_BAD_ARGUMENT);
99
return BRASERO_SCSI_FAILURE;
102
cdb = brasero_scsi_command_new (&info, fd);
103
cdb->data_type = BRASERO_DISC_INFO_STD;
104
BRASERO_SET_16 (cdb->alloc_len, sizeof (BraseroScsiDiscInfoStd));
106
memset (&std_info, 0, sizeof (BraseroScsiDiscInfoStd));
107
res = brasero_scsi_command_issue_sync (cdb,
109
sizeof (BraseroScsiDiscInfoStd),
114
request_size = BRASERO_GET_16 (std_info.len) +
115
sizeof (std_info.len);
116
buffer = (BraseroScsiDiscInfoStd *) g_new0 (uchar, request_size);
118
BRASERO_SET_16 (cdb->alloc_len, request_size);
119
res = brasero_scsi_command_issue_sync (cdb, buffer, request_size, error);
125
if (request_size != BRASERO_GET_16 (buffer->len) + sizeof (buffer->len)) {
126
BRASERO_SCSI_SET_ERRCODE (error, BRASERO_SCSI_SIZE_MISMATCH);
128
res = BRASERO_SCSI_FAILURE;
133
*info_return = buffer;
134
*size = request_size;
138
brasero_scsi_command_free (cdb);
143
brasero_mmc5_read_disc_information_tracks (int fd,
144
BraseroScsiTrackResInfo *info_return,
146
BraseroScsiErrCode *error)
148
BraseroRdDiscInfoCDB *cdb;
149
BraseroScsiResult res;
151
cdb = brasero_scsi_command_new (&info, fd);
152
cdb->data_type = BRASERO_DISC_INFO_TRACK_RES;
153
BRASERO_SET_16 (cdb->alloc_len, size);
155
memset (info_return, 0, size);
156
res = brasero_scsi_command_issue_sync (cdb, info_return, size, error);
157
brasero_scsi_command_free (cdb);
162
brasero_mmc5_read_disc_information_pows (int fd,
163
BraseroScsiPOWResInfo *info_return,
165
BraseroScsiErrCode *error)
167
BraseroRdDiscInfoCDB *cdb;
168
BraseroScsiResult res;
170
cdb = brasero_scsi_command_new (&info, fd);
171
cdb->data_type = BRASERO_DISC_INFO_POW_RES;
172
BRASERO_SET_16 (cdb->alloc_len, size);
174
memset (info_return, 0, size);
175
res = brasero_scsi_command_issue_sync (cdb, info_return, size, error);
176
brasero_scsi_command_free (cdb);