No subject


Thu Nov 20 16:09:27 PST 2014


----------------------------
revision 1.18
date: 2005-07-29 17:22:36 +0400;  author: imura;  state: Exp;  lines: 
+10 -6;
Change API of mb_copy_t in libmchain so that netsmb can handle
multibyte character share name correctly.

Reviewed by:    bp
----------------------------
revision 1.16
date: 2004-04-06 01:03:35 +0400;  author: imp;  state: Exp;  lines: +0 -3;
branches:  1.16.2;
Remove advertising clause from University of California Regent's license,
per letter dated July 22, 1999.
Approved by: core
----------------------------
revision 1.10
date: 2002-12-16 19:20:06 +0300;  author: robert;  state: Exp;  lines: 
+12 -13;
Remove the hto(be|le)[slq] and (be|le)toh[slq] macros defined in
_KERNEL scope from "src/sys/sys/mchain.h".

Replace each occurrence of the above in _KERNEL scope with the
appropriate macro from the set of hto(be|le)(16|32|64) and
(be|le)toh(16|32|64) from "src/sys/sys/endian.h".
Tested by:              tjr
Requested by:           comment marked with XXX
----------------------------
revision 1.9
date: 2002-10-22 22:44:59 +0400;  author: jhb;  state: Exp;  lines: +12 -6;
Don't dereference the 'x' pointer if it is NULL, instead skip the
assignment.  The netsmb code likes to call these functions with a NULL
x argument a lot.
Reported by:    Vallo Kallaste <kalts at xxxxxxxxx>
----------------------------
revision 1.8
date: 2002-10-11 18:58:30 +0400;  author: mike;  state: Exp;  lines: +4 -2;
Change iov_base's type from `char *' to the standard `void *'.  All
uses of iov_base which assume its type is `char *' (in order to do
pointer arithmetic) have been updated to cast iov_base to `char *'.
----------------------------
revision 1.6
date: 2002-07-15 17:15:31 +0400;  author: markm;  state: Exp;  lines: +4 -4;
Convert GNU-styled variadic macros to ISO(9x) style.
P.S. And in FreeBSD m_fixhdr() moved from mbchain to mbuf. Does we need it?
Index: sys/kern/libmchain/subr_mchain.c
===================================================================
RCS file: /mnt/share/dragonfly-cvs/src/sys/kern/libmchain/subr_mchain.c,v
retrieving revision 1.4
diff -u -r1.4 subr_mchain.c
--- sys/kern/libmchain/subr_mchain.c	7 Jun 2005 19:06:08 -0000	1.4
+++ sys/kern/libmchain/subr_mchain.c	21 Jan 2006 11:45:03 -0000
@@ -10,9 +10,6 @@
  * 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 Boris Popov.
  * 4. Neither the name of the author nor the names of any co-contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
@@ -37,8 +34,8 @@
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
+#include <sys/endian.h>
 #include <sys/errno.h>
-#include <sys/malloc.h>
 #include <sys/mbuf.h>
 #include <sys/module.h>
 #include <sys/uio.h>
@@ -47,11 +44,11 @@
 
 MODULE_VERSION(libmchain, 1);
 
-#define MBERROR(format, args...) printf("%s(%d): "format, __func__ , \
-				    __LINE__ ,## args)
+#define MBERROR(format, ...) printf("%s(%d): "format, __func__ , \
+				    __LINE__ , ## __VA_ARGS__)
 
-#define MBPANIC(format, args...) printf("%s(%d): "format, __func__ , \
-				    __LINE__ ,## args)
+#define MBPANIC(format, ...) printf("%s(%d): "format, __func__ , \
+				    __LINE__ , ## __VA_ARGS__)
 
 /*
  * Various helper functions
@@ -157,42 +154,42 @@
 int
 mb_put_uint16be(struct mbchain *mbp, u_int16_t x)
 {
-	x = htobes(x);
+	x = htobe16(x);
 	return mb_put_mem(mbp, (caddr_t)&x, sizeof(x), MB_MSYSTEM);
 }
 
 int
 mb_put_uint16le(struct mbchain *mbp, u_int16_t x)
 {
-	x = htoles(x);
+	x = htole16(x);
 	return mb_put_mem(mbp, (caddr_t)&x, sizeof(x), MB_MSYSTEM);
 }
 
 int
 mb_put_uint32be(struct mbchain *mbp, u_int32_t x)
 {
-	x = htobel(x);
+	x = htobe32(x);
 	return mb_put_mem(mbp, (caddr_t)&x, sizeof(x), MB_MSYSTEM);
 }
 
 int
 mb_put_uint32le(struct mbchain *mbp, u_int32_t x)
 {
-	x = htolel(x);
+	x = htole32(x);
 	return mb_put_mem(mbp, (caddr_t)&x, sizeof(x), MB_MSYSTEM);
 }
 
 int
 mb_put_int64be(struct mbchain *mbp, int64_t x)
 {
-	x = htobeq(x);
+	x = htobe64(x);
 	return mb_put_mem(mbp, (caddr_t)&x, sizeof(x), MB_MSYSTEM);
 }
 
 int
 mb_put_int64le(struct mbchain *mbp, int64_t x)
 {
-	x = htoleq(x);
+	x = htole64(x);
 	return mb_put_mem(mbp, (caddr_t)&x, sizeof(x), MB_MSYSTEM);
 }
 
@@ -203,6 +200,7 @@
 	caddr_t dst;
 	c_caddr_t src;
 	int cplen, error, mleft, count;
+	size_t srclen, dstlen;
 
 	m = mbp->mb_cur;
 	mleft = mbp->mb_mleft;
@@ -219,10 +217,13 @@
 			continue;
 		}
 		cplen = mleft > size ? size : mleft;
+		srclen = dstlen = cplen;
 		dst = mtod(m, caddr_t) + m->m_len;
 		switch (type) {
 		    case MB_MCUSTOM:
-			error = mbp->mb_copy(mbp, source, dst, cplen);
+			srclen = size;
+			dstlen = mleft;
+			error = mbp->mb_copy(mbp, source, dst, &srclen, &dstlen);
 			if (error)
 				return error;
 			break;
@@ -242,11 +243,11 @@
 			bzero(dst, cplen);
 			break;
 		}
-		size -= cplen;
-		source += cplen;
-		m->m_len += cplen;
-		mleft -= cplen;
-		mbp->mb_count += cplen;
+		size -= srclen;
+		source += srclen;
+		m->m_len += dstlen;
+		mleft -= dstlen;
+		mbp->mb_count += dstlen;
 	}
 	mbp->mb_cur = m;
 	mbp->mb_mleft = mleft;
@@ -295,7 +296,8 @@
 			return error;
 		uiop->uio_offset += left;
 		uiop->uio_resid -= left;
-		uiop->uio_iov->iov_base += left;
+		uiop->uio_iov->iov_base =
+		    (char *)uiop->uio_iov->iov_base + left;
 		uiop->uio_iov->iov_len -= left;
 		size -= left;
 	}
@@ -393,7 +395,8 @@
 	u_int16_t v;
 	int error = md_get_uint16(mdp, &v);
 
-	*x = letohs(v);
+	if (x != NULL)
+		*x = le16toh(v);
 	return error;
 }
 
@@ -402,7 +405,8 @@
 	u_int16_t v;
 	int error = md_get_uint16(mdp, &v);
 
-	*x = betohs(v);
+	if (x != NULL)
+		*x = be16toh(v);
 	return error;
 }
 
@@ -419,7 +423,8 @@
 	int error;
 
 	error = md_get_uint32(mdp, &v);
-	*x = betohl(v);
+	if (x != NULL)
+		*x = be32toh(v);
 	return error;
 }
 
@@ -430,7 +435,8 @@
 	int error;
 
 	error = md_get_uint32(mdp, &v);
-	*x = letohl(v);
+	if (x != NULL)
+		*x = le32toh(v);
 	return error;
 }
 
@@ -447,7 +453,8 @@
 	int error;
 
 	error = md_get_int64(mdp, &v);
-	*x = betohq(v);
+	if (x != NULL)
+		*x = be64toh(v);
 	return error;
 }
 
@@ -458,7 +465,8 @@
 	int error;
 
 	error = md_get_int64(mdp, &v);
-	*x = letohq(v);
+	if (x != NULL)
+		*x = le64toh(v);
 	return error;
 }
 
@@ -546,7 +554,8 @@
 			return error;
 		uiop->uio_offset += left;
 		uiop->uio_resid -= left;
-		uiop->uio_iov->iov_base += left;
+		uiop->uio_iov->iov_base =
+		    (char *)uiop->uio_iov->iov_base + left;
 		uiop->uio_iov->iov_len -= left;
 		size -= left;
 	}
Index: sys/sys/mchain.h
===================================================================
RCS file: /mnt/share/dragonfly-cvs/src/sys/sys/mchain.h,v
retrieving revision 1.3
diff -u -r1.3 mchain.h
--- sys/sys/mchain.h	23 Sep 2004 16:11:47 -0000	1.3
+++ sys/sys/mchain.h	20 Jan 2006 17:32:41 -0000
@@ -35,67 +35,22 @@
 #ifndef _SYS_MCHAIN_H_
 #define _SYS_MCHAIN_H_
 
-#include <machine/endian.h>
-
-/*
- * This macros probably belongs to the endian.h
- */
-#if _BYTE_ORDER == _LITTLE_ENDIAN
-
-#define htoles(x)	((u_int16_t)(x))
-#define letohs(x)	((u_int16_t)(x))
-#define	htolel(x)	((u_int32_t)(x))
-#define	letohl(x)	((u_int32_t)(x))
-#define	htoleq(x)	((int64_t)(x))
-#define	letohq(x)	((int64_t)(x))
-
-#define htobes(x)	(htons(x))
-#define betohs(x)	(ntohs(x))
-#define htobel(x)	(htonl(x))
-#define betohl(x)	(ntohl(x))
-
-static __inline int64_t
-htobeq(int64_t x)
-{
-	return (int64_t)htonl((u_int32_t)(x >> 32)) |
-	    (int64_t)htonl((u_int32_t)(x & 0xffffffff)) << 32;
-}
-
-static __inline int64_t
-betohq(int64_t x)
-{
-	return (int64_t)ntohl((u_int32_t)(x >> 32)) |
-	    (int64_t)ntohl((u_int32_t)(x & 0xffffffff)) << 32;
-}
-
-#else	/* (BYTE_ORDER == LITTLE_ENDIAN) */
-
-#error "Macros for Big-Endians are incomplete"
-
-/*
-#define htoles(x)	((u_int16_t)(x))
-#define letohs(x)	((u_int16_t)(x))
-#define	htolel(x)	((u_int32_t)(x))
-#define	letohl(x)	((u_int32_t)(x))
-*/
-#endif	/* (BYTE_ORDER == LITTLE_ENDIAN) */
-
-
 #ifdef _KERNEL
 
 /*
  * Type of copy for mb_{put|get}_mem()
  */
 #define	MB_MSYSTEM	0		/* use bcopy() */
-#define MB_MUSER	1		/* use copyin()/copyout() */
-#define MB_MINLINE	2		/* use an inline copy loop */
+#define	MB_MUSER	1		/* use copyin()/copyout() */
+#define	MB_MINLINE	2		/* use an inline copy loop */
 #define	MB_MZERO	3		/* bzero(), mb_put_mem only */
 #define	MB_MCUSTOM	4		/* use an user defined function */
 
 struct mbuf;
 struct mbchain;
 
-typedef int mb_copy_t(struct mbchain *mbp, c_caddr_t src, caddr_t dst, int len);
+typedef int mb_copy_t(struct mbchain *mbp, c_caddr_t src, caddr_t dst,
+    size_t *srclen, size_t *dstlen);
 
 struct mbchain {
 	struct mbuf *	mb_top;		/* head of mbufs chain */




More information about the Submit mailing list