Rewrite the way report_luns() works, after suspicion by Matt Green, and
following Dan Carosone's suggestion of the uint64_t array. Abstract a bit more from the HTOBE64() macro intrigue, for platforms like Solaris/x86 which have fun in this part. Tested only with little-endian initiators for now. Bump version to 20060526.
This commit is contained in:
parent
eeb8ad7128
commit
2fa516b2eb
|
@ -42,20 +42,20 @@ size_t strlcpy(char *, const char *, size_t);
|
|||
#define __UNCONST(a) ((void *)(unsigned long)(const void *)(a))
|
||||
#endif
|
||||
|
||||
#ifndef HTOBE64
|
||||
#ifdef HAVE_HTOBE64
|
||||
# define ISCSI_HTOBE64(x) htobe64(x)
|
||||
# define ISCSI_BE64TOH(x) be64toh(x)
|
||||
#else
|
||||
# if defined(HAVE_LIBKERN_OSBYTEORDER_H)
|
||||
# define HTOBE64(x) (x) = OSSwapBigToHostInt64((u_int64_t)(x))
|
||||
# define ISCSI_HTOBE64(x) (x) = OSSwapBigToHostInt64((u_int64_t)(x))
|
||||
# elif _BYTE_ORDER == _BIG_ENDIAN
|
||||
# define HTOBE64(x) (x)
|
||||
# define ISCSI_HTOBE64(x) (x)
|
||||
# elif defined(HAVE___BSWAP64)
|
||||
# define HTOBE64(x) (x) = __bswap64((u_int64_t)(x))
|
||||
# define ISCSI_HTOBE64(x) (x) = __bswap64((u_int64_t)(x))
|
||||
# else /* LITTLE_ENDIAN */
|
||||
# define HTOBE64(x) (((uint64_t)(ISCSI_NTOHL((uint32_t)(((x) << 32) >> 32))) << 32) | (uint32_t)ISCSI_NTOHL(((uint32_t)((x) >> 32))))
|
||||
# define ISCSI_HTOBE64(x) (((uint64_t)(ISCSI_NTOHL((uint32_t)(((x) << 32) >> 32))) << 32) | (uint32_t)ISCSI_NTOHL(((uint32_t)((x) >> 32))))
|
||||
# endif /* LITTLE_ENDIAN */
|
||||
#endif
|
||||
|
||||
#ifndef BE64TOH
|
||||
# define BE64TOH(x) HTOBE64(x)
|
||||
# define ISCSI_BE64TOH(x) ISCSI_HTOBE64(x)
|
||||
#endif
|
||||
|
||||
#ifndef _DIAGASSERT
|
||||
|
|
|
@ -34,6 +34,9 @@
|
|||
/* Define to 1 if you have the `fsync_range' function. */
|
||||
#define HAVE_FSYNC_RANGE 1
|
||||
|
||||
/* Define to 1 if you have the `htobe64' function. */
|
||||
/* #undef HAVE_HTOBE64 */
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
|
@ -109,6 +112,9 @@
|
|||
/* Define to 1 if you have the <syslog.h> header file. */
|
||||
#define HAVE_SYSLOG_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/bswap.h> header file. */
|
||||
#define HAVE_SYS_BSWAP_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/byteorder.h> header file. */
|
||||
/* #undef HAVE_SYS_BYTEORDER_H */
|
||||
|
||||
|
@ -173,13 +179,13 @@
|
|||
#define PACKAGE_NAME "netbsd-iscsi"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "netbsd-iscsi 20060520"
|
||||
#define PACKAGE_STRING "netbsd-iscsi 20060526"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "netbsd-iscsi"
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "20060520"
|
||||
#define PACKAGE_VERSION "20060526"
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
|
|
@ -33,6 +33,9 @@
|
|||
/* Define to 1 if you have the `fsync_range' function. */
|
||||
#undef HAVE_FSYNC_RANGE
|
||||
|
||||
/* Define to 1 if you have the `htobe64' function. */
|
||||
#undef HAVE_HTOBE64
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
|
@ -108,6 +111,9 @@
|
|||
/* Define to 1 if you have the <syslog.h> header file. */
|
||||
#undef HAVE_SYSLOG_H
|
||||
|
||||
/* Define to 1 if you have the <sys/bswap.h> header file. */
|
||||
#undef HAVE_SYS_BSWAP_H
|
||||
|
||||
/* Define to 1 if you have the <sys/byteorder.h> header file. */
|
||||
#undef HAVE_SYS_BYTEORDER_H
|
||||
|
||||
|
|
|
@ -167,8 +167,8 @@ void iscsi_print_buffer(const char *, const size_t);
|
|||
#define __BIG_ENDIAN _BIG_ENDIAN
|
||||
#define __LITTLE_ENDIAN _LITTLE_ENDIAN
|
||||
|
||||
#define ISCSI_NTOHLL(a) be64toh(a)
|
||||
#define ISCSI_HTONLL(a) htobe64(a)
|
||||
#define ISCSI_NTOHLL(a) ISCSI_BE64TOH(a)
|
||||
#define ISCSI_HTONLL(a) ISCSI_HTOBE64(a)
|
||||
#define ISCSI_NTOHL(a) ntohl(a)
|
||||
#define ISCSI_HTONL(a) htonl(a)
|
||||
#define ISCSI_NTOHS(a) ntohs(a)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#! /bin/sh
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.59 for netbsd-iscsi 20060520.
|
||||
# Generated by GNU Autoconf 2.59 for netbsd-iscsi 20060526.
|
||||
#
|
||||
# Report bugs to <Alistair Crooks <agc@NetBSD.org>>.
|
||||
#
|
||||
|
@ -269,8 +269,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
|
|||
# Identity of this package.
|
||||
PACKAGE_NAME='netbsd-iscsi'
|
||||
PACKAGE_TARNAME='netbsd-iscsi'
|
||||
PACKAGE_VERSION='20060520'
|
||||
PACKAGE_STRING='netbsd-iscsi 20060520'
|
||||
PACKAGE_VERSION='20060526'
|
||||
PACKAGE_STRING='netbsd-iscsi 20060526'
|
||||
PACKAGE_BUGREPORT='Alistair Crooks <agc@NetBSD.org>'
|
||||
|
||||
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.
|
||||
# This message is too long to be a string in the A/UX 3.1 sh.
|
||||
cat <<_ACEOF
|
||||
\`configure' configures netbsd-iscsi 20060520 to adapt to many kinds of systems.
|
||||
\`configure' configures netbsd-iscsi 20060526 to adapt to many kinds of systems.
|
||||
|
||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||
|
||||
|
@ -837,7 +837,7 @@ fi
|
|||
|
||||
if test -n "$ac_init_help"; then
|
||||
case $ac_init_help in
|
||||
short | recursive ) echo "Configuration of netbsd-iscsi 20060520:";;
|
||||
short | recursive ) echo "Configuration of netbsd-iscsi 20060526:";;
|
||||
esac
|
||||
cat <<\_ACEOF
|
||||
|
||||
|
@ -949,7 +949,7 @@ fi
|
|||
test -n "$ac_init_help" && exit 0
|
||||
if $ac_init_version; then
|
||||
cat <<\_ACEOF
|
||||
netbsd-iscsi configure 20060520
|
||||
netbsd-iscsi configure 20060526
|
||||
generated by GNU Autoconf 2.59
|
||||
|
||||
Copyright (C) 2003 Free Software Foundation, Inc.
|
||||
|
@ -963,7 +963,7 @@ cat >&5 <<_ACEOF
|
|||
This file contains any messages produced by compilers while
|
||||
running configure, to aid debugging if configure makes a mistake.
|
||||
|
||||
It was created by netbsd-iscsi $as_me 20060520, which was
|
||||
It was created by netbsd-iscsi $as_me 20060526, which was
|
||||
generated by GNU Autoconf 2.59. Invocation command line was
|
||||
|
||||
$ $0 $@
|
||||
|
@ -3223,7 +3223,8 @@ done
|
|||
|
||||
|
||||
|
||||
for ac_header in asm/byteorder.h sys/byteorder.h libkern/OSByteOrder.h byteswap.h machine/endian.h
|
||||
|
||||
for ac_header in asm/byteorder.h sys/bswap.h sys/byteorder.h libkern/OSByteOrder.h byteswap.h machine/endian.h
|
||||
do
|
||||
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
|
||||
if eval "test \"\${$as_ac_Header+set}\" = set"; then
|
||||
|
@ -4157,7 +4158,8 @@ fi
|
|||
|
||||
|
||||
|
||||
for ac_func in __bswap64 asprintf asnprintf bswap64 daemon fsync_range snprintf strlcpy strtoll syslog vasprintf vasnprintf vsnprintf uuid_create uuid_to_string
|
||||
|
||||
for ac_func in __bswap64 asprintf asnprintf bswap64 daemon htobe64 fsync_range snprintf strlcpy strtoll syslog uuid_create uuid_to_string vasprintf vasnprintf vsnprintf
|
||||
do
|
||||
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
||||
echo "$as_me:$LINENO: checking for $ac_func" >&5
|
||||
|
@ -4622,7 +4624,7 @@ _ASBOX
|
|||
} >&5
|
||||
cat >&5 <<_CSEOF
|
||||
|
||||
This file was extended by netbsd-iscsi $as_me 20060520, which was
|
||||
This file was extended by netbsd-iscsi $as_me 20060526, which was
|
||||
generated by GNU Autoconf 2.59. Invocation command line was
|
||||
|
||||
CONFIG_FILES = $CONFIG_FILES
|
||||
|
@ -4682,7 +4684,7 @@ _ACEOF
|
|||
|
||||
cat >>$CONFIG_STATUS <<_ACEOF
|
||||
ac_cs_version="\\
|
||||
netbsd-iscsi config.status 20060520
|
||||
netbsd-iscsi config.status 20060526
|
||||
configured by $0, generated by GNU Autoconf 2.59,
|
||||
with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
dnl Process this file with autoconf to produce a configure script.
|
||||
AC_PREREQ(2.57)
|
||||
AC_INIT([netbsd-iscsi],[20060520],[Alistair Crooks <agc@NetBSD.org>])
|
||||
AC_INIT([netbsd-iscsi],[20060526],[Alistair Crooks <agc@NetBSD.org>])
|
||||
AC_CONFIG_SRCDIR([iscsi.c])
|
||||
AC_CONFIG_HEADER(../include/config.h)
|
||||
|
||||
|
@ -13,7 +13,7 @@ dnl Checks for header files.
|
|||
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(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/bswap.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 uuid.h)
|
||||
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
|
@ -34,7 +34,7 @@ AC_CHECK_LIB(socket, connect)
|
|||
AC_CHECK_LIB(resolv, inet_aton)
|
||||
|
||||
dnl Check for functionality
|
||||
AC_CHECK_FUNCS(__bswap64 asprintf asnprintf bswap64 daemon fsync_range snprintf strlcpy strtoll syslog vasprintf vasnprintf vsnprintf uuid_create uuid_to_string)
|
||||
AC_CHECK_FUNCS(__bswap64 asprintf asnprintf bswap64 daemon htobe64 fsync_range snprintf strlcpy strtoll syslog uuid_create uuid_to_string vasprintf vasnprintf vsnprintf)
|
||||
|
||||
dnl that's it for now...
|
||||
AC_OUTPUT(Makefile)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disk.c,v 1.17 2006/05/21 09:26:38 agc Exp $ */
|
||||
/* $NetBSD: disk.c,v 1.18 2006/05/26 16:34:43 agc Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright © 2006 Alistair Crooks. All rights reserved.
|
||||
|
@ -827,16 +827,15 @@ strpadcpy(uint8_t *dst, size_t dstlen, const char *src, const size_t srclen, cha
|
|||
|
||||
/* handle REPORT LUNs SCSI command */
|
||||
static int
|
||||
report_luns(uint8_t *data, int64_t luns)
|
||||
report_luns(uint64_t *data, int64_t luns)
|
||||
{
|
||||
uint64_t lun;
|
||||
int32_t off;
|
||||
|
||||
for (lun = 0, off = 8 ; lun < luns ; lun++, off += sizeof(lun)) {
|
||||
*((uint64_t *) (void *)data + off) = ISCSI_HTONLL(lun);
|
||||
data[lun] = ISCSI_HTONLL(lun);
|
||||
}
|
||||
*((uint32_t *) (void *)data) = ISCSI_HTONL(off - 7);
|
||||
return (int)(luns * sizeof(lun));
|
||||
return off;
|
||||
}
|
||||
|
||||
/* initialise the device */
|
||||
|
@ -1169,7 +1168,8 @@ device_command(target_session_t * sess, target_cmd_t * cmd)
|
|||
|
||||
case REPORT_LUNS:
|
||||
iscsi_trace(TRACE_SCSI_CMD, __FILE__, __LINE__, "REPORT LUNS\n");
|
||||
args->length = report_luns(args->send_data, disks.v[sess->d].luns);
|
||||
args->length = report_luns((uint64_t *) &args->send_data[8], disks.v[sess->d].luns);
|
||||
*((uint32_t *) (void *)args->send_data) = ISCSI_HTONL(disks.v[sess->d].luns * sizeof(uint64_t));
|
||||
args->input = 8;
|
||||
args->status = 0;
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue