From 96121a70dc5ee75c76683fb60e0810a8122ec39a Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Mon, 18 Aug 2008 13:42:44 +0000 Subject: [PATCH] New -find action report_lba --- xorriso/README | 20 ++++++ xorriso/xorriso.1 | 11 ++- xorriso/xorriso_timestamp.h | 2 +- xorriso/xorrisoburn.c | 139 +++++++++--------------------------- 4 files changed, 63 insertions(+), 109 deletions(-) diff --git a/xorriso/README b/xorriso/README index 14f6531a..437a174a 100644 --- a/xorriso/README +++ b/xorriso/README @@ -147,6 +147,26 @@ and vice versa: | less + File Formats + +Currently there is only one file format peculiar to xorriso : sector maps +which describe the valid and invalid blocks on a media or a disk copy of +a media. xorriso creates and reads these file with its option -check_media. + +The file begins with 32 bytes of cleartext of which the last one is a +newline character. The first 25 say "xorriso sector bitmap v2 ", the +remaining six characters give the size of the info text as decimal number. +This number of bytes follows the first 32 and will not be interpreted +by xorriso. They are rather to inform a human reader about the media type +and its track layout. +After the info text there are two 4 byte signed integers, most significant +byte first. The first one, N, gives the number of bits in the following bitmap +and the second number S gives the number of 2 KiB blocks governed by a single +bit in the map. Then come the bits in form of 8-bit bytes. +Media block M is covered by bit B=M/S in the map, bit number B is stored in +byte B/8 as bit B%8. A valid readable data block has its bit set to 1. + + libisoburn xorriso is based on libisofs which does ISO 9600 filesystem aspects and on diff --git a/xorriso/xorriso.1 b/xorriso/xorriso.1 index 0f569238..140cfed4 100644 --- a/xorriso/xorriso.1 +++ b/xorriso/xorriso.1 @@ -2,7 +2,7 @@ .\" First parameter, NAME, should be all caps .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) -.TH XORRISO 1 "Aug 17, 2008" +.TH XORRISO 1 "Aug 18, 2008" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: @@ -936,6 +936,15 @@ E.g.: .br -find / -damaged -exec report_damage .br +"report_lba" prints files which are associated to image data blocks. +It tells the logical block address, the block number, the byte size, +and the path of each file. In future there may be reported more than one +line per file if thie file is very large. +.br +E.g.: +.br + -find / -lba_range 302000 50000 -exec report_lba +.br "find" performs another run of -find on the matching file address. It accepts the same params as -find, except iso_rr_path. E.g.: diff --git a/xorriso/xorriso_timestamp.h b/xorriso/xorriso_timestamp.h index 9ffd9fcb..d250115a 100644 --- a/xorriso/xorriso_timestamp.h +++ b/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2008.08.17.221350" +#define Xorriso_timestamP "2008.08.18.134140" diff --git a/xorriso/xorrisoburn.c b/xorriso/xorrisoburn.c index 9a023b55..cd11910d 100644 --- a/xorriso/xorrisoburn.c +++ b/xorriso/xorrisoburn.c @@ -5599,6 +5599,26 @@ int Xorriso_file_eval_damage(struct XorrisO *xorriso, IsoNode *node, } +int Xorriso_report_lba(struct XorrisO *xorriso, char *show_path, + IsoNode *node, int flag) +{ + int ret, start_lba, end_lba; + off_t size; + char sfe[5*SfileadrL]; + + ret= Xorriso_start_end_lba(xorriso, node, &start_lba, &end_lba, &size, 0); + if(ret < 0) + return(ret); + if(ret == 0) + return(1); /* it is ok to ignore other types */ + sprintf(xorriso->result_line, "File data lba: %2d , %8d , %8d , %8.f , %s\n", + 0, start_lba, end_lba + 1 - start_lba, (double) size, + Text_shellsafe(show_path, sfe, 0)); + Xorriso_result(xorriso, 0); + return(1); +} + + int Xorriso_report_damage(struct XorrisO *xorriso, char *show_path, IsoNode *node, int flag) { @@ -5626,76 +5646,6 @@ int Xorriso_report_damage(struct XorrisO *xorriso, char *show_path, } -/* <<< shall be replaced by tests and -exec report_damage -#define Xorriso_check_find_as_exeC 1 -*/ - -#ifdef Xorriso_check_find_as_exeC - -/* @param flag bit0= report about undamaged files -*/ -int Xorriso_file_vs_bitmap(struct XorrisO *xorriso, char *show_path, - IsoNode *node, int flag) -{ - uint32_t start_lba; - int end_lba, i, sectors, sector_size, damaged= 0, ret; - int next_good_lba, first_bad_lba= -1; - off_t size= 0, damage_start, damage_count; - struct SectorbitmaP *map; - char sfe[5*SfileadrL]; - - ret= iso_node_get_old_image_lba(node, &start_lba, 0); - if(ret < 0) - return(0); - if(ret == 0) { - if(flag & 1) - goto undamaged; - return(2); - } - map= xorriso->in_sector_map; - if(map == NULL) { - if(flag & 1) - goto undamaged; - return(2); - } - if(LIBISO_ISREG(node)) - size= iso_file_get_size((IsoFile *) node); - end_lba= start_lba + size / 2048; - if(size % 2048) - end_lba++; - - Sectorbitmap_get_layout(map, §ors, §or_size, 0); - sector_size/= 2048; - for(i= start_lba; i < end_lba; i+= sector_size) - if(Sectorbitmap_is_set(map, i / sector_size, 0) == 0) { - damaged= 1; - if(first_bad_lba < 0) - first_bad_lba= i; - next_good_lba= (i / sector_size + 1) * sector_size; - } - - if(damaged && !(flag & 1)) { - damage_start= (first_bad_lba - start_lba) * 2048; - damage_count= (next_good_lba - start_lba) * 2048; - if(damage_count > size) - damage_count= size; - damage_count-= damage_start; - sprintf(xorriso->result_line, "File damage : %13.f , %13.f , %13.f , %s\n", - (double) damage_start, (double) damage_count, (double) size, - Text_shellsafe(show_path, sfe, 0)); - Xorriso_result(xorriso, 0); - } else if((flag & 1) && !damaged) { -undamaged:; - sprintf(xorriso->result_line, "File seems ok: %s\n", - Text_shellsafe(show_path, sfe, 0)); - Xorriso_result(xorriso, 0); - } - return(1); -} - -#endif /* Xorriso_check_find_as_exeC */ - - /* @param flag bit0= not a command parameter (directory iteration or recursion) bit1= do not count deleted files with rm and rm_r @return <=0 error, @@ -5764,24 +5714,10 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job, ret= 1; } else if(action==16 || action==18) { /* not_in_iso , add_missing */ ; - -#ifdef Xorriso_check_find_as_exeC - - } else if(action == 21) { /* is_damaged */ - ret= Xorriso_file_vs_bitmap(xorriso, show_path, node, 0); - } else if(action == 22) { /* is_undamaged */ - ret= Xorriso_file_vs_bitmap(xorriso, show_path, node, 1); - -#else - } else if(action == 21) { /* report_damage */ ret= Xorriso_report_damage(xorriso, show_path, node, 0); } else if(action == 22) { - /* >>> report_lba */; - -#endif /* ! Xorriso_check_find_as_exeC */ - - + ret= Xorriso_report_lba(xorriso, show_path, node, 0); } else { /* includes : 15 in_iso */ sprintf(xorriso->result_line, "%s\n", Text_shellsafe(show_path, sfe, 0)); Xorriso_result(xorriso, 0); @@ -5865,10 +5801,17 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job, action= Findjob_get_action(job, 0); if(action<0) action= 0; - if(action == 21 && !(flag & 1)) { - sprintf(xorriso->result_line, "Report layout: %8s , %8s , %8s , %s\n", - "at byte", "range", "filesize", "ISO image path"); - Xorriso_result(xorriso, 0); + if(!(flag & 1)) { + if(action == 21) { + sprintf(xorriso->result_line, "Report layout: %8s , %8s , %8s , %s\n", + "at byte", "Range", "Filesize", "ISO image path"); + Xorriso_result(xorriso, 0); + } else if(action == 22) { + sprintf(xorriso->result_line, + "Report layout: %2s , %8s , %8s , %8s , %s\n", + "xt", "Startlba", "Blocks", "Filesize", "ISO image path"); + Xorriso_result(xorriso, 0); + } } dir_node= (IsoDir *) dir_node_generic; @@ -5893,17 +5836,8 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job, else name++; -#ifdef Xorriso_check_find_as_exeC - - ret= Findjob_test(job, name, NULL, dir_stbuf, depth, 0); - -#else - ret= Xorriso_findi_test(xorriso, job, iso_node, name, NULL, dir_stbuf, depth, 0); - -#endif /* ! Xorriso_check_find_as_exeC */ - if(ret<0) goto ex; if(ret>0) { @@ -5971,17 +5905,8 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job, handling of the find start path with mount points. Dangerous to change. */ -#ifdef Xorriso_check_find_as_exeC - - ret= Findjob_test(job, name, dir_stbuf, &stbuf, depth, 0); - -#else - ret= Xorriso_findi_test(xorriso, job, node, name, dir_stbuf, &stbuf, depth, 0); - -#endif /* ! Xorriso_check_find_as_exeC */ - if(ret<0) goto ex; if(ret>0) {