"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "libisofs/fs_image.c" between
xorriso-1.5.2.tar.gz and xorriso-1.5.4.tar.gz

About: GNU xorriso creates, loads, manipulates and writes ISO 9660 filesystem images with Rock Ridge extensions. It is suitable for incremental data backup and for production of bootable ISO 9660 images. GNU xorriso is a statical compilation of the libraries libburn, libisofs, libisoburn, and libjte.

fs_image.c  (xorriso-1.5.2):fs_image.c  (xorriso-1.5.4)
/* /*
* Copyright (c) 2007 Vreixo Formoso * Copyright (c) 2007 Vreixo Formoso
* Copyright (c) 2009 - 2018 Thomas Schmitt * Copyright (c) 2009 - 2020 Thomas Schmitt
* *
* This file is part of the libisofs project; you can redistribute it and/or * This file is part of the libisofs project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2 * modify it under the terms of the GNU General Public License version 2
* or later as published by the Free Software Foundation. * or later as published by the Free Software Foundation.
* See COPYING file for details. * See COPYING file for details.
*/ */
/* /*
* Filesystem/FileSource implementation to access an ISO image, using an * Filesystem/FileSource implementation to access an ISO image, using an
* IsoDataSource to read image data. * IsoDataSource to read image data.
skipping to change at line 104 skipping to change at line 104
/** /**
* When both Joliet and RR extensions are present, the RR tree is used. * When both Joliet and RR extensions are present, the RR tree is used.
* If you prefer using Joliet, set this to 1. * If you prefer using Joliet, set this to 1.
*/ */
unsigned int preferjoliet : 1; unsigned int preferjoliet : 1;
/** /**
* If neither Rock Ridge nor Joliet is used, the ECMA-119 names are mapped * If neither Rock Ridge nor Joliet is used, the ECMA-119 names are mapped
* according to one of these rules * according to one of these rules
* 0 = unmapped: show name as recorded in ECMA-119 directory record * 0 = unmapped: show name as recorded in ECMA-119 directory record
* (not suitable for writing them to a new ISO filesystem) * (not suitable for writing it to a new ISO filesystem)
* 1 = stripped: like unmapped, but strip off trailing ";1" or ".;1" * 1 = stripped: like unmapped, but strip off trailing ";1" or ".;1"
* 2 = uppercase: like stripped, but {a-z} mapped to {A-Z} * 2 = uppercase: like stripped, but {a-z} mapped to {A-Z}
* 3 = lowercase: like stripped, but {A-Z} mapped to {a-z} * 3 = lowercase: like stripped, but {A-Z} mapped to {a-z}
*/ */
unsigned int ecma119_map : 2; unsigned int ecma119_map : 2;
/**
* If Joliet is used, apply one of these mapping rules:
* 0 = unmapped: show name as recorded in Joliet directory record
* (not suitable for writing it to a new ISO filesystem)
* 1 = stripped: strip off trailing ";1" or ".;1"
*/
unsigned int joliet_map : 1;
uid_t uid; /**< Default uid when no RR */ uid_t uid; /**< Default uid when no RR */
gid_t gid; /**< Default uid when no RR */ gid_t gid; /**< Default uid when no RR */
mode_t dir_mode; /**< Default mode when no RR (only permissions) */ mode_t dir_mode; /**< Default mode when no RR (only permissions) */
mode_t file_mode; mode_t file_mode;
/* TODO #00024 : option to convert names to lower case for iso reading */ /* TODO #00024 : option to convert names to lower case for iso reading */
/** /**
* Input charset for RR file names. NULL to use default locale charset. * Input charset for RR file names. NULL to use default locale charset.
*/ */
char *input_charset; char *input_charset;
skipping to change at line 179 skipping to change at line 187
unsigned int hasJoliet :1; unsigned int hasJoliet :1;
/** /**
* It will be set to 1 if the image is an ISO 9660:1999, i.e. it has * It will be set to 1 if the image is an ISO 9660:1999, i.e. it has
* a version 2 Enhanced Volume Descriptor. * a version 2 Enhanced Volume Descriptor.
*/ */
unsigned int hasIso1999 :1; unsigned int hasIso1999 :1;
/** It will be set to 1 if El-Torito boot record is present, to 0 if not.*/ /** It will be set to 1 if El-Torito boot record is present, to 0 if not.*/
unsigned int hasElTorito :1; unsigned int hasElTorito :1;
/**
* Which tree was loaded:
* 0= ISO 9660 + Rock Ridge , 1= Joliet , 2= ISO 9660:1999
*/
int tree_loaded;
/** Whether Rock Ridge info was used while loading: 0= no, 1= yes */
int rr_loaded;
}; };
static int ifs_fs_open(IsoImageFilesystem *fs); static int ifs_fs_open(IsoImageFilesystem *fs);
static int ifs_fs_close(IsoImageFilesystem *fs); static int ifs_fs_close(IsoImageFilesystem *fs);
static int iso_file_source_new_ifs(IsoImageFilesystem *fs, static int iso_file_source_new_ifs(IsoImageFilesystem *fs,
IsoFileSource *parent, struct ecma119_dir_record *record, IsoFileSource *parent, struct ecma119_dir_record *record,
IsoFileSource **src, int flag); IsoFileSource **src, int flag);
/** unique identifier for each image */ /** unique identifier for each image */
unsigned int fs_dev_id = 0; unsigned int fs_dev_id = 0;
skipping to change at line 211 skipping to change at line 229
*/ */
typedef struct typedef struct
{ {
/** DataSource from where data will be read */ /** DataSource from where data will be read */
IsoDataSource *src; IsoDataSource *src;
/** unique id for the each image (filesystem instance) */ /** unique id for the each image (filesystem instance) */
unsigned int id; unsigned int id;
/** /**
* Counter of the times the filesystem has been openned still pending of * Counter of the times the filesystem has been opened still pending of
* close. It is used to keep track of when we need to actually open or * close. It is used to keep track of when we need to actually open or
* close the IsoDataSource. * close the IsoDataSource.
*/ */
unsigned int open_count; unsigned int open_count;
uid_t uid; /**< Default uid when no RR */ uid_t uid; /**< Default uid when no RR */
gid_t gid; /**< Default uid when no RR */ gid_t gid; /**< Default uid when no RR */
mode_t dir_mode; /**< Default mode when no RR (only permissions) */ mode_t dir_mode; /**< Default mode when no RR (only permissions) */
mode_t file_mode; mode_t file_mode;
skipping to change at line 308 skipping to change at line 326
/** If ISO 9660:1999 is available on image */ /** If ISO 9660:1999 is available on image */
unsigned int iso1999 : 1; unsigned int iso1999 : 1;
/** /**
* See struct iso_read_opts. * See struct iso_read_opts.
*/ */
int truncate_mode; int truncate_mode;
int truncate_length; int truncate_length;
unsigned int ecma119_map : 2; unsigned int ecma119_map : 2;
unsigned int joliet_map : 1;
/** Whether AAIP info shall be loaded if it is present. /** Whether AAIP info shall be loaded if it is present.
* 1 = yes , 0 = no * 1 = yes , 0 = no
*/ */
int aaip_load; int aaip_load;
/** Whether the MD5 array shall be read if available. /** Whether the MD5 array shall be read if available.
* 2 = yes, but do not check tags , 1 = yes , 0 = no * 2 = yes, but do not check tags , 1 = yes , 0 = no
*/ */
int md5_load; int md5_load;
skipping to change at line 417 skipping to change at line 436
/** /**
* Location of file extents. * Location of file extents.
*/ */
struct iso_file_section *sections; struct iso_file_section *sections;
int nsections; int nsections;
unsigned int opened : 2; /**< 0 not opened, 1 opened file, 2 opened dir */ unsigned int opened : 2; /**< 0 not opened, 1 opened file, 2 opened dir */
#ifdef Libisofs_with_zliB #ifdef Libisofs_with_zliB
uint8_t zisofs_algo[2];
uint8_t header_size_div4; uint8_t header_size_div4;
uint8_t block_size_log2; uint8_t block_size_log2;
uint32_t uncompressed_size; uint64_t uncompressed_size;
#endif #endif
/* info for content reading */ /* info for content reading */
struct struct
{ {
/** /**
* - For regular files, once opened it points to a temporary data * - For regular files, once opened it points to a temporary data
* buffer of 2048 bytes. * buffer of 2048 bytes.
* - For dirs, once opened it points to a IsoFileSource* array with * - For dirs, once opened it points to a IsoFileSource* array with
* its children * its children
skipping to change at line 597 skipping to change at line 617
/* skip ".." */ /* skip ".." */
record = (struct ecma119_dir_record *)(buffer + pos); record = (struct ecma119_dir_record *)(buffer + pos);
tlen += record->len_dr[0]; tlen += record->len_dr[0];
pos += record->len_dr[0]; pos += record->len_dr[0];
while (tlen < size) { while (tlen < size) {
record = (struct ecma119_dir_record *)(buffer + pos); record = (struct ecma119_dir_record *)(buffer + pos);
if (pos == 2048 || record->len_dr[0] == 0) { if (pos == 2048 || record->len_dr[0] == 0) {
/* /*
* The directory entries are splitted in several blocks * The directory entries are split in several blocks
* read next block * read next block
*/ */
ret = fsdata->src->read_block(fsdata->src, ++block, buffer); ret = fsdata->src->read_block(fsdata->src, ++block, buffer);
if (ret < 0) { if (ret < 0) {
goto ex; goto ex;
} }
tlen += 2048 - pos; tlen += 2048 - pos;
pos = 0; pos = 0;
continue; continue;
} }
skipping to change at line 709 skipping to change at line 729
if (src == NULL || src->data == NULL) { if (src == NULL || src->data == NULL) {
return ISO_NULL_POINTER; return ISO_NULL_POINTER;
} }
data = (ImageFileSourceData*)src->data; data = (ImageFileSourceData*)src->data;
if (data->opened) { if (data->opened) {
return ISO_FILE_ALREADY_OPENED; return ISO_FILE_ALREADY_OPENED;
} }
if (S_ISDIR(data->info.st_mode)) { if (S_ISDIR(data->info.st_mode)) {
/* ensure fs is openned */ /* ensure fs is opened */
ret = data->fs->open(data->fs); ret = data->fs->open(data->fs);
if (ret < 0) { if (ret < 0) {
return ret; return ret;
} }
/* /*
* Cache all directory entries. * Cache all directory entries.
* This can waste more memory, but improves as disc is read in much more * This can waste more memory, but improves as disc is read in much more
* sequencially way, thus reducing jump between tracks on disc * sequentially way, thus reducing jump between tracks on disc
*/ */
ret = read_dir(data); ret = read_dir(data);
data->fs->close(data->fs); data->fs->close(data->fs);
if (ret < 0) { if (ret < 0) {
/* free probably allocated children */ /* free probably allocated children */
child_list_free((struct child_list*)data->data.content); child_list_free((struct child_list*)data->data.content);
} else { } else {
data->opened = 2; data->opened = 2;
} }
return ret; return ret;
} else if (S_ISREG(data->info.st_mode)) { } else if (S_ISREG(data->info.st_mode)) {
/* ensure fs is openned */ /* ensure fs is opened */
ret = data->fs->open(data->fs); ret = data->fs->open(data->fs);
if (ret < 0) { if (ret < 0) {
return ret; return ret;
} }
data->data.content = malloc(BLOCK_SIZE); data->data.content = malloc(BLOCK_SIZE);
if (data->data.content == NULL) { if (data->data.content == NULL) {
return ISO_OUT_OF_MEM; return ISO_OUT_OF_MEM;
} }
data->data.offset = 0; data->data.offset = 0;
data->opened = 1; data->opened = 1;
} else { } else {
/* symlinks and special files inside image can't be openned */ /* symlinks and special files inside image can't be opened */
return ISO_FILE_ERROR; return ISO_FILE_ERROR;
} }
return ISO_SUCCESS; return ISO_SUCCESS;
} }
static static
int ifs_close(IsoFileSource *src) int ifs_close(IsoFileSource *src)
{ {
ImageFileSourceData *data; ImageFileSourceData *data;
skipping to change at line 1106 skipping to change at line 1126
return data->fs; return data->fs;
} }
static static
void ifs_free(IsoFileSource *src) void ifs_free(IsoFileSource *src)
{ {
ImageFileSourceData *data; ImageFileSourceData *data;
data = src->data; data = src->data;
/* close the file if it is already openned */ /* close the file if it is already opened */
if (data->opened) { if (data->opened) {
src->class->close(src); src->class->close(src);
} }
/* free destination if it is a link */ /* free destination if it is a link */
if (S_ISLNK(data->info.st_mode)) { if (S_ISLNK(data->info.st_mode)) {
free(data->data.content); free(data->data.content);
} }
iso_filesystem_unref(data->fs); iso_filesystem_unref(data->fs);
if (data->parent != NULL) { if (data->parent != NULL) {
skipping to change at line 1247 skipping to change at line 1267
ifs_readlink, ifs_readlink,
ifs_get_filesystem, ifs_get_filesystem,
ifs_free, ifs_free,
ifs_lseek, ifs_lseek,
ifs_get_aa_string, ifs_get_aa_string,
ifs_clone_src ifs_clone_src
}; };
/* Used from libisofs/stream.c : iso_stream_get_src_zf() */ /* Used from libisofs/stream.c : iso_stream_get_src_zf() */
int iso_ifs_source_get_zf(IsoFileSource *src, int *header_size_div4, int iso_ifs_source_get_zf(IsoFileSource *src, uint8_t zisofs_algo[2],
int *block_size_log2, uint32_t *uncompressed_size, int *header_size_div4, int *block_size_log2,
int flag) uint64_t *uncompressed_size, int flag)
{ {
#ifdef Libisofs_with_zliB #ifdef Libisofs_with_zliB
ImageFileSourceData *data; ImageFileSourceData *data;
if (src->class != &ifs_class) if (src->class != &ifs_class)
return 0; return 0;
data = src->data; data = src->data;
zisofs_algo[0] = data->zisofs_algo[0];
zisofs_algo[1] = data->zisofs_algo[1];
*header_size_div4 = data->header_size_div4; *header_size_div4 = data->header_size_div4;
*block_size_log2 = data->block_size_log2; *block_size_log2 = data->block_size_log2;
*uncompressed_size = data->uncompressed_size; *uncompressed_size = data->uncompressed_size;
return 1; return 1;
#else #else
return 0; return 0;
#endif /* ! Libisofs_with_zliB */ #endif /* ! Libisofs_with_zliB */
skipping to change at line 1451 skipping to change at line 1473
size_t aa_size = 0, aa_len = 0, prev_field = 0; size_t aa_size = 0, aa_len = 0, prev_field = 0;
int aa_done = 0; int aa_done = 0;
char *msg = NULL; char *msg = NULL;
uint8_t *buffer = NULL; uint8_t *buffer = NULL;
char *cpt; char *cpt;
int has_px = 0; int has_px = 0;
#ifdef Libisofs_with_zliB #ifdef Libisofs_with_zliB
uint8_t zisofs_alg[2], zisofs_hs4 = 0, zisofs_bsl2 = 0; uint8_t zisofs_alg[2], zisofs_hs4 = 0, zisofs_bsl2 = 0;
uint32_t zisofs_usize = 0; uint64_t zisofs_usize = 0;
#endif #endif
if (fs == NULL || fs->data == NULL || record == NULL || src == NULL) { if (fs == NULL || fs->data == NULL || record == NULL || src == NULL) {
ret = ISO_NULL_POINTER; goto ex; ret = ISO_NULL_POINTER; goto ex;
} }
fsdata = (_ImageFsData*)fs->data; fsdata = (_ImageFsData*)fs->data;
memset(&atts, 0, sizeof(struct stat)); memset(&atts, 0, sizeof(struct stat));
atts.st_nlink = 1; atts.st_nlink = 1;
skipping to change at line 1583 skipping to change at line 1605
iter = susp_iter_new(fsdata->src, record, iter = susp_iter_new(fsdata->src, record,
fsdata->session_lba + fsdata->nblocks, fsdata->session_lba + fsdata->nblocks,
fsdata->len_skp, fsdata->msgid); fsdata->len_skp, fsdata->msgid);
if (iter == NULL) { if (iter == NULL) {
{ret = ISO_OUT_OF_MEM; goto ex;} {ret = ISO_OUT_OF_MEM; goto ex;}
} }
while ((ret = susp_iter_next(iter, &sue, 0)) > 0) { while ((ret = susp_iter_next(iter, &sue, 0)) > 0) {
/* ignore entries from different version */ /* ignore entries from different version */
if (sue->version[0] != 1) if (sue->version[0] != 1 &&
!(SUSP_SIG(sue, 'Z', 'F') || SUSP_SIG(sue, 'Z', '2')))
continue; continue;
if (SUSP_SIG(sue, 'P', 'X')) { if (SUSP_SIG(sue, 'P', 'X')) {
has_px = 1; has_px = 1;
ret = read_rr_PX(sue, &atts); ret = read_rr_PX(sue, &atts);
if (ret < 0) { if (ret < 0) {
/* notify and continue */ /* notify and continue */
ret = iso_rr_msg_submit(fsdata, 0, ISO_WRONG_RR_WARN, ret, ret = iso_rr_msg_submit(fsdata, 0, ISO_WRONG_RR_WARN, ret,
"Invalid PX entry"); "Invalid PX entry");
fsdata->px_ino_status |= 8; fsdata->px_ino_status |= 8;
skipping to change at line 1789 skipping to change at line 1812
&prev_field, &aa_done, 0); &prev_field, &aa_done, 0);
if (ret < 0) { if (ret < 0) {
/* notify and continue */ /* notify and continue */
ret = iso_rr_msg_submit(fsdata, 12, ISO_WRONG_RR_WARN, ret, ret = iso_rr_msg_submit(fsdata, 12, ISO_WRONG_RR_WARN, ret,
"Invalid AL entry"); "Invalid AL entry");
continue; continue;
} }
#ifdef Libisofs_with_zliB #ifdef Libisofs_with_zliB
} else if (SUSP_SIG(sue, 'Z', 'F')) { } else if (SUSP_SIG(sue, 'Z', 'F') || SUSP_SIG(sue, 'Z', '2')) {
ret = read_zisofs_ZF(sue, zisofs_alg, &zisofs_hs4, ret = read_zisofs_ZF(sue, zisofs_alg, &zisofs_hs4,
&zisofs_bsl2, &zisofs_usize, 0); &zisofs_bsl2, &zisofs_usize, 0);
if (ret < 0 || zisofs_alg[0] != 'p' || zisofs_alg[1] != 'z') { if (ret < 0) {
invalid_zf:
/* notify and continue */ /* notify and continue */
ret = iso_rr_msg_submit(fsdata, 13, ISO_WRONG_RR_WARN, ret, ret = iso_rr_msg_submit(fsdata, 13, ISO_WRONG_RR_WARN, ret,
"Invalid ZF entry"); SUSP_SIG(sue, 'Z', 'F') ?
"Invalid ZF entry" :
"Invalid Z2 entry");
zisofs_hs4 = 0; zisofs_hs4 = 0;
continue; continue;
} }
if (zisofs_alg[0] == 'p' || zisofs_alg[1] == 'z') {
if (sue->version[0] != 1)
goto invalid_zf;
} else if (zisofs_alg[0] == 'P' || zisofs_alg[1] == 'Z') {
if (sue->version[0] != 2)
goto invalid_zf;
} else {
ret = 0;
goto invalid_zf;
}
#endif /* Libisofs_with_zliB */ #endif /* Libisofs_with_zliB */
/* This message is inflationary */ /* This message is inflationary */
/* /*
} else { } else {
ret = iso_msg_submit(fsdata->msgid, ISO_SUSP_UNHANDLED, 0, ret = iso_msg_submit(fsdata->msgid, ISO_SUSP_UNHANDLED, 0,
"Unhandled SUSP entry %c%c.", sue->sig[0], sue->sig[1]); "Unhandled SUSP entry %c%c.", sue->sig[0], sue->sig[1]);
*/ */
skipping to change at line 1932 skipping to change at line 1968
name = get_name(fsdata, (char*)record->file_id, record->len_fi[0]); name = get_name(fsdata, (char*)record->file_id, record->len_fi[0]);
if (name == NULL) { if (name == NULL) {
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_ECMA119, 0, ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_ECMA119, 0,
"Cannot retrieve file name"); "Cannot retrieve file name");
goto ex; goto ex;
} }
/* remove trailing version number */ /* remove trailing version number */
len = strlen(name); len = strlen(name);
ecma119_map = fsdata->ecma119_map;
if (fsdata->iso_root_block == fsdata->svd_root_block) if (fsdata->iso_root_block == fsdata->svd_root_block)
ecma119_map = 0; ecma119_map = fsdata->joliet_map;
else
ecma119_map = fsdata->ecma119_map;
if (ecma119_map >= 1 && ecma119_map <= 3 && if (ecma119_map >= 1 && ecma119_map <= 3 &&
len > 2 && name[len-2] == ';' && name[len-1] == '1') { len > 2 && name[len-2] == ';' && name[len-1] == '1') {
if (len > 3 && name[len-3] == '.') { if (len > 3 && name[len-3] == '.') {
/* /*
* the "." is mandatory, so in most cases is included only * the "." is mandatory, so in most cases is included only
* for standard compliance * for standard compliance
*/ */
name[len-3] = '\0'; name[len-3] = '\0';
} else { } else {
name[len-2] = '\0'; name[len-2] = '\0';
skipping to change at line 2074 skipping to change at line 2111
if (parent != NULL) { if (parent != NULL) {
ifsdata->parent = parent; ifsdata->parent = parent;
iso_file_source_ref(parent); iso_file_source_ref(parent);
} }
ifsdata->info = atts; ifsdata->info = atts;
ifsdata->name = name; ifsdata->name = name;
ifsdata->aa_string = aa_string; ifsdata->aa_string = aa_string;
#ifdef Libisofs_with_zliB #ifdef Libisofs_with_zliB
if (zisofs_hs4 > 0) { if (zisofs_hs4 > 0) {
ifsdata->zisofs_algo[0] = zisofs_alg[0];
ifsdata->zisofs_algo[1] = zisofs_alg[1];
ifsdata->header_size_div4 = zisofs_hs4; ifsdata->header_size_div4 = zisofs_hs4;
ifsdata->block_size_log2 = zisofs_bsl2; ifsdata->block_size_log2 = zisofs_bsl2;
ifsdata->uncompressed_size = zisofs_usize; ifsdata->uncompressed_size = zisofs_usize;
} else { } else {
ifsdata->header_size_div4 = 0; ifsdata->header_size_div4 = 0;
} }
#endif #endif
/* save extents */ /* save extents */
ifsdata->sections = realloc(ifsdata->sections, ifsdata->sections = realloc(ifsdata->sections,
skipping to change at line 2323 skipping to change at line 2362
return ISO_SUCCESS; return ISO_SUCCESS;
} }
static static
void ifs_fs_free(IsoFilesystem *fs) void ifs_fs_free(IsoFilesystem *fs)
{ {
_ImageFsData *data; _ImageFsData *data;
data = (_ImageFsData*) fs->data; data = (_ImageFsData*) fs->data;
/* close data source if already openned */ /* close data source if already opened */
if (data->open_count > 0) { if (data->open_count > 0) {
data->src->close(data->src); data->src->close(data->src);
} }
/* free our ref to datasource */ /* free our ref to datasource */
iso_data_source_unref(data->src); iso_data_source_unref(data->src);
/* free volume atts */ /* free volume atts */
free(data->volset_id); free(data->volset_id);
free(data->volume_id); free(data->volume_id);
skipping to change at line 2356 skipping to change at line 2395
free(data->local_charset); free(data->local_charset);
if(data->catcontent != NULL) if(data->catcontent != NULL)
free(data->catcontent); free(data->catcontent);
free(data); free(data);
} }
/** /**
* Read the SUSP system user entries of the "." entry of the root directory, * Read the SUSP system user entries of the "." entry of the root directory,
* indentifying when Rock Ridge extensions are being used. * identifying when Rock Ridge extensions are being used.
* *
* @return * @return
* 1 success, 0 ignored, < 0 error * 1 success, 0 ignored, < 0 error
*/ */
static static
int read_root_susp_entries(_ImageFsData *data, uint32_t block) int read_root_susp_entries(_ImageFsData *data, uint32_t block)
{ {
int ret; int ret;
unsigned char *buffer = NULL; unsigned char *buffer = NULL;
struct ecma119_dir_record *record; struct ecma119_dir_record *record;
skipping to change at line 2855 skipping to change at line 2894
data = calloc(1, sizeof(_ImageFsData)); data = calloc(1, sizeof(_ImageFsData));
if (data == NULL) { if (data == NULL) {
ret = ISO_OUT_OF_MEM; goto ex; ret = ISO_OUT_OF_MEM; goto ex;
} }
ifs = calloc(1, sizeof(IsoImageFilesystem)); ifs = calloc(1, sizeof(IsoImageFilesystem));
if (ifs == NULL) { if (ifs == NULL) {
free(data); free(data);
{ret = ISO_OUT_OF_MEM; goto ex;} {ret = ISO_OUT_OF_MEM; goto ex;}
} }
data->rr = RR_EXT_NO;
/* get our ref to IsoDataSource */ /* get our ref to IsoDataSource */
data->src = src; data->src = src;
iso_data_source_ref(src); iso_data_source_ref(src);
data->open_count = 0; data->open_count = 0;
data->catcontent = NULL; data->catcontent = NULL;
/* get an id for the filesystem */ /* get an id for the filesystem */
data->id = ++fs_dev_id; data->id = ++fs_dev_id;
skipping to change at line 2898 skipping to change at line 2938
data->joliet_ucs2_failures = 0; data->joliet_ucs2_failures = 0;
data->local_charset = strdup(iso_get_local_charset(0)); data->local_charset = strdup(iso_get_local_charset(0));
if (data->local_charset == NULL) { if (data->local_charset == NULL) {
ret = ISO_OUT_OF_MEM; ret = ISO_OUT_OF_MEM;
LIBISO_FREE_MEM(data); LIBISO_FREE_MEM(data);
data = NULL; data = NULL;
goto fs_cleanup; goto fs_cleanup;
} }
strncpy(ifs->type, "iso ", 4); memcpy(ifs->type, "iso ", 4);
ifs->data = data; ifs->data = data;
ifs->refcount = 1; ifs->refcount = 1;
ifs->version = 0; ifs->version = 0;
ifs->get_root = ifs_get_root; ifs->get_root = ifs_get_root;
ifs->get_by_path = ifs_get_by_path; ifs->get_by_path = ifs_get_by_path;
ifs->get_id = ifs_get_id; ifs->get_id = ifs_get_id;
ifs->open = ifs_fs_open; ifs->open = ifs_fs_open;
ifs->close = ifs_fs_close; ifs->close = ifs_fs_close;
ifs->free = ifs_fs_free; ifs->free = ifs_fs_free;
skipping to change at line 2969 skipping to change at line 3009
data->catblock = iso_read_lsb(vol->boot_catalog, 4); data->catblock = iso_read_lsb(vol->boot_catalog, 4);
ret = read_el_torito_boot_catalog(data, data->catblock); ret = read_el_torito_boot_catalog(data, data->catblock);
if (ret < 0 && ret != (int) ISO_UNSUPPORTED_EL_TORITO && if (ret < 0 && ret != (int) ISO_UNSUPPORTED_EL_TORITO &&
ret != (int) ISO_WRONG_EL_TORITO) { ret != (int) ISO_WRONG_EL_TORITO) {
goto fs_cleanup; goto fs_cleanup;
} }
} }
} }
break; break;
case 2: case 2:
/* suplementary volume descritor */ /* supplementary volume descritor */
{ {
struct ecma119_sup_vol_desc *sup; struct ecma119_sup_vol_desc *sup;
struct ecma119_dir_record *root; struct ecma119_dir_record *root;
sup = (struct ecma119_sup_vol_desc*)buffer; sup = (struct ecma119_sup_vol_desc*)buffer;
if (sup->esc_sequences[0] == 0x25 && if (sup->esc_sequences[0] == 0x25 &&
sup->esc_sequences[1] == 0x2F && sup->esc_sequences[1] == 0x2F &&
(sup->esc_sequences[2] == 0x40 || (sup->esc_sequences[2] == 0x40 ||
sup->esc_sequences[2] == 0x43 || sup->esc_sequences[2] == 0x43 ||
sup->esc_sequences[2] == 0x45) ) { sup->esc_sequences[2] == 0x45) ) {
skipping to change at line 3024 skipping to change at line 3064
break; break;
default: default:
iso_msg_submit(data->msgid, ISO_UNSUPPORTED_VD, 0, iso_msg_submit(data->msgid, ISO_UNSUPPORTED_VD, 0,
"Ignoring Volume descriptor %x.", buffer[0]); "Ignoring Volume descriptor %x.", buffer[0]);
break; break;
} }
block++; block++;
} while (buffer[0] != 255); } while (buffer[0] != 255);
/* 4. check if RR extensions are being used */ /* 4. check if RR extensions are being used */
if (opts->norock) { ret = read_root_susp_entries(data, data->pvd_root_block);
/* user doesn't want to read RR extensions */ if (ret < 0)
data->rr = RR_EXT_NO; goto fs_cleanup;
} else { if (!opts->norock)
ret = read_root_susp_entries(data, data->pvd_root_block);
if (ret < 0) {
goto fs_cleanup;
}
data->rr = data->rr_version; data->rr = data->rr_version;
}
/* select what tree to read */ /* select what tree to read */
if (data->rr) { if (data->rr) {
/* RR extensions are available */ /* RR extensions are available */
if (!opts->nojoliet && opts->preferjoliet && data->joliet) { if (!opts->nojoliet && opts->preferjoliet && data->joliet) {
/* if user prefers joliet, that is used */ /* if user prefers joliet, that is used */
iso_msg_debug(data->msgid, "Reading Joliet extensions."); iso_msg_debug(data->msgid, "Reading Joliet extensions.");
/* Although Joliet prescribes UCS-2BE, interpret names by its /* Although Joliet prescribes UCS-2BE, interpret names by its
superset UTF-16BE in order to avoid conversion failures. superset UTF-16BE in order to avoid conversion failures.
*/ */
skipping to change at line 3073 skipping to change at line 3108
} else { } else {
/* default to plain iso */ /* default to plain iso */
iso_msg_debug(data->msgid, "Reading plain ISO-9660 tree."); iso_msg_debug(data->msgid, "Reading plain ISO-9660 tree.");
data->iso_root_block = data->pvd_root_block; data->iso_root_block = data->pvd_root_block;
data->input_charset = strdup("ASCII"); data->input_charset = strdup("ASCII");
} }
} }
data->truncate_mode = opts->truncate_mode; data->truncate_mode = opts->truncate_mode;
data->truncate_length = opts->truncate_length; data->truncate_length = opts->truncate_length;
data->ecma119_map = opts->ecma119_map; data->ecma119_map = opts->ecma119_map;
data->joliet_map = opts->joliet_map;
if (data->input_charset == NULL) { if (data->input_charset == NULL) {
if (opts->input_charset != NULL) { if (opts->input_charset != NULL) {
data->input_charset = strdup(opts->input_charset); data->input_charset = strdup(opts->input_charset);
} else { } else {
data->input_charset = strdup(data->local_charset); data->input_charset = strdup(data->local_charset);
} }
} }
if (data->input_charset == NULL) { if (data->input_charset == NULL) {
ret = ISO_OUT_OF_MEM; ret = ISO_OUT_OF_MEM;
skipping to change at line 3155 skipping to change at line 3191
struct stat info; struct stat info;
IsoNode *new = NULL; IsoNode *new = NULL;
IsoBoot *bootcat; IsoBoot *bootcat;
char *name = NULL; char *name = NULL;
char *dest = NULL; char *dest = NULL;
ImageFileSourceData *data; ImageFileSourceData *data;
_ImageFsData *fsdata; _ImageFsData *fsdata;
#ifdef Libisofs_with_zliB #ifdef Libisofs_with_zliB
/* Intimate friendship with this function in filters/zisofs.c */ /* Intimate friendship with this function in filters/zisofs.c */
int ziso_add_osiz_filter(IsoFile *file, uint8_t header_size_div4, int ziso_add_osiz_filter(IsoFile *file, uint8_t zisofs_algo[2],
uint8_t block_size_log2, uint8_t header_size_div4, uint8_t block_size_log2,
uint32_t uncompressed_size, int flag); uint64_t uncompressed_size, int flag);
#endif /* Libisofs_with_zliB */ #endif /* Libisofs_with_zliB */
if (builder == NULL || src == NULL || node == NULL || src->data == NULL) { if (builder == NULL || src == NULL || node == NULL || src->data == NULL) {
ret = ISO_NULL_POINTER; goto ex; ret = ISO_NULL_POINTER; goto ex;
} }
data = (ImageFileSourceData*)src->data; data = (ImageFileSourceData*)src->data;
fsdata = data->fs->data; fsdata = data->fs->data;
if (in_name == NULL) { if (in_name == NULL) {
skipping to change at line 3270 skipping to change at line 3306
*/ */
file->sort_weight = file->sort_weight =
fsdata->nblocks / 16 - data->sections[0].block / 16 + 1; fsdata->nblocks / 16 - data->sections[0].block / 16 + 1;
file->stream = stream; file->stream = stream;
file->node.type = LIBISO_FILE; file->node.type = LIBISO_FILE;
#ifdef Libisofs_with_zliB #ifdef Libisofs_with_zliB
if (data->header_size_div4 > 0) { if (data->header_size_div4 > 0) {
ret = ziso_add_osiz_filter(file, data->header_size_div4, ret = ziso_add_osiz_filter(file, data->zisofs_algo,
data->header_size_div4,
data->block_size_log2, data->block_size_log2,
data->uncompressed_size, 0); data->uncompressed_size, 0);
if (ret < 0) { if (ret < 0) {
iso_stream_unref(stream); iso_stream_unref(stream);
goto ex; goto ex;
} }
} }
#endif /* Libisofs_with_zliB */ #endif /* Libisofs_with_zliB */
skipping to change at line 6042 skipping to change at line 6079
*features = malloc(sizeof(IsoReadImageFeatures)); *features = malloc(sizeof(IsoReadImageFeatures));
if (*features == NULL) { if (*features == NULL) {
ret = ISO_OUT_OF_MEM; ret = ISO_OUT_OF_MEM;
goto import_revert; goto import_revert;
} }
(*features)->hasJoliet = data->joliet; (*features)->hasJoliet = data->joliet;
(*features)->hasRR = data->rr_version != 0; (*features)->hasRR = data->rr_version != 0;
(*features)->hasIso1999 = data->iso1999; (*features)->hasIso1999 = data->iso1999;
(*features)->hasElTorito = data->eltorito; (*features)->hasElTorito = data->eltorito;
(*features)->size = data->nblocks; (*features)->size = data->nblocks;
(*features)->tree_loaded = 0;
if (data->iso_root_block == data->svd_root_block)
(*features)->tree_loaded = 1;
else if (data->iso_root_block == data->evd_root_block &&
data->iso_root_block != data->pvd_root_block)
(*features)->tree_loaded = 2;
(*features)->rr_loaded = (data->rr != RR_EXT_NO);
} }
if (data->md5_load) { if (data->md5_load) {
/* Read checksum array */ /* Read checksum array */
ret = iso_root_get_isofsca((IsoNode *) image->root, ret = iso_root_get_isofsca((IsoNode *) image->root,
&(image->checksum_start_lba), &(image->checksum_start_lba),
&(image->checksum_end_lba), &(image->checksum_end_lba),
&(image->checksum_idx_count), &(image->checksum_idx_count),
&checksum_size, checksum_type, 0); &checksum_size, checksum_type, 0);
if (ret > 0) if (ret > 0)
skipping to change at line 6227 skipping to change at line 6271
ropts = calloc(1, sizeof(IsoReadOpts)); ropts = calloc(1, sizeof(IsoReadOpts));
if (ropts == NULL) { if (ropts == NULL) {
return ISO_OUT_OF_MEM; return ISO_OUT_OF_MEM;
} }
ropts->file_mode = 0444; ropts->file_mode = 0444;
ropts->dir_mode = 0555; ropts->dir_mode = 0555;
ropts->noaaip = 1; ropts->noaaip = 1;
ropts->ecma119_map = 1; ropts->ecma119_map = 1;
ropts->joliet_map = 1;
ropts->nomd5 = 1; ropts->nomd5 = 1;
ropts->load_system_area = 0; ropts->load_system_area = 0;
ropts->keep_import_src = 0; ropts->keep_import_src = 0;
ropts->truncate_mode = 1; ropts->truncate_mode = 1;
ropts->truncate_length = LIBISOFS_NODE_NAME_MAX; ropts->truncate_length = LIBISOFS_NODE_NAME_MAX;
*opts = ropts; *opts = ropts;
return ISO_SUCCESS; return ISO_SUCCESS;
} }
skipping to change at line 6330 skipping to change at line 6375
{ {
if (opts == NULL) { if (opts == NULL) {
return ISO_NULL_POINTER; return ISO_NULL_POINTER;
} }
if (ecma119_map < 0 || ecma119_map > 3) if (ecma119_map < 0 || ecma119_map > 3)
return 0; return 0;
opts->ecma119_map = ecma119_map; opts->ecma119_map = ecma119_map;
return ISO_SUCCESS; return ISO_SUCCESS;
} }
int iso_read_opts_set_joliet_map(IsoReadOpts *opts, int joliet_map)
{
if (opts == NULL)
return ISO_NULL_POINTER;
if (joliet_map < 0 || joliet_map > 1)
return 0;
opts->joliet_map = joliet_map;
return ISO_SUCCESS;
}
int iso_read_opts_set_default_uid(IsoReadOpts *opts, uid_t uid) int iso_read_opts_set_default_uid(IsoReadOpts *opts, uid_t uid)
{ {
if (opts == NULL) { if (opts == NULL) {
return ISO_NULL_POINTER; return ISO_NULL_POINTER;
} }
opts->uid = uid; opts->uid = uid;
return ISO_SUCCESS; return ISO_SUCCESS;
} }
int iso_read_opts_set_default_gid(IsoReadOpts *opts, gid_t gid) int iso_read_opts_set_default_gid(IsoReadOpts *opts, gid_t gid)
skipping to change at line 6447 skipping to change at line 6502
/** /**
* Whether El-Torito boot record is present present in the image imported. * Whether El-Torito boot record is present present in the image imported.
*/ */
int iso_read_image_features_has_eltorito(IsoReadImageFeatures *f) int iso_read_image_features_has_eltorito(IsoReadImageFeatures *f)
{ {
return f->hasElTorito; return f->hasElTorito;
} }
/** /**
* Tells what directory tree was loaded:
* 0= ISO 9660 , 1 = Joliet , 2 = ISO 9660:1999
*/
int iso_read_image_features_tree_loaded(IsoReadImageFeatures *f)
{
return f->tree_loaded;
}
/**
* Tells whether Rock Ridge information was used while loading the tree.
*/
int iso_read_image_features_rr_loaded(IsoReadImageFeatures *f)
{
return f->rr_loaded;
}
/**
* Get the start addresses and the sizes of the data extents of a file node * Get the start addresses and the sizes of the data extents of a file node
* if it was imported from an old image. * if it was imported from an old image.
* *
* @param file * @param file
* The file * The file
* @param section_count * @param section_count
* Returns the number of extent entries in sections arrays * Returns the number of extent entries in sections arrays
* @param sections * @param sections
* Returns the array of file sections. Apply free() to dispose it. * Returns the array of file sections. Apply free() to dispose it.
* @param flag * @param flag
 End of changes. 39 change blocks. 
37 lines changed or deleted 109 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)