New API call burn_get_read_capacity_v2()

This commit is contained in:
Thomas Schmitt 2024-03-03 16:24:13 +01:00
parent f0d9795cd1
commit e5a8d91e4d
8 changed files with 51 additions and 30 deletions

View File

@ -1 +1 @@
#define Cdrskin_timestamP "2024.03.03.105146"
#define Cdrskin_timestamP "2024.03.03.152344"

View File

@ -3494,15 +3494,32 @@ int burn_drive_set_media_capacity_remaining(struct burn_drive *d, off_t value)
return 1;
}
/* ts C40303 : API */
int burn_get_read_capacity_v2(struct burn_drive *d, off_t *capacity, int flag)
{
*capacity = d->media_read_capacity +
(d->media_read_capacity != 0x7fffffffffffffff);
return (d->media_read_capacity != 0x7fffffffffffffff);
}
/* ts A81215 : API */
int burn_get_read_capacity(struct burn_drive *d, int *capacity, int flag)
{
*capacity = d->media_read_capacity +
(d->media_read_capacity != 0x7fffffff);
return (d->media_read_capacity != 0x7fffffff);
}
int ret;
off_t cap;
ret= burn_get_read_capacity_v2(d, &cap, flag);
if (cap < -0x7fffffff) {
*capacity = -0x7fffffff;
ret = 0;
} else if (cap > 0x7fffffff) {
*capacity = 0x7fffffff;
ret = 0;
} else {
*capacity = cap;
}
return ret;
}
/* ts A90903 : API */
int burn_disc_get_media_id(struct burn_drive *d,

View File

@ -1,7 +1,7 @@
/* -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 8; -*- */
/* Copyright (c) 2004 - 2006 Derek Foreman, Ben Jansens
Copyright (c) 2006 - 2021 Thomas Schmitt <scdbackup@gmx.net>
Copyright (c) 2006 - 2024 Thomas Schmitt <scdbackup@gmx.net>
Provided under GPL version 2 or later.
*/
@ -172,9 +172,10 @@ int burn_drive_grab_stdio(struct burn_drive *d, int flag);
/* ts C10213 */
/* The size of limitless or oversized devices as pseudo drives */
/* Do not change this value because of its meaning to
/* Do not lightheartedly change this value because of its meaning to
burn_drive.media_read_capacity in libburn/transport.h
64 TiB = 2 exp 46 = 2 exp 35 blocks
*/
#define BURN_DRIVE_MAX_BYTES ((off_t) (0x7ffffff0) * (off_t) 2048)
#define BURN_DRIVE_MAX_BYTES ((off_t) (0x800000000) * (off_t) 2048)
#endif /* __DRIVE */

View File

@ -4251,6 +4251,12 @@ int burn_random_access_write(struct burn_drive *d, off_t byte_address,
*/
int burn_get_read_capacity(struct burn_drive *d, int *capacity, int flag);
/* ts C40303 */
/** Like burn_get_read_capacity(), but with off_t result.
@since 1.5.8
*/
int burn_get_read_capacity_v2(struct burn_drive *d, off_t *capacity, int flag);
/* ts A70812 */
/** Read data in random access mode.

View File

@ -218,6 +218,7 @@ LIBBURN4_1.5.8 {
burn_disc_get_sectors_v2;
burn_disc_track_lba_nwa_v2;
burn_drive_get_status_v2;
burn_get_read_capacity_v2;
burn_session_get_sectors_v2;
burn_track_get_sectors_v2;
} LIBBURN4;

View File

@ -1774,8 +1774,8 @@ static int mmc_read_toc_al(struct burn_drive *d, int *alloc_len)
TOC format 2 always reports 2 blocks more than are readable.
So here it is possible to check and mark as trusted.
*/
if (highest_leadout > 0 && d->media_read_capacity != 0x7fffffff &&
!d->mr_capacity_trusted) {
if (highest_leadout > 0 && d->media_read_capacity != 0x7fffffffffffffff
&& !d->mr_capacity_trusted) {
if (highest_leadout - 3 == d->media_read_capacity) {
d->mr_capacity_trusted = 1;
libdax_msgs_submit(libdax_messenger, d->global_index,
@ -2015,7 +2015,7 @@ static int mmc_read_disc_info_al(struct burn_drive *d, int *alloc_len)
d->media_lba_limit = 0;
/* ts A81210 */
d->media_read_capacity = 0x7fffffff;
d->media_read_capacity = 0x7fffffffffffffff;
d->mr_capacity_trusted = -1;
/* ts A61202 */
@ -4967,7 +4967,7 @@ int mmc_read_capacity(struct burn_drive *d)
BURN_ALLOC_MEM(buf, struct buffer, 1);
BURN_ALLOC_MEM(c, struct command, 1);
d->media_read_capacity = 0x7fffffff;
d->media_read_capacity = 0x7fffffffffffffff;
d->mr_capacity_trusted = -1;
mmc_start_if_needed(d, 1);
if (mmc_function_spy(d, "mmc_read_capacity") <= 0)
@ -4981,11 +4981,7 @@ int mmc_read_capacity(struct burn_drive *d)
c->page->sectors = 0;
c->dir = FROM_DRIVE;
d->issue_command(d, c);
d->media_read_capacity = mmc_four_char_to_int(c->page->data);
if (d->media_read_capacity < 0) {
d->media_read_capacity = 0x7fffffff;
{ret = 0; goto ex;}
}
d->media_read_capacity = mmc_four_char_to_uint(c->page->data);
if (d->current_profile >= 0x08 && d->current_profile <= 0x0A)
d->mr_capacity_trusted = 0;
else
@ -5505,7 +5501,7 @@ int mmc_setup_drive(struct burn_drive *d)
d->last_track_no = 1;
d->media_capacity_remaining = 0;
d->media_lba_limit = 0;
d->media_read_capacity = 0x7fffffff;
d->media_read_capacity = 0x7fffffffffffffff;
d->mr_capacity_trusted = 0;
d->pessimistic_buffer_free = 0;
d->pbf_altered = 0;

View File

@ -1,7 +1,7 @@
/* -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 8; -*- */
/* Copyright (c) 2004 - 2006 Derek Foreman, Ben Jansens
Copyright (c) 2006 - 2014 Thomas Schmitt <scdbackup@gmx.net>
Copyright (c) 2006 - 2024 Thomas Schmitt <scdbackup@gmx.net>
Provided under GPL version 2 or later.
*/
@ -492,13 +492,13 @@ int burn_read_data(struct burn_drive *d, off_t byte_address,
msg, 0, 0);
{ret = 0; goto ex;}
}
if (d->media_read_capacity != 0x7fffffff && byte_address >=
((off_t) d->media_read_capacity + (off_t) 1) * (off_t) 2048) {
if (d->media_read_capacity != 0x7fffffffffffffff &&
byte_address >= (d->media_read_capacity + 1) * (off_t) 2048) {
if (!(flag & 2)) {
sprintf(msg,
"Read start address %ds larger than number of readable blocks %d",
(int) (byte_address / 2048 + !!(byte_address % 2048)),
d->media_read_capacity + 1);
"Read start address %.fs larger than number of readable blocks %.f",
(double) (byte_address / 2048 + !!(byte_address % 2048)),
(double) (d->media_read_capacity + 1));
libdax_msgs_submit(libdax_messenger, d->global_index,
0x00020172, (flag & 32) ?
LIBDAX_MSGS_SEV_DEBUG : LIBDAX_MSGS_SEV_SORRY,

View File

@ -371,13 +371,13 @@ struct burn_drive
/* ts A70215 : if > 0 : first lba on media that is too high for write*/
int media_lba_limit;
/* ts A81210 : Upper limit of readable data size,
0x7fffffff = unknown
0x7ffffff0 = BURN_DRIVE_MAX_BYTES / 2048
possibly truncated to prevent 32 bit
overflow, or unknown stdio size
/* ts A81210 / C40303 : Upper limit of readable data size,
0x7fffffffffffffff = unknown
BURN_DRIVE_MAX_BYTES / 2048 = possibly truncated
or unknown stdio size
*/
int media_read_capacity;
off_t media_read_capacity;
/* ts B60305 : Whether READ CAPACITY of CD is credible:
-1= no READ CAPACITY yet , 0= untrusted READ CAPACITY
1= READ CAPACITY confirmed or corrected by other commands