12 #include "../config.h"
28 #define PATH_MAX Libisofs_default_path_maX
56 if (info.st_size == esize) {
59 return (esize > info.st_size) ? 3 : 2;
100 if (stream == NULL) {
110 if (S_ISREG(info.st_mode) || S_ISBLK(info.st_mode)) {
148 if (stream == NULL) {
186 if (new_data == NULL) {
187 free((
char *) stream);
190 *new_stream = stream;
193 stream->
data = new_data;
197 free((
char *) stream);
198 free((
char *) new_data);
232 if (src == NULL || stream == NULL) {
240 if (S_ISDIR(info.st_mode)) {
262 data->
size = info.st_size;
279 data->
dev_id = info.st_dev;
280 data->
ino_id = info.st_ino;
294 int *header_size_div4,
int *block_size_log2,
295 uint64_t *uncompressed_size,
int flag)
303 int *header_size_div4,
int *block_size_log2,
304 uint64_t *uncompressed_size,
int flag);
311 block_size_log2, uncompressed_size, 0);
336 if (stream == NULL) {
353 if (data->
offset > info.st_size) {
364 if (data->
offset + data->
size > info.st_size) {
375 if (stream == NULL) {
393 count = (size_t)
MIN((
size_t) (data->
size - data->
pos), count);
464 if (new_data == NULL) {
465 free((
char *) stream);
470 free((
char *) stream);
471 free((
char *) new_data);
475 new_data->
dev_id = (dev_t) 0;
481 stream->
data = new_data;
482 *new_stream = stream;
515 if (
src == NULL || stream == NULL) {
526 if (!S_ISREG(info.st_mode)) {
529 if (
offset > info.st_size) {
582 if (stream == NULL) {
597 if (stream == NULL) {
614 return (off_t)data->
size;
622 if (stream == NULL || buf == NULL) {
639 memcpy(buf, data->
buf + data->
offset, len);
666 if (data->
buf != NULL)
689 uint8_t *new_buf = NULL;
701 if (new_data == NULL) {
702 free((
char *) stream);
706 if (data->
size > 0) {
707 new_buf = calloc(1, data->
size);
708 if (new_buf == NULL) {
709 free((
char *) stream);
710 free((
char *) new_data);
713 memcpy(new_buf, data->
buf, data->
size);
715 new_data->
buf = new_buf;
720 stream->
data = new_data;
721 *new_stream = stream;
756 if (buf == NULL || stream == NULL) {
818 return stream->
class->
read(stream, buf, count);
831 return (class->version >= 1) ?
class->update_size(stream) : 0;
838 stream->
class->
get_id(stream, fs_id, dev_id, ino_id);
845 if (!strncmp(type,
"fsrc", 4)) {
855 }
else if (!strncmp(type,
"boot", 4)) {
856 strcpy(name,
"BOOT CATALOG");
857 }
else if (!strncmp(type,
"mem ", 4)) {
858 strcpy(name,
"MEM SOURCE");
859 }
else if (!strncmp(type,
"extf", 4)) {
860 strcpy(name,
"EXTERNAL FILTER");
862 strcpy(name,
"UNKNOWN SOURCE");
872 if (stream == NULL) {
876 class = stream->class;
877 if (class->version < 2)
879 next =
class->get_input_stream(stream, 0);
891 char *path = NULL, ivd[80], *raw_path = NULL;
893 if (stream == NULL) {
904 sprintf(ivd,
" %.f %.f",
905 (
double) cout_data->
offset, (
double) cout_data->
size);
906 path= calloc(strlen(raw_path) + strlen(ivd) + 1, 1);
910 strcpy(path, raw_path);
914 if (raw_path != NULL)
927 if (stream == NULL) {
932 if (base_stream != NULL)
933 stream = base_stream;
1008 if (last_cpr != NULL)
1009 last_cpr->
next = cpr;
1025 return rank1 < rank2 ? -1 : 1;
1045 unsigned int fs_id1, fs_id2;
1046 dev_t dev_id1, dev_id2;
1047 ino_t ino_id1, ino_id2;
1053 #ifdef Libisofs_stream_cmp_ino_debuG
1054 static int report_counter = 0;
1055 static int debug = 1;
1135 if (fs_id1 < fs_id2) {
1137 }
else if (fs_id1 > fs_id2) {
1141 if (dev_id1 > dev_id2) {
1143 }
else if (dev_id1 < dev_id2) {
1145 }
else if (ino_id1 < ino_id2) {
1147 }
else if (ino_id1 > ino_id2) {
1152 if (size1 < size2) {
1154 #ifdef Libisofs_stream_cmp_ino_debuG
1156 if (report_counter < 5)
1158 "\n\nlibisofs_DEBUG : Program error: same ino but differing size\n\n\n");
1159 else if (report_counter == 5)
1161 "\n\nlibisofs_DEBUG : Inode error: more of same ino but differing size\n\n\n");
1167 }
else if (size1 > size2) {
1169 #ifdef Libisofs_stream_cmp_ino_debuG
1171 if (report_counter < 5)
1173 "\n\nlibisofs_DEBUG : Inode error: same ino but differing size\n\n\n");
1174 else if (report_counter == 5)
1176 "\n\nlibisofs_DEBUG : Program error: more of same ino but differing size\n\n\n");
1186 if (fs_id1 == 0 && dev_id1 == 0 && ino_id1 == 0) {
1187 return (s1 < s2 ? -1 : 1);
1206 memset(buf + *got, 0, count - *got);
1212 }
while (*got < count);
1216 memset(buf + *got, 0, count - *got);
1229 int ret, is_open = 0;
1233 uint32_t b, nblocks;
1241 if (input_stream == NULL)
1243 stream = input_stream;
1258 for (b = 0; b < nblocks; ++b) {
1302 if (input_stream == NULL)
1309 free((
char *) stream);
1314 stream->
data = NULL;
1315 *new_stream = stream;
static off_t file_size(struct burn_source *source)
int iso_ifs_sections_cmp(IsoFileSource *s1, IsoFileSource *s2, int *cmp_ret, int flag)
int iso_ifs_source_get_zf(IsoFileSource *src, uint8_t zisofs_algo[2], int *header_size_div4, int *block_size_log2, uint64_t *uncompressed_size, int flag)
off_t iso_file_source_lseek(IsoFileSource *src, off_t offset, int flag)
int iso_file_source_read(IsoFileSource *src, void *buf, size_t count)
void iso_file_source_unref(IsoFileSource *src)
int iso_file_source_access(IsoFileSource *src)
int iso_file_source_close(IsoFileSource *src)
int iso_file_source_stat(IsoFileSource *src, struct stat *info)
void iso_file_source_ref(IsoFileSource *src)
IsoFilesystem * iso_file_source_get_filesystem(IsoFileSource *src)
int iso_file_source_open(IsoFileSource *src)
char * iso_file_source_get_path(IsoFileSource *src)
#define LIBISO_FREE_MEM(pt)
#define LIBISO_ALLOC_MEM_VOID(pt, typ, count)
#define LIBISO_ALLOC_MEM(pt, typ, count)
int iso_md5_end(void **md5_context, char result[16])
#define ISO_STREAM_NO_CLONE
#define ISO_FILE_NOT_OPENED
#define ISO_FILE_OFFSET_TOO_BIG
#define ISO_WRONG_ARG_VALUE
int iso_md5_start(void **md5_context)
int iso_md5_compute(void *md5_context, char *data, int datalen)
#define ISO_FILE_ALREADY_OPENED
static IsoStreamIface fsrc_stream_class
static int cut_out_is_repeatable(IsoStream *stream)
int iso_stream_read_buffer(IsoStream *stream, char *buf, size_t count, size_t *got)
int iso_file_source_stream_new(IsoFileSource *src, IsoStream **stream)
static IsoStreamIface mem_stream_class
static int mem_clone_stream(IsoStream *old_stream, IsoStream **new_stream, int flag)
static IsoStream * fsrc_get_input_stream(IsoStream *stream, int flag)
static void cut_out_get_id(IsoStream *stream, unsigned int *fs_id, dev_t *dev_id, ino_t *ino_id)
static int fsrc_is_repeatable(IsoStream *stream)
static void cut_out_free(IsoStream *stream)
char * iso_stream_get_source_path(IsoStream *stream, int flag)
static off_t cut_out_get_size(IsoStream *stream)
static int fsrc_open(IsoStream *stream)
void iso_stream_get_file_name(IsoStream *stream, char *name)
static int iso_get_streamcmprank(int(*cmp_func)(IsoStream *s1, IsoStream *s2), int flag)
int iso_stream_update_size(IsoStream *stream)
int iso_stream_clone(IsoStream *old_stream, IsoStream **new_stream, int flag)
IsoStream * iso_stream_get_input_stream(IsoStream *stream, int flag)
static int mem_read(IsoStream *stream, void *buf, size_t count)
int iso_stream_get_src_zf(IsoStream *stream, uint8_t zisofs_algo[2], int *header_size_div4, int *block_size_log2, uint64_t *uncompressed_size, int flag)
int iso_stream_open(IsoStream *stream)
static int cut_out_clone_stream(IsoStream *old_stream, IsoStream **new_stream, int flag)
int iso_memory_stream_new(unsigned char *buf, size_t size, IsoStream **stream)
static int iso_cmp_streamcmpranks(int(*cf1)(IsoStream *s1, IsoStream *s2), int(*cf2)(IsoStream *s1, IsoStream *s2))
static struct iso_streamcmprank * streamcmpranks
off_t iso_stream_get_size(IsoStream *stream)
static IsoStreamIface cut_out_stream_class
static int cut_out_read(IsoStream *stream, void *buf, size_t count)
static int fsrc_close(IsoStream *stream)
static int mem_is_repeatable(IsoStream *stream)
static off_t fsrc_get_size(IsoStream *stream)
int iso_stream_make_md5(IsoStream *stream, char md5[16], int flag)
static int cut_out_close(IsoStream *stream)
static int cut_out_open(IsoStream *stream)
static int mem_open(IsoStream *stream)
int iso_stream_cmp_ifs_sections(IsoStream *s1, IsoStream *s2, int *cmp_ret, int flag)
void iso_stream_get_id(IsoStream *stream, unsigned int *fs_id, dev_t *dev_id, ino_t *ino_id)
int iso_stream_read(IsoStream *stream, void *buf, size_t count)
int iso_stream_set_image_ino(IsoStream *stream, ino_t ino, int flag)
static IsoStream * mem_get_input_stream(IsoStream *stream, int flag)
static void mem_get_id(IsoStream *stream, unsigned int *fs_id, dev_t *dev_id, ino_t *ino_id)
int iso_stream_cmp_ino(IsoStream *s1, IsoStream *s2, int flag)
static off_t mem_get_size(IsoStream *stream)
int iso_cut_out_stream_new(IsoFileSource *src, off_t offset, off_t size, IsoStream **stream)
static int cut_out_update_size(IsoStream *stream)
static void fsrc_free(IsoStream *stream)
void iso_stream_unref(IsoStream *stream)
static int mem_close(IsoStream *stream)
static int mem_update_size(IsoStream *stream)
static void mem_free(IsoStream *stream)
static IsoStream * cut_out_get_input_stream(IsoStream *stream, int flag)
int iso_stream_destroy_cmpranks(int flag)
static int fsrc_read(IsoStream *stream, void *buf, size_t count)
static void fsrc_get_id(IsoStream *stream, unsigned int *fs_id, dev_t *dev_id, ino_t *ino_id)
int iso_stream_close(IsoStream *stream)
static int fsrc_update_size(IsoStream *stream)
int iso_stream_clone_filter_common(IsoStream *old_stream, IsoStream **new_stream, IsoStream **new_input, int flag)
void iso_stream_ref(IsoStream *stream)
int fsrc_clone_stream(IsoStream *old_stream, IsoStream **new_stream, int flag)
int iso_stream_is_repeatable(IsoStream *stream)
int(* clone_src)(IsoFileSource *old_src, IsoFileSource **new_src, int flag)
void(* get_id)(IsoStream *stream, unsigned int *fs_id, dev_t *dev_id, ino_t *ino_id)
int(* cmp_ino)(IsoStream *s1, IsoStream *s2)
int(* clone_stream)(IsoStream *old_stream, IsoStream **new_stream, int flag)
int(* is_repeatable)(IsoStream *stream)
off_t(* get_size)(IsoStream *stream)
int(* close)(IsoStream *stream)
void(* free)(IsoStream *stream)
int(* open)(IsoStream *stream)
int(* read)(IsoStream *stream, void *buf, size_t count)
const IsoFileSourceIface * class
unsigned int(* get_id)(IsoFilesystem *fs)
struct iso_streamcmprank * next
int(* cmp_func)(IsoStream *s1, IsoStream *s2)