Narrowed rules for recognizing split file parts

This commit is contained in:
Thomas Schmitt 2009-09-27 08:04:05 +00:00
parent f02a22eba0
commit 8ec9dd6a05
4 changed files with 101 additions and 48 deletions

View File

@ -2,7 +2,7 @@
.\" First parameter, NAME, should be all caps .\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1) .\" other parameters are allowed: see man(7), man(1)
.TH XORRISO 1 "Sep 19, 2009" .TH XORRISO 1 "Sep 25, 2009"
.\" Please adjust this date whenever revising the manpage. .\" Please adjust this date whenever revising the manpage.
.\" .\"
.\" Some roff macros, for reference: .\" Some roff macros, for reference:
@ -994,30 +994,11 @@ E.g:
.br .br
/file/part_3_of_3_at_4094m_with_2047m_of_5753194821 /file/part_3_of_3_at_4094m_with_2047m_of_5753194821
.br .br
-cut_out is coordinated with -compare* and -update* if the names of the While option -split_size is set larger than 0 such file pieces will be
part files follow a convention by which xorriso is able to recognize recognized by their peculiar names. They get handled by options -compare* and
file parts and process them accordingly: -update*. In overwrite situations the common parent directory will be handled
.br like a regular file, if it contains exactly one complete set of file parts.
A disk file gets mapped to an ISO directory containing its split parts See option -split_size for details.
as regular files. The parts have names which describe the splitting
by 5 numbers which are separated by some non-numerical text:
.br
part_number, total_parts, byte_offset, byte_count, disk_file_size
.br
Scaling characters like "m" or "k" are taken into respect and may
serve as separators as well. All digits are interpreted as decimal,
even if leading zeros are present.
.br
Not all parts have to be present on the same media. But those parts
which are present have to sit in the same directory. No other files
are allowed in there. Parts have to be disjoint. Their numbers have
to be plausible. E.g. byte_count must be valid as -cut_out argument
and it must be the same with all parts.
.br
If the disk file grows enough to need new parts then those get added
to the directory if it already contains all parts of the old disk file.
If not all parts are present, then only those present parts will
be updated.
.TP .TP
\fB\-cpr\fR disk_path [***] iso_rr_path \fB\-cpr\fR disk_path [***] iso_rr_path
Insert the given files or directory trees from filesystem Insert the given files or directory trees from filesystem
@ -1806,12 +1787,45 @@ maps a large disk file onto a ISO directory with several part files in it.
This is necessary if the size of the disk file exceeds -file_size_limit. This is necessary if the size of the disk file exceeds -file_size_limit.
Older operating systems can handle files in mounted ISO 9660 filesystems Older operating systems can handle files in mounted ISO 9660 filesystems
only if they are smaller than 2 GiB resp. 4 GiB. only if they are smaller than 2 GiB resp. 4 GiB.
See also option -cut_out for more information about file parts.
.br .br
Default is 0 which will exclude files larger than -file_size_limit by a Default is 0 which will exclude files larger than -file_size_limit by a
FAILURE event. FAILURE event.
A well tested -split_size is 2047m. Sizes above -file_size_limit are not A well tested -split_size is 2047m. Sizes above -file_size_limit are not
permissible. permissible.
.br
While option -split_size is set larger than 0 such file pieces will be
recognized and handled by options -compare* and -update*. In overwrite
situations, the common parent directory will be handled like a regular file
if it contains only one complete set of file parts.
.br
In order to be recognizable, the names of the part files have to follow
a convention:
.br
A disk file gets mapped to an ISO directory containing its split parts
as regular files. The parts have names which describe the splitting
by 5 numbers
.br
part_number,total_parts,byte_offset,byte_count,disk_file_size
.br
which are embedded in the following text form:
.br
part_#_of_#_at_#_with_#_of_#
.br
Scaling characters like "m" or "k" are taken into respect.
All digits are interpreted as decimal, even if leading zeros are present.
.br
E.g: /file/part_1_of_3_at_0_with_2047m_of_5753194821
.br
For -update* and -compar* not all parts have to be present on the same media.
But those parts which are present have to sit in the same directory.
No other files are allowed in there. Parts have to be disjoint. Their numbers
have to be plausible. E.g. byte_count must be valid as -cut_out argument
and it must be the same with all parts.
.br
If the disk file grows enough to need new parts then those get added
to the directory if it already contains all parts of the old disk file.
If not all parts are present, then only those present parts will
be updated.
.TP .TP
.B Settings for result writing: .B Settings for result writing:
.TP .TP

