From 078f75c2a7c89237ebb8a5c286255e5c72faad93 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Thu, 21 Jul 2016 10:29:15 +0000 Subject: [PATCH] Enabled SCSI command execution on OpenBSD. Thanks to SASANO Takayoshi. --- cdrskin/cdrskin_timestamp.h | 2 +- libburn/os-netbsd.h | 17 ++++++++++++++++- libburn/os.h | 16 ++++++++++++---- libburn/sg-netbsd.c | 21 +++++++++++++++++++-- libburn/sg.c | 19 +++++++++---------- 5 files changed, 57 insertions(+), 18 deletions(-) diff --git a/cdrskin/cdrskin_timestamp.h b/cdrskin/cdrskin_timestamp.h index 553e178..2b9fbd6 100644 --- a/cdrskin/cdrskin_timestamp.h +++ b/cdrskin/cdrskin_timestamp.h @@ -1 +1 @@ -#define Cdrskin_timestamP "2016.07.01.190459" +#define Cdrskin_timestamP "2016.07.21.102919" diff --git a/libburn/os-netbsd.h b/libburn/os-netbsd.h index fc38fdf..f854c3b 100644 --- a/libburn/os-netbsd.h +++ b/libburn/os-netbsd.h @@ -6,10 +6,11 @@ with MMC transport adapter sg-netbsd.c >>> for OpenBSD too ? - Copyright (C) 2010 - 2014 Thomas Schmitt + Copyright (C) 2010 - 2016 Thomas Schmitt provided under GPLv2+ Derived 2014 from libburn/os-solaris.c + Adapted 2016 to OpenBSD by help of SASANO Takayoshi */ @@ -33,6 +34,19 @@ /* The number of above list items */ #define BURN_OS_SIGNAL_COUNT 20 +#ifdef __OpenBSD__ + +/** To list all signals which shall surely not be caught */ +#define BURN_OS_NON_SIGNAL_MACRO_LIST \ + SIGKILL, SIGURG, SIGSTOP, SIGTSTP, SIGCONT, \ + SIGCHLD, SIGTTIN, SIGTTOU, SIGIO, SIGWINCH, \ + SIGINFO + +/* The number of above list items */ +#define BURN_OS_NON_SIGNAL_COUNT 11 + +#else /* __OpenBSD__ */ + /** To list all signals which shall surely not be caught */ #define BURN_OS_NON_SIGNAL_MACRO_LIST \ SIGKILL, SIGURG, SIGSTOP, SIGTSTP, SIGCONT, \ @@ -42,6 +56,7 @@ /* The number of above list items */ #define BURN_OS_NON_SIGNAL_COUNT 12 +#endif /* ! __OpenBSD__ */ /* The maximum size for a (SCSI) i/o transaction */ /* Important : MUST be at least 32768 ! */ diff --git a/libburn/os.h b/libburn/os.h index 9ed5e15..0e7eefa 100644 --- a/libburn/os.h +++ b/libburn/os.h @@ -3,7 +3,7 @@ Operating system specific libburn definitions and declarations. The macros defined here are used by libburn modules in order to avoid own system dependent case distinctions. - Copyright (C) 2009 - 2014 Thomas Schmitt , + Copyright (C) 2009 - 2016 Thomas Schmitt , provided under GPLv2+ */ @@ -37,14 +37,21 @@ #else -#ifdef Libburn_use_sg_netbsD -/* To become: # ifdef __NetBSD__ */ +#ifdef __NetBSD__ /* -------------------------- NetBSD with SCIOCCOMMAND --------------------- */ #include "os-netbsd.h" +#else +#ifdef __OpenBSD__ + + +/* -------------------------- OpenBSD with SCIOCCOMMAND -------------------- */ +#include "os-netbsd.h" + + #else #ifdef __FreeBSD__ @@ -88,7 +95,8 @@ #endif /* ! __linux */ #endif /* ! __FreeBSD__kernel__ */ #endif /* ! __FreeBSD__ */ -#endif /* ! Libburn_use_sg_netbsD */ +#endif /* ! __OpenBSD__ */ +#endif /* ! __NetBSD__ */ #endif /* ! Libburn_use_libcdiO */ #endif /* ! Libburn_use_sg_dummY */ diff --git a/libburn/sg-netbsd.c b/libburn/sg-netbsd.c index 172a58a..6fe91a0 100644 --- a/libburn/sg-netbsd.c +++ b/libburn/sg-netbsd.c @@ -1,13 +1,15 @@ /* -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 8; -*- */ /* - Copyright (c) 2010 - 2014 Thomas Schmitt + Copyright (c) 2010 - 2016 Thomas Schmitt Provided under GPL version 2 or later. Derived 2014 from libburn/sg-solaris.c with information learned from dvd+rw-tools, http://fxr.watson.org/fxr/source/sys/scsiio.h?v=NETBSD, http://netbsd.gw.com/cgi-bin/man-cgi?scsi+4+NetBSD-current, and experiments made by Freddy Fisker. + Adapted 2016 to OpenBSD by help of SASANO Takayoshi . + */ @@ -312,7 +314,11 @@ static int guess_size_by_seek_set(int fd, off_t *bytes, int flag) */ int sg_id_string(char msg[1024], int flag) { +#ifdef __OpenBSD___ + sprintf(msg, "internal OpenBSD SCIOCCOMMAND adapter sg-netbsd"); +#else sprintf(msg, "internal NetBSD SCIOCCOMMAND adapter sg-netbsd"); +#endif return 1; } @@ -687,10 +693,21 @@ int sg_obtain_scsi_adr(char *path, int *bus_no, int *host_no, int *channel_no, {ret = 0; goto ex;} if (addr.type != TYPE_SCSI) {ret = 0; goto ex;} + +#ifdef __OpenBSD___ + + *bus_no = *host_no = addr.scbus; + *target_no = addr.target; + *lun_no = addr.lun; + +#else /* __OpenBSD___ */ + *bus_no = *host_no = addr.addr.scsi.scbus; - *channel_no = 0; *target_no = addr.addr.scsi.target; *lun_no = addr.addr.scsi.lun; + +#endif /* ! __OpenBSD___ */ + ret = 1; ex:; if (fd != -1) diff --git a/libburn/sg.c b/libburn/sg.c index bc07c95..f018bfc 100644 --- a/libburn/sg.c +++ b/libburn/sg.c @@ -1,7 +1,7 @@ /* sg.c Switcher for operating system dependent transport level modules of libburn. - Copyright (C) 2009 - 2014 Thomas Schmitt , + Copyright (C) 2009 - 2016 Thomas Schmitt , provided under GPLv2+ */ @@ -11,12 +11,6 @@ #endif -/* <<< Until it is known whether this adapter would work on OpenBSD too */ -#ifdef __NetBSD__ -#define Libburn_use_sg_netbsD -#endif - - #ifdef Libburn_use_sg_dummY #include "sg-dummy.c" @@ -27,8 +21,12 @@ #include "sg-libcdio.c" #else -#ifdef Libburn_use_sg_netbsD -/* To become: # ifdef __NetBSD__ */ +#ifdef __NetBSD__ + +#include "sg-netbsd.c" + +#else +#ifdef __OpenBSD__ #include "sg-netbsd.c" @@ -88,7 +86,8 @@ static int intentional_compiler_warning(void) #endif /* ! __linux */ #endif /* ! __FreeBSD_kernel__ */ #endif /* ! __FreeBSD__ */ -#endif /* ! Libburn_use_sg_netbsD */ +#endif /* ! __OpenBSD__ */ +#endif /* ! __NetBSD__ */ #endif /* ! Libburn_use_libcdiO */ #endif /* ! Libburn_use_sg_dummY */