Converted "libburn_experimental:" messages of address conversion into "DEBUG"

trunk@386
Thomas Schmitt 16 years ago
parent f2c87eae59
commit a27361b3b0
  1. 93
      cdrskin/cdrskin.c
  2. 2
      cdrskin/cdrskin_timestamp.h
  3. 98
      libburn/drive.c
  4. 22
      libburn/init.c

@ -250,6 +250,16 @@ or
#endif
/** Verbosity level for pacifying progress messages */
#define Cdrskin_verbose_progresS 1
/** Verbosity level for command recognition and execution logging */
#define Cdrskin_verbose_cmD 2
/** Verbosity level for reporting of debugging messages */
#define Cdrskin_verbose_debuG 3
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
@ -1119,12 +1129,14 @@ static char Cdrpreskin_sys_rc_nameS[Cdrpreskin_rc_nuM][80]= {
};
/** A structure which bundles several parameters for initialization of
libburn and creation of the CdrskiN object. It finally becomes a managed
subordinate of the CdrskiN object.
/** A structure which bundles several parameters for creation of the CdrskiN
object. It finally becomes a managed subordinate of the CdrskiN object.
*/
struct CdrpreskiN {
/* to be transfered into skin */
int verbosity;
/** Stores eventually given absolute device address before translation */
char raw_device_adr[Cdrskin_adrleN];
@ -1212,6 +1224,7 @@ int Cdrpreskin_new(struct CdrpreskiN **preskin, int flag)
if(o==NULL)
return(-1);
o->verbosity= 0;
o->raw_device_adr[0]= 0;
o->device_adr[0]= 0;
o->adr_trn= NULL;
@ -1269,6 +1282,19 @@ int Cdrpreskin_destroy(struct CdrpreskiN **preskin, int flag)
}
int Cdrpreskin_initialize_lib(struct CdrpreskiN *preskin, int flag)
{
if(!burn_initialize()) {
fprintf(stderr,"cdrskin : FATAL : Initialization of libburn failed\n");
return(0);
}
#ifdef Cdrskin_libburn_has_burn_msgS
burn_msgs_set_severities("NEVER","SORRY","cdrskin: ");
#endif
return(1);
}
/** Convert a cdrecord-style device address into a libburn device address or
into a libburn drive number. It depends on the "scsibus" number of the
cdrecord-style address which kind of libburn address emerges:
@ -1732,6 +1758,16 @@ see_cdrskin_eng_html:;
} else if(strcmp(argv[i],"-scanbus")==0) {
o->no_whitelist= 1;
} else if(strcmp(argv[i],"-v")==0 || strcmp(argv[i],"-verbose")==0) {
(o->verbosity)++;
printf("cdrskin: verbosity level : %d\n",o->verbosity);
#ifdef Cdrskin_libburn_has_burn_msgS
if(o->verbosity>=Cdrskin_verbose_debuG)
burn_msgs_set_severities("NEVER","DEBUG","cdrskin: ");
#endif
} else if(strcmp(argv[i],"-version")==0) {
printf(
"Cdrecord 2.01-Emulation Copyright (C) 2006, see libburn.pykix.org\n");
@ -1838,16 +1874,6 @@ ex:;
/** Verbosity level for pacifying progress messages */
#define Cdrskin_verbose_progresS 1
/** Verbosity level for command recognition and execution logging */
#define Cdrskin_verbose_cmD 2
/** Verbosity level for reporting of debugging messages */
#define Cdrskin_verbose_debuG 3
/** The maximum number of tracks */
#define Cdrskin_track_maX 99
@ -2018,7 +2044,7 @@ int Cdrskin_new(struct CdrskiN **skin, struct CdrpreskiN *preskin, int flag)
if(o==NULL)
return(-1);
o->preskin= preskin;
o->verbosity= 0;
o->verbosity= preskin->verbosity;
o->x_speed= -1.0;
o->gracetime= 0;
o->dummy_mode= 0;
@ -4288,9 +4314,7 @@ track_too_large:;
printf("cdrskin: fixed track size : %.f\n",skin->fixed_size);
} else if(strcmp(argv[i],"-v")==0 || strcmp(argv[i],"-verbose")==0) {
(skin->verbosity)++;
/* <<< is much too verbous: burn_set_verbosity(skin->verbosity); */
printf("cdrskin: verbosity level : %d\n",skin->verbosity);
/* is handled in Cdrpreskin_setup() */;
} else if( i==argc-1 ||
(skin->single_track==0 && strchr(argv[i],'=')==NULL
@ -4370,7 +4394,6 @@ ignore_unknown:;
if(flag&1) /* no finalizing yet */
return(1);
if(skin->verbosity>=Cdrskin_verbose_cmD) {
if(skin->preskin->abort_handler==1)
printf("cdrskin: installed abort handler.\n");
@ -4445,24 +4468,13 @@ ignore_unknown:;
@return <=0 error, 1 success
*/
int Cdrskin_create(struct CdrskiN **o, struct CdrpreskiN **preskin,
int *lib_initialized, int *exit_value, int flag)
int *exit_value, int flag)
{
int ret;
struct CdrskiN *skin;
*o= NULL;
*exit_value= 0;
*lib_initialized= 0;
if(!burn_initialize()) {
fprintf(stderr,"cdrskin : FATAL : initialization of libburn failed\n");
{*exit_value= 11; goto ex;}
}
*lib_initialized= 1;
#ifdef Cdrskin_libburn_has_burn_msgS
burn_msgs_set_severities("NEVER","SORRY","cdrskin: ");
#endif
#ifndef Cdrskin_libburn_no_burn_preset_device_opeN
burn_preset_device_open((*preskin)->drive_exclusive,
@ -4492,9 +4504,11 @@ int Cdrskin_create(struct CdrskiN **o, struct CdrpreskiN **preskin,
printf("cdrskin: scanning for devices ...\n");
fflush(stdout);
while (!burn_drive_scan(&(skin->drives), &(skin->n_drives))) {
/*
if(skin->verbosity>=Cdrskin_verbose_debuG)
ClN(fprintf(stderr,"\ncdrskin_debug: ... still scanning ..."));
/* >>> ??? wait a while ? */
ClN(fprintf(stderr,"cdrskin_debug: ... still scanning ...\n"));
*/
usleep(20000);
/* >>> ??? set a timeout ? */
}
printf("cdrskin: ... scanning for devices done\n");
@ -4581,15 +4595,26 @@ int main(int argc, char **argv)
ret= Cdrpreskin_new(&preskin,0);
if(ret<=0) {
fprintf(stderr,"cdrskin: FATAL : creation of control object failed\n");
fprintf(stderr,"cdrskin: FATAL : Creation of control object failed\n");
{exit_value= 2; goto ex;}
}
/* <<< A60925: i would prefer to do this later, after it is clear that no
-version or -help cause idle end. But address conversion and its debug
messaging need libburn running */
ret= Cdrpreskin_initialize_lib(preskin,0);
if(ret<=0) {
fprintf(stderr,"cdrskin: FATAL : Initializiation of burn library failed\n");
{exit_value= 2; goto ex;}
}
lib_initialized= 1;
ret= Cdrpreskin_setup(preskin,argc,argv,0);
if(ret<=0)
{exit_value= 11; goto ex;}
if(ret==2)
{exit_value= 0; goto ex;}
ret= Cdrskin_create(&skin,&preskin,&lib_initialized,&exit_value,0);
ret= Cdrskin_create(&skin,&preskin,&exit_value,0);
if(ret<=0)
{exit_value= 2; goto ex;}
if(skin->n_drives<=0) {

@ -1 +1 @@
#define Cdrskin_timestamP "2006.09.24.180836"
#define Cdrskin_timestamP "2006.09.25.104629"

@ -13,7 +13,11 @@
#include "libburn.h"
#include "drive.h"
#include "transport.h"
/* ts A60925 : obsoleted by libdax_msgs.h
#include "message.h"
*/
#include "debug.h"
#include "init.h"
#include "toc.h"
@ -22,6 +26,9 @@
#include "structure.h"
#include "back_hacks.h"
#include "libdax_msgs.h"
extern struct libdax_msgs *libdax_messenger;
static struct burn_drive drive_array[255];
static int drivetop = -1;
@ -658,6 +665,29 @@ int burn_drive_scan_and_grab(struct burn_drive_info *drive_infos[], char* adr,
return 1;
}
/* ts A60925 */
/** Simple debug message frontend to libdax_msgs_submit().
If arg is not NULL, then fmt MUST contain exactly one %s and no
other sprintf() %-formatters.
*/
int burn_drive_adr_debug_msg(char *fmt, char *arg)
{
int ret;
char msg[4096], *msgpt;
msgpt= msg;
if(arg != NULL)
sprintf(msg, fmt, arg);
else
msgpt= fmt;
if(libdax_messenger == NULL)
return 0;
ret = libdax_msgs_submit(libdax_messenger, -1, 0x00000002,
LIBDAX_MSGS_SEV_DEBUG, LIBDAX_MSGS_PRIO_ZERO,
msgpt, 0, 0);
return ret;
}
/* ts A60923 */
/** Inquire the persistent address of the given drive. */
int burn_drive_raw_get_adr(struct burn_drive *d, char adr[])
@ -691,29 +721,24 @@ int burn_drive_is_enumerable_adr(char *adr)
int burn_drive_resolve_link(char *path, char adr[])
{
int ret;
char link_target[4096];
fprintf(stderr,"libburn experimental: burn_drive_resolve_link( %s )\n",path);
char link_target[4096], msg[4096+100];
burn_drive_adr_debug_msg("burn_drive_resolve_link( %s )",path);
ret = readlink(path, link_target, sizeof(link_target));
if(ret == -1) {
fprintf(stderr,"libburn experimental: readlink( %s ) returns -1\n",path);
burn_drive_adr_debug_msg("readlink( %s ) returns -1", path);
return 0;
}
if(ret >= sizeof(link_target) - 1) {
fprintf(stderr,"libburn experimental: readlink( %s ) returns %d (too much)\n",path,ret);
sprintf(msg,"readlink( %s ) returns %d (too much)", path, ret);
burn_drive_adr_debug_msg(msg, NULL);
return -1;
}
link_target[ret] = 0;
ret = burn_drive_convert_fs_adr(link_target, adr);
fprintf(stderr,"libburn experimental: burn_drive_convert_fs_adr( %s ) returns %d\n",link_target,ret);
sprintf(msg,"burn_drive_convert_fs_adr( %s ) returns %d",
link_target, ret);
burn_drive_adr_debug_msg(msg, NULL);
return ret;
}
@ -721,7 +746,7 @@ fprintf(stderr,"libburn experimental: burn_drive_convert_fs_adr( %s ) returns %d
/* Try to find an enumerated address with the given stat.st_rdev number */
int burn_drive_find_devno(dev_t devno, char adr[])
{
char fname[4096];
char fname[4096], msg[4096+100];
int i, ret = 0, first = 1;
struct stat stbuf;
@ -738,8 +763,9 @@ int burn_drive_find_devno(dev_t devno, char adr[])
if(strlen(fname) >= BURN_DRIVE_ADR_LEN)
return -1;
fprintf(stderr,"libburn experimental: burn_drive_find_devno( 0x%lX ) found %s\n", (long) devno, fname);
sprintf(msg, "burn_drive_find_devno( 0x%lX ) found %s",
(long) devno, fname);
burn_drive_adr_debug_msg(msg, NULL);
strcpy(adr, fname);
return 1;
}
@ -783,12 +809,14 @@ int burn_drive_obtain_scsi_adr(char *path, int *host_no, int *channel_no,
int burn_drive_convert_scsi_adr(int host_no, int channel_no, int target_no,
int lun_no, char adr[])
{
char fname[4096];
char fname[4096],msg[4096+100];
int i, ret = 0, first = 1;
int i_host_no = -1, i_channel_no = -1, i_target_no = -1, i_lun_no = -1;
fprintf(stderr,"libburn experimental: burn_drive_convert_scsi_adr( %d,%d,%d,%d )\n", host_no, channel_no, target_no, lun_no);
sprintf(msg,"burn_drive_convert_scsi_adr( %d,%d,%d,%d )",
host_no, channel_no, target_no, lun_no);
burn_drive_adr_debug_msg(msg, NULL);
while (1) {
ret= sg_give_next_adr(&i, fname, sizeof(fname), first);
@ -809,9 +837,8 @@ fprintf(stderr,"libburn experimental: burn_drive_convert_scsi_adr( %d,%d,%d,%d )
continue;
if(strlen(fname) >= BURN_DRIVE_ADR_LEN)
return -1;
fprintf(stderr,"libburn experimental: burn_drive_convert_scsi_adr() found %s\n", fname);
burn_drive_adr_debug_msg(
"burn_drive_convert_scsi_adr() found %s", fname);
strcpy(adr, fname);
return 1;
}
@ -825,17 +852,19 @@ int burn_drive_find_scsi_equiv(char *path, char adr[])
{
int ret = 0;
int host_no, channel_no, target_no, lun_no;
char msg[4096];
ret = burn_drive_obtain_scsi_adr(path, &host_no, &channel_no,
&target_no, &lun_no);
if(ret <= 0) {
fprintf(stderr,"libburn experimental: burn_drive_obtain_scsi_adr( %s ) returns %d\n", path, ret);
sprintf(msg,"burn_drive_obtain_scsi_adr( %s ) returns %d\n",
path, ret);
burn_drive_adr_debug_msg(msg, NULL);
return 0;
}
fprintf(stderr,"libburn experimental: burn_drive_find_scsi_equiv( %s ) : %d,%d,%d,%d\n", path, host_no, channel_no, target_no, lun_no);
sprintf(msg, "burn_drive_find_scsi_equiv( %s ) : %d,%d,%d,%d\n",
path, host_no, channel_no, target_no, lun_no);
burn_drive_adr_debug_msg(msg, NULL);
ret= burn_drive_convert_scsi_adr(host_no, channel_no, target_no,
lun_no, adr);
@ -850,23 +879,20 @@ int burn_drive_convert_fs_adr(char *path, char adr[])
{
int ret;
struct stat stbuf;
char msg[4096];
fprintf(stderr,"libburn experimental: burn_drive_convert_fs_adr( %s )\n",path);
burn_drive_adr_debug_msg("burn_drive_convert_fs_adr( %s )", path);
if(burn_drive_is_enumerable_adr(path)) {
if(strlen(path) >= BURN_DRIVE_ADR_LEN)
return -1;
fprintf(stderr,"libburn experimental: burn_drive_is_enumerable_adr( %s ) is true\n",path);
burn_drive_adr_debug_msg(
"burn_drive_is_enumerable_adr( %s ) is true", path);
strcpy(adr, path);
return 1;
}
if(lstat(path, &stbuf) == -1) {
fprintf(stderr,"libburn experimental: lstat( %s ) returns -1\n",path);
burn_drive_adr_debug_msg("lstat( %s ) returns -1", path);
return 0;
}
if((stbuf.st_mode & S_IFMT) == S_IFLNK) {
@ -883,9 +909,7 @@ fprintf(stderr,"libburn experimental: lstat( %s ) returns -1\n",path);
if(ret > 0)
return 1;
}
fprintf(stderr,"libburn experimental: Nothing found for %s \n",path);
burn_drive_adr_debug_msg("Nothing found for %s", path);
return 0;
}

@ -38,6 +38,21 @@ int burn_sg_open_o_nonblock = 1;
int burn_sg_open_abort_busy = 0;
/* ts A60925 : ticket 74 */
/** Create the messenger object for libburn. */
int burn_msgs_initialize(void)
{
int ret;
if(libdax_messenger == NULL)
ret = libdax_msgs_new(&libdax_messenger,0);
if (ret <= 0)
return 0;
libdax_msgs_set_severities(libdax_messenger, LIBDAX_MSGS_SEV_NEVER,
LIBDAX_MSGS_SEV_FATAL, "libburn: ", 0);
return 1;
}
/* ts A60924 : ticket 74 : Added use of global libdax_messenger */
int burn_initialize(void)
{
@ -45,14 +60,9 @@ int burn_initialize(void)
if (burn_running)
return 1;
ret = libdax_msgs_new(&libdax_messenger,0);
ret = burn_msgs_initialize();
if (ret <= 0)
return 0;
/* A60924: Apps enable queueing via burn_msgs_set_severities() */
libdax_msgs_set_severities(libdax_messenger, LIBDAX_MSGS_SEV_NEVER,
LIBDAX_MSGS_SEV_FATAL, "libburn: ", 0);
burn_running = 1;
return 1;
}

Loading…
Cancel
Save