View File

@ -3619,6 +3619,8 @@ struct SplitparT {
off_t total_bytes; off_t total_bytes;
}; };
static char Splitpart_wordS[][16]= {"part_", "_of_", "_at_", "_with_", "_of_"};
int Splitparts_new(struct SplitparT **o, int count, int flag) int Splitparts_new(struct SplitparT **o, int count, int flag)
{ {
@ -3691,6 +3693,7 @@ int Splitpart__read_next_num(char *base_pt, char **next_pt, off_t *num,
int flag) int flag)
{ {
char *cpt, *ept, scale[4]; char *cpt, *ept, scale[4];
double sfak;
*num= 0; *num= 0;
for(cpt= base_pt; *cpt!=0 && !isdigit(*cpt); cpt++); for(cpt= base_pt; *cpt!=0 && !isdigit(*cpt); cpt++);
@ -3701,8 +3704,9 @@ int Splitpart__read_next_num(char *base_pt, char **next_pt, off_t *num,
scale[0]= '1'; scale[0]= '1';
scale[1]= *ept; scale[1]= *ept;
scale[2]= 0; scale[2]= 0;
*num *= (off_t) Scanf_io_size(scale, 0); sfak= Scanf_io_size(scale, 0);
if(*ept!=0) *num *= (off_t) sfak;
if(sfak > 1.0)
ept++; ept++;
*next_pt= ept; *next_pt= ept;
return(1); return(1);
@ -3718,27 +3722,39 @@ int Splitpart__parse(char *name, int *partno, int *total_parts,
char *cpt, *ept; char *cpt, *ept;
cpt= name; cpt= name;
if(strncmp(cpt, Splitpart_wordS[0], strlen(Splitpart_wordS[0])) != 0)
return(0);
ret= Splitpart__read_next_num(cpt, &ept, &num, 0); ret= Splitpart__read_next_num(cpt, &ept, &num, 0);
if(ret<=0) if(ret<=0)
return(ret); return(ret);
*partno= num; *partno= num;
cpt= ept; cpt= ept;
if(strncmp(cpt, Splitpart_wordS[1], strlen(Splitpart_wordS[1])) != 0)
return(0);
ret= Splitpart__read_next_num(cpt, &ept, &num, 0); ret= Splitpart__read_next_num(cpt, &ept, &num, 0);
if(ret<=0) if(ret<=0)
return(ret); return(ret);
*total_parts= num; *total_parts= num;
cpt= ept; cpt= ept;
if(strncmp(cpt, Splitpart_wordS[2], strlen(Splitpart_wordS[2])) != 0)
return(0);
ret= Splitpart__read_next_num(cpt, &ept, offset, 0); ret= Splitpart__read_next_num(cpt, &ept, offset, 0);
if(ret<=0) if(ret<=0)
return(ret); return(ret);
cpt= ept; cpt= ept;
if(strncmp(cpt, Splitpart_wordS[3], strlen(Splitpart_wordS[3])) != 0)
return(0);
ret= Splitpart__read_next_num(cpt, &ept, bytes, 0); ret= Splitpart__read_next_num(cpt, &ept, bytes, 0);
if(ret<=0) if(ret<=0)
return(ret); return(ret);
cpt= ept; cpt= ept;
if(strncmp(cpt, Splitpart_wordS[4], strlen(Splitpart_wordS[4])) != 0)
return(0);
ret= Splitpart__read_next_num(cpt, &ept, total_bytes, 0); ret= Splitpart__read_next_num(cpt, &ept, total_bytes, 0);
if(ret<=0) if(ret<=0)
return(ret); return(ret);
if(*ept != 0)
return(0);
return(1); return(1);
} }
@ -3752,28 +3768,33 @@ int Splitpart__is_part_path(char *path, int flag)
name= strrchr(path, '/'); name= strrchr(path, '/');
if(name == NULL) if(name == NULL)
name= path; name= path;
else
name++;
ret= Splitpart__parse(name, &partno, &total_parts, &offset, &bytes, ret= Splitpart__parse(name, &partno, &total_parts, &offset, &bytes,
&total_bytes, 0); &total_bytes, 0);
return(ret > 0); return(ret > 0);
} }
/* part_#_of_#_at_#_with_#_of_#
*/
int Splitpart__compose(char *adr, int partno, int total_parts, int Splitpart__compose(char *adr, int partno, int total_parts,
off_t offset, off_t bytes, off_t total_bytes, int flag) off_t offset, off_t bytes, off_t total_bytes, int flag)
{ {
sprintf(adr, "part_%d_of_%d_at_", partno, total_parts); sprintf(adr, "%s%d%s%d%s", Splitpart_wordS[0], partno, Splitpart_wordS[1],
total_parts, Splitpart_wordS[2]);
if((offset % (1024*1024))==0 && offset>0) { if((offset % (1024*1024))==0 && offset>0) {
Sfile_off_t_text(adr+strlen(adr), offset / (1024*1024), 0); Sfile_off_t_text(adr+strlen(adr), offset / (1024*1024), 0);
strcat(adr, "m"); strcat(adr, "m");
} else } else
Sfile_off_t_text(adr+strlen(adr), offset, 0); Sfile_off_t_text(adr+strlen(adr), offset, 0);
strcat(adr, "_with_"); strcat(adr, Splitpart_wordS[3]);
if((bytes % (1024*1024))==0) { if((bytes % (1024*1024))==0) {
Sfile_off_t_text(adr+strlen(adr), bytes / (1024*1024), 0); Sfile_off_t_text(adr+strlen(adr), bytes / (1024*1024), 0);
strcat(adr, "m"); strcat(adr, "m");
} else } else
Sfile_off_t_text(adr+strlen(adr), bytes, 0); Sfile_off_t_text(adr+strlen(adr), bytes, 0);
strcat(adr, "_of_"); strcat(adr, Splitpart_wordS[4]);
Sfile_off_t_text(adr+strlen(adr), total_bytes, 0); Sfile_off_t_text(adr+strlen(adr), total_bytes, 0);
return(1); return(1);
} }
@ -19815,6 +19836,10 @@ next_command:;
} else if(strcmp(cmd,"test")==0) { /* This option does not exist. */ } else if(strcmp(cmd,"test")==0) { /* This option does not exist. */
/* install temporary test code here */; /* install temporary test code here */;
(*idx)++;
fprintf(stderr, "xorriso_DEBUG: Xorriso_is_split(%s)= %d\n",
arg1, Xorriso_is_split(xorriso, arg1, NULL, 2));
} else if(strcmp(cmd,"toc")==0) { } else if(strcmp(cmd,"toc")==0) {
Xorriso_option_toc(xorriso, 0); Xorriso_option_toc(xorriso, 0);

View File

@ -1 +1 @@
#define Xorriso_timestamP "2009.09.22.143534" #define Xorriso_timestamP "2009.09.27.080401"

View File

@ -2705,7 +2705,6 @@ int Xorriso_graft_split(struct XorrisO *xorriso, IsoImage *volume,
if(ret<0) if(ret<0)
return(ret); return(ret);
*node= (IsoNode *) new_dir; *node= (IsoNode *) new_dir;
total_parts= size / xorriso->split_size; total_parts= size / xorriso->split_size;
if(size % xorriso->split_size) if(size % xorriso->split_size)
total_parts++; total_parts++;
@ -2767,7 +2766,6 @@ int Xorriso_tree_graft_node(struct XorrisO *xorriso, IsoImage *volume,
node, 0); node, 0);
if(ret<=0) if(ret<=0)
goto ex; goto ex;
return(1);
} else if(size > xorriso->file_size_limit && xorriso->file_size_limit > 0) { } else if(size > xorriso->file_size_limit && xorriso->file_size_limit > 0) {
sprintf(xorriso->info_text, sprintf(xorriso->info_text,
"File exceeds size limit of %.f bytes: %s\n", "File exceeds size limit of %.f bytes: %s\n",
@ -2775,10 +2773,11 @@ int Xorriso_tree_graft_node(struct XorrisO *xorriso, IsoImage *volume,
Text_shellsafe(disk_path, sfe, 0)); Text_shellsafe(disk_path, sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0); return(0);
} else {
ret= iso_tree_add_new_node(volume, dir, img_name, disk_path, node);
if(ret<0)
goto ex;
} }
ret= iso_tree_add_new_node(volume, dir, img_name, disk_path, node);
if(ret<0)
goto ex;
} }
if(stbuf_valid && ((xorriso->do_aaip & 16) || !(xorriso->ino_behavior & 2))) { if(stbuf_valid && ((xorriso->do_aaip & 16) || !(xorriso->ino_behavior & 2))) {
@ -2804,6 +2803,7 @@ ex:;
/* @param flag bit0= recursion is active /* @param flag bit0= recursion is active
bit1= do not report added files bit1= do not report added files
bit6= do not delete eventually existing node from di_array bit6= do not delete eventually existing node from di_array
bit7= no special handling of split file directories
*/ */
int Xorriso_add_tree(struct XorrisO *xorriso, IsoDir *dir, int Xorriso_add_tree(struct XorrisO *xorriso, IsoDir *dir,
char *img_dir_path, char *disk_dir_path, char *img_dir_path, char *disk_dir_path,
@ -2955,8 +2955,8 @@ cannot_lstat:;
if(ret>0) { if(ret>0) {
target_is_dir= LIBISO_ISDIR(node); target_is_dir= LIBISO_ISDIR(node);
target_is_split= 0; target_is_split= 0;
if(target_is_dir) if(target_is_dir && !(flag & 128))
target_is_split= Xorriso_is_split(xorriso, "", (void *) node, 1); target_is_split= Xorriso_is_split(xorriso, "", (void *) node, 1 | 2);
if(!((target_is_dir && !target_is_split) && source_is_dir)) { if(!((target_is_dir && !target_is_split) && source_is_dir)) {
Xorriso_process_msg_queues(xorriso,0); Xorriso_process_msg_queues(xorriso,0);
@ -3014,7 +3014,7 @@ cannot_lstat:;
} else { } else {
ret= Xorriso_add_tree(xorriso, (IsoDir *) node, ret= Xorriso_add_tree(xorriso, (IsoDir *) node,
img_path, disk_path, own_link_stack, img_path, disk_path, own_link_stack,
1 | (flag & (2 | 64))); 1 | (flag & (2 | 64 | 128)));
} }
if(ret<=0) if(ret<=0)
goto was_problem; goto was_problem;
@ -3258,8 +3258,8 @@ int Xorriso_graft_in(struct XorrisO *xorriso, void *boss_iter,
target_is_dir= LIBISO_ISDIR(node); target_is_dir= LIBISO_ISDIR(node);
target_is_split= 0; target_is_split= 0;
if(target_is_dir && !(flag&128)) if(target_is_dir && !(flag & 128))
target_is_split= Xorriso_is_split(xorriso, "", (void *) node, 1); target_is_split= Xorriso_is_split(xorriso, "", (void *) node, 1 | 2);
if(!((target_is_dir && !target_is_split) && source_is_dir)) { if(!((target_is_dir && !target_is_split) && source_is_dir)) {
Xorriso_process_msg_queues(xorriso,0); Xorriso_process_msg_queues(xorriso,0);
@ -3325,7 +3325,7 @@ attach_source:;
(IsoNode *) dir, 4 | 32); (IsoNode *) dir, 4 | 32);
if(!(flag&32)) { if(!(flag&32)) {
ret= Xorriso_add_tree(xorriso, dir, img_path, disk_path, NULL, ret= Xorriso_add_tree(xorriso, dir, img_path, disk_path, NULL,
flag & (2 | 64)); flag & (2 | 64 | 128));
if(ret<=0) if(ret<=0)
return(ret); return(ret);
} }
@ -8033,7 +8033,7 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job,
void *dir_node_generic, char *dir_path, void *dir_node_generic, char *dir_path,
struct stat *dir_stbuf, int depth, int flag) struct stat *dir_stbuf, int depth, int flag)
{ {
int ret, action= 0, hflag, deleted= 0, no_dive= 0; int ret, action= 0, hflag, deleted= 0, no_dive= 0, split_flag;
IsoDirIter *iter= NULL; IsoDirIter *iter= NULL;
IsoDir *dir_node= NULL; IsoDir *dir_node= NULL;
IsoNode *node, *iso_node; IsoNode *node, *iso_node;
@ -8128,7 +8128,10 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job,
} }
if(no_dive || !LIBISO_ISDIR((IsoNode *) dir_node)) if(no_dive || !LIBISO_ISDIR((IsoNode *) dir_node))
{ret= 1; goto ex;} {ret= 1; goto ex;}
if(Xorriso_is_split(xorriso, dir_path, (IsoNode *) dir_node, 1)>0) split_flag= 1 | 2;
if(action == 14 || action == 17)
split_flag &= ~2;
if(Xorriso_is_split(xorriso, dir_path, (IsoNode *) dir_node, split_flag)>0)
{ret= 1; goto ex;} {ret= 1; goto ex;}
mem= boss_mem; mem= boss_mem;
@ -9236,6 +9239,8 @@ int Xorriso_iso_file_close(struct XorrisO *xorriso, void **stream, int flag)
/* @param flag bit0= in_node is valid, do not resolve iso_adr /* @param flag bit0= in_node is valid, do not resolve iso_adr
bit1= insist in complete collection of part files bit1= insist in complete collection of part files
??? <<< bit2= recognize and parse split parts despite
xorrio->split_size <= 0
*/ */
int Xorriso_identify_split(struct XorrisO *xorriso, char *iso_adr, int Xorriso_identify_split(struct XorrisO *xorriso, char *iso_adr,
void *in_node, void *in_node,
@ -9257,6 +9262,13 @@ int Xorriso_identify_split(struct XorrisO *xorriso, char *iso_adr,
*count= 0; *count= 0;
*parts= NULL; *parts= NULL;
/* <<< remove bit1 and hardcode it
flag|= 2;
*/
if(xorriso->split_size <= 0 && !(flag & 4))
return(0);
if(flag&1) { if(flag&1) {
node= (IsoNode *) in_node; node= (IsoNode *) in_node;
} else { } else {
@ -9304,12 +9316,14 @@ cannot_iter:;
size= stbuf.st_size; size= stbuf.st_size;
} }
/* check for plausible size */ /* check for plausible size */
if(!((partno<total_parts && size==bytes) || if(!((partno != total_parts && size == bytes) ||
(partno==total_parts && size<=bytes))) (partno == total_parts && size <= bytes)))
{ret= 0; goto ex;}
if(offset != first_bytes * (off_t) (partno - 1))
{ret= 0; goto ex;} {ret= 0; goto ex;}
(*count)++; (*count)++;
} }
if((*count)<=0) if(*count <= 0 || (*count != first_total_parts && (flag & 2)))
{ret= 0; goto ex;} {ret= 0; goto ex;}
ret= Splitparts_new(parts, (*count)+1, 0); /* (have one end marker item) */ ret= Splitparts_new(parts, (*count)+1, 0); /* (have one end marker item) */