Support for specify image creation options.

This commit is contained in:
Vreixo Formoso Lopes 2007-09-28 16:10:48 +00:00
parent 6770c4af16
commit 6d4e145dc4
3 changed files with 115 additions and 32 deletions

View File

@ -224,8 +224,8 @@ int isoburn_find_by_drive(struct isoburn **pt, struct burn_drive *d, int flag)
}
static
int isoburn_prepare_disc_aux(struct burn_drive *d, struct burn_disc **disc,
int new_img)
int isoburn_prepare_disc_aux(struct burn_drive *d, struct burn_disc **disc,
struct isoburn_source_opts *opts, int new_img)
{
struct burn_source *wsrc;
struct burn_session *session;
@ -244,25 +244,24 @@ int isoburn_prepare_disc_aux(struct burn_drive *d, struct burn_disc **disc,
session = burn_session_create();
burn_disc_add_session(*disc, session, BURN_POS_END);
// FIXME we need a way to allow users to pass parameters to this!!
wopts.volnum = 0;
wopts.level = 2;
wopts.flags = 0;
wopts.relaxed_constraints = 0;
wopts.copy_eltorito = 0;
wopts.no_cache_inodes = 0;
wopts.sort_files = 1;
wopts.default_mode = 0;
wopts.replace_dir_mode = 0;
wopts.replace_file_mode = 0;
wopts.replace_uid = 0;
wopts.replace_gid = 0;
wopts.dir_mode = 0555;
wopts.file_mode = 0555;
wopts.gid = 0;
wopts.uid = 0;
wopts.input_charset = NULL;
wopts.ouput_charset = NULL;
wopts.level = opts->level;
wopts.flags = opts->flag;
wopts.relaxed_constraints = opts->relaxed_constraints;
wopts.copy_eltorito = opts->copy_eltorito;
wopts.no_cache_inodes = opts->no_cache_inodes;
wopts.sort_files = opts->sort_files;
wopts.default_mode = opts->default_mode;
wopts.replace_dir_mode = opts->replace_dir_mode;
wopts.replace_file_mode = opts->replace_file_mode;
wopts.replace_uid = opts->replace_uid;
wopts.replace_gid = opts->replace_gid;
wopts.dir_mode = opts->dir_mode;
wopts.file_mode = opts->file_mode;
wopts.gid = opts->gid;
wopts.uid = opts->uid;
wopts.input_charset = opts->input_charset;
wopts.ouput_charset = opts->ouput_charset;
wopts.ms_block = (new_img ? 0 : o->nwa);
wopts.src = o->src;
@ -276,12 +275,14 @@ int isoburn_prepare_disc_aux(struct burn_drive *d, struct burn_disc **disc,
return 1;
}
int isoburn_prepare_disc(struct burn_drive *d, struct burn_disc **disc)
int isoburn_prepare_disc(struct burn_drive *d, struct burn_disc **disc,
struct isoburn_source_opts *opts)
{
return isoburn_prepare_disc_aux(d, disc, 0);
return isoburn_prepare_disc_aux(d, disc, opts, 0);
}
int isoburn_prepare_new_image(struct burn_drive *d, struct burn_disc **disc)
int isoburn_prepare_new_image(struct burn_drive *d, struct burn_disc **disc,
struct isoburn_source_opts *opts)
{
return isoburn_prepare_disc_aux(d, disc, 1);
return isoburn_prepare_disc_aux(d, disc, opts, 1);
}

View File

@ -87,12 +87,12 @@ void isoburn_disc_erase(struct burn_drive *drive, int fast);
/**
* Options for image reading.
*/
struct isoburn_read_opts {
struct isoburn_read_opts {
unsigned int norock:1; /*< Do not read Rock Ridge extensions */
unsigned int nojoliet:1; /*< Do not read Joliet extensions */
unsigned int preferjoliet:1;
/*< When both Joliet and RR extensions are present, the RR
* tree is used. If you prefer using Joliet, set this to 1. */
* tree is used. If you prefer using Joliet, set this to 1. */
uid_t uid; /**< Default uid when no RR */
gid_t gid; /**< Default uid when no RR */
mode_t mode; /**< Default mode when no RR (only permissions) */
@ -106,6 +106,69 @@ struct isoburn_read_opts {
* the image, as reported in the PVM. */
};
/**
* Options for image generation.
*/
struct isoburn_source_opts {
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 no_cache_inodes:1;
/**< If use inode caching or not. Set it to 1 to prevent
* inode caching.
* Usage of inode caching allows detection of hard-links,
* which contents are only written once to disc this way.
* Don't use inode caching in systems with non unique inodes
* per device.
*/
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 */
};
/** Load the ISO filesystem directory tree from the media in the given drive.
This will give libisoburn the base on which it can let libisofs perform
@ -146,8 +209,8 @@ int isoburn_disc_track_lba_nwa(struct burn_drive *d, struct burn_write_opts *o,
@param disc A burn_disc suitable to pass to isoburn_disc_write.
@return <=0 error , 1 = success
*/
// TODO we need to pass reduced ecma119_source_opts
int isoburn_prepare_disc(struct burn_drive *d, struct burn_disc **disc);
int isoburn_prepare_disc(struct burn_drive *d, struct burn_disc **disc,
struct isoburn_source_opts *opts);
/** Prepare a disc for creating a new image from the contents of a previous
@ -158,9 +221,8 @@ int isoburn_prepare_disc(struct burn_drive *d, struct burn_disc **disc);
@param disc A burn_disc suitable to pass to burn_disc_write.
@return <=0 error , 1 = success
*/
// TODO we need to pass reduced ecma119_source_opts
int isoburn_prepare_new_image(struct burn_drive *d, struct burn_disc **disc);
int isoburn_prepare_new_image(struct burn_drive *d, struct burn_disc **disc,
struct isoburn_source_opts *opts);
/** Start writing of the new session.
This call is asynchrounous. I.e. it returns quite soon and the progress has

View File

@ -46,6 +46,7 @@ int main(int argc, char **argv)
struct burn_disc *disc;
enum burn_disc_status state;
struct isoburn_read_opts ropts;
struct isoburn_source_opts sopts;
int c;
struct iso_tree_radd_dir_behavior behav = {0,0,0};
int flags=0;
@ -121,8 +122,27 @@ int main(int argc, char **argv)
/* add a new dir */
iso_tree_radd_dir(root, argv[optind+1], &behav);
if (isoburn_prepare_disc(drive, &disc) <= 0) {
sopts.level = 2;
sopts.flags = flags;
sopts.relaxed_constraints = 0;
sopts.copy_eltorito = 1;
sopts.no_cache_inodes = 0;
sopts.sort_files = 1;
sopts.default_mode = 0;
sopts.replace_dir_mode = 0;
sopts.replace_file_mode = 0;
sopts.replace_uid = 0;
sopts.replace_gid = 0;
sopts.dir_mode = 0555;
sopts.file_mode = 0444;
sopts.gid = 0;
sopts.uid = 0;
sopts.input_charset = NULL;
sopts.ouput_charset = NULL;
if (isoburn_prepare_disc(drive, &disc, &sopts) <= 0) {
printf("Can't prepare disc");
goto volset_cleanup;
}