5917 User-mode SMB server
[unleashed.git] / usr / src / lib / libfakekernel / common / copy.c
blobb1eb215b5c1112d3b1c0328f78cdee73a8339989
1 /*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
13 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
17 #include <sys/types.h>
18 #include <sys/time.h>
19 #include <sys/systm.h>
20 #include <sys/errno.h>
22 int
23 copyinstr(const char *src, char *dst, size_t max_len, size_t *copied)
25 return (copystr(src, dst, max_len, copied));
28 int
29 copystr(const char *src, char *dst, size_t max_len, size_t *outlen)
31 size_t copied;
33 if (max_len == 0)
34 return (ENAMETOOLONG);
36 copied = strlcpy(dst, src, max_len) + 1;
37 if (copied >= max_len)
38 return (ENAMETOOLONG);
40 if (outlen != NULL)
41 *outlen = copied;
43 return (0);
46 void
47 ovbcopy(const void *src, void *dst, size_t len)
49 (void) memmove(dst, src, len);