From 67a80503840087e7fea09ca612946b05d647053a Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Tue, 22 Apr 2008 20:10:38 +0000 Subject: [PATCH] New option --list_formats --- libburn/trunk/cdrskin/cdrskin.1 | 12 +++- libburn/trunk/cdrskin/cdrskin.c | 80 +++++++++++++++++++++++ libburn/trunk/cdrskin/cdrskin_timestamp.h | 2 +- 3 files changed, 92 insertions(+), 2 deletions(-) diff --git a/libburn/trunk/cdrskin/cdrskin.1 b/libburn/trunk/cdrskin/cdrskin.1 index cb4a29be..75fa01da 100644 --- a/libburn/trunk/cdrskin/cdrskin.1 +++ b/libburn/trunk/cdrskin/cdrskin.1 @@ -345,7 +345,7 @@ audio track. Same is done for suffix ".au" and SUN Audio. Option -audio may be used only with CD media and not with DVD. .TP .BI blank= type -Blank a CD-RW, a DVD-RW, or format a DVD+/-RW. +Blank a CD-RW, a DVD-RW, or format a DVD-RW, DVD+RW or DVD-RAM. This is combinable with burning in the same run of cdrskin. The type given with blank= selects the particular behavior: .RS @@ -1063,6 +1063,16 @@ Try to ignore any signals rather than to abort the program. This is not a very good idea. You might end up waiting a very long time for cdrskin to finish. .TP +.BI \--list_formats +List the available format descriptors as reported by the drive for the +loaded media. Each descriptor line begins with "Format idx" and the +descriptor's list index, followed by a ":", the format type, the number +of payload blocks and that same number converted to MiB. +.br +The meaning of the format types is defined by the MMC standard +with command FORMAT UNIT. A user will more be interested in the +sizes than in the types. +.TP .BI modesty_on_drive= [:min_percent=][:max_percent=] Mode 1 keeps the program from trying to write to the burner drive while its buffer is in danger to be filled by more than max_percent. If this filling is diff --git a/libburn/trunk/cdrskin/cdrskin.c b/libburn/trunk/cdrskin/cdrskin.c index e8d1fa32..6f8bc743 100644 --- a/libburn/trunk/cdrskin/cdrskin.c +++ b/libburn/trunk/cdrskin/cdrskin.c @@ -2654,6 +2654,7 @@ set_dev:; " --grow_overwriteable_iso emulate multi-session on media like DVD+RW\n"); printf( " --ignore_signals try to ignore any signals rather than to abort\n"); + printf(" --list_formats list format descriptors for loaded media.\n"); printf(" --list_ignored_options list all ignored cdrecord options.\n"); #ifdef Cdrskin_libburn_has_set_waitinG printf(" modesty_on_drive= no writing into full drive buffer\n"); @@ -3115,6 +3116,7 @@ struct CdrskiN { char msifile[Cdrskin_strleN]; int do_atip; + int do_list_formats; int do_blank; int blank_fast; @@ -3295,6 +3297,7 @@ int Cdrskin_new(struct CdrskiN **skin, struct CdrpreskiN *preskin, int flag) o->do_msinfo= 0; o->msifile[0]= 0; o->do_atip= 0; + o->do_list_formats= 0; o->do_blank= 0; o->blank_fast= 0; o->no_blank_appendable= 0; @@ -4858,6 +4861,73 @@ ex:; } +/** Perform --list_formats + @param flag Bitfield for control purposes: + @return <=0 error, 1 success +*/ +int Cdrskin_list_formats(struct CdrskiN *skin, int flag) +{ + struct burn_drive *drive; + int ret, i, status, num_formats, profile_no, type; + off_t size; + unsigned dummy; + char status_text[80], profile_name[90]; + + ret= Cdrskin_grab_drive(skin,0); + if(ret<=0) + return(ret); + drive= skin->drives[skin->driveno].drive; + + ret = burn_disc_get_formats(drive, &status, &size, &dummy, + &num_formats); + if(ret <= 0) { + fprintf(stderr, "cdrskin: SORRY: Cannot obtain format list info\n"); + ret= 2; goto ex; + } + ret= burn_disc_get_profile(drive, &profile_no, profile_name); + printf("Media current: "); + if(profile_no > 0 && ret > 0) { + if(profile_name[0]) + printf("%s\n", profile_name); + else + printf("%4.4Xh\n", profile_no); + } else + printf("is not recognizable\n"); + + if(status == BURN_FORMAT_IS_UNFORMATTED) + sprintf(status_text, "unformatted, up to %.1f MiB", + ((double) size) / 1024.0 / 1024.0); + else if(status == BURN_FORMAT_IS_FORMATTED) { + if(profile_no==0x12 || profile_no==0x13 || profile_no==0x1a || + profile_no==0x43) + sprintf(status_text, "formatted, with %.1f MiB", + ((double) size) / 1024.0 / 1024.0); + else + sprintf(status_text, "written, with %.1f MiB", + ((double) size) / 1024.0 / 1024.0); + } else if(status == BURN_FORMAT_IS_UNKNOWN) { + if (profile_no > 0) + sprintf(status_text, "intermediate or unknown"); + else + sprintf(status_text, "no media or unknown media"); + } else + sprintf(status_text, "illegal status according to MMC-5"); + printf("Format status: %s\n", status_text); + + for (i = 0; i < num_formats; i++) { + ret= burn_disc_get_format_descr(drive, i, &type, &size, &dummy); + if (ret <= 0) + continue; + printf("Format idx %-2d: %2.2Xh , %.fs , %.1f MiB\n", + i, type, ((double) size) / 2048.0, ((double) size) / 1024.0/1024.0); + } + ret= 1; +ex:; + Cdrskin_release_drive(skin,0); + return(ret); +} + + #ifndef Cdrskin_extra_leaN /* A70324: proposal by Eduard Bloch */ @@ -7288,6 +7358,9 @@ gracetime_equals:; } else if(strcmp(argv[i],"-isosize")==0) { skin->use_data_image_size= 1; + } else if(strcmp(argv[i],"--list_formats")==0) { + skin->do_list_formats= 1; + } else if(strcmp(argv[i],"--list_ignored_options")==0) { char line[80]; @@ -7936,6 +8009,13 @@ int Cdrskin_run(struct CdrskiN *skin, int *exit_value, int flag) if(ret<=0) {*exit_value= 7; goto ex;} } + if(skin->do_list_formats) { + if(skin->n_drives<=0) + {*exit_value= 14; goto no_drive;} + ret= Cdrskin_list_formats(skin, 0); + if(ret<=0) + {*exit_value= 14; goto ex;} + } if(skin->do_blank) { if(skin->n_drives<=0) {*exit_value= 8; goto no_drive;} diff --git a/libburn/trunk/cdrskin/cdrskin_timestamp.h b/libburn/trunk/cdrskin/cdrskin_timestamp.h index 22c2fa35..070d21e4 100644 --- a/libburn/trunk/cdrskin/cdrskin_timestamp.h +++ b/libburn/trunk/cdrskin/cdrskin_timestamp.h @@ -1 +1 @@ -#define Cdrskin_timestamP "2008.04.22.161139" +#define Cdrskin_timestamP "2008.04.22.200949"