From 170eb96356b0d753ef8ad2664e49fb0b689c2353 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Fri, 13 Oct 2006 10:22:21 +0000 Subject: [PATCH] Made libburn and cdrskin build on my Linux again --- Makefile.am | 3 ++- cdrskin/cleanup.c | 25 +++++++++++++++++++++++++ libburn/cleanup.c | 37 +++++++++++++++++++++++++++---------- libburn/drive.c | 21 ++++++++++++--------- libburn/read.c | 6 ++---- libburn/sbc.c | 5 ----- libburn/sg-linux.c | 6 ++++-- libburn/sg.c | 13 +++++++++++++ libburn/transport.h | 21 +++++++++++++++------ 9 files changed, 100 insertions(+), 37 deletions(-) create mode 100644 libburn/sg.c diff --git a/Makefile.am b/Makefile.am index cce8356..fc5dc36 100644 --- a/Makefile.am +++ b/Makefile.am @@ -43,7 +43,7 @@ libburn_libburn_la_SOURCES = \ libburn/sbc.h \ libburn/sector.c \ libburn/sector.h \ - libburn/sg-@ARCH@.c \ + libburn/sg.c \ libburn/sg.h \ libburn/source.h \ libburn/source.c \ @@ -60,6 +60,7 @@ libburn_libburn_la_SOURCES = \ libburn/write.h \ version.h +## libburn/sg-@ARCH@.c \ libisofs_libisofs_la_LDFLAGS = \ -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) diff --git a/cdrskin/cleanup.c b/cdrskin/cleanup.c index 2ac2ccc..f3ea8b0 100644 --- a/cdrskin/cleanup.c +++ b/cdrskin/cleanup.c @@ -23,6 +23,29 @@ typedef void (*sighandler_t)(int); #include "cleanup.h" +#ifdef __FreeBSD__ + +/* Signals to be caught */ +static int signal_list[]= { + SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGABRT, + SIGFPE, SIGSEGV, SIGPIPE, SIGALRM, SIGTERM, + SIGUSR1, SIGUSR2, SIGXCPU, SIGTSTP, SIGTTIN, + SIGTTOU, + SIGBUS, SIGPROF, SIGSYS, SIGTRAP, + SIGVTALRM, SIGXCPU, SIGXFSZ, -1 +}; +static char *signal_name_list[]= { + "SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", "SIGABRT", + "SIGFPE", "SIGSEGV", "SIGPIPE", "SIGALRM", "SIGTERM", + "SIGUSR1", "SIGUSR2", "SIGXCPU", "SIGTSTP", "SIGTTIN", + "SIGTTOU", + "SIGBUS", "SIGPROF", "SIGSYS", "SIGTRAP", + "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "@" +}; +static int signal_list_count= 23; + +#else /* __FreeBSD__ */ + /* Signals to be caught */ static int signal_list[]= { SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGABRT, @@ -42,6 +65,8 @@ static char *signal_name_list[]= { }; static int signal_list_count= 24; +#endif /* ! __FreeBSD__ */ + /* Signals not to be caught */ static int non_signal_list[]= { SIGKILL, SIGCHLD, SIGSTOP, SIGURG, -1 diff --git a/libburn/cleanup.c b/libburn/cleanup.c index db370fc..f3ea8b0 100644 --- a/libburn/cleanup.c +++ b/libburn/cleanup.c @@ -23,17 +23,15 @@ typedef void (*sighandler_t)(int); #include "cleanup.h" +#ifdef __FreeBSD__ + /* Signals to be caught */ static int signal_list[]= { SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGABRT, SIGFPE, SIGSEGV, SIGPIPE, SIGALRM, SIGTERM, SIGUSR1, SIGUSR2, SIGXCPU, SIGTSTP, SIGTTIN, SIGTTOU, - SIGBUS, -#ifdef __Linux__ - SIGPOLL, -#endif - SIGPROF, SIGSYS, SIGTRAP, + SIGBUS, SIGPROF, SIGSYS, SIGTRAP, SIGVTALRM, SIGXCPU, SIGXFSZ, -1 }; static char *signal_name_list[]= { @@ -41,15 +39,34 @@ static char *signal_name_list[]= { "SIGFPE", "SIGSEGV", "SIGPIPE", "SIGALRM", "SIGTERM", "SIGUSR1", "SIGUSR2", "SIGXCPU", "SIGTSTP", "SIGTTIN", "SIGTTOU", - "SIGBUS", -#ifdef __Linux__ - "SIGPOLL", -#endif - "SIGPROF", "SIGSYS", "SIGTRAP", + "SIGBUS", "SIGPROF", "SIGSYS", "SIGTRAP", + "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "@" +}; +static int signal_list_count= 23; + +#else /* __FreeBSD__ */ + +/* Signals to be caught */ +static int signal_list[]= { + SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGABRT, + SIGFPE, SIGSEGV, SIGPIPE, SIGALRM, SIGTERM, + SIGUSR1, SIGUSR2, SIGXCPU, SIGTSTP, SIGTTIN, + SIGTTOU, + SIGBUS, SIGPOLL, SIGPROF, SIGSYS, SIGTRAP, + SIGVTALRM, SIGXCPU, SIGXFSZ, -1 +}; +static char *signal_name_list[]= { + "SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", "SIGABRT", + "SIGFPE", "SIGSEGV", "SIGPIPE", "SIGALRM", "SIGTERM", + "SIGUSR1", "SIGUSR2", "SIGXCPU", "SIGTSTP", "SIGTTIN", + "SIGTTOU", + "SIGBUS", "SIGPOLL", "SIGPROF", "SIGSYS", "SIGTRAP", "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "@" }; static int signal_list_count= 24; +#endif /* ! __FreeBSD__ */ + /* Signals not to be caught */ static int non_signal_list[]= { SIGKILL, SIGCHLD, SIGSTOP, SIGURG, -1 diff --git a/libburn/drive.c b/libburn/drive.c index f331947..6ab7c85 100644 --- a/libburn/drive.c +++ b/libburn/drive.c @@ -2,11 +2,10 @@ #include #include -#ifdef __Linux__ -#include -#else + +/* #include ts A61013 : not in Linux man 3 malloc */ + #include -#endif #include #include @@ -65,16 +64,20 @@ void burn_drive_free_all(void) /* ts A60822 */ int burn_drive_is_open(struct burn_drive *d) { -#if defined(__Linux__) +#if defined(__FreeBSD__) + + if (d->cam == NULL) + return 0; + +#else /* __FreeBSD__ */ + /* 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 + +#endif /* ! __FreeBSD__ */ return 1; } diff --git a/libburn/read.c b/libburn/read.c index a715809..72f60d7 100644 --- a/libburn/read.c +++ b/libburn/read.c @@ -1,10 +1,8 @@ /* -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 8; -*- */ -#ifdef __Linux__ -#include -#else +/* #include ts A61013 : not in Linux man 3 malloc */ + #include -#endif #include #include diff --git a/libburn/sbc.c b/libburn/sbc.c index 48a01ec..68df3ac 100644 --- a/libburn/sbc.c +++ b/libburn/sbc.c @@ -2,11 +2,6 @@ /* scsi block commands */ -#ifdef __Linux__ -/* XXX Why do we need this here? */ -#include -#include -#endif #include #include "transport.h" diff --git a/libburn/sg-linux.c b/libburn/sg-linux.c index 9d71cfe..8af3b9c 100644 --- a/libburn/sg-linux.c +++ b/libburn/sg-linux.c @@ -10,7 +10,9 @@ #include #include #include -#include + +/* #include ts A61013 : not in Linux man 3 malloc */ + #include #include #include @@ -452,7 +454,7 @@ static void enumerate_common(char *fname, int bus_no, int host_no, out.get_nwa = mmc_get_nwa; out.close_disc = mmc_close_disc; out.close_session = mmc_close_session; - out.idata = malloc(sizeof(struct scsi_inquiry_data)); + out.idata = malloc(sizeof(struct burn_scsi_inquiry_data)); out.idata->valid = 0; out.mdata = malloc(sizeof(struct scsi_mode_data)); out.mdata->valid = 0; diff --git a/libburn/sg.c b/libburn/sg.c new file mode 100644 index 0000000..23c90c4 --- /dev/null +++ b/libburn/sg.c @@ -0,0 +1,13 @@ + +/* ts A61013 : It would be nice if autotools could do that job */ + +#ifdef __FreeBSD__ + +#include "sg-freebsd.c" + +#else + +#include "sg-linux.c" + +#endif + diff --git a/libburn/transport.h b/libburn/transport.h index 6ed65ec..a924031 100644 --- a/libburn/transport.h +++ b/libburn/transport.h @@ -8,18 +8,26 @@ #include /* sg data structures */ #include -#ifdef __Linux__ + +#ifdef __FreeBSD__ + +#define BUFFER_SIZE 65536/2 + +#else /* __FreeBSD__ */ + /* XXX Why do we need this here? */ +/* ts A61013: because Linux wants to see them */ #include #include -#endif +#define BUFFER_SIZE 65536 + +#endif /* ! __FreeBSD__ */ /* 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/2 enum transfer_direction { TO_DRIVE, FROM_DRIVE, NO_TRANSFER }; @@ -104,10 +112,11 @@ struct burn_drive int channel; int lun; char *devname; -#if defined(__Linux__) - int fd; -#elif defined(__FreeBSD__) + +#if defined(__FreeBSD__) struct cam_device* cam; +#else + int fd; #endif /* ts A60926 : trying to lock against growisofs /dev/srN, /dev/scdN */