Comitted file which was forgotten with commit f0d9795

This commit is contained in:
Thomas Schmitt 2024-03-09 18:59:18 +01:00
parent f84d038121
commit 51f43127ac
2 changed files with 76 additions and 19 deletions

View File

@ -1 +1 @@
#define Cdrskin_timestamP "2024.03.03.201314" #define Cdrskin_timestamP "2024.03.09.175618"

View File

@ -34,6 +34,7 @@
#include "util.h" #include "util.h"
#include "transport.h" #include "transport.h"
#include "mmc.h" #include "mmc.h"
#include "drive.h"
#include "libdax_msgs.h" #include "libdax_msgs.h"
extern struct libdax_msgs *libdax_messenger; extern struct libdax_msgs *libdax_messenger;
@ -319,8 +320,8 @@ void burn_structure_print_track(struct burn_track *t)
{ {
char msg[80]; char msg[80];
sprintf(msg, " track size %d sectors", sprintf(msg, " track size %.f sectors",
burn_track_get_sectors(t)); (double) burn_track_get_sectors_v2(t));
libdax_msgs_submit(libdax_messenger, -1, 0x00000002, libdax_msgs_submit(libdax_messenger, -1, 0x00000002,
LIBDAX_MSGS_SEV_DEBUG, LIBDAX_MSGS_PRIO_HIGH, LIBDAX_MSGS_SEV_DEBUG, LIBDAX_MSGS_PRIO_HIGH,
msg, 0, 0); msg, 0, 0);
@ -506,14 +507,14 @@ int burn_track_set_postgap_size(struct burn_track *t, int size, int flag)
return 1; return 1;
} }
/* ts B20119: outsourced from burn_track_get_sectors() /* ts B20119 / C40302: outsourced from burn_track_get_sectors()
@param flag bit0= do not add post-gap @param flag bit0= do not add post-gap
*/ */
int burn_track_get_sectors_2(struct burn_track *t, int flag) off_t burn_track_get_sectors_2_v2(struct burn_track *t, int flag)
{ {
/* ts A70125 : was int */ /* ts A70125 : was int */
off_t size = 0; off_t size = 0, sectors;
int sectors, seclen; int seclen;
seclen = burn_sector_length(t->mode); seclen = burn_sector_length(t->mode);
@ -529,14 +530,22 @@ int burn_track_get_sectors_2(struct burn_track *t, int flag)
} else if(t->entry != NULL) { } else if(t->entry != NULL) {
/* ts A80808 : all burn_toc_entry of track starts should now /* ts A80808 : all burn_toc_entry of track starts should now
have (extensions_valid & 1), even those from CD. have (extensions_valid & 1), even those from CD.
ts C40302 : Now there should be long_track_blocks.
*/ */
if (t->entry->extensions_valid & 1) if (t->entry->extensions_valid & 8) {
size = t->entry->long_track_blocks * (off_t) 2048;
} else if (t->entry->extensions_valid & 1) {
size = ((off_t) t->entry->track_blocks) * (off_t) 2048; size = ((off_t) t->entry->track_blocks) * (off_t) 2048;
} }
if (size > ((off_t) 0x7ffffff0) * (off_t) 2048) { }
if (size > BURN_DRIVE_MAX_BYTES) {
char msg[80];
sprintf(msg, "Track size exceeds limit of %.f bytes",
(double) (BURN_DRIVE_MAX_BYTES));
libdax_msgs_submit(libdax_messenger, -1, 0x000201ae, libdax_msgs_submit(libdax_messenger, -1, 0x000201ae,
LIBDAX_MSGS_SEV_FAILURE, LIBDAX_MSGS_PRIO_HIGH, LIBDAX_MSGS_SEV_FAILURE, LIBDAX_MSGS_PRIO_HIGH,
"Track size exceeds 4 TiB - 32 KiB", 0, 0); msg, 0, 0);
return -1; return -1;
} }
sectors = size / seclen; sectors = size / seclen;
@ -545,14 +554,34 @@ int burn_track_get_sectors_2(struct burn_track *t, int flag)
return sectors; return sectors;
} }
int burn_track_get_sectors_2(struct burn_track *t, int flag)
{
/* ts A70125 : was int */
off_t sectors = 0;
sectors = burn_track_get_sectors_2_v2(t, flag);
if (sectors > (off_t) 0x7ffffff0) {
libdax_msgs_submit(libdax_messenger, -1, 0x000201ae,
LIBDAX_MSGS_SEV_FAILURE, LIBDAX_MSGS_PRIO_HIGH,
"Track size exceeds 4 TiB - 32 KiB", 0, 0);
return -1;
}
return (int) sectors;
}
int burn_track_get_sectors(struct burn_track *t) int burn_track_get_sectors(struct burn_track *t)
{ {
return burn_track_get_sectors_2(t, 0); return burn_track_get_sectors_2(t, 0);
} }
/* ts C40302 : API */
off_t burn_track_get_sectors_v2(struct burn_track *t)
{
return burn_track_get_sectors_2_v2(t, 0);
}
/* ts A70125 */ /* ts A70125 */
int burn_track_set_sectors(struct burn_track *t, int sectors) int burn_track_set_sectors(struct burn_track *t, off_t sectors)
{ {
off_t size, seclen; off_t size, seclen;
int ret; int ret;
@ -595,26 +624,29 @@ int burn_track_set_fillup(struct burn_track *t, int fill_up_media)
*/ */
int burn_track_apply_fillup(struct burn_track *t, off_t max_size, int flag) int burn_track_apply_fillup(struct burn_track *t, off_t max_size, int flag)
{ {
int max_sectors, ret = 2, track_sectors; int ret = 2;
off_t max_sectors, track_sectors;
char msg[80]; char msg[80];
if (t->fill_up_media <= 0) if (t->fill_up_media <= 0)
return 2; return 2;
if (max_size > (off_t) 0x7ffffff0 * (off_t) 2048) { if (max_size > BURN_DRIVE_MAX_BYTES) {
sprintf(msg, "Track size exceeds limit of %.f bytes",
(double) (BURN_DRIVE_MAX_BYTES));
libdax_msgs_submit(libdax_messenger, -1, 0x000201ae, libdax_msgs_submit(libdax_messenger, -1, 0x000201ae,
LIBDAX_MSGS_SEV_FAILURE, LIBDAX_MSGS_PRIO_HIGH, LIBDAX_MSGS_SEV_FAILURE, LIBDAX_MSGS_PRIO_HIGH,
"Track size exceeds 4 TiB - 32 KiB", 0, 0); msg, 0, 0);
return 0; return 0;
} }
max_sectors = max_size / 2048; max_sectors = max_size / 2048;
track_sectors = burn_track_get_sectors(t); track_sectors = burn_track_get_sectors_v2(t);
if (track_sectors < 0) if (track_sectors < 0)
return 0; return 0;
if (track_sectors < max_sectors || (flag & 1)) { if (track_sectors < max_sectors || (flag & 1)) {
sprintf(msg, "Setting total track size to %ds (payload %ds)\n", sprintf(msg,
max_sectors & 0x7fffffff, "Setting total track size to %.fs (payload %.fs)\n",
(int) ((t->source->get_size(t->source) / 2048) (double) max_sectors,
& 0x7fffffff)); (double) (t->source->get_size(t->source) / 2048));
libdax_msgs_submit(libdax_messenger, -1, 0x00000002, libdax_msgs_submit(libdax_messenger, -1, 0x00000002,
LIBDAX_MSGS_SEV_DEBUG, LIBDAX_MSGS_PRIO_ZERO, LIBDAX_MSGS_SEV_DEBUG, LIBDAX_MSGS_PRIO_ZERO,
msg, 0, 0); msg, 0, 0);
@ -691,6 +723,20 @@ int burn_session_get_sectors(struct burn_session *s)
return sectors; return sectors;
} }
/* ts C40302: API */
off_t burn_session_get_sectors_v2(struct burn_session *s)
{
int i;
off_t sectors = 0, track_sectors;
for (i = 0; i < s->tracks; i++) {
track_sectors = burn_track_get_sectors_v2(s->track[i]);
if (track_sectors < 0)
track_sectors = 0;
sectors += track_sectors;
}
return sectors;
}
int burn_disc_get_sectors(struct burn_disc *d) int burn_disc_get_sectors(struct burn_disc *d)
{ {
@ -701,6 +747,17 @@ int burn_disc_get_sectors(struct burn_disc *d)
return sectors; return sectors;
} }
/* ts C40302: API */
off_t burn_disc_get_sectors_v2(struct burn_disc *d)
{
int i;
off_t sectors = 0;
for (i = 0; i < d->sessions; i++)
sectors += burn_session_get_sectors_v2(d->session[i]);
return sectors;
}
void burn_track_get_entry(struct burn_track *t, struct burn_toc_entry *entry) void burn_track_get_entry(struct burn_track *t, struct burn_toc_entry *entry)
{ {
if (t->entry == NULL) if (t->entry == NULL)