Define some functions and responsabilities for image generation.

Still very preliminary work.
release-1.5.4.branch
Vreixo Formoso 15 years ago
parent c03d4d9b33
commit c8715941e6
  1. 3
      Makefile.am
  2. 119
      src/ecma119.c
  3. 29
      src/ecma119.h
  4. 4
      src/ecma119_tree.c
  5. 9
      src/ecma119_tree.h
  6. 12
      src/filesrc.c
  7. 5
      src/filesrc.h
  8. 86
      src/libisofs.h
  9. 22
      src/writer.h

@ -34,7 +34,8 @@ src_libisofs_la_SOURCES = \
src/ecma119.h \
src/ecma119.c \
src/ecma119_tree.h \
src/ecma119_tree.c
src/ecma119_tree.c \
src/writer.h
libinclude_HEADERS = \
src/libisofs.h

@ -6,4 +6,123 @@
* published by the Free Software Foundation. See COPYING file for details.
*/
#include "libisofs.h"
#include "ecma119.h"
#include "ecma119_tree.h"
#include "error.h"
#include "filesrc.h"
#include "image.h"
#include "writer.h"
#include "libburn/libburn.h"
#include <stdlib.h>
static
int ecma119_image_new(IsoImage *src, Ecma119WriteOpts *opts,
Ecma119Image **img)
{
int ret;
Ecma119Image *target;
/* 1. Allocate target and copy opts there */
target = calloc(1, sizeof(Ecma119Image));
if (target == NULL) {
return ISO_MEM_ERROR;
}
ret = ecma119_tree_create(target, src->root);
if (ret < 0) {
// TODO free image data
return ret;
}
/*
* 2. Based on those options, create needed writers: iso, joliet...
* Each writer inits its structures and stores needed info into
* target.
* If the writer needs an volume descriptor, it increments image
* current block.
* Finally, create Writer for files.
*/
/*
* 3.
* Call compute_data_blocks() in each Writer.
* That function computes the size needed by its structures and
* increments image current block propertly.
*/
/* 4. Start writting thread */
*img = target;
return ISO_SUCCESS;
}
static int
bs_read(struct burn_source *bs, unsigned char *buf, int size)
{
// TODO to implement
return 0;
}
static off_t
bs_get_size(struct burn_source *bs)
{
Ecma119Image *image = (Ecma119Image*)bs->data;
return image->total_size;
}
static void
bs_free_data(struct burn_source *bs)
{
Ecma119Image *t = (Ecma119Image*)bs->data;
ecma119_node_free(t->root);
iso_image_unref(t->image);
iso_file_src_free(t);
free(t);
}
static
int bs_set_size(struct burn_source *bs, off_t size)
{
//TODO to implement!!
// struct ecma119_write_target *t = (struct ecma119_write_target*)bs->data;
// t->total_size = size;
return 1;
}
int iso_image_create(IsoImage *image, Ecma119WriteOpts *opts,
struct burn_source **burn_src)
{
int ret;
struct burn_source *source;
Ecma119Image *target = NULL;
if (image == NULL || opts == NULL || burn_src == NULL) {
return ISO_NULL_POINTER;
}
source = calloc(1, sizeof(struct burn_source));
if (source == NULL) {
return ISO_MEM_ERROR;
}
ret = ecma119_image_new(image, opts, &target);
if (ret < 0) {
free(source);
return ret;
}
source->refcount = 1;
source->read = bs_read;
source->get_size = bs_get_size;
source->set_size = bs_set_size;
source->free_data = bs_free_data;
source->data = target;
return ISO_SUCCESS;
}

