libisofs  1.5.4
About: libisofs is a library to create an ISO 9660 filesystem, supports extensions like RockRidge or Joliet, makes bootable ISO 9660, and records file attributes which are of interest for data backups.
  Fossies Dox: libisofs-1.5.4.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

writer.h File Reference
#include "ecma119.h"
Include dependency graph for writer.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Iso_Image_Writer
 

Functions

int iso_write (Ecma119Image *target, void *buf, size_t count)
 This is the function all Writers should call to write data to image. More...
 
int ecma119_writer_create (Ecma119Image *target)
 

Function Documentation

◆ ecma119_writer_create()

int ecma119_writer_create ( Ecma119Image target)

Definition at line 984 of file ecma119.c.

985 {
986  int ret;
987  IsoImageWriter *writer;
988 
989  writer = malloc(sizeof(IsoImageWriter));
990  if (writer == NULL) {
991  return ISO_OUT_OF_MEM;
992  }
993 
998  writer->data = NULL;
999  writer->target = target;
1000 
1001  /* add this writer to image */
1002  target->writers[target->nwriters++] = writer;
1003 
1004  iso_msg_debug(target->image->id, "Creating low level ECMA-119 tree...");
1005  ret = ecma119_tree_create(target);
1006  if (ret < 0) {
1007  return ret;
1008  }
1009 
1010  if (target->image->sparc_core_node != NULL) {
1011  /* Obtain a duplicate of the IsoFile's Ecma119Node->file */
1012  ret = iso_file_src_create(target, target->image->sparc_core_node,
1013  &target->sparc_core_src);
1014  if (ret < 0)
1015  return ret;
1016  }
1017 
1018  if(target->opts->partition_offset > 0) {
1019  /* Create second tree */
1020  target->eff_partition_offset = target->opts->partition_offset;
1021  ret = ecma119_tree_create(target);
1022  target->eff_partition_offset = 0;
1023  if (ret < 0)
1024  return ret;
1025  }
1026 
1027  /* we need the volume descriptor */
1028  target->curblock++;
1029  return ISO_SUCCESS;
1030 }
static int ecma119_writer_write_data(IsoImageWriter *writer)
Write directory structure and Path Tables of the ECMA-119 tree.
Definition: ecma119.c:936
static int ecma119_writer_compute_data_blocks(IsoImageWriter *writer)
Definition: ecma119.c:303
static int ecma119_writer_write_vol_desc(IsoImageWriter *writer)
Write the Primary Volume Descriptor (ECMA-119, 8.4)
Definition: ecma119.c:536
static int ecma119_writer_free_data(IsoImageWriter *writer)
Definition: ecma119.c:978
int ecma119_tree_create(Ecma119Image *img)
int iso_file_src_create(Ecma119Image *img, IsoFile *file, IsoFileSrc **src)
Create a new IsoFileSrc to get data from a specific IsoFile.
Definition: filesrc.c:69
#define ISO_SUCCESS
successfully execution
Definition: libisofs.h:8719
#define ISO_OUT_OF_MEM
Memory allocation error (FATAL,HIGH, -6)
Definition: libisofs.h:8745
void iso_msg_debug(int imgid, const char *fmt,...)
Submit a debug message.
Definition: messages.c:253
Ecma119Image * target
Definition: writer.h:28
int(* write_data)(IsoImageWriter *writer)
Definition: writer.h:23
void * data
Definition: writer.h:27
int(* compute_data_blocks)(IsoImageWriter *writer)
Definition: writer.h:19
int(* write_vol_desc)(IsoImageWriter *writer)
Definition: writer.h:21
int(* free_data)(IsoImageWriter *writer)
Definition: writer.h:25
IsoFile * sparc_core_node
Definition: image.h:81
int id
Definition: image.h:97
IsoImage * image
Definition: ecma119.h:560
IsoWriteOpts * opts
Definition: ecma119.h:563
IsoImageWriter ** writers
Definition: ecma119.h:753
size_t nwriters
Definition: ecma119.h:752
uint32_t curblock
Definition: ecma119.h:618
IsoFileSrc * sparc_core_src
Definition: ecma119.h:815
uint32_t eff_partition_offset
Definition: ecma119.h:794
uint32_t partition_offset
Definition: ecma119.h:451

References Iso_Image_Writer::compute_data_blocks, ecma119_image::curblock, Iso_Image_Writer::data, ecma119_tree_create(), ecma119_writer_compute_data_blocks(), ecma119_writer_free_data(), ecma119_writer_write_data(), ecma119_writer_write_vol_desc(), ecma119_image::eff_partition_offset, Iso_Image_Writer::free_data, Iso_Image::id, ecma119_image::image, iso_file_src_create(), iso_msg_debug(), ISO_OUT_OF_MEM, ISO_SUCCESS, ecma119_image::nwriters, ecma119_image::opts, iso_write_opts::partition_offset, Iso_Image::sparc_core_node, ecma119_image::sparc_core_src, Iso_Image_Writer::target, Iso_Image_Writer::write_data, Iso_Image_Writer::write_vol_desc, and ecma119_image::writers.

