2007-12-15 12:13:49 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2007 Vreixo Formoso
|
|
|
|
*
|
|
|
|
* 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 as
|
|
|
|
* published by the Free Software Foundation. See COPYING file for details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LIBISO_ECMA119_H_
|
|
|
|
#define LIBISO_ECMA119_H_
|
|
|
|
|
2007-12-16 18:10:47 +00:00
|
|
|
#include "libisofs.h"
|
2007-12-19 23:25:25 +00:00
|
|
|
#include "util.h"
|
2007-12-23 01:46:35 +00:00
|
|
|
#include "buffer.h"
|
2007-12-16 18:10:47 +00:00
|
|
|
|
2007-12-17 22:22:19 +00:00
|
|
|
#include <stdint.h>
|
2007-12-22 16:09:28 +00:00
|
|
|
#include <pthread.h>
|
2007-12-17 22:22:19 +00:00
|
|
|
|
2007-12-17 23:20:03 +00:00
|
|
|
#define BLOCK_SIZE 2048
|
|
|
|
|
2007-12-15 12:13:49 +00:00
|
|
|
typedef struct ecma119_image Ecma119Image;
|
2007-12-15 15:55:44 +00:00
|
|
|
typedef struct ecma119_node Ecma119Node;
|
2007-12-15 15:48:50 +00:00
|
|
|
typedef struct Iso_File_Src IsoFileSrc;
|
2007-12-16 18:10:47 +00:00
|
|
|
typedef struct Iso_Image_Writer IsoImageWriter;
|
2007-12-15 12:13:49 +00:00
|
|
|
|
2007-12-28 21:10:17 +00:00
|
|
|
struct ecma119_image
|
|
|
|
{
|
2007-12-16 18:10:47 +00:00
|
|
|
IsoImage *image;
|
2007-12-15 15:55:44 +00:00
|
|
|
Ecma119Node *root;
|
2007-12-28 21:10:17 +00:00
|
|
|
|
|
|
|
unsigned int iso_level :2;
|
|
|
|
|
2007-12-23 15:16:26 +00:00
|
|
|
/* extensions */
|
2007-12-28 21:10:17 +00:00
|
|
|
unsigned int rockridge :1;
|
|
|
|
|
2007-12-21 22:08:21 +00:00
|
|
|
/* relaxed constraints */
|
2007-12-28 21:10:17 +00:00
|
|
|
unsigned int omit_version_numbers :1;
|
|
|
|
unsigned int allow_deep_paths :1;
|
2008-01-06 16:38:31 +00:00
|
|
|
|
|
|
|
/** Allow paths on Joliet tree to be larger than 240 bytes */
|
|
|
|
unsigned int joliet_longer_paths :1;
|
2007-12-28 21:10:17 +00:00
|
|
|
// int relaxed_constraints; /**< see ecma119_relaxed_constraints_flag */
|
|
|
|
|
2007-12-27 17:10:14 +00:00
|
|
|
/*
|
|
|
|
* Mode replace. If one of these flags is set, the correspodent values are
|
|
|
|
* replaced with values below.
|
|
|
|
*/
|
2007-12-28 21:10:17 +00:00
|
|
|
unsigned int replace_uid :1;
|
|
|
|
unsigned int replace_gid :1;
|
|
|
|
unsigned int replace_file_mode :1;
|
|
|
|
unsigned int replace_dir_mode :1;
|
|
|
|
|
2007-12-27 17:10:14 +00:00
|
|
|
uid_t uid;
|
|
|
|
gid_t gid;
|
|
|
|
mode_t file_mode;
|
|
|
|
mode_t dir_mode;
|
|
|
|
|
2007-12-28 21:10:17 +00:00
|
|
|
/**
|
|
|
|
* if sort files or not. Sorting is based of the weight of each file
|
|
|
|
*/
|
|
|
|
int sort_files;
|
2007-12-25 17:51:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* In the CD, each file must have an unique inode number. So each
|
|
|
|
* time we add a new file, this is incremented.
|
|
|
|
*/
|
|
|
|
ino_t ino;
|
2007-12-28 21:10:17 +00:00
|
|
|
|
2007-12-18 20:55:01 +00:00
|
|
|
char *input_charset;
|
2007-12-27 17:55:47 +00:00
|
|
|
char *output_charset;
|
2007-12-28 21:10:17 +00:00
|
|
|
|
2008-01-04 22:54:31 +00:00
|
|
|
unsigned int appendable : 1;
|
2007-12-18 20:55:01 +00:00
|
|
|
uint32_t ms_block; /**< start block for a ms image */
|
2007-12-28 21:10:17 +00:00
|
|
|
time_t now; /**< Time at which writing began. */
|
|
|
|
|
|
|
|
/** Total size of the output. This only includes the current volume. */
|
|
|
|
off_t total_size;
|
2007-12-18 20:55:01 +00:00
|
|
|
uint32_t vol_space_size;
|
2007-12-15 12:13:49 +00:00
|
|
|
|
2007-12-29 16:42:57 +00:00
|
|
|
/* Bytes already written, just for progress notification */
|
|
|
|
off_t bytes_written;
|
|
|
|
int percent_written;
|
|
|
|
|
2007-12-17 22:22:19 +00:00
|
|
|
/*
|
|
|
|
* Block being processed, either during image writing or structure
|
|
|
|
* size calculation.
|
|
|
|
*/
|
|
|
|
uint32_t curblock;
|
2007-12-17 23:20:03 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* number of dirs in ECMA-119 tree, computed together with dir position,
|
|
|
|
* and needed for path table computation in a efficient way
|
|
|
|
*/
|
|
|
|
size_t ndirs;
|
2007-12-18 20:55:01 +00:00
|
|
|
uint32_t path_table_size;
|
2007-12-17 23:20:03 +00:00
|
|
|
uint32_t l_path_table_pos;
|
|
|
|
uint32_t m_path_table_pos;
|
2007-12-28 21:10:17 +00:00
|
|
|
|
2008-01-05 02:16:33 +00:00
|
|
|
/*
|
|
|
|
* Number of pad blocks that we need to write. Padding blocks are blocks
|
|
|
|
* filled by 0s that we put between the directory structures and the file
|
|
|
|
* data. These padding blocks are added by libisofs to improve the handling
|
|
|
|
* of image growing. The idea is that the first blocks in the image are
|
|
|
|
* overwritten with the volume descriptors of the new image. These first
|
|
|
|
* blocks usually correspond to the volume descriptors and directory
|
|
|
|
* structure of the old image, and can be safety overwritten. However,
|
|
|
|
* with very small images they might correspond to valid data. To ensure
|
|
|
|
* this never happens, what we do is to add padding bytes, to ensure no
|
|
|
|
* file data is written in the first 64 KiB, that are the bytes we usually
|
|
|
|
* overwrite.
|
|
|
|
*/
|
|
|
|
uint32_t pad_blocks;
|
|
|
|
|
2007-12-17 22:22:19 +00:00
|
|
|
size_t nwriters;
|
|
|
|
IsoImageWriter **writers;
|
|
|
|
|
2007-12-15 12:13:49 +00:00
|
|
|
/* tree of files sources */
|
2007-12-19 23:25:25 +00:00
|
|
|
IsoRBTree *files;
|
2007-12-28 21:10:17 +00:00
|
|
|
|
2007-12-23 01:46:35 +00:00
|
|
|
/* Buffer for communication between burn_source and writer thread */
|
|
|
|
IsoRingBuffer *buffer;
|
2007-12-28 21:10:17 +00:00
|
|
|
|
2007-12-22 16:09:28 +00:00
|
|
|
/* writer thread descriptor */
|
|
|
|
pthread_t wthread;
|
|
|
|
pthread_attr_t th_attr;
|
2007-12-15 12:13:49 +00:00
|
|
|
};
|
|
|
|
|
2007-12-18 20:55:01 +00:00
|
|
|
#define BP(a,b) [(b) - (a) + 1]
|
|
|
|
|
2007-12-20 23:05:41 +00:00
|
|
|
/* ECMA-119, 8.4 */
|
2007-12-18 20:55:01 +00:00
|
|
|
struct ecma119_pri_vol_desc
|
|
|
|
{
|
2007-12-20 23:05:41 +00:00
|
|
|
uint8_t vol_desc_type BP(1, 1);
|
|
|
|
uint8_t std_identifier BP(2, 6);
|
|
|
|
uint8_t vol_desc_version BP(7, 7);
|
|
|
|
uint8_t unused1 BP(8, 8);
|
|
|
|
uint8_t system_id BP(9, 40);
|
|
|
|
uint8_t volume_id BP(41, 72);
|
|
|
|
uint8_t unused2 BP(73, 80);
|
|
|
|
uint8_t vol_space_size BP(81, 88);
|
|
|
|
uint8_t unused3 BP(89, 120);
|
|
|
|
uint8_t vol_set_size BP(121, 124);
|
|
|
|
uint8_t vol_seq_number BP(125, 128);
|
|
|
|
uint8_t block_size BP(129, 132);
|
|
|
|
uint8_t path_table_size BP(133, 140);
|
|
|
|
uint8_t l_path_table_pos BP(141, 144);
|
|
|
|
uint8_t opt_l_path_table_pos BP(145, 148);
|
|
|
|
uint8_t m_path_table_pos BP(149, 152);
|
|
|
|
uint8_t opt_m_path_table_pos BP(153, 156);
|
|
|
|
uint8_t root_dir_record BP(157, 190);
|
|
|
|
uint8_t vol_set_id BP(191, 318);
|
|
|
|
uint8_t publisher_id BP(319, 446);
|
|
|
|
uint8_t data_prep_id BP(447, 574);
|
|
|
|
uint8_t application_id BP(575, 702);
|
|
|
|
uint8_t copyright_file_id BP(703, 739);
|
|
|
|
uint8_t abstract_file_id BP(740, 776);
|
|
|
|
uint8_t bibliographic_file_id BP(777, 813);
|
|
|
|
uint8_t vol_creation_time BP(814, 830);
|
|
|
|
uint8_t vol_modification_time BP(831, 847);
|
|
|
|
uint8_t vol_expiration_time BP(848, 864);
|
|
|
|
uint8_t vol_effective_time BP(865, 881);
|
|
|
|
uint8_t file_structure_version BP(882, 882);
|
|
|
|
uint8_t reserved1 BP(883, 883);
|
|
|
|
uint8_t app_use BP(884, 1395);
|
|
|
|
uint8_t reserved2 BP(1396, 2048);
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ECMA-119, 9.1 */
|
|
|
|
struct ecma119_dir_record
|
|
|
|
{
|
|
|
|
uint8_t len_dr BP(1, 1);
|
|
|
|
uint8_t len_xa BP(2, 2);
|
|
|
|
uint8_t block BP(3, 10);
|
|
|
|
uint8_t length BP(11, 18);
|
|
|
|
uint8_t recording_time BP(19, 25);
|
|
|
|
uint8_t flags BP(26, 26);
|
|
|
|
uint8_t file_unit_size BP(27, 27);
|
|
|
|
uint8_t interleave_gap_size BP(28, 28);
|
|
|
|
uint8_t vol_seq_number BP(29, 32);
|
|
|
|
uint8_t len_fi BP(33, 33);
|
|
|
|
uint8_t file_id BP(34, 34); /* 34 to 33+len_fi */
|
|
|
|
/* padding field (if len_fi is even) */
|
|
|
|
/* system use (len_dr - len_su + 1 to len_dr) */
|
2007-12-18 20:55:01 +00:00
|
|
|
};
|
|
|
|
|
2007-12-21 21:53:48 +00:00
|
|
|
/* ECMA-119, 9.4 */
|
|
|
|
struct ecma119_path_table_record
|
|
|
|
{
|
2007-12-22 13:45:00 +00:00
|
|
|
uint8_t len_di BP(1, 1);
|
|
|
|
uint8_t len_xa BP(2, 2);
|
|
|
|
uint8_t block BP(3, 6);
|
|
|
|
uint8_t parent BP(7, 8);
|
|
|
|
uint8_t dir_id BP(9, 9); /* 9 to 8+len_di */
|
2007-12-21 21:53:48 +00:00
|
|
|
/* padding field (if len_di is odd) */
|
|
|
|
};
|
|
|
|
|
2007-12-22 13:45:00 +00:00
|
|
|
/* ECMA-119, 8.3 */
|
|
|
|
struct ecma119_vol_desc_terminator
|
|
|
|
{
|
|
|
|
uint8_t vol_desc_type BP(1, 1);
|
|
|
|
uint8_t std_identifier BP(2, 6);
|
|
|
|
uint8_t vol_desc_version BP(7, 7);
|
|
|
|
uint8_t reserved BP(8, 2048);
|
|
|
|
};
|
|
|
|
|
2007-12-15 12:13:49 +00:00
|
|
|
#endif /*LIBISO_ECMA119_H_*/
|