Tue Jun 23 05:11:47 2009 UTC ()
Apply some fixes from HEO SeonMeyong to allow the iSCSI target to build
and operate on Mac OS X - with apologies for taking so long to apply them.


(agc)
diff -r1.9 -r1.10 src/dist/iscsi/include/compat.h
diff -r1.5 -r1.6 src/dist/iscsi/include/storage.h
diff -r1.39 -r1.40 src/dist/iscsi/src/disk.c
diff -r1.3 -r1.4 src/dist/iscsi/src/uuid.c

cvs diff -r1.9 -r1.10 src/dist/iscsi/include/Attic/compat.h (expand / switch to context diff)
--- src/dist/iscsi/include/Attic/compat.h 2007/12/06 00:08:05 1.9
+++ src/dist/iscsi/include/Attic/compat.h 2009/06/23 05:11:46 1.10
@@ -74,28 +74,4 @@
 #define INFTIM	-1
 #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_ */

cvs diff -r1.5 -r1.6 src/dist/iscsi/include/Attic/storage.h (expand / switch to context diff)
--- src/dist/iscsi/include/Attic/storage.h 2007/12/09 09:16:42 1.5
+++ src/dist/iscsi/include/Attic/storage.h 2009/06/23 05:11:46 1.6
@@ -1,4 +1,4 @@
-/* $NetBSD: storage.h,v 1.5 2007/12/09 09:16:42 agc Exp $ */
+/* $NetBSD: storage.h,v 1.6 2009/06/23 05:11:46 agc Exp $ */
 
 /*
  * Copyright © 2006 Alistair Crooks.  All rights reserved.
@@ -32,6 +32,28 @@
 
 #include "defs.h"
 
+/* Length of a node address (an IEEE 802 address). */
+#define NB_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 nbuuid_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[NB_UUID_NODE_LEN];
+} nbuuid_t;
+
+void    nbuuid_create(nbuuid_t *, uint32_t *);
+void    nbuuid_to_string(nbuuid_t *, char **, uint32_t *);
+
 enum {
 	DE_EXTENT,
 	DE_DEVICE
@@ -51,7 +73,7 @@
 typedef struct disc_extent_t {
 	char		*extent;	/* extent name */
 	char		*dev;		/* device associated with it */
-	uint64_t	sacred;		/* offset of extent from start of device */
+	uint64_t	sacred;		/* offset of extent from start of dev */
 	uint64_t	len;		/* size of extent */
 	int		fd;		/* in-core file descriptor */
 	int		used;		/* extent has been used in a device */

cvs diff -r1.39 -r1.40 src/dist/iscsi/src/Attic/disk.c (expand / switch to context diff)
--- src/dist/iscsi/src/Attic/disk.c 2009/01/25 14:25:27 1.39
+++ src/dist/iscsi/src/Attic/disk.c 2009/06/23 05:11:47 1.40
@@ -1,4 +1,4 @@
-/* $NetBSD: disk.c,v 1.39 2009/01/25 14:25:27 lukem Exp $ */
+/* $NetBSD: disk.c,v 1.40 2009/06/23 05:11:47 agc Exp $ */
 
 /*
  * Copyright © 2006 Alistair Crooks.  All rights reserved.
@@ -108,10 +108,6 @@
 
 #include <unistd.h>
 
-#ifdef HAVE_UUID_H
-#include <uuid.h>
-#endif
-
 #include "scsi_cmd_codes.h"
 
 #include "iscsi.h"
@@ -151,7 +147,7 @@
 	uint64_t	 blocklen;			/* block size */
 	uint64_t	 luns;				/* # of luns */
 	uint64_t	 size;				/* size of complete disk */
-	uuid_t		 uuid;				/* disk's uuid */
+	nbuuid_t	 uuid;				/* disk's uuid */
 	char		*uuid_string;			/* uuid string */
 	targv_t		*tv;				/* the component devices and extents */
 	uint32_t	 resc;				/* # of reservation keys */
@@ -976,8 +972,8 @@
 				cp[0] = (INQUIRY_DEVICE_ISCSI_PROTOCOL << 4) | INQUIRY_DEVICE_CODESET_UTF8;
 				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);
+					nbuuid_create(&disks.v[sess->d].uuid, &status);
+					nbuuid_to_string(&disks.v[sess->d].uuid, &disks.v[sess->d].uuid_string, &status);
 				}
 				len = (uint8_t) snprintf((char *)&cp[4],
 							(unsigned)(*totsize - (int)(cp - &data[4])),

cvs diff -r1.3 -r1.4 src/dist/iscsi/src/Attic/uuid.c (expand / switch to context diff)
--- src/dist/iscsi/src/Attic/uuid.c 2007/06/16 23:13:26 1.3
+++ src/dist/iscsi/src/Attic/uuid.c 2009/06/23 05:11:47 1.4
@@ -1,4 +1,4 @@
-/* $NetBSD: uuid.c,v 1.3 2007/06/16 23:13:26 agc Exp $ */
+/* $NetBSD: uuid.c,v 1.4 2009/06/23 05:11:47 agc Exp $ */
 
 /*
  * Copyright © 2006 Alistair Crooks.  All rights reserved.
@@ -48,23 +48,19 @@
 #include <string.h>
 #include <unistd.h>
 
-#ifdef HAVE_UUID_H
-#include <uuid.h>
-#endif
-
+#include "storage.h"
 #include "compat.h"
 #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)
+nbuuid_create(nbuuid_t *uuid, uint32_t *status)
 {
 	uint64_t	ether;
 	time_t		t;
 
 	(void) time(&t);
-	ether = (random() << 32) | random();
+	ether = ((uint64_t)random() << 32) | random();
 	uuid->time_low = t;
 	uuid->time_mid = (uint16_t)(random() & 0xffff);
 	uuid->time_hi_and_version = (uint16_t)(random() & 0xffff);
@@ -73,12 +69,10 @@
 	(void) memcpy(&uuid->node, &ether, 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)
+nbuuid_to_string(nbuuid_t *uuid, char **str, uint32_t *status)
 {
 	char	s[64];
 
@@ -97,4 +91,3 @@
 	*str = strdup(s);
 	*status = 0;
 }
-#endif