Referenced by ecma119_image_new().

◆ iso_write()

int iso_write ( Ecma119Image target,
void *  buf,
size_t  count 
)

This is the function all Writers should call to write data to image.

Currently, it is just a wrapper for write(2) Unix system call.

It is implemented in ecma119.c

Returns
1 on success, < 0 error

Definition at line 3471 of file ecma119.c.

3472 {
3473  int ret;
3474 
3475  if (target->bytes_written + (off_t) count > target->total_size) {
3477  "ISO overwrite");
3478  return ISO_ASSERT_FAILURE;
3479  }
3480 
3481  ret = iso_ring_buffer_write(target->buffer, buf, count);
3482  if (ret == 0) {
3483  /* reader cancelled */
3484  return ISO_CANCELED;
3485  }
3486  if (ret < 0)
3487  return ret;
3488  if (target->checksum_ctx != NULL) {
3489  /* Add to image checksum */
3490  target->checksum_counter += count;
3491  iso_md5_compute(target->checksum_ctx, (char *) buf, (int) count);
3492  }
3493 
3494  ret = show_chunk_to_jte(target, buf, count);
3495  if (ret != ISO_SUCCESS)
3496  return ret;
3497 
3498  /* total size is 0 when writing the overwrite buffer */
3499  if (target->total_size != (off_t) 0){
3500  unsigned int kbw, kbt;
3501  int percent;
3502 
3503  target->bytes_written += (off_t) count;
3504  kbw = (unsigned int) (target->bytes_written >> 10);
3505  kbt = (unsigned int) (target->total_size >> 10);
3506  percent = (kbw * 100) / kbt;
3507 
3508  /* only report in 5% chunks */
3509  if (percent >= target->percent_written + 5) {
3510  iso_msg_debug(target->image->id, "Processed %u of %u KB (%d %%)",
3511  kbw, kbt, percent);
3512  target->percent_written = percent;
3513  }
3514  }
3515 
3516  return ISO_SUCCESS;
3517 }
int iso_ring_buffer_write(IsoRingBuffer *buf, uint8_t *data, size_t count)
Write count bytes into buffer.
Definition: buffer.c:150
static int show_chunk_to_jte(Ecma119Image *target, char *buf, int count)
Definition: ecma119.c:141
#define ISO_CANCELED
Operation canceled (FAILURE,HIGH, -1)
Definition: libisofs.h:8728
int iso_md5_compute(void *md5_context, char *data, int datalen)
Advance the computation of a MD5 checksum by a chunk of data bytes.
Definition: md5.c:365
#define ISO_ASSERT_FAILURE
Internal programming error.
Definition: libisofs.h:8737
int iso_msg_submit(int imgid, int errcode, int causedby, const char *fmt,...)
Definition: messages.c:579
IsoRingBuffer * buffer
Definition: ecma119.h:778
int percent_written
Definition: ecma119.h:612
void * checksum_ctx
Definition: ecma119.h:761
off_t total_size
Definition: ecma119.h:599
off_t bytes_written
Definition: ecma119.h:610
off_t checksum_counter
Definition: ecma119.h:762

References ecma119_image::buffer, ecma119_image::bytes_written, ecma119_image::checksum_counter, ecma119_image::checksum_ctx, Iso_Image::id, ecma119_image::image, ISO_ASSERT_FAILURE, ISO_CANCELED, iso_md5_compute(), iso_msg_debug(), iso_msg_submit(), iso_ring_buffer_write(), ISO_SUCCESS, ecma119_image::percent_written, show_chunk_to_jte(), and ecma119_image::total_size.

Referenced by checksum_writer_write_data(), ecma119_writer_write_vol_desc(), eltorito_writer_write_vol_desc(), filesrc_writer_write_data(), gpt_tail_writer_write_data(), hfsplus_tail_writer_write_data(), hfsplus_writer_write_data(), iso1999_writer_write_vol_desc(), iso_filesrc_write_data(), iso_md5_write_tag(), iso_write_partition_file(), joliet_writer_write_vol_desc(), mspad_writer_write_data(), pad_up_block(), rrip_write_ce_fields(), write_head_part1(), write_head_part2(), write_one_dir(), write_path_table(), write_sb(), write_vol_desc_terminator(), and zero_writer_write_data().