Control size of extents with #define blocks, to help testing.
This commit is contained in:
parent
643dbef05c
commit
ff480b35e9
@ -18,6 +18,18 @@
|
||||
|
||||
#define BLOCK_SIZE 2048
|
||||
|
||||
/*
|
||||
* Maximum file section size. Set to 4GB - 1 = 0xffffffff
|
||||
*/
|
||||
#define MAX_ISO_FILE_SECTION_SIZE 0xffffffff
|
||||
|
||||
/*
|
||||
* When a file need to be splitted in several sections, the maximum size
|
||||
* of such sections, but the last one. Set to a multiple of BLOCK_SIZE.
|
||||
* Default to 4GB - 2048 = 0xFFFFF800
|
||||
*/
|
||||
#define ISO_EXTENT_SIZE 0xFFFFF800
|
||||
|
||||
/**
|
||||
* Holds the options for the image generation.
|
||||
*/
|
||||
|
@ -161,7 +161,7 @@ int create_file(Ecma119Image *img, IsoFile *iso, Ecma119Node **node)
|
||||
off_t size;
|
||||
|
||||
size = iso_stream_get_size(iso->stream);
|
||||
if (size > (off_t)0xffffffff && img->iso_level != 3) {
|
||||
if (size > (off_t)MAX_ISO_FILE_SECTION_SIZE && img->iso_level != 3) {
|
||||
return iso_msg_submit(img->image->id, ISO_FILE_TOO_BIG, 0,
|
||||
"File \"%s\" can't be added to image because "
|
||||
"is greater than 4GB", iso->node.name);
|
||||
|
@ -187,26 +187,28 @@ int filesrc_writer_compute_data_blocks(IsoImageWriter *writer)
|
||||
IsoFileSrc *file = filelist[i];
|
||||
|
||||
off_t section_size = iso_stream_get_size(file->stream);
|
||||
if (section_size > (off_t) 0xffffffff) {
|
||||
if (section_size > (off_t) MAX_ISO_FILE_SECTION_SIZE) {
|
||||
file->nsections = DIV_UP(iso_stream_get_size(file->stream)
|
||||
- (off_t) 0xffffffff, (off_t)0xFFFFF800) + 1;
|
||||
- (off_t) MAX_ISO_FILE_SECTION_SIZE,
|
||||
(off_t)ISO_EXTENT_SIZE) + 1;
|
||||
} else {
|
||||
file->nsections = 1;
|
||||
}
|
||||
file->sections = realloc(file->sections, file->nsections *
|
||||
sizeof(struct iso_file_section));
|
||||
for (extent = 0; extent < file->nsections - 1; ++extent) {
|
||||
file->sections[extent].block = t->curblock + extent * 2097151;
|
||||
file->sections[extent].size = 0xFFFFF800;
|
||||
section_size -= (off_t) 0xFFFFF800;
|
||||
file->sections[extent].block = t->curblock + extent *
|
||||
(ISO_EXTENT_SIZE / BLOCK_SIZE);
|
||||
file->sections[extent].size = ISO_EXTENT_SIZE;
|
||||
section_size -= (off_t) ISO_EXTENT_SIZE;
|
||||
}
|
||||
|
||||
/*
|
||||
* final section
|
||||
*/
|
||||
file->sections[extent].block = t->curblock + extent * 2097151;
|
||||
file->sections[extent].block = t->curblock + extent * (ISO_EXTENT_SIZE / BLOCK_SIZE);
|
||||
file->sections[extent].size = section_size;
|
||||
section_size -= (off_t) 0xFFFFF800;
|
||||
section_size -= (off_t) ISO_EXTENT_SIZE;
|
||||
|
||||
t->curblock += DIV_UP(iso_file_src_get_size(file), BLOCK_SIZE);
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ int create_node(Ecma119Image *t, IsoNode *iso, Iso1999Node **node)
|
||||
IsoFile *file = (IsoFile*) iso;
|
||||
|
||||
size = iso_stream_get_size(file->stream);
|
||||
if (size > (off_t)0xffffffff && t->iso_level != 3) {
|
||||
if (size > (off_t)MAX_ISO_FILE_SECTION_SIZE && t->iso_level != 3) {
|
||||
free(n);
|
||||
return iso_msg_submit(t->image->id, ISO_FILE_TOO_BIG, 0,
|
||||
"File \"%s\" can't be added to image because is "
|
||||
|
@ -111,7 +111,7 @@ int create_node(Ecma119Image *t, IsoNode *iso, JolietNode **node)
|
||||
IsoFile *file = (IsoFile*) iso;
|
||||
|
||||
size = iso_stream_get_size(file->stream);
|
||||
if (size > (off_t)0xffffffff && t->iso_level != 3) {
|
||||
if (size > (off_t)MAX_ISO_FILE_SECTION_SIZE && t->iso_level != 3) {
|
||||
free(joliet);
|
||||
return iso_msg_submit(t->image->id, ISO_FILE_TOO_BIG, 0,
|
||||
"File \"%s\" can't be added to image because is "
|
||||
|
@ -2546,7 +2546,7 @@ int iso_file_get_old_image_lba(IsoFile *file, uint32_t *lba, int flag);
|
||||
* @param file
|
||||
* The file
|
||||
* @param section_count
|
||||
* Returns the number of extent entries in sections arrays
|
||||
* Returns the number of extent entries in sections array.
|
||||
* @param sections
|
||||
* Returns the array of file sections. Apply free() to dispose it.
|
||||
* @param flag
|
||||
|
Loading…
Reference in New Issue
Block a user