Adjust the data VPD returns, to work around a problem in the Cisco
initiator (used on Solaris 10 Update 1) - the initiator demands that a UUID is returned, so give it one. Add autoconf glue for that, and a compat uuid_create(3) and uuid_to_string(3). This still spews a lot of output via the target's syslog, but persevere, since it does actually make the target work with the Solaris initiator: solaris10# format Searching for disks...done AVAILABLE DISK SELECTIONS: 0. c1d0 <DEFAULT cyl 29728 alt 2 hd 64 sec 63> /pci@0,0/pci-ide@1f,1/ide@0/cmdk@0,0 1. c2t5d0 <DEFAULT cyl 96 alt 2 hd 64 sec 32> /iscsi/disk@0000iqn.1994-04.org.netbsd.iscsi-target%3Atarget00001,0 Specify disk (enter its number): ^D solaris10# df -k /mnt Filesystem kbytes used avail capacity Mounted on /dev/dsk/c2t5d0s0 91407 1041 81226 2% /mnt solaris10# uname -a SunOS solaris10 5.10 Generic_118844-26 i86pc i386 i86pc solaris10#
This commit is contained in:
parent
c03d07d01d
commit
e32a776a5a
|
@ -44,17 +44,18 @@ size_t strlcpy(char *, const char *, size_t);
|
||||||
|
|
||||||
#ifndef HTOBE64
|
#ifndef HTOBE64
|
||||||
# if defined(HAVE_LIBKERN_OSBYTEORDER_H)
|
# if defined(HAVE_LIBKERN_OSBYTEORDER_H)
|
||||||
# define HTOBE64(x) (x) = OSSwapBigToHostInt64((u_int64_t)(x))
|
# define HTOBE64(x) (x) = OSSwapBigToHostInt64((u_int64_t)(x))
|
||||||
# elif _BYTE_ORDER == _BIG_ENDIAN
|
# elif _BYTE_ORDER == _BIG_ENDIAN
|
||||||
# define HTOBE64(x) (x)
|
# define HTOBE64(x) (x)
|
||||||
|
# elif defined(HAVE___BSWAP64)
|
||||||
|
# define HTOBE64(x) (x) = __bswap64((u_int64_t)(x))
|
||||||
# else /* LITTLE_ENDIAN */
|
# else /* LITTLE_ENDIAN */
|
||||||
# define HTOBE64(x) (x) = __bswap64((u_int64_t)(x))
|
# define HTOBE64(x) (((uint64_t)(ISCSI_NTOHL((uint32_t)(((x) << 32) >> 32))) << 32) | (uint32_t)ISCSI_NTOHL(((uint32_t)((x) >> 32))))
|
||||||
# define bswap64(x) __bswap64(x)
|
|
||||||
# endif /* LITTLE_ENDIAN */
|
# endif /* LITTLE_ENDIAN */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef BE64TOH
|
#ifndef BE64TOH
|
||||||
#define BE64TOH(x) HTOBE64(x)
|
# define BE64TOH(x) HTOBE64(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _DIAGASSERT
|
#ifndef _DIAGASSERT
|
||||||
|
@ -64,4 +65,28 @@ size_t strlcpy(char *, const char *, size_t);
|
||||||
#define _DIAGASSERT(e) (__static_cast(void,0))
|
#define _DIAGASSERT(e) (__static_cast(void,0))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_UUID_H
|
||||||
|
/* Length of a node address (an IEEE 802 address). */
|
||||||
|
#define _UUID_NODE_LEN 6
|
||||||
|
|
||||||
|
/*
|
||||||
|
* See also:
|
||||||
|
* http://www.opengroup.org/dce/info/draft-leach-uuids-guids-01.txt
|
||||||
|
* http://www.opengroup.org/onlinepubs/009629399/apdxa.htm
|
||||||
|
*
|
||||||
|
* A DCE 1.1 compatible source representation of UUIDs.
|
||||||
|
*/
|
||||||
|
typedef struct uuid_t {
|
||||||
|
uint32_t time_low;
|
||||||
|
uint16_t time_mid;
|
||||||
|
uint16_t time_hi_and_version;
|
||||||
|
uint8_t clock_seq_hi_and_reserved;
|
||||||
|
uint8_t clock_seq_low;
|
||||||
|
uint8_t node[_UUID_NODE_LEN];
|
||||||
|
} uuid_t;
|
||||||
|
|
||||||
|
void uuid_create(uuid_t *, uint32_t *);
|
||||||
|
void uuid_to_string(uuid_t *, char **, uint32_t *);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* COMPAT_H_ */
|
#endif /* COMPAT_H_ */
|
||||||
|
|
|
@ -145,6 +145,15 @@
|
||||||
/* Define to 1 if you have the <utime.h> header file. */
|
/* Define to 1 if you have the <utime.h> header file. */
|
||||||
#define HAVE_UTIME_H 1
|
#define HAVE_UTIME_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `uuid_create' function. */
|
||||||
|
#define HAVE_UUID_CREATE 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <uuid.h> header file. */
|
||||||
|
#define HAVE_UUID_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `uuid_to_string' function. */
|
||||||
|
#define HAVE_UUID_TO_STRING 1
|
||||||
|
|
||||||
/* Define to 1 if you have the `vasnprintf' function. */
|
/* Define to 1 if you have the `vasnprintf' function. */
|
||||||
/* #undef HAVE_VASNPRINTF */
|
/* #undef HAVE_VASNPRINTF */
|
||||||
|
|
||||||
|
@ -154,6 +163,9 @@
|
||||||
/* Define to 1 if you have the `vsnprintf' function. */
|
/* Define to 1 if you have the `vsnprintf' function. */
|
||||||
#define HAVE_VSNPRINTF 1
|
#define HAVE_VSNPRINTF 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `__bswap64' function. */
|
||||||
|
/* #undef HAVE___BSWAP64 */
|
||||||
|
|
||||||
/* Define to the address where bug reports for this package should be sent. */
|
/* Define to the address where bug reports for this package should be sent. */
|
||||||
#define PACKAGE_BUGREPORT "Alistair Crooks <agc@NetBSD.org>"
|
#define PACKAGE_BUGREPORT "Alistair Crooks <agc@NetBSD.org>"
|
||||||
|
|
||||||
|
@ -161,13 +173,13 @@
|
||||||
#define PACKAGE_NAME "netbsd-iscsi"
|
#define PACKAGE_NAME "netbsd-iscsi"
|
||||||
|
|
||||||
/* Define to the full name and version of this package. */
|
/* Define to the full name and version of this package. */
|
||||||
#define PACKAGE_STRING "netbsd-iscsi 20060417"
|
#define PACKAGE_STRING "netbsd-iscsi 20060520"
|
||||||
|
|
||||||
/* Define to the one symbol short name of this package. */
|
/* Define to the one symbol short name of this package. */
|
||||||
#define PACKAGE_TARNAME "netbsd-iscsi"
|
#define PACKAGE_TARNAME "netbsd-iscsi"
|
||||||
|
|
||||||
/* Define to the version of this package. */
|
/* Define to the version of this package. */
|
||||||
#define PACKAGE_VERSION "20060417"
|
#define PACKAGE_VERSION "20060520"
|
||||||
|
|
||||||
/* Define to 1 if you have the ANSI C header files. */
|
/* Define to 1 if you have the ANSI C header files. */
|
||||||
#define STDC_HEADERS 1
|
#define STDC_HEADERS 1
|
||||||
|
|
|
@ -144,6 +144,15 @@
|
||||||
/* Define to 1 if you have the <utime.h> header file. */
|
/* Define to 1 if you have the <utime.h> header file. */
|
||||||
#undef HAVE_UTIME_H
|
#undef HAVE_UTIME_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `uuid_create' function. */
|
||||||
|
#undef HAVE_UUID_CREATE
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <uuid.h> header file. */
|
||||||
|
#undef HAVE_UUID_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `uuid_to_string' function. */
|
||||||
|
#undef HAVE_UUID_TO_STRING
|
||||||
|
|
||||||
/* Define to 1 if you have the `vasnprintf' function. */
|
/* Define to 1 if you have the `vasnprintf' function. */
|
||||||
#undef HAVE_VASNPRINTF
|
#undef HAVE_VASNPRINTF
|
||||||
|
|
||||||
|
@ -153,6 +162,9 @@
|
||||||
/* Define to 1 if you have the `vsnprintf' function. */
|
/* Define to 1 if you have the `vsnprintf' function. */
|
||||||
#undef HAVE_VSNPRINTF
|
#undef HAVE_VSNPRINTF
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `__bswap64' function. */
|
||||||
|
#undef HAVE___BSWAP64
|
||||||
|
|
||||||
/* Define to the address where bug reports for this package should be sent. */
|
/* Define to the address where bug reports for this package should be sent. */
|
||||||
#undef PACKAGE_BUGREPORT
|
#undef PACKAGE_BUGREPORT
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: scsi_cmd_codes.h,v 1.6 2006/04/26 20:29:56 agc Exp $ */
|
/* $NetBSD: scsi_cmd_codes.h,v 1.7 2006/05/21 09:26:37 agc Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright © 2006 Alistair Crooks. All rights reserved.
|
* Copyright © 2006 Alistair Crooks. All rights reserved.
|
||||||
|
@ -68,8 +68,15 @@ enum {
|
||||||
INQUIRY_DEVICE_IDENTIFICATION_VPD = 0x83,
|
INQUIRY_DEVICE_IDENTIFICATION_VPD = 0x83,
|
||||||
INQUIRY_SUPPORTED_VPD_PAGES = 0x0,
|
INQUIRY_SUPPORTED_VPD_PAGES = 0x0,
|
||||||
INQUIRY_DEVICE_PIV = 0x1,
|
INQUIRY_DEVICE_PIV = 0x1,
|
||||||
|
|
||||||
|
INQUIRY_IDENTIFIER_TYPE_T10 = 0x1,
|
||||||
|
INQUIRY_IDENTIFIER_TYPE_EUI64 = 0x2,
|
||||||
|
INQUIRY_IDENTIFIER_TYPE_NAA = 0x3,
|
||||||
|
|
||||||
|
INQUIRY_DEVICE_ASSOCIATION_LOGICAL_UNIT = 0x0,
|
||||||
INQUIRY_DEVICE_ASSOCIATION_TARGET_PORT = 0x1,
|
INQUIRY_DEVICE_ASSOCIATION_TARGET_PORT = 0x1,
|
||||||
INQUIRY_DEVICE_ASSOCIATION_TARGET_DEVICE = 0x2,
|
INQUIRY_DEVICE_ASSOCIATION_TARGET_DEVICE = 0x2,
|
||||||
|
|
||||||
INQUIRY_DEVICE_CODESET_UTF8 = 0x3,
|
INQUIRY_DEVICE_CODESET_UTF8 = 0x3,
|
||||||
INQUIRY_DEVICE_ISCSI_PROTOCOL = 0x5,
|
INQUIRY_DEVICE_ISCSI_PROTOCOL = 0x5,
|
||||||
INQUIRY_DEVICE_T10_VENDOR = 0x1,
|
INQUIRY_DEVICE_T10_VENDOR = 0x1,
|
||||||
|
|
|
@ -167,8 +167,8 @@ void iscsi_print_buffer(const char *, const size_t);
|
||||||
#define __BIG_ENDIAN _BIG_ENDIAN
|
#define __BIG_ENDIAN _BIG_ENDIAN
|
||||||
#define __LITTLE_ENDIAN _LITTLE_ENDIAN
|
#define __LITTLE_ENDIAN _LITTLE_ENDIAN
|
||||||
|
|
||||||
#define ISCSI_NTOHLL(x) be64toh(x)
|
#define ISCSI_NTOHLL(a) BE64TOH(a)
|
||||||
#define ISCSI_HTONLL(x) htobe64(x)
|
#define ISCSI_HTONLL(a) HTOBE64(a)
|
||||||
#define ISCSI_NTOHL(a) ntohl(a)
|
#define ISCSI_NTOHL(a) ntohl(a)
|
||||||
#define ISCSI_HTONL(a) htonl(a)
|
#define ISCSI_HTONL(a) htonl(a)
|
||||||
#define ISCSI_NTOHS(a) ntohs(a)
|
#define ISCSI_NTOHS(a) ntohs(a)
|
||||||
|
|
|
@ -45,7 +45,7 @@ $(BIN):
|
||||||
#
|
#
|
||||||
# User-level Targets
|
# User-level Targets
|
||||||
#
|
#
|
||||||
COMPATOBJS= strlcpy.o snprintf.o strtoll.o
|
COMPATOBJS= strlcpy.o snprintf.o strtoll.o uuid.o
|
||||||
|
|
||||||
USER_TARGET_OBJS = target.o iscsi.o util.o parameters.o netmask.o conffile.o storage.o ${COMPATOBJS}
|
USER_TARGET_OBJS = target.o iscsi.o util.o parameters.o netmask.o conffile.o storage.o ${COMPATOBJS}
|
||||||
$(BIN)/osd: osd-target.c osd.c $(USER_TARGET_OBJS)
|
$(BIN)/osd: osd-target.c osd.c $(USER_TARGET_OBJS)
|
||||||
|
|
|
@ -31,3 +31,5 @@ raid0
|
||||||
add discovery masking
|
add discovery masking
|
||||||
clean up IPv6
|
clean up IPv6
|
||||||
add socklen_t awareness
|
add socklen_t awareness
|
||||||
|
add uuid
|
||||||
|
Solaris initiator compatibility
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# Guess values for system-dependent variables and create Makefiles.
|
# Guess values for system-dependent variables and create Makefiles.
|
||||||
# Generated by GNU Autoconf 2.59 for netbsd-iscsi 20060417.
|
# Generated by GNU Autoconf 2.59 for netbsd-iscsi 20060520.
|
||||||
#
|
#
|
||||||
# Report bugs to <Alistair Crooks <agc@NetBSD.org>>.
|
# Report bugs to <Alistair Crooks <agc@NetBSD.org>>.
|
||||||
#
|
#
|
||||||
|
@ -269,8 +269,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
|
||||||
# Identity of this package.
|
# Identity of this package.
|
||||||
PACKAGE_NAME='netbsd-iscsi'
|
PACKAGE_NAME='netbsd-iscsi'
|
||||||
PACKAGE_TARNAME='netbsd-iscsi'
|
PACKAGE_TARNAME='netbsd-iscsi'
|
||||||
PACKAGE_VERSION='20060417'
|
PACKAGE_VERSION='20060520'
|
||||||
PACKAGE_STRING='netbsd-iscsi 20060417'
|
PACKAGE_STRING='netbsd-iscsi 20060520'
|
||||||
PACKAGE_BUGREPORT='Alistair Crooks <agc@NetBSD.org>'
|
PACKAGE_BUGREPORT='Alistair Crooks <agc@NetBSD.org>'
|
||||||
|
|
||||||
ac_unique_file="iscsi.c"
|
ac_unique_file="iscsi.c"
|
||||||
|
@ -780,7 +780,7 @@ if test "$ac_init_help" = "long"; then
|
||||||
# Omit some internal or obsolete options to make the list less imposing.
|
# Omit some internal or obsolete options to make the list less imposing.
|
||||||
# This message is too long to be a string in the A/UX 3.1 sh.
|
# This message is too long to be a string in the A/UX 3.1 sh.
|
||||||
cat <<_ACEOF
|
cat <<_ACEOF
|
||||||
\`configure' configures netbsd-iscsi 20060417 to adapt to many kinds of systems.
|
\`configure' configures netbsd-iscsi 20060520 to adapt to many kinds of systems.
|
||||||
|
|
||||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||||
|
|
||||||
|
@ -837,7 +837,7 @@ fi
|
||||||
|
|
||||||
if test -n "$ac_init_help"; then
|
if test -n "$ac_init_help"; then
|
||||||
case $ac_init_help in
|
case $ac_init_help in
|
||||||
short | recursive ) echo "Configuration of netbsd-iscsi 20060417:";;
|
short | recursive ) echo "Configuration of netbsd-iscsi 20060520:";;
|
||||||
esac
|
esac
|
||||||
cat <<\_ACEOF
|
cat <<\_ACEOF
|
||||||
|
|
||||||
|
@ -949,7 +949,7 @@ fi
|
||||||
test -n "$ac_init_help" && exit 0
|
test -n "$ac_init_help" && exit 0
|
||||||
if $ac_init_version; then
|
if $ac_init_version; then
|
||||||
cat <<\_ACEOF
|
cat <<\_ACEOF
|
||||||
netbsd-iscsi configure 20060417
|
netbsd-iscsi configure 20060520
|
||||||
generated by GNU Autoconf 2.59
|
generated by GNU Autoconf 2.59
|
||||||
|
|
||||||
Copyright (C) 2003 Free Software Foundation, Inc.
|
Copyright (C) 2003 Free Software Foundation, Inc.
|
||||||
|
@ -963,7 +963,7 @@ cat >&5 <<_ACEOF
|
||||||
This file contains any messages produced by compilers while
|
This file contains any messages produced by compilers while
|
||||||
running configure, to aid debugging if configure makes a mistake.
|
running configure, to aid debugging if configure makes a mistake.
|
||||||
|
|
||||||
It was created by netbsd-iscsi $as_me 20060417, which was
|
It was created by netbsd-iscsi $as_me 20060520, which was
|
||||||
generated by GNU Autoconf 2.59. Invocation command line was
|
generated by GNU Autoconf 2.59. Invocation command line was
|
||||||
|
|
||||||
$ $0 $@
|
$ $0 $@
|
||||||
|
@ -3384,7 +3384,8 @@ done
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for ac_header in ctype.h errno.h fcntl.h pthread.h pwd.h signal.h stdlib.h syslog.h unistd.h string.h stdarg.h utime.h
|
|
||||||
|
for ac_header in ctype.h errno.h fcntl.h pthread.h pwd.h signal.h stdlib.h syslog.h unistd.h string.h stdarg.h utime.h uuid.h
|
||||||
do
|
do
|
||||||
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
|
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
|
||||||
if eval "test \"\${$as_ac_Header+set}\" = set"; then
|
if eval "test \"\${$as_ac_Header+set}\" = set"; then
|
||||||
|
@ -4153,7 +4154,10 @@ fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for ac_func in asprintf asnprintf bswap64 daemon fsync_range snprintf strlcpy strtoll syslog vasprintf vasnprintf vsnprintf
|
|
||||||
|
|
||||||
|
|
||||||
|
for ac_func in __bswap64 asprintf asnprintf bswap64 daemon fsync_range snprintf strlcpy strtoll syslog vasprintf vasnprintf vsnprintf uuid_create uuid_to_string
|
||||||
do
|
do
|
||||||
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
||||||
echo "$as_me:$LINENO: checking for $ac_func" >&5
|
echo "$as_me:$LINENO: checking for $ac_func" >&5
|
||||||
|
@ -4618,7 +4622,7 @@ _ASBOX
|
||||||
} >&5
|
} >&5
|
||||||
cat >&5 <<_CSEOF
|
cat >&5 <<_CSEOF
|
||||||
|
|
||||||
This file was extended by netbsd-iscsi $as_me 20060417, which was
|
This file was extended by netbsd-iscsi $as_me 20060520, which was
|
||||||
generated by GNU Autoconf 2.59. Invocation command line was
|
generated by GNU Autoconf 2.59. Invocation command line was
|
||||||
|
|
||||||
CONFIG_FILES = $CONFIG_FILES
|
CONFIG_FILES = $CONFIG_FILES
|
||||||
|
@ -4678,7 +4682,7 @@ _ACEOF
|
||||||
|
|
||||||
cat >>$CONFIG_STATUS <<_ACEOF
|
cat >>$CONFIG_STATUS <<_ACEOF
|
||||||
ac_cs_version="\\
|
ac_cs_version="\\
|
||||||
netbsd-iscsi config.status 20060417
|
netbsd-iscsi config.status 20060520
|
||||||
configured by $0, generated by GNU Autoconf 2.59,
|
configured by $0, generated by GNU Autoconf 2.59,
|
||||||
with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
|
with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
dnl Process this file with autoconf to produce a configure script.
|
dnl Process this file with autoconf to produce a configure script.
|
||||||
AC_PREREQ(2.57)
|
AC_PREREQ(2.57)
|
||||||
AC_INIT([netbsd-iscsi],[20060417],[Alistair Crooks <agc@NetBSD.org>])
|
AC_INIT([netbsd-iscsi],[20060520],[Alistair Crooks <agc@NetBSD.org>])
|
||||||
AC_CONFIG_SRCDIR([iscsi.c])
|
AC_CONFIG_SRCDIR([iscsi.c])
|
||||||
AC_CONFIG_HEADER(../include/config.h)
|
AC_CONFIG_HEADER(../include/config.h)
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ AC_HEADER_STDC
|
||||||
AC_CHECK_HEADERS(sys/types.h sys/param.h sys/stat.h sys/time.h sys/mman.h sys/uio.h sys/socket.h sys/time.h sys/vfs.h)
|
AC_CHECK_HEADERS(sys/types.h sys/param.h sys/stat.h sys/time.h sys/mman.h sys/uio.h sys/socket.h sys/time.h sys/vfs.h)
|
||||||
AC_CHECK_HEADERS(arpa/inet.h netinet/in.h netinet/tcp.h netdb.h)
|
AC_CHECK_HEADERS(arpa/inet.h netinet/in.h netinet/tcp.h netdb.h)
|
||||||
AC_CHECK_HEADERS(asm/byteorder.h sys/byteorder.h libkern/OSByteOrder.h byteswap.h machine/endian.h)
|
AC_CHECK_HEADERS(asm/byteorder.h sys/byteorder.h libkern/OSByteOrder.h byteswap.h machine/endian.h)
|
||||||
AC_CHECK_HEADERS(ctype.h errno.h fcntl.h pthread.h pwd.h signal.h stdlib.h syslog.h unistd.h string.h stdarg.h utime.h)
|
AC_CHECK_HEADERS(ctype.h errno.h fcntl.h pthread.h pwd.h signal.h stdlib.h syslog.h unistd.h string.h stdarg.h utime.h uuid.h)
|
||||||
|
|
||||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||||
AC_C_CONST
|
AC_C_CONST
|
||||||
|
@ -34,7 +34,7 @@ AC_CHECK_LIB(socket, connect)
|
||||||
AC_CHECK_LIB(resolv, inet_aton)
|
AC_CHECK_LIB(resolv, inet_aton)
|
||||||
|
|
||||||
dnl Check for functionality
|
dnl Check for functionality
|
||||||
AC_CHECK_FUNCS(asprintf asnprintf bswap64 daemon fsync_range snprintf strlcpy strtoll syslog vasprintf vasnprintf vsnprintf)
|
AC_CHECK_FUNCS(__bswap64 asprintf asnprintf bswap64 daemon fsync_range snprintf strlcpy strtoll syslog vasprintf vasnprintf vsnprintf uuid_create uuid_to_string)
|
||||||
|
|
||||||
dnl that's it for now...
|
dnl that's it for now...
|
||||||
AC_OUTPUT(Makefile)
|
AC_OUTPUT(Makefile)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: disk.c,v 1.16 2006/04/26 20:31:43 agc Exp $ */
|
/* $NetBSD: disk.c,v 1.17 2006/05/21 09:26:38 agc Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright © 2006 Alistair Crooks. All rights reserved.
|
* Copyright © 2006 Alistair Crooks. All rights reserved.
|
||||||
|
@ -112,9 +112,14 @@
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_UUID_H
|
||||||
|
#include <uuid.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "scsi_cmd_codes.h"
|
#include "scsi_cmd_codes.h"
|
||||||
|
|
||||||
#include "iscsi.h"
|
#include "iscsi.h"
|
||||||
|
#include "compat.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
#include "target.h"
|
#include "target.h"
|
||||||
|
@ -157,7 +162,9 @@ typedef struct iscsi_disk_t {
|
||||||
uint64_t blocklen;
|
uint64_t blocklen;
|
||||||
uint64_t luns;
|
uint64_t luns;
|
||||||
uint64_t size;
|
uint64_t size;
|
||||||
targv_t *tv;
|
uuid_t uuid;
|
||||||
|
char *uuid_string;
|
||||||
|
targv_t *tv;
|
||||||
} iscsi_disk_t;
|
} iscsi_disk_t;
|
||||||
|
|
||||||
DEFINE_ARRAY(disks_t, iscsi_disk_t);
|
DEFINE_ARRAY(disks_t, iscsi_disk_t);
|
||||||
|
@ -822,14 +829,14 @@ strpadcpy(uint8_t *dst, size_t dstlen, const char *src, const size_t srclen, cha
|
||||||
static int
|
static int
|
||||||
report_luns(uint8_t *data, int64_t luns)
|
report_luns(uint8_t *data, int64_t luns)
|
||||||
{
|
{
|
||||||
uint64_t i;
|
uint64_t lun;
|
||||||
int32_t off;
|
int32_t off;
|
||||||
|
|
||||||
for (i = 0, off = 8 ; i < luns ; i++, off += sizeof(i)) {
|
for (lun = 0, off = 8 ; lun < luns ; lun++, off += sizeof(lun)) {
|
||||||
*((uint64_t *) (void *)data + off) = ISCSI_HTONLL(i);
|
*((uint64_t *) (void *)data + off) = ISCSI_HTONLL(lun);
|
||||||
}
|
}
|
||||||
*((uint32_t *) (void *)data) = ISCSI_HTONL(off - 7);
|
*((uint32_t *) (void *)data) = ISCSI_HTONL(off - 7);
|
||||||
return (off - 7) * sizeof(i);
|
return (int)(luns * sizeof(lun));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* initialise the device */
|
/* initialise the device */
|
||||||
|
@ -898,14 +905,15 @@ device_init(globals_t *gp, targv_t *tvp, disc_target_t *tp)
|
||||||
int
|
int
|
||||||
device_command(target_session_t * sess, target_cmd_t * cmd)
|
device_command(target_session_t * sess, target_cmd_t * cmd)
|
||||||
{
|
{
|
||||||
iscsi_scsi_cmd_args_t *args = cmd->scsi_cmd;
|
iscsi_scsi_cmd_args_t *args = cmd->scsi_cmd;
|
||||||
uint32_t lba;
|
uint32_t status;
|
||||||
uint16_t len;
|
uint32_t lba;
|
||||||
uint8_t *cp;
|
uint16_t len;
|
||||||
uint8_t *data;
|
uint8_t *cp;
|
||||||
uint8_t *cdb = args->cdb;
|
uint8_t *data;
|
||||||
uint8_t lun = (uint8_t) (args->lun >> 32);
|
uint8_t *cdb = args->cdb;
|
||||||
int mode_data_len;
|
uint8_t lun = (uint8_t) (args->lun >> 32);
|
||||||
|
int mode_data_len;
|
||||||
|
|
||||||
#if (CONFIG_DISK_INITIAL_CHECK_CONDITION==1)
|
#if (CONFIG_DISK_INITIAL_CHECK_CONDITION==1)
|
||||||
static int initialized = 0;
|
static int initialized = 0;
|
||||||
|
@ -965,22 +973,48 @@ device_command(target_session_t * sess, target_cmd_t * cmd)
|
||||||
case INQUIRY_DEVICE_IDENTIFICATION_VPD:
|
case INQUIRY_DEVICE_IDENTIFICATION_VPD:
|
||||||
data[0] = DISK_PERIPHERAL_DEVICE;
|
data[0] = DISK_PERIPHERAL_DEVICE;
|
||||||
data[1] = INQUIRY_DEVICE_IDENTIFICATION_VPD;
|
data[1] = INQUIRY_DEVICE_IDENTIFICATION_VPD;
|
||||||
len = data[3] = cdb[4] - 7;
|
data[3] = 0;
|
||||||
cp = &data[4];
|
cp = &data[4];
|
||||||
|
/* add target device's IQN */
|
||||||
cp[0] = (INQUIRY_DEVICE_ISCSI_PROTOCOL << 4) | INQUIRY_DEVICE_CODESET_UTF8;
|
cp[0] = (INQUIRY_DEVICE_ISCSI_PROTOCOL << 4) | INQUIRY_DEVICE_CODESET_UTF8;
|
||||||
cp[1] = (INQUIRY_DEVICE_PIV << 7) | (INQUIRY_DEVICE_ASSOCIATION_TARGET_DEVICE << 4) | INQUIRY_DEVICE_IDENTIFIER_SCSI_NAME;
|
cp[1] = (INQUIRY_DEVICE_PIV << 7) | (INQUIRY_DEVICE_ASSOCIATION_TARGET_DEVICE << 4) | INQUIRY_DEVICE_IDENTIFIER_SCSI_NAME;
|
||||||
len = (uint8_t) snprintf((char *)&cp[4], (int)len, "%s", sess->globals->targetname) + 4;
|
len = (uint8_t) snprintf((char *)&cp[4], (int)(cdb[4] - 7), "%s", sess->globals->targetname);
|
||||||
cp[3] = len;
|
cp[3] = len;
|
||||||
cp += len;
|
data[3] += len + 4;
|
||||||
|
cp += len + 4;
|
||||||
|
/* add target port's IQN + LUN */
|
||||||
cp[0] = (INQUIRY_DEVICE_ISCSI_PROTOCOL << 4) | INQUIRY_DEVICE_CODESET_UTF8;
|
cp[0] = (INQUIRY_DEVICE_ISCSI_PROTOCOL << 4) | INQUIRY_DEVICE_CODESET_UTF8;
|
||||||
cp[1] = (INQUIRY_DEVICE_PIV << 7) | (INQUIRY_DEVICE_ASSOCIATION_TARGET_PORT << 4) | INQUIRY_DEVICE_IDENTIFIER_SCSI_NAME;
|
cp[1] = (INQUIRY_DEVICE_PIV << 7) | (INQUIRY_DEVICE_ASSOCIATION_TARGET_PORT << 4) | INQUIRY_DEVICE_IDENTIFIER_SCSI_NAME;
|
||||||
len = (uint8_t) snprintf((char *)&cp[4], (int)len, "%s,t,0x%x", sess->globals->targetname, lun) + 4;
|
len = (uint8_t) snprintf((char *)&cp[4], (int)(cdb[4] - 7), "%s,t,0x%x", sess->globals->targetname, lun);
|
||||||
cp[3] = len;
|
cp[3] = len;
|
||||||
cp += len;
|
data[3] += len + 4;
|
||||||
|
cp += len + 4;
|
||||||
|
/* add target port's IQN + LUN extension */
|
||||||
cp[0] = (INQUIRY_DEVICE_ISCSI_PROTOCOL << 4) | INQUIRY_DEVICE_CODESET_UTF8;
|
cp[0] = (INQUIRY_DEVICE_ISCSI_PROTOCOL << 4) | INQUIRY_DEVICE_CODESET_UTF8;
|
||||||
cp[1] = (INQUIRY_DEVICE_PIV << 7) | (INQUIRY_DEVICE_ASSOCIATION_TARGET_DEVICE << 4) | INQUIRY_DEVICE_T10_VENDOR;
|
cp[1] = (INQUIRY_DEVICE_PIV << 7) | (INQUIRY_DEVICE_ASSOCIATION_LOGICAL_UNIT << 4) | INQUIRY_DEVICE_IDENTIFIER_SCSI_NAME;
|
||||||
|
if (disks.v[sess->d].uuid_string == NULL) {
|
||||||
|
uuid_create(&disks.v[sess->d].uuid, &status);
|
||||||
|
uuid_to_string(&disks.v[sess->d].uuid, &disks.v[sess->d].uuid_string, &status);
|
||||||
|
}
|
||||||
|
len = (uint8_t) snprintf((char *)&cp[4], (int)(cdb[4] - 7), "%s,L,0x%8.8s%4.4s%4.4s",
|
||||||
|
sess->globals->targetname,
|
||||||
|
disks.v[sess->d].uuid_string,
|
||||||
|
&disks.v[sess->d].uuid_string[9],
|
||||||
|
&disks.v[sess->d].uuid_string[14]);
|
||||||
|
cp[3] = len;
|
||||||
|
data[3] += len + 4;
|
||||||
|
cp += len + 4;
|
||||||
|
/* add target's uuid as a T10 identifier */
|
||||||
|
cp[0] = (INQUIRY_DEVICE_ISCSI_PROTOCOL << 4) | INQUIRY_DEVICE_CODESET_UTF8;
|
||||||
|
cp[1] = (INQUIRY_DEVICE_PIV << 7) | (INQUIRY_DEVICE_ASSOCIATION_TARGET_DEVICE << 4) | INQUIRY_IDENTIFIER_TYPE_T10;
|
||||||
strpadcpy(&cp[4], 8, ISCSI_VENDOR, strlen(ISCSI_VENDOR), ' ');
|
strpadcpy(&cp[4], 8, ISCSI_VENDOR, strlen(ISCSI_VENDOR), ' ');
|
||||||
cp[3] = 8;
|
len = (uint8_t) snprintf((char *)&cp[8 + 4], (int)(cdb[8 + 4] - 7), "0x%8.8s%4.4s%4.4s",
|
||||||
|
disks.v[sess->d].uuid_string,
|
||||||
|
&disks.v[sess->d].uuid_string[9],
|
||||||
|
&disks.v[sess->d].uuid_string[14]);
|
||||||
|
cp[3] = len;
|
||||||
|
data[3] += len + 4;
|
||||||
|
args->length = data[3] + 6;
|
||||||
break;
|
break;
|
||||||
case INQUIRY_SUPPORTED_VPD_PAGES:
|
case INQUIRY_SUPPORTED_VPD_PAGES:
|
||||||
data[0] = DISK_PERIPHERAL_DEVICE;
|
data[0] = DISK_PERIPHERAL_DEVICE;
|
||||||
|
@ -988,6 +1022,7 @@ device_command(target_session_t * sess, target_cmd_t * cmd)
|
||||||
data[3] = 2; /* # of supported pages */
|
data[3] = 2; /* # of supported pages */
|
||||||
data[4] = INQUIRY_SUPPORTED_VPD_PAGES;
|
data[4] = INQUIRY_SUPPORTED_VPD_PAGES;
|
||||||
data[5] = INQUIRY_DEVICE_IDENTIFICATION_VPD;
|
data[5] = INQUIRY_DEVICE_IDENTIFICATION_VPD;
|
||||||
|
args->length = cdb[4] + 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
iscsi_trace_error(__FILE__, __LINE__, "Unsupported INQUIRY VPD page %x\n", cdb[2]);
|
iscsi_trace_error(__FILE__, __LINE__, "Unsupported INQUIRY VPD page %x\n", cdb[2]);
|
||||||
|
@ -1005,10 +1040,10 @@ device_command(target_session_t * sess, target_cmd_t * cmd)
|
||||||
strpadcpy(&data[16], 16, ISCSI_PRODUCT, strlen(ISCSI_PRODUCT), ' ');
|
strpadcpy(&data[16], 16, ISCSI_PRODUCT, strlen(ISCSI_PRODUCT), ' ');
|
||||||
(void) snprintf(versionstr, sizeof(versionstr), "%d", ISCSI_VERSION);
|
(void) snprintf(versionstr, sizeof(versionstr), "%d", ISCSI_VERSION);
|
||||||
strpadcpy(&data[32], 4, versionstr, strlen(versionstr), ' ');
|
strpadcpy(&data[32], 4, versionstr, strlen(versionstr), ' ');
|
||||||
|
args->length = cdb[4] + 1;
|
||||||
}
|
}
|
||||||
if (args->status == 0) {
|
if (args->status == 0) {
|
||||||
args->input = 1;
|
args->input = 1;
|
||||||
args->length = cdb[4] + 1;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,103 @@
|
||||||
|
/* $NetBSD: uuid.c,v 1.1 2006/05/21 09:26:38 agc Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright © 2006 Alistair Crooks. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by Alistair Crooks
|
||||||
|
* for the NetBSD project.
|
||||||
|
* 4. The name of the author may not be used to endorse or promote
|
||||||
|
* products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||||
|
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||||
|
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_INTTYPES_H
|
||||||
|
#include <inttypes.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_SYS_PARAM_H
|
||||||
|
#include <sys/param.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_SYS_TIME_H
|
||||||
|
#include <sys/time.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_UUID_H
|
||||||
|
#include <uuid.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "defs.h"
|
||||||
|
|
||||||
|
#ifndef HAVE_UUID_CREATE
|
||||||
|
/* just fill the struct with random values for now */
|
||||||
|
void
|
||||||
|
uuid_create(uuid_t *uuid, uint32_t *status)
|
||||||
|
{
|
||||||
|
uint64_t ether;
|
||||||
|
time_t t;
|
||||||
|
|
||||||
|
(void) time(&t);
|
||||||
|
ether = (random() << 32) | random();
|
||||||
|
uuid->time_low = t;
|
||||||
|
uuid->time_mid = (uint16_t)(random() & 0xffff);
|
||||||
|
uuid->time_hi_and_version = (uint16_t)(random() & 0xffff);
|
||||||
|
uuid->clock_seq_low = random() & 0xff;
|
||||||
|
uuid->clock_seq_hi_and_reserved = random() & 0xff;
|
||||||
|
(void) memcpy(&uuid->node, ðer, sizeof(uuid->node));
|
||||||
|
*status = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_UUID_TO_STRING
|
||||||
|
/* convert the struct to a printable string */
|
||||||
|
void
|
||||||
|
uuid_to_string(uuid_t *uuid, char **str, uint32_t *status)
|
||||||
|
{
|
||||||
|
char s[64];
|
||||||
|
|
||||||
|
(void) snprintf(s, sizeof(s), "%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x",
|
||||||
|
uuid->time_low,
|
||||||
|
uuid->time_mid,
|
||||||
|
uuid->time_hi_and_version,
|
||||||
|
uuid->clock_seq_hi_and_reserved,
|
||||||
|
uuid->clock_seq_low,
|
||||||
|
uuid->node[0],
|
||||||
|
uuid->node[1],
|
||||||
|
uuid->node[2],
|
||||||
|
uuid->node[3],
|
||||||
|
uuid->node[4],
|
||||||
|
uuid->node[5]);
|
||||||
|
*str = strdup(s);
|
||||||
|
*status = 0;
|
||||||
|
}
|
||||||
|
#endif
|
Loading…
Reference in New Issue