@ -9,14 +9,43 @@
#ifndef LIBISO_ECMA119_H_
#define LIBISO_ECMA119_H_
#include "libisofs.h"
typedef struct ecma119_image Ecma119Image;
typedef struct ecma119_node Ecma119Node;
typedef struct Iso_File_Src IsoFileSrc;
typedef struct Iso_Image_Writer IsoImageWriter;
struct ecma119_image {
IsoImage *image;
Ecma119Node *root;
//int volnum;
unsigned int iso_level:2;
// int relaxed_constraints; /**< see ecma119_relaxed_constraints_flag */
//
// int replace_mode; /**< Replace ownership and modes of files
// *
// * 0. filesystem values
// * 1. useful values
// * bits 1-4 bitmask:
// * 2 - replace dir
// * 3 - replace file
// * 4 - replace gid
// * 5 - replace uid
// */
// mode_t dir_mode;
// mode_t file_mode;
// gid_t gid;
// uid_t uid;
time_t now; /**< Time at which writing began. */
off_t total_size; /**< Total size of the output. This only
* includes the current volume. */
//uint32_t vol_space_size;
/* tree of files sources */
void *file_srcs;

@ -479,12 +479,12 @@ int mangle_tree(Ecma119Image *img)
}
int ecma119_tree_create(Ecma119Image *img, IsoNode *iso)
int ecma119_tree_create(Ecma119Image *img, IsoDir *iso)
{
int ret;
Ecma119Node *root;
ret = create_tree(img, iso, &root, 1, 0);
ret = create_tree(img, (IsoNode*)iso, &root, 1, 0);
if (ret < 0) {
return ret;
}

@ -40,15 +40,12 @@ struct ecma119_node
*/
char *iso_name;
// TODO mmm, is this needed?
// or should we compute charset translation on-the-fly?
//char *name; /**< full name, in output charset (UTF-8 for now) */
Ecma119Node *parent;
IsoNode *node; /*< reference to the iso node */
enum ecma119_node_type type; /**< file, symlink, directory or placeholder */
/**< file, symlink, directory or placeholder */
enum ecma119_node_type type;
union {
IsoFileSrc *file;
struct ecma119_dir_info dir;
@ -58,7 +55,7 @@ struct ecma119_node
/**
*
*/
int ecma119_tree_create(Ecma119Image *img, IsoNode *iso);
int ecma119_tree_create(Ecma119Image *img, IsoDir *iso);
/**
* Free an Ecma119Node, and its children if node is a dir

@ -11,6 +11,9 @@
#include "node.h"
#include <stdlib.h>
/* tdestroy is a GNU specific function */
#define __USE_GNU
#include <search.h>
static
@ -100,3 +103,12 @@ int iso_file_src_create(Ecma119Image *img, IsoFile *file, IsoFileSrc **src)
return ISO_SUCCESS;
}
void free_node(void *nodep)
{
/* nothing to do */
}
void iso_file_src_free(Ecma119Image *img)
{
tdestroy(img->file_srcs, free_node);
}

@ -47,6 +47,11 @@ struct Iso_File_Src {
*/
int iso_file_src_create(Ecma119Image *img, IsoFile *file, IsoFileSrc **src);
/**
* Free the IsoFileSrc especific data
*/
void iso_file_src_free(Ecma119Image *img);
// TODO not implemented
int iso_file_src_open(IsoFileSrc *file);

@ -53,6 +53,92 @@ enum IsoHideNodeFlag {
LIBISO_HIDE_ON_JOLIET = 1 << 1
};
/**
* Holds the options for the image generation.
*/
typedef struct {
//int volnum; /**< The volume in the set which you want to write (usually 0) */
int level; /**< ISO level to write at. */
int flags; /**< Which extensions to support. */
//int relaxed_constraints; /**< see ecma119_relaxed_constraints_flag */
//unsigned int copy_eltorito:1;
/**<
* In multisession discs, select whether to copy el-torito catalog
* and boot image. Copy is needed for isolinux images, that need to
* be patched. However, it can lead to problems when the image is
* not present in the iso filesystem, because we can't figure out
* its size. In those cases, we only copy 1 block of data.
*/
//unsigned int sort_files:1;
/**< If files should be sorted based on their weight. */
// unsigned int default_mode:1;
// /**<
// * The default values for files and directory permissions,
// * gid and uid. This option can be overwritten when set
// * one of the following.
// * 0 to use useful values, 1 to use node modes (this are
// * the same as filesystem ones if not changed after added
// * to tree).
// */
// unsigned int replace_dir_mode:1;
// /**<
// * When 1, permissions for all dirs will be replaced by the
// * specified in dir_mode field.
// */
// unsigned int replace_file_mode:1;
// /**<
// * When 1, permissions for all files will be replaced by the
// * specified in file_mode field.
// */
// unsigned int replace_uid:1;
// /**<
// * When 1, uid of all nodes (both files and dirs) will be
// * replaced by the specified in uid field.
// */
// unsigned int replace_gid:1;
// /**<
// * When 1, gid of all nodes (both files and dirs) will be
// * replaced by the specified in gid field.
// */
// mode_t dir_mode; /**< Mode to use on dirs when replace_dir_mode is set. */
// mode_t file_mode; /**< Mode to use on files when replace_file_mode is set. */
// gid_t gid; /**< gid to use when replace_gid is set. */
// uid_t uid; /**< uid to use when replace_uid is set. */
// char *input_charset; /**< NULL to use default charset */
// char *ouput_charset; /**< NULL to use default charset */
// uint32_t ms_block;
/**<
* Start block for multisession. When this is greater than 0,
* it's suppossed to be the lba of the next writable address
* on disc; all block lba on image will take this into account,
* and files from a previous session will not be written on
* image. This behavior is only suitable for images to be
* appended to a multisession disc.
* When this is 0, no multisession image will be created. If
* some files are taken from a previous image, its contents
* will be written again to the new image. Use this with new
* images or if you plan to modify an existin image.
*/
// struct data_source* src;
// /**<
// * When modifying a image, this is the source of the original
// * image, used to read file contents.
// * Otherwise it can be NULL.
// */
// uint8_t *overwrite;
// /**<
// * When not NULL, it should point to a buffer of at least
// * 64KiB, where libisofs will write the contents that should
// * be written at the beginning of a overwriteable media, to
// * grow the image.
// * You shoudl initialize the buffer either with 0s, or with
// * the contents of the first blocks of the image you're
// * growing. In most cases, 0 is good enought.
// */
} Ecma119WriteOpts;
/**
* Create a new image, empty.
*

@ -8,28 +8,24 @@
#ifndef LIBISO_IMAGE_WRITER_H_
#define LIBISO_IMAGE_WRITER_H_
struct Iso_Writer_State
{
};
#include "ecma119.h"
struct Iso_Image_Writer
{
/**
*
*/
int (*compute_data_blocks)(IsoImageWriter *writer);
//init()
int (*write_vol_desc)(IsoImageWriter *writer, int fd);
//compute_dir_structure()
int (*write_data)(IsoImageWriter *writer, int fd);
//write_vol_desc
//
//free
int (*free_data)(IsoImageWriter *writer);
void *data;
Ecma119Image *image;
IsoImageWriter *next;
};
#endif /*LIBISO_IMAGE_WRITER_H_*/
Loading…
Cancel
Save