udftools

- Main Page
- Classes
- Files

- File List
- File Members

All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
cdrwtool.h
Go to the documentation of this file.
1 /*
2 * Perform all sort of actions on a CD-R, CD-RW, and DVD-R drive.
3 *
4 * Copyright Jens Axboe, 1999, 2000
5 *
6 * Released under the GPL licences.
7 *
8 */
9
10 #ifndef _CDRWTOOL_H
11 #define _CDRWTOOL_H 1
12
13 #include <inttypes.h>
14 #include <linux/cdrom.h>
15 #include "../include/libudffs.h"
16
17 /*
18 * define this to be the default cdrom device
19 */
20 #define CDROM_DEVICE "/dev/scd1"
21
22 #ifndef HZ
23 #define HZ sysconf(_SC_CLK_TCK)
24 #endif
25
26 /*
27 * adjust these values if commands are timing out before completion
28 */
29 #define WAIT_PC (5 * HZ)
30 #define WAIT_SYNC (25 * HZ)
31 #define WAIT_BLANK (60 * 60 * HZ)
32
33 /*
34 * define this to 0 to make format and blank block until the entire
35 * operation has succeeded. otherwise control is returned as soon as
36 * the drive has verified the command -- this can be used for polling
37 * the device for completion.
38 */
39 #define USE_IMMED 0
40
41 #define PAGE_CURRENT 0
42 #define PAGE_CHANGE 1
43 #define PAGE_DEFAULT 2
44 #define PAGE_SAVE 3
45
46 #define BLANK_FULL 1
47 #define BLANK_FAST 2
48
49 #define WRITE_MODE1 1
50 #define WRITE_MODE2 2 /* mode2, form 1 */
51
52 #define CDROM_BLOCK 2048
53 #define PACKET_BLOCK 32
54 #define PACKET_SIZE CDROM_BLOCK*PACKET_BLOCK
55
56 #ifndef NAME_MAX
57 #define NAME_MAX 255
58 #endif
59
60 #define DEFAULT_SPEED 12
61
62 typedef struct
63 {
64 unsigned char ls_v; /* link_size valid */
65 unsigned char border; /* or session */
66 unsigned char fpacket; /* fixed, variable */
67 unsigned char track_mode; /* control nibbler, sub q */
68 unsigned char data_block; /* write type */
69 unsigned char link_size; /* links loss size */
70 unsigned char session_format; /* session closure settings */
71 unsigned long packet_size; /* fixed packet size */
72 } write_params_t;
73
74 struct cdrw_disc
75 {
76 char filename[NAME_MAX]; /* file to write */
77 unsigned long offset; /* write file / format */
78 unsigned char get_settings; /* just print settings */
79 unsigned char set_settings; /* save settings */
80 unsigned char blank; /* blank cdrw disc */
81 unsigned char fpacket; /* fixed/variable packets */
82 unsigned char packet_size; /* fixed packet size */
83 unsigned char link_size; /* link loss size */
84 unsigned char write_type; /* mode1 or mode2 */
85 unsigned char disc_track_info; /* list disc/track info */
86 unsigned char format; /* format disc */
87 unsigned char border; /* border/session */
88 unsigned char speed; /* writing speed */
89 unsigned int buffer; /* buffer size */
90 unsigned int reserve_track; /* reserve a track */
91 unsigned char quick_setup;
92 unsigned char mkudf;
93 unsigned int close_track;
94 unsigned int close_session;
95 struct udf_disc udf_disc;
96 };
97
98 #ifndef be16_to_cpu
99 #define be16_to_cpu(x) \
100 ((uint16_t)( \
101 (((uint16_t)(x) & (uint16_t)0x00ffU) << 8) | \
102 (((uint16_t)(x) & (uint16_t)0xff00U) >> 8) ))
103 #endif
104
105 #ifndef be32_to_cpu
106 #define be32_to_cpu(x) \
107 ((uint32_t)( \
108 (((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) | \
109 (((uint32_t)(x) & (uint32_t)0x0000ff00UL) << 8) | \
110 (((uint32_t)(x) & (uint32_t)0x00ff0000UL) >> 8) | \
111 (((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24) ))
112 #endif
113
114 typedef struct disc_info {
115 uint16_t length;
116 #if __BYTE_ORDER == __BIG_ENDIAN
117 unsigned char reserved1 : 3;
118 unsigned char erasable : 1;
119 unsigned char border : 2;
120 unsigned char status : 2;
121 #elif __BYTE_ORDER == __LITTLE_ENDIAN
122 unsigned char status : 2;
123 unsigned char border : 2;
124 unsigned char erasable : 1;
125 unsigned char reserved1 : 3;
126 #else
127 #error "<bits/endian.h> is wack"
128 #endif
129 uint8_t n_first_track;
130 uint8_t n_sessions_l;
131 uint8_t first_track_l;
132 uint8_t last_track_l;
133 #if __BYTE_ORDER == __BIG_ENDIAN
134 unsigned char did_v : 1;
135 unsigned char dbc_v : 1;
136 unsigned char uru : 1;
137 unsigned char reserved2 : 5;
138 #elif __BYTE_ORDER == __LITTLE_ENDIAN
139 unsigned char reserved2 : 5;
140 unsigned char uru : 1;
141 unsigned char dbc_v : 1;
142 unsigned char did_v : 1;
143 #endif
144 uint8_t disc_type;
145 uint8_t n_sessions_m;
146 uint8_t first_track_m;
147 uint8_t last_track_m;
148 uint32_t disc_id;
149 uint8_t lead_in_r;
150 uint8_t lead_in_m;
151 uint8_t lead_in_s;
152 uint8_t lead_in_f;
153 uint8_t lead_out_r;
154 uint8_t lead_out_m;
155 uint8_t lead_out_s;
156 uint8_t lead_out_f;
157 uint8_t disc_bar_code[8];
158 uint8_t reserved3;
159 uint8_t opc_entries;
160 } disc_info_t;
161
162 typedef struct track_info {
163 uint16_t info_length;
164 uint8_t track_number_l;
165 uint8_t session_number_l;
166 uint8_t reserved1;
167 #if __BYTE_ORDER == __BIG_ENDIAN
168 uint8_t reserved2 : 2;
169 uint8_t damage : 1;
170 uint8_t copy : 1;
171 uint8_t track_mode : 4;
172 uint8_t rt : 1;
173 uint8_t blank : 1;
174 uint8_t packet : 1;
175 uint8_t fp : 1;
176 uint8_t data_mode : 4;
177 uint8_t reserved3 : 6;
178 uint8_t lra_v : 1;
179 uint8_t nwa_v : 1;
180 #elif __BYTE_ORDER == __LITTLE_ENDIAN
181 uint8_t track_mode : 4;
182 uint8_t copy : 1;
183 uint8_t damage : 1;
184 uint8_t reserved2 : 2;
185 uint8_t data_mode : 4;
186 uint8_t fp : 1;
187 uint8_t packet : 1;
188 uint8_t blank : 1;
189 uint8_t rt : 1;
190 uint8_t nwa_v : 1;
191 uint8_t lra_v : 1;
192 uint8_t reserved3 : 6;
193 #endif
194 uint32_t track_start;
195 uint32_t next_writable;
196 uint32_t free_blocks;
197 uint32_t packet_size;
198 uint32_t track_size;
199 uint32_t last_recorded;
200 uint8_t track_number_m;
201 uint8_t session_number_m;
202 uint8_t reserved4;
203 uint8_t reserved5;
204 } track_info_t;
205
206 typedef struct opc_table {
207 uint16_t speed;
208 uint8_t opc_value[6];
209 } opc_table_t;
210
211 typedef struct disc_capacity {
212 uint32_t lba;
213 uint32_t block_length;
214 } disc_capacity_t;
215
216 int msf_to_lba(int, int, int);
217 void hexdump(const void *, int);
218 void dump_sense(unsigned char *, struct request_sense *);
219 int wait_cmd(int, struct cdrom_generic_command *, unsigned char *, int, int);
220 int mode_select(int, unsigned char *, int);
221 int mode_sense(int, unsigned char *, int, char, int);
222 int set_write_mode(int, write_params_t *);
223 int get_write_mode(int, write_params_t *);
224 int sync_cache(int);
225 int write_blocks(int, unsigned char *, int, int);
226 int write_file(int, struct cdrw_disc *);
227 int blank_disc(int, int);
228 int format_disc(int, struct cdrw_disc *);
229 int read_disc_info(int, disc_info_t *);
230 int read_track_info(int, track_info_t *, int);
231 int reserve_track(int, struct cdrw_disc *);
232 int close_track(int, unsigned int);
233 int close_session(int, unsigned int);
234 int read_buffer_cap(int, struct cdrw_disc *);
235 int set_cd_speed(int, int);
236 void cdrom_close(int);
237 int cdrom_open_check(int);
238 void print_disc_info(disc_info_t *);
239 void print_track_info(track_info_t *);
240 int print_disc_track_info(int);
241 void make_write_page(write_params_t *, struct cdrw_disc *);
242 void print_params(write_params_t *);
243 void cdrw_init_disc(struct cdrw_disc *);
244 int udf_set_version(struct udf_disc *, int);
245
246 #endif /* _CDRWTOOL_H */
cdrw_disc::border
unsigned char border
Definition: cdrwtool.h:87
msf_to_lba
int msf_to_lba(int, int, int)
Definition: cdrwtool.c:44
write_file
int write_file(int, struct cdrw_disc *)
Definition: cdrwtool.c:323
track_info::track_number_m
uint8_t track_number_m
Definition: cdrwtool.h:200
track_info::damage
uint8_t damage
Definition: cdrwtool.h:169
track_info::track_start
uint32_t track_start
Definition: cdrwtool.h:194
disc_capacity::block_length
uint32_t block_length
Definition: cdrwtool.h:213
disc_info::last_track_l
uint8_t last_track_l
Definition: cdrwtool.h:132
disc_info::lead_in_r
uint8_t lead_in_r
Definition: cdrwtool.h:149
disc_info::lead_out_m
uint8_t lead_out_m
Definition: cdrwtool.h:154
track_info::reserved5
uint8_t reserved5
Definition: cdrwtool.h:203
cdrw_disc::get_settings
unsigned char get_settings
Definition: cdrwtool.h:78
sync_cache
int sync_cache(int)
Definition: cdrwtool.c:292
cdrw_disc
Definition: cdrwtool.h:74
disc_info::lead_out_r
uint8_t lead_out_r
Definition: cdrwtool.h:153
disc_info::disc_type
uint8_t disc_type
Definition: cdrwtool.h:144
print_params
void print_params(write_params_t *)
Definition: cdrwtool.c:759
format_disc
int format_disc(int, struct cdrw_disc *)
Definition: cdrwtool.c:412
track_info::data_mode
uint8_t data_mode
Definition: cdrwtool.h:176
NAME_MAX
#define NAME_MAX
Definition: cdrwtool.h:57
disc_info::lead_in_m
uint8_t lead_in_m
Definition: cdrwtool.h:150
read_track_info
int read_track_info(int, track_info_t *, int)
Definition: cdrwtool.c:486
track_info::track_mode
uint8_t track_mode
Definition: cdrwtool.h:171
cdrw_disc::quick_setup
unsigned char quick_setup
Definition: cdrwtool.h:91
track_info::reserved1
uint8_t reserved1
Definition: cdrwtool.h:166
opc_table::speed
uint16_t speed
Definition: cdrwtool.h:207
disc_info::disc_id
uint32_t disc_id
Definition: cdrwtool.h:148
get_write_mode
int get_write_mode(int, write_params_t *)
Definition: cdrwtool.c:242
opc_table::opc_value
uint8_t opc_value[6]
Definition: cdrwtool.h:208
write_params_t::fpacket
unsigned char fpacket
Definition: cdrwtool.h:66
disc_info::erasable
unsigned char erasable
Definition: cdrwtool.h:118
disc_info::length
uint16_t length
Definition: cdrwtool.h:115
cdrw_disc::reserve_track
unsigned int reserve_track
Definition: cdrwtool.h:90
disc_info::first_track_m
uint8_t first_track_m
Definition: cdrwtool.h:146
cdrw_disc::close_session
unsigned int close_session
Definition: cdrwtool.h:94
set_write_mode
int set_write_mode(int, write_params_t *)
Definition: cdrwtool.c:176
disc_info::first_track_l
uint8_t first_track_l
Definition: cdrwtool.h:131
write_params_t::ls_v
unsigned char ls_v
Definition: cdrwtool.h:64
cdrw_disc::buffer
unsigned int buffer
Definition: cdrwtool.h:89
disc_info::disc_bar_code
uint8_t disc_bar_code[8]
Definition: cdrwtool.h:157
cdrw_disc::offset
unsigned long offset
Definition: cdrwtool.h:77
read_buffer_cap
int read_buffer_cap(int, struct cdrw_disc *)
Definition: cdrwtool.c:570
print_disc_info
void print_disc_info(disc_info_t *)
Definition: cdrwtool.c:655
cdrw_disc::close_track
unsigned int close_track
Definition: cdrwtool.h:93
write_params_t::data_block
unsigned char data_block
Definition: cdrwtool.h:68
track_info::next_writable
uint32_t next_writable
Definition: cdrwtool.h:195
cdrw_disc::blank
unsigned char blank
Definition: cdrwtool.h:80
cdrw_disc::packet_size
unsigned char packet_size
Definition: cdrwtool.h:82
track_info::session_number_m
uint8_t session_number_m
Definition: cdrwtool.h:201
cdrw_disc::speed
unsigned char speed
Definition: cdrwtool.h:88
disc_info::reserved2
unsigned char reserved2
Definition: cdrwtool.h:137
track_info::reserved2
uint8_t reserved2
Definition: cdrwtool.h:168
track_info::nwa_v
uint8_t nwa_v
Definition: cdrwtool.h:179
track_info_t
struct track_info track_info_t
write_blocks
int write_blocks(int, unsigned char *, int, int)
Definition: cdrwtool.c:302
disc_info
Definition: cdrwtool.h:114
disc_info::lead_out_f
uint8_t lead_out_f
Definition: cdrwtool.h:156
cdrw_disc::filename
char filename[NAME_MAX]
Definition: cdrwtool.h:76
cdrw_disc::write_type
unsigned char write_type
Definition: cdrwtool.h:84
disc_info::opc_entries
uint8_t opc_entries
Definition: cdrwtool.h:159
track_info::packet
uint8_t packet
Definition: cdrwtool.h:174
disc_info::border
unsigned char border
Definition: cdrwtool.h:119
disc_capacity_t
struct disc_capacity disc_capacity_t
dump_sense
void dump_sense(unsigned char *, struct request_sense *)
Definition: cdrwtool.c:59
disc_info::status
unsigned char status
Definition: cdrwtool.h:120
track_info::info_length
uint16_t info_length
Definition: cdrwtool.h:163
track_info::session_number_l
uint8_t session_number_l
Definition: cdrwtool.h:165
cdrw_disc::format
unsigned char format
Definition: cdrwtool.h:86
disc_info::n_first_track
uint8_t n_first_track
Definition: cdrwtool.h:129
reserve_track
int reserve_track(int, struct cdrw_disc *)
Definition: cdrwtool.c:507
write_params_t::packet_size
unsigned long packet_size
Definition: cdrwtool.h:71
close_track
int close_track(int, unsigned int)
Definition: cdrwtool.c:528
disc_capacity
Definition: cdrwtool.h:211
disc_info_t
struct disc_info disc_info_t
track_info::rt
uint8_t rt
Definition: cdrwtool.h:172
udf_set_version
int udf_set_version(struct udf_disc *, int)
Definition: mkudffs.c:152
disc_info::reserved1
unsigned char reserved1
Definition: cdrwtool.h:117
track_info::track_number_l
uint8_t track_number_l
Definition: cdrwtool.h:164
write_params_t
Definition: cdrwtool.h:62
track_info::reserved3
uint8_t reserved3
Definition: cdrwtool.h:177
cdrw_disc::disc_track_info
unsigned char disc_track_info
Definition: cdrwtool.h:85
disc_info::lead_in_f
uint8_t lead_in_f
Definition: cdrwtool.h:152
cdrw_disc::fpacket
unsigned char fpacket
Definition: cdrwtool.h:81
track_info::blank
uint8_t blank
Definition: cdrwtool.h:173
write_params_t::track_mode
unsigned char track_mode
Definition: cdrwtool.h:67
track_info::copy
uint8_t copy
Definition: cdrwtool.h:170
print_track_info
void print_track_info(track_info_t *)
Definition: cdrwtool.c:683
opc_table
Definition: cdrwtool.h:206
disc_info::n_sessions_m
uint8_t n_sessions_m
Definition: cdrwtool.h:145
track_info::track_size
uint32_t track_size
Definition: cdrwtool.h:198
mode_select
int mode_select(int, unsigned char *, int)
Definition: cdrwtool.c:150
disc_info::n_sessions_l
uint8_t n_sessions_l
Definition: cdrwtool.h:130
udf_disc
Definition: libudffs.h:95
track_info::last_recorded
uint32_t last_recorded
Definition: cdrwtool.h:199
mode_sense
int mode_sense(int, unsigned char *, int, char, int)
Definition: cdrwtool.c:163
disc_info::lead_in_s
uint8_t lead_in_s
Definition: cdrwtool.h:151
print_disc_track_info
int print_disc_track_info(int)
Definition: cdrwtool.c:706
track_info::lra_v
uint8_t lra_v
Definition: cdrwtool.h:178
disc_info::dbc_v
unsigned char dbc_v
Definition: cdrwtool.h:135
set_cd_speed
int set_cd_speed(int, int)
Definition: cdrwtool.c:594
make_write_page
void make_write_page(write_params_t *, struct cdrw_disc *)
Definition: cdrwtool.c:734
cdrw_init_disc
void cdrw_init_disc(struct cdrw_disc *)
Definition: cdrwtool.c:769
disc_capacity::lba
uint32_t lba
Definition: cdrwtool.h:212
disc_info::did_v
unsigned char did_v
Definition: cdrwtool.h:134
disc_info::lead_out_s
uint8_t lead_out_s
Definition: cdrwtool.h:155
close_session
int close_session(int, unsigned int)
Definition: cdrwtool.c:549
disc_info::uru
unsigned char uru
Definition: cdrwtool.h:136
blank_disc
int blank_disc(int, int)
Definition: cdrwtool.c:392
cdrom_open_check
int cdrom_open_check(int)
Definition: cdrwtool.c:623
write_params_t::border
unsigned char border
Definition: cdrwtool.h:65
track_info::free_blocks
uint32_t free_blocks
Definition: cdrwtool.h:196
hexdump
void hexdump(const void *, int)
Definition: cdrwtool.c:49
write_params_t::link_size
unsigned char link_size
Definition: cdrwtool.h:69
track_info
Definition: cdrwtool.h:162
track_info::packet_size
uint32_t packet_size
Definition: cdrwtool.h:197
track_info::reserved4
uint8_t reserved4
Definition: cdrwtool.h:202
opc_table_t
struct opc_table opc_table_t
write_params_t::session_format
unsigned char session_format
Definition: cdrwtool.h:70
track_info::fp
uint8_t fp
Definition: cdrwtool.h:175
cdrw_disc::link_size
unsigned char link_size
Definition: cdrwtool.h:83
cdrw_disc::mkudf
unsigned char mkudf
Definition: cdrwtool.h:92
disc_info::reserved3
uint8_t reserved3
Definition: cdrwtool.h:158
wait_cmd
int wait_cmd(int, struct cdrom_generic_command *, unsigned char *, int, int)
Definition: cdrwtool.c:76
cdrw_disc::set_settings
unsigned char set_settings
Definition: cdrwtool.h:79
cdrom_close
void cdrom_close(int)
Definition: cdrwtool.c:614
read_disc_info
int read_disc_info(int, disc_info_t *)
Definition: cdrwtool.c:456
disc_info::last_track_m
uint8_t last_track_m
Definition: cdrwtool.h:147