Made use of new message handling facility and removed first bugs

This commit is contained in:
2006-09-24 18:07:10 +00:00
parent bcaf610800
commit 5038e2afb0
6 changed files with 39 additions and 32 deletions

View File

@ -18,7 +18,7 @@
/* ts A60924 : a new message handling facility */
#include "libdax_msgs.h"
static struct libdax_msgs *libdax_messenger= NULL;
struct libdax_msgs *libdax_messenger= NULL;
int burn_running = 0;

View File

@ -270,7 +270,7 @@ int libdax_msgs_submit(struct libdax_msgs *m, int driveno, int error_code,
int os_errno, int flag)
{
int ret;
char *textpt,*sev_name,sev_text[81];
char *textpt,*sev_name,sev_text[81],error_buf[1024];
struct libdax_msgs_item *item= NULL;
if(severity >= m->print_severity) {
@ -285,7 +285,9 @@ int libdax_msgs_submit(struct libdax_msgs *m, int driveno, int error_code,
fprintf(stderr,"%s%s%s\n",m->print_id,sev_text,textpt);
if(os_errno!=0)
perror(m->print_id);
fprintf(stderr,"%s( Most recent system error: %d '%s' )\n",
m->print_id,os_errno,strerror_r(os_errno, error_buf,1024));
}
if(severity < m->queue_severity)
return(0);

View File

@ -168,8 +168,8 @@ int libdax_msgs_destroy(struct libdax_msgs **m, int flag);
occasions but those should be equivalent out of the view
of a libdax application. (E.g. "cannot open ATA drive"
versus "cannot open SCSI drive" would be equivalent.)
@param severity The LIBDAX_MSGS_SEVERITY_* of the event.
@param priority The LIBDAX_MSGS_PRIORITY_* number of the event.
@param severity The LIBDAX_MSGS_SEV_* of the event.
@param priority The LIBDAX_MSGS_PRIO_* number of the event.
@param msg_text Printable and human readable message text.
@param os_errno Eventual error code from operating system (0 if none)
@param flag Bitfield for control purposes (unused yet, submit 0)

View File

@ -23,6 +23,9 @@
#include "toc.h"
#include "util.h"
#include "libdax_msgs.h"
extern struct libdax_msgs *libdax_messenger;
static void enumerate_common(char *fname, int host_no, int channel_no,
int target_no, int lun_no);
@ -115,6 +118,27 @@ int sg_is_enumerable_adr(char *adr)
}
/* ts A60924 */
int sg_handle_busy_drive(char *fname, int os_errno)
{
char msg[4096];
/* ts A60814 : i saw no way to do this more nicely */
if (burn_sg_open_abort_busy) {
fprintf(stderr,
"\nlibburn: FATAL : Application triggered abort on busy drive '%s'\n",
fname);
assert("drive busy" == "non fatal");
}
/* ts A60924 : now reporting to libdax_msgs */
sprintf(msg, "Cannot open busy drive '%s'", fname);
libdax_msgs_submit(libdax_messenger, -1, 0x00020001,
LIBDAX_MSGS_SEV_SORRY, LIBDAX_MSGS_PRIO_LOW,
msg, os_errno, 0);
return 1;
}
void ata_enumerate(void)
{
struct hd_driveid tm;
@ -152,14 +176,8 @@ void ata_enumerate(void)
"\nlibburn: experimental: fname= %s , errno= %d\n",
fname,errno);
*/
/* ts A60814 : i see no way to do this more nicely */
if (errno == EBUSY && burn_sg_open_abort_busy) {
fprintf(stderr,
"\nlibburn: FATAL : Application triggered abort on busy drive '%s'\n",
fname);
/* <<< maybe one should plainly exit here */
assert("drive busy" == "non fatal");
}
if (errno == EBUSY)
sg_handle_busy_drive(fname, errno);
continue;
}
/* found a drive */
@ -230,14 +248,8 @@ void sg_enumerate(void)
"\n cdrskin: experimental: fname= %s , errno= %d\n",
fname,errno);
*/
/* ts A60814 : i see no way to do this more nicely */
if (errno == EBUSY && burn_sg_open_abort_busy) {
fprintf(stderr,
"\nlibburn: FATAL : Application triggered abort on busy drive '%s'\n",
fname);
/* <<< maybe one should plainly exit here */
assert("drive busy" == "non fatal");
}
if (errno == EBUSY)
sg_handle_busy_drive(fname, errno);
continue;
}
/* found a drive */