~ubuntu-branches/debian/wheezy/brasero/wheezy

« back to all changes in this revision

Viewing changes to src/scsi-sense-data.c

  • Committer: Bazaar Package Importer
  • Author(s): Josselin Mouette, Pedro Fragoso, Luca Bruno, Josselin Mouette, Emilio Pozuelo Monfort
  • Date: 2009-06-24 18:59:46 UTC
  • mfrom: (1.2.13 upstream)
  • Revision ID: james.westby@ubuntu.com-20090624185946-iyxkgf3gjptir5y3
Tags: 2.26.2-1
[ Pedro Fragoso ]
* Add myself to Maintainer field
  - Thanks Ondřej Surý
* New upstream version (Closes: #528945)
  - Split package into brasero, libbrasero-media0 and libbrasero-dev
  - Add Replaces to libbrasero-media0
  - Bump libgtk to 2.14.0
  - Remove libnotify Build-dep
  - Add Build-dep libnautilus-extension-dev (>= 2.22.2)
    and install it.
  - Add Build-dep to libsm-dev
  - Add Build-dep on intltool
* Install omf files to prevent crash on Help
* Move gstreamer0.10-plugins-bad to Suggests, and add
  dvdauthor and vcdimager
* Recommends gvfs (Closes: #491827)
* Pass --disable-scrollkeeper in DEB_CONFIGURE_EXTRA_FLAGS
* debian/patches/007-fix-gnome-doc-utils-path.patch:
  - Removed, not needed anymore
* debian/patches/008-fix-volume-identifier-crash.patch:
  - Removed, merged upstream
* debian/patches/011_nautilus_menu_move.patch:
 - Move CD/DVD Creator Menu to Acessories, taken from Ubuntu

[ Luca Bruno ]
* debian/control.in:
  - Add Build-Depend gtk-doc-tools 1.9.
* debian/patches/006-fix-libdvdcss.patch:
  - Removed as applied upstream.

[ Josselin Mouette ]
* New upstream release.
* Update build-dependencies.
* Move the translations and data to a new brasero-common package.
* Rewrite the descriptions.
* Add -dev depends to the development package.
* Remove inappropriate recommends in the library package.
* Let’s not forget dvd+rw-tools so that we can write DVDs too.
* Rework dependencies accordingly.
* Put the nautilus extension in brasero.
* Conflict against nautilus-cd-burner to avoid having two burning 
  extensions.
* Include clean-la.mk and gnome-version.mk; build-depend on 
  gnome-pkg-tools 0.7.
* Don’t run dh_makeshlibs on brasero and libbrasero-plugins.
* 011_nautilus_menu_move.patch: add NoDisplay=true, this icon is 
  duplicating existing functionality (brasero icon in sound&video 
  menu, and nautilus autorun).
* Update list of copyright holders.

[ Emilio Pozuelo Monfort ]
* debian/copyright: updated.

[ Josselin Mouette ]
* copyright: improve indentation, and point to versioned LGPL.
* 090_relibtoolize.patch: add a relibtoolization patch to avoid the 
  rpath crap.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
 *            burn-sense-data.c
3
 
 *
4
 
 *  Fri Oct 20 12:24:41 2006
5
 
 *  Copyright  2006  Rouquier Philippe
6
 
 *  <Rouquier Philippe@localhost.localdomain>
7
 
 ****************************************************************************/
8
 
 
9
 
/*
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.
14
 
 * 
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.
19
 
 * 
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
23
 
 */
24
 
 
25
 
#ifdef HAVE_CONFIG_H
26
 
#  include <config.h>
27
 
#endif
28
 
 
29
 
#include <errno.h>
30
 
#include <stdio.h>
31
 
 
32
 
#include "scsi-error.h"
33
 
#include "scsi-utils.h"
34
 
#include "scsi-base.h"
35
 
#include "scsi-sense-data.h"
36
 
 
37
 
/**
38
 
 * defines to interpret sense data (returned after SENSE REQUEST)
39
 
 * (defined in SCSI Primary command 3 / SPC specs)
40
 
 **/
41
 
 
42
 
#define SENSE_DATA_KEY(sense)                   ((sense) ? (sense) [2] & 0x0F : 0x00)                   /* Sense code itself */
43
 
#define SENSE_DATA_ASC(sense)                   ((sense) ? (sense) [12] : 0x00)                         /* Additional Sense Code */
44
 
#define SENSE_DATA_ASCQ(sense)                  ((sense) ? (sense) [13] : 0x00)                         /* Additional Sense Code Qualifier */
45
 
#define SENSE_DATA_ASC_ASCQ(sense)              ((sense) ? (sense) [12] << 8 | (sense) [13] : 0x00)     /* ASC and ASCQ combined */
46
 
 
47
 
#define SENSE_CODE_NOT_READY                            0x02
48
 
#define SENSE_CODE_ILLEGAL_REQUEST                      0x05
49
 
#define SENSE_CODE_UNIT_ATTENTION                       0x06
50
 
 
51
 
#define ASC_CODE_NOT_READY                              0x04
52
 
#define ASC_CODE_PARAMETER                              0x26
53
 
#define ASC_CODE_PROTECTION_KEY                         0x6F
54
 
 
55
 
#define ASC_ASCQ_CODE_INVALID_COMMAND                   0x2000
56
 
#define ASC_ASCQ_CODE_OUTRANGE_ADDRESS                  0x2100
57
 
#define ASC_ASCQ_CODE_INVALID_ADDRESS                   0x2101
58
 
#define ASC_ASCQ_CODE_INVALID_FIELD_IN_PARAM            0x2600
59
 
#define ASC_ASCQ_CODE_INVALID_FIELD_IN_CDB              0x2400
60
 
#define ASC_ASCQ_CODE_INSUFFICIENT_TIME_FOR_OPERATION   0x2E00
61
 
#define ASC_ASCQ_CODE_KEY_NOT_ESTABLISHED               0x6F02
62
 
#define ASC_ASCQ_CODE_SCRAMBLED_SECTOR                  0x6F03
63
 
#define ASC_ASCQ_CODE_INVALID_TRACK_MODE                0x6400
64
 
 
65
 
/**
66
 
 * error processing 
67
 
 */
68
 
 
69
 
static void
70
 
brasero_sense_data_print (uchar *sense_data)
71
 
{
72
 
        int i;
73
 
 
74
 
        if (!sense_data)
75
 
                return;
76
 
 
77
 
        printf("Sense key: 0x%02x ", sense_data [0]);
78
 
        for (i = 1; i < BRASERO_SENSE_DATA_SIZE; i ++)
79
 
                printf("0x%02x ", sense_data [i]);
80
 
 
81
 
        printf("\n");
82
 
}
83
 
 
84
 
static BraseroScsiResult
85
 
brasero_sense_data_unknown (uchar *sense_data, BraseroScsiErrCode *err)
86
 
{
87
 
        BRASERO_SCSI_SET_ERRCODE (err, BRASERO_SCSI_ERR_UNKNOWN);
88
 
        brasero_sense_data_print (sense_data);
89
 
 
90
 
        return BRASERO_SCSI_FAILURE;
91
 
}
92
 
 
93
 
static BraseroScsiResult
94
 
brasero_sense_data_not_ready (uchar *sense_data, BraseroScsiErrCode *err)
95
 
{
96
 
        BraseroScsiResult res = BRASERO_SCSI_FAILURE;
97
 
 
98
 
        switch (SENSE_DATA_ASCQ (sense_data)) {
99
 
                case ASC_CODE_NOT_READY:
100
 
                        BRASERO_SCSI_SET_ERRCODE (err, BRASERO_SCSI_NOT_READY);
101
 
                        break;
102
 
 
103
 
                default:
104
 
                        res = brasero_sense_data_unknown (sense_data, err);
105
 
                        break;
106
 
        }
107
 
 
108
 
        return res;
109
 
}
110
 
 
111
 
static BraseroScsiResult
112
 
brasero_sense_data_illegal_request (uchar *sense_data, BraseroScsiErrCode *err)
113
 
{
114
 
        BraseroScsiResult res = BRASERO_SCSI_FAILURE;
115
 
 
116
 
        switch (SENSE_DATA_ASC_ASCQ (sense_data)) {
117
 
                case ASC_ASCQ_CODE_INVALID_COMMAND:
118
 
                        BRASERO_SCSI_SET_ERRCODE (err, BRASERO_SCSI_INVALID_COMMAND);
119
 
                        break;
120
 
 
121
 
                case ASC_ASCQ_CODE_OUTRANGE_ADDRESS:
122
 
                        BRASERO_SCSI_SET_ERRCODE (err, BRASERO_SCSI_OUTRANGE_ADDRESS);
123
 
                        break;
124
 
 
125
 
                case ASC_ASCQ_CODE_INVALID_ADDRESS:
126
 
                        BRASERO_SCSI_SET_ERRCODE (err, BRASERO_SCSI_INVALID_ADDRESS);
127
 
                        break;
128
 
 
129
 
                case ASC_ASCQ_CODE_INVALID_FIELD_IN_PARAM:
130
 
                        BRASERO_SCSI_SET_ERRCODE (err, BRASERO_SCSI_INVALID_PARAMETER);
131
 
                        break;
132
 
 
133
 
                case ASC_ASCQ_CODE_INVALID_FIELD_IN_CDB:
134
 
                        BRASERO_SCSI_SET_ERRCODE (err, BRASERO_SCSI_INVALID_FIELD);
135
 
                        break;
136
 
 
137
 
                case ASC_ASCQ_CODE_KEY_NOT_ESTABLISHED:
138
 
                case ASC_ASCQ_CODE_SCRAMBLED_SECTOR:
139
 
                        BRASERO_SCSI_SET_ERRCODE (err, BRASERO_SCSI_KEY_NOT_ESTABLISHED);
140
 
                        break;
141
 
 
142
 
                case ASC_ASCQ_CODE_INVALID_TRACK_MODE:
143
 
                        BRASERO_SCSI_SET_ERRCODE (err, BRASERO_SCSI_INVALID_TRACK_MODE);
144
 
                        break;
145
 
 
146
 
                default:
147
 
                        res = brasero_sense_data_unknown (sense_data, err);
148
 
                        break;
149
 
        }
150
 
 
151
 
        return res;
152
 
}
153
 
 
154
 
static BraseroScsiResult
155
 
brasero_sense_data_unit_attention (uchar *sense_data,
156
 
                                   BraseroScsiErrCode *err)
157
 
{
158
 
        BraseroScsiResult res = BRASERO_SCSI_FAILURE;
159
 
 
160
 
        switch (SENSE_DATA_ASC_ASCQ (sense_data)) {
161
 
                case ASC_ASCQ_CODE_INSUFFICIENT_TIME_FOR_OPERATION:
162
 
                        BRASERO_SCSI_SET_ERRCODE (err, BRASERO_SCSI_TIMEOUT);
163
 
                        break;
164
 
 
165
 
                default:
166
 
                        res = brasero_sense_data_unknown (sense_data, err);
167
 
                        break;
168
 
        }
169
 
 
170
 
        return res;
171
 
}
172
 
 
173
 
BraseroScsiResult
174
 
brasero_sense_data_process (uchar *sense_data,
175
 
                            BraseroScsiErrCode *err)
176
 
{
177
 
        BraseroScsiResult res = BRASERO_SCSI_FAILURE;
178
 
 
179
 
        errno = EIO;
180
 
 
181
 
        /* see if something was written to the sense buffer and if we
182
 
         * can interpret more precisely what went wrong */
183
 
        switch (SENSE_DATA_KEY (sense_data)) {
184
 
                case SENSE_CODE_NOT_READY:
185
 
                        res = brasero_sense_data_not_ready (sense_data, err);
186
 
                        break;
187
 
 
188
 
                case SENSE_CODE_ILLEGAL_REQUEST:
189
 
                        res = brasero_sense_data_illegal_request (sense_data, err);
190
 
                        break;
191
 
 
192
 
                case SENSE_CODE_UNIT_ATTENTION:
193
 
                        res = brasero_sense_data_unit_attention (sense_data, err);
194
 
                        break;
195
 
 
196
 
                default:
197
 
                        res = brasero_sense_data_unknown (sense_data, err);
198
 
                        break;
199
 
        }
200
 
 
201
 
        return res;
202
 
}