Introduced xorriso sector bitmap v3 with 8-byte N and S

This commit is contained in:
Thomas Schmitt 2024-03-17 17:09:00 +01:00
parent 73b3923f72
commit 86261b7972
3 changed files with 57 additions and 24 deletions

View File

@ -323,14 +323,17 @@ Sector maps describe the valid and invalid blocks on a media or a disk copy of
a media. xorriso creates and reads these file with its option -check_media. a media. xorriso creates and reads these file with its option -check_media.
The file begins with 32 bytes of cleartext of which the last one is a The file begins with 32 bytes of cleartext of which the last one is a
newline character. The first 25 say "xorriso sector bitmap v2 ", the newline character. The first 25 say "xorriso sector bitmap v2 " or
remaining six characters give the size of the info text as decimal number. "xorriso sector bitmap v3 ". The remaining six characters give the size
of the info text as decimal number.
This number of bytes follows the first 32 and will not be interpreted This number of bytes follows the first 32 and will not be interpreted
by xorriso. They are rather to inform a human reader about the media type by xorriso. They are rather to inform a human reader about the media type
and its track layout. and its track layout.
After the info text there are two 4 byte signed integers, most significant After the info text there are two signed integers, most significant byte
byte first. The first one, N, gives the number of bits in the following bitmap first. The number of bytes per integer is 4 for "v2" and 8 for "v3".
and the second number S gives the number of 2 KiB blocks governed by a single In both cases, the highest bit of the integers must be 0.
The first integer, N, gives the number of bits in the following bitmap.
The second number, S, gives the number of 2 KiB blocks governed by a single
bit in the map. Then come the bits in form of 8-bit bytes. bit in the map. Then come the bits in form of 8-bit bytes.
Data block M is covered by bit B=M/S in the map, bit number B is stored in Data block M is covered by bit B=M/S in the map, bit number B is stored in
byte B/8 as bit B%8. A valid readable data block has its bit set to 1. byte B/8 as bit B%8. A valid readable data block has its bit set to 1.
@ -521,7 +524,7 @@ By Mario Danic <mario.danic@gmail.com>, libburn, libisofs
Vreixo Formoso <metalpain2002@yahoo.es>, libisofs, libisoburn Vreixo Formoso <metalpain2002@yahoo.es>, libisofs, libisoburn
Thomas Schmitt <scdbackup@gmx.net>, libburn, libisofs, Thomas Schmitt <scdbackup@gmx.net>, libburn, libisofs,
libisoburn, xorriso libisoburn, xorriso
Copyright (C) 2006-2023 Mario Danic, Vreixo Formoso, Thomas Schmitt. Copyright (C) 2006-2024 Mario Danic, Vreixo Formoso, Thomas Schmitt.
libburnia-project.org is inspired by and in libburn still containing parts libburnia-project.org is inspired by and in libburn still containing parts
of old of old
@ -540,7 +543,7 @@ Copyright (C) 2019-2021 Nio Wiklund alias sudodus, Thomas Schmitt
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
This text itself is This text itself is
Copyright (c) 2007 - 2023 Thomas Schmitt <scdbackup@gmx.net> Copyright (c) 2007 - 2024 Thomas Schmitt <scdbackup@gmx.net>
and is freely distributable. and is freely distributable.
It shall only be modified in sync with the technical properties of xorriso. It shall only be modified in sync with the technical properties of xorriso.
If you make use of the license to derive modified versions of xorriso If you make use of the license to derive modified versions of xorriso

View File

