From 7b456c60c6bbd33dfd7c0995f1dfea96921a1e4d Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Thu, 12 Oct 2006 17:35:06 +0000 Subject: [PATCH] Made several changes for freebsd support --- trunk/libburn/cleanup.c | 12 ++++++++++-- trunk/libburn/drive.c | 13 +++++++++++-- trunk/libburn/read.c | 4 ++++ trunk/libburn/sbc.c | 5 ++++- trunk/libburn/spc.c | 4 ++-- trunk/libburn/transport.h | 13 ++++++++++--- 6 files changed, 41 insertions(+), 10 deletions(-) diff --git a/trunk/libburn/cleanup.c b/trunk/libburn/cleanup.c index 2ac2cccf..db370fc9 100644 --- a/trunk/libburn/cleanup.c +++ b/trunk/libburn/cleanup.c @@ -29,7 +29,11 @@ static int signal_list[]= { SIGFPE, SIGSEGV, SIGPIPE, SIGALRM, SIGTERM, SIGUSR1, SIGUSR2, SIGXCPU, SIGTSTP, SIGTTIN, SIGTTOU, - SIGBUS, SIGPOLL, SIGPROF, SIGSYS, SIGTRAP, + SIGBUS, +#ifdef __Linux__ + SIGPOLL, +#endif + SIGPROF, SIGSYS, SIGTRAP, SIGVTALRM, SIGXCPU, SIGXFSZ, -1 }; static char *signal_name_list[]= { @@ -37,7 +41,11 @@ static char *signal_name_list[]= { "SIGFPE", "SIGSEGV", "SIGPIPE", "SIGALRM", "SIGTERM", "SIGUSR1", "SIGUSR2", "SIGXCPU", "SIGTSTP", "SIGTTIN", "SIGTTOU", - "SIGBUS", "SIGPOLL", "SIGPROF", "SIGSYS", "SIGTRAP", + "SIGBUS", +#ifdef __Linux__ + "SIGPOLL", +#endif + "SIGPROF", "SIGSYS", "SIGTRAP", "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "@" }; static int signal_list_count= 24; diff --git a/trunk/libburn/drive.c b/trunk/libburn/drive.c index dfec94e2..f3319474 100644 --- a/trunk/libburn/drive.c +++ b/trunk/libburn/drive.c @@ -2,7 +2,11 @@ #include #include +#ifdef __Linux__ #include +#else +#include +#endif #include #include @@ -61,11 +65,16 @@ void burn_drive_free_all(void) /* ts A60822 */ int burn_drive_is_open(struct burn_drive *d) { +#if defined(__Linux__) /* a bit more detailed case distinction than needed */ if (d->fd == -1337) return 0; if (d->fd < 0) return 0; +#elif defined(__FreeBSD__) + if (d->cam == NULL) + return 0; +#endif return 1; } @@ -456,7 +465,7 @@ static void strip_spaces(char *str) static int drive_getcaps(struct burn_drive *d, struct burn_drive_info *out) { - struct scsi_inquiry_data *id; + struct burn_scsi_inquiry_data *id; /* ts A61007 : now prevented in enumerate_common() */ #if 0 @@ -467,7 +476,7 @@ static int drive_getcaps(struct burn_drive *d, struct burn_drive_info *out) if (!d->idata->valid || !d->mdata->valid) return 0; - id = (struct scsi_inquiry_data *)d->idata; + id = (struct burn_scsi_inquiry_data *)d->idata; memcpy(out->vendor, id->vendor, sizeof(id->vendor)); strip_spaces(out->vendor); diff --git a/trunk/libburn/read.c b/trunk/libburn/read.c index 4f27207a..a7158094 100644 --- a/trunk/libburn/read.c +++ b/trunk/libburn/read.c @@ -1,6 +1,10 @@ /* -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 8; -*- */ +#ifdef __Linux__ #include +#else +#include +#endif #include #include diff --git a/trunk/libburn/sbc.c b/trunk/libburn/sbc.c index dcd64ae0..48a01ec8 100644 --- a/trunk/libburn/sbc.c +++ b/trunk/libburn/sbc.c @@ -2,9 +2,12 @@ /* scsi block commands */ +#ifdef __Linux__ +/* XXX Why do we need this here? */ #include -#include #include +#endif +#include #include "transport.h" #include "sbc.h" diff --git a/trunk/libburn/spc.c b/trunk/libburn/spc.c index 186eef73..d90ab60e 100644 --- a/trunk/libburn/spc.c +++ b/trunk/libburn/spc.c @@ -75,7 +75,7 @@ int spc_get_erase_progress(struct burn_drive *d) void spc_inquiry(struct burn_drive *d) { struct buffer buf; - struct scsi_inquiry_data *id; + struct burn_scsi_inquiry_data *id; struct command c; memcpy(c.opcode, SPC_INQUIRY, sizeof(SPC_INQUIRY)); @@ -87,7 +87,7 @@ void spc_inquiry(struct burn_drive *d) c.dir = FROM_DRIVE; d->issue_command(d, &c); - id = (struct scsi_inquiry_data *)d->idata; + id = (struct burn_scsi_inquiry_data *)d->idata; id->vendor[8] = 0; id->product[16] = 0; id->revision[4] = 0; diff --git a/trunk/libburn/transport.h b/trunk/libburn/transport.h index 7b903179..6ed65ec2 100644 --- a/trunk/libburn/transport.h +++ b/trunk/libburn/transport.h @@ -8,15 +8,18 @@ #include /* sg data structures */ #include +#ifdef __Linux__ +/* XXX Why do we need this here? */ #include #include +#endif /* kludge! glibc headers don't define all the SCSI shit that we use! */ #ifndef SG_GET_ACCESS_COUNT # define SG_GET_ACCESS_COUNT 0x2289 #endif -#define BUFFER_SIZE 65536 +#define BUFFER_SIZE 65536/2 enum transfer_direction { TO_DRIVE, FROM_DRIVE, NO_TRANSFER }; @@ -55,7 +58,7 @@ struct command struct buffer *page; }; -struct scsi_inquiry_data +struct burn_scsi_inquiry_data { char vendor[9]; char product[17]; @@ -101,7 +104,11 @@ struct burn_drive int channel; int lun; char *devname; +#if defined(__Linux__) int fd; +#elif defined(__FreeBSD__) + struct cam_device* cam; +#endif /* ts A60926 : trying to lock against growisofs /dev/srN, /dev/scdN */ int sibling_count; @@ -174,7 +181,7 @@ struct burn_drive int (*test_unit_ready) (struct burn_drive * d); void (*probe_write_modes) (struct burn_drive * d); struct params params; - struct scsi_inquiry_data *idata; + struct burn_scsi_inquiry_data *idata; struct scsi_mode_data *mdata; int toc_entries; struct burn_toc_entry *toc_entry;