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. 6 * 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. 10 */ 11 12 /* 13 * Copyright 2013 Nexenta Systems, Inc. All rights reserved. 14 */ 15 16 17 #include <sys/types.h> 18 #include <sys/time.h> 19 #include <sys/systm.h> 20 #include <sys/errno.h> 21 22 int 23 copyinstr(const char *src, char *dst, size_t max_len, size_t *copied) 24 { 25 return (copystr(src, dst, max_len, copied)); 26 } 27 28 int 29 copystr(const char *src, char *dst, size_t max_len, size_t *outlen) 30 { 31 size_t copied; 32 33 if (max_len == 0) 34 return (ENAMETOOLONG); 35 36 copied = strlcpy(dst, src, max_len) + 1; 37 if (copied >= max_len) 38 return (ENAMETOOLONG); 39 40 if (outlen != NULL) 41 *outlen = copied; 42 43 return (0); 44 } 45 46 void 47 ovbcopy(const void *src, void *dst, size_t len) 48 { 49 (void) memmove(dst, src, len); 50 } 51