@ -323,7 +323,8 @@ wrong_filetype:;
} }
if(strncmp((char *) buf, "xorriso sector bitmap v1 ", 32) == 0) if(strncmp((char *) buf, "xorriso sector bitmap v1 ", 32) == 0)
/* ok */; /* ok */;
else if(strncmp((char *) buf, "xorriso sector bitmap v2 ", 25) == 0) { else if(strncmp((char *) buf, "xorriso sector bitmap v2 ", 25) == 0 ||
strncmp((char *) buf, "xorriso sector bitmap v3 ", 25) == 0) {
skip= -1; skip= -1;
sscanf(((char *) buf) + 25, "%d", &skip); sscanf(((char *) buf) + 25, "%d", &skip);
if(skip < 0) if(skip < 0)
@ -338,13 +339,28 @@ wrong_filetype:;
} }
} else } else
{ret= 0; goto wrong_filetype;} {ret= 0; goto wrong_filetype;}
ret= read(fd, buf, 8); if(strncmp((char *) buf, "xorriso sector bitmap v2 ", 25) == 0) {
if(ret < 4) ret= read(fd, buf, 8);
goto wrong_filetype; if(ret < 8)
sectors= (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; goto wrong_filetype;
sector_size= (buf[4] << 24) | (buf[5] << 16) | (buf[6] << 8) | buf[7]; if((buf[0] & 128) || (buf[4] & 128))
if(sectors <= 0 || sector_size <= 0) goto wrong_filetype;
goto wrong_filetype; sectors= (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3];
sector_size= (buf[4] << 24) | (buf[5] << 16) | (buf[6] << 8) | buf[7];
} else {
ret= read(fd, buf, 16);
if(ret < 16)
goto wrong_filetype;
if((buf[0] & 128) || (buf[8] & 128))
goto wrong_filetype;
/* (My compiler hates off_t = 1 << 32. So i do it by multiplication) */
sectors= ((buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]) *
(off_t) 0x100000000;
sectors|= (buf[4] << 24) | (buf[5] << 16) | (buf[6] << 8) | buf[7];
sector_size= ((buf[8] << 24) | (buf[9] << 16) | (buf[10] << 8) | buf[11]) *
(off_t) 0x100000000;
sector_size|= (buf[12] << 24) | (buf[13] << 16) | (buf[14] << 8) | buf[15];
}
ret= Sectorbitmap_new(o, sectors, sector_size, 0); ret= Sectorbitmap_new(o, sectors, sector_size, 0);
if(ret <= 0) { if(ret <= 0) {
if(msg != NULL) if(msg != NULL)
@ -378,7 +394,8 @@ ex:;
int Sectorbitmap_to_file(struct SectorbitmaP *o, char *path, char *info, int Sectorbitmap_to_file(struct SectorbitmaP *o, char *path, char *info,
char *msg, int *os_errno, int flag) char *msg, int *os_errno, int flag)
{ {
int ret, fd= -1, j, l; int fd= -1, j, l, version= 2;
ssize_t ret;
unsigned char buf[40]; unsigned char buf[40];
*os_errno= 0; *os_errno= 0;
@ -392,6 +409,8 @@ int Sectorbitmap_to_file(struct SectorbitmaP *o, char *path, char *info,
ret= 0; goto ex; ret= 0; goto ex;
} }
if(o->sectors > 0x7fffffff || o->sector_size > 0x7fffffff)
version= 3;
l= 0; l= 0;
if(info != NULL) if(info != NULL)
l= strlen(info); l= strlen(info);
@ -399,7 +418,7 @@ int Sectorbitmap_to_file(struct SectorbitmaP *o, char *path, char *info,
strcpy(msg, "Info string is longer than 999999 bytes"); strcpy(msg, "Info string is longer than 999999 bytes");
ret= 0; goto ex; ret= 0; goto ex;
} }
sprintf((char *) buf, "xorriso sector bitmap v2 %-6d\n", l); sprintf((char *) buf, "xorriso sector bitmap v%d %-6d\n", version, l);
ret= write(fd, buf, 32); ret= write(fd, buf, 32);
if(ret != 32) { if(ret != 32) {
@ -417,13 +436,24 @@ cannot_write:;
goto cannot_write; goto cannot_write;
} }
for(j= 0; j < 4; j++) { if(version == 2) {
buf[j]= o->sectors >> (24 - j * 8); for(j= 0; j < 4; j++) {
buf[j+4]= o->sector_size >> (24 - j * 8); buf[j]= o->sectors >> (24 - j * 8);
buf[j + 4]= o->sector_size >> (24 - j * 8);
}
ret= write(fd, buf, 8);
if(ret != 8)
goto cannot_write;
} else {
for(j= 0; j < 8; j++) {
buf[j]= o->sectors >> (56 - j * 8);
buf[j + 8]= o->sector_size >> (56 - j * 8);
}
ret= write(fd, buf, 16);
if(ret != 16)
goto cannot_write;
} }
ret= write(fd, buf, 8);
if(ret != 8)
goto cannot_write;
ret= write(fd, o->map, o->map_size); ret= write(fd, o->map, o->map_size);
if(ret != o->map_size) if(ret != o->map_size)
goto cannot_write; goto cannot_write;

View File

@ -1 +1 @@
#define Xorriso_timestamP "2024.03.17.152556" #define Xorriso_timestamP "2024.03.17.160830"