Implement iso_file_get_old_image_sections() and deprecate old way to obtain image lba.

This commit is contained in:
Vreixo Formoso 2008-08-19 02:01:42 +02:00
parent 87f08d27ac
commit 3a503a3e85
4 changed files with 116 additions and 39 deletions

View File

@ -2889,3 +2889,54 @@ int iso_read_image_features_has_eltorito(IsoReadImageFeatures *f)
{
return f->hasElTorito;
}
/**
* Get the start addresses and the sizes of the data extents of a file node
* if it was imported from an old image.
*
* @param file
* The file
* @param section_count
* Returns the number of extent entries in sections arrays
* @param sections
* Returns the array of file sections. Apply free() to dispose it.
* @param flag
* Reserved for future usage, submit 0
* @return
* 1 if there are valid extents (file comes from old image),
* 0 if file was newly added, i.e. it does not come from an old image,
* < 0 error
*/
int iso_file_get_old_image_sections(IsoFile *file, int *section_count,
struct iso_file_section **sections,
int flag)
{
if (file == NULL || section_count == NULL || sections == NULL) {
return ISO_NULL_POINTER;
}
if (flag != 0) {
return ISO_WRONG_ARG_VALUE;
}
if (file->from_old_session != 0) {
/*
* When file is from old session, we retrieve the original IsoFileSource
* to get the sections. This break encapsultation, but safes memory as
* we don't need to store the sections in the IsoFile node.
*/
FSrcStreamData *data = file->stream->data;
ImageFileSourceData *ifsdata = data->src->data;
*section_count = ifsdata->nsections;
*sections = malloc(ifsdata->nsections *
sizeof(struct iso_file_section));
if (*sections == NULL) {
return ISO_OUT_OF_MEM;
}
memcpy(*sections, ifsdata->sections,
ifsdata->nsections * sizeof(struct iso_file_section));
return 1;
}
return 0;
}

View File

@ -2533,9 +2533,35 @@ IsoStream *iso_file_get_stream(IsoFile *file);
* added, i.e. it does not come from an old image, < 0 error
*
* @since 0.6.4
*
* @deprecated Use iso_file_get_old_image_sections(), as this function does
* not work with multi-extend files.
*/
int iso_file_get_old_image_lba(IsoFile *file, uint32_t *lba, int flag);
/**
* Get the start addresses and the sizes of the data extents of a file node
* if it was imported from an old image.
*
* @param file
* The file
* @param section_count
* Returns the number of extent entries in sections arrays
* @param sections
* Returns the array of file sections. Apply free() to dispose it.
* @param flag
* Reserved for future usage, submit 0
* @return
* 1 if there are valid extents (file comes from old image),
* 0 if file was newly added, i.e. it does not come from an old image,
* < 0 error
*
* @since 0.6.8
*/
int iso_file_get_old_image_sections(IsoFile *file, int *section_count,
struct iso_file_section **sections,
int flag);
/*
* Like iso_file_get_old_image_lba(), but take an IsoNode.
*

View File

@ -19,16 +19,6 @@ ino_t serial_id = (ino_t)1;
ino_t mem_serial_id = (ino_t)1;
ino_t cut_out_serial_id = (ino_t)1;
typedef struct
{
IsoFileSource *src;
/* key for file identification inside filesystem */
dev_t dev_id;
ino_t ino_id;
off_t size; /**< size of this file */
} FSrcStreamData;
static
int fsrc_open(IsoStream *stream)
{

View File

@ -13,6 +13,16 @@
*/
#include "fsource.h"
typedef struct
{
IsoFileSource *src;
/* key for file identification inside filesystem */
dev_t dev_id;
ino_t ino_id;
off_t size; /**< size of this file */
} FSrcStreamData;
/**
* Get an identifier for the file of the source, for debug purposes
* @param name