Moving lib/libspl to linux-libspl branch
This commit is contained in:
parent
a4076c7544
commit
6b2c60acca
|
@ -1,67 +0,0 @@
|
||||||
/*
|
|
||||||
* CDDL HEADER START
|
|
||||||
*
|
|
||||||
* The contents of this file are subject to the terms of the
|
|
||||||
* Common Development and Distribution License (the "License").
|
|
||||||
* You may not use this file except in compliance with the License.
|
|
||||||
*
|
|
||||||
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
|
||||||
* or http://www.opensolaris.org/os/licensing.
|
|
||||||
* See the License for the specific language governing permissions
|
|
||||||
* and limitations under the License.
|
|
||||||
*
|
|
||||||
* When distributing Covered Code, include this CDDL HEADER in each
|
|
||||||
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
|
||||||
* If applicable, add the following below this CDDL HEADER, with the
|
|
||||||
* fields enclosed by brackets "[]" replaced with your own identifying
|
|
||||||
* information: Portions Copyright [yyyy] [name of copyright owner]
|
|
||||||
*
|
|
||||||
* CDDL HEADER END
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SYS_LIST_H
|
|
||||||
#define _SYS_LIST_H
|
|
||||||
|
|
||||||
#pragma ident "%Z%%M% %I% %E% SMI"
|
|
||||||
|
|
||||||
#include <sys/list_impl.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct list_node list_node_t;
|
|
||||||
typedef struct list list_t;
|
|
||||||
|
|
||||||
void list_create(list_t *, size_t, size_t);
|
|
||||||
void list_destroy(list_t *);
|
|
||||||
|
|
||||||
void list_insert_after(list_t *, void *, void *);
|
|
||||||
void list_insert_before(list_t *, void *, void *);
|
|
||||||
void list_insert_head(list_t *, void *);
|
|
||||||
void list_insert_tail(list_t *, void *);
|
|
||||||
void list_remove(list_t *, void *);
|
|
||||||
void *list_remove_head(list_t *);
|
|
||||||
void *list_remove_tail(list_t *);
|
|
||||||
void list_move_tail(list_t *, list_t *);
|
|
||||||
|
|
||||||
void *list_head(list_t *);
|
|
||||||
void *list_tail(list_t *);
|
|
||||||
void *list_next(list_t *, void *);
|
|
||||||
void *list_prev(list_t *, void *);
|
|
||||||
int list_is_empty(list_t *);
|
|
||||||
|
|
||||||
void list_link_init(list_node_t *);
|
|
||||||
void list_link_replace(list_node_t *, list_node_t *);
|
|
||||||
|
|
||||||
int list_link_active(list_node_t *);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _SYS_LIST_H */
|
|
|
@ -1,53 +0,0 @@
|
||||||
/*
|
|
||||||
* CDDL HEADER START
|
|
||||||
*
|
|
||||||
* The contents of this file are subject to the terms of the
|
|
||||||
* Common Development and Distribution License, Version 1.0 only
|
|
||||||
* (the "License"). You may not use this file except in compliance
|
|
||||||
* with the License.
|
|
||||||
*
|
|
||||||
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
|
||||||
* or http://www.opensolaris.org/os/licensing.
|
|
||||||
* See the License for the specific language governing permissions
|
|
||||||
* and limitations under the License.
|
|
||||||
*
|
|
||||||
* When distributing Covered Code, include this CDDL HEADER in each
|
|
||||||
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
|
||||||
* If applicable, add the following below this CDDL HEADER, with the
|
|
||||||
* fields enclosed by brackets "[]" replaced with your own identifying
|
|
||||||
* information: Portions Copyright [yyyy] [name of copyright owner]
|
|
||||||
*
|
|
||||||
* CDDL HEADER END
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* Copyright 2003 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SYS_LIST_IMPL_H
|
|
||||||
#define _SYS_LIST_IMPL_H
|
|
||||||
|
|
||||||
#pragma ident "%Z%%M% %I% %E% SMI"
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct list_node {
|
|
||||||
struct list_node *list_next;
|
|
||||||
struct list_node *list_prev;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct list {
|
|
||||||
size_t list_size;
|
|
||||||
size_t list_offset;
|
|
||||||
struct list_node list_head;
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _SYS_LIST_IMPL_H */
|
|
|
@ -1,245 +0,0 @@
|
||||||
/*
|
|
||||||
* CDDL HEADER START
|
|
||||||
*
|
|
||||||
* The contents of this file are subject to the terms of the
|
|
||||||
* Common Development and Distribution License (the "License").
|
|
||||||
* You may not use this file except in compliance with the License.
|
|
||||||
*
|
|
||||||
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
|
||||||
* or http://www.opensolaris.org/os/licensing.
|
|
||||||
* See the License for the specific language governing permissions
|
|
||||||
* and limitations under the License.
|
|
||||||
*
|
|
||||||
* When distributing Covered Code, include this CDDL HEADER in each
|
|
||||||
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
|
||||||
* If applicable, add the following below this CDDL HEADER, with the
|
|
||||||
* fields enclosed by brackets "[]" replaced with your own identifying
|
|
||||||
* information: Portions Copyright [yyyy] [name of copyright owner]
|
|
||||||
*
|
|
||||||
* CDDL HEADER END
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma ident "%Z%%M% %I% %E% SMI"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Generic doubly-linked list implementation
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/list.h>
|
|
||||||
#include <sys/list_impl.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/sysmacros.h>
|
|
||||||
#include <sys/debug.h>
|
|
||||||
|
|
||||||
#define list_d2l(a, obj) ((list_node_t *)(((char *)obj) + (a)->list_offset))
|
|
||||||
#define list_object(a, node) ((void *)(((char *)node) - (a)->list_offset))
|
|
||||||
#define list_empty(a) ((a)->list_head.list_next == &(a)->list_head)
|
|
||||||
|
|
||||||
#define list_insert_after_node(list, node, object) { \
|
|
||||||
list_node_t *lnew = list_d2l(list, object); \
|
|
||||||
lnew->list_prev = (node); \
|
|
||||||
lnew->list_next = (node)->list_next; \
|
|
||||||
(node)->list_next->list_prev = lnew; \
|
|
||||||
(node)->list_next = lnew; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define list_insert_before_node(list, node, object) { \
|
|
||||||
list_node_t *lnew = list_d2l(list, object); \
|
|
||||||
lnew->list_next = (node); \
|
|
||||||
lnew->list_prev = (node)->list_prev; \
|
|
||||||
(node)->list_prev->list_next = lnew; \
|
|
||||||
(node)->list_prev = lnew; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define list_remove_node(node) \
|
|
||||||
(node)->list_prev->list_next = (node)->list_next; \
|
|
||||||
(node)->list_next->list_prev = (node)->list_prev; \
|
|
||||||
(node)->list_next = (node)->list_prev = NULL
|
|
||||||
|
|
||||||
void
|
|
||||||
list_create(list_t *list, size_t size, size_t offset)
|
|
||||||
{
|
|
||||||
ASSERT(list);
|
|
||||||
ASSERT(size > 0);
|
|
||||||
ASSERT(size >= offset + sizeof (list_node_t));
|
|
||||||
|
|
||||||
list->list_size = size;
|
|
||||||
list->list_offset = offset;
|
|
||||||
list->list_head.list_next = list->list_head.list_prev =
|
|
||||||
&list->list_head;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
list_destroy(list_t *list)
|
|
||||||
{
|
|
||||||
list_node_t *node = &list->list_head;
|
|
||||||
|
|
||||||
ASSERT(list);
|
|
||||||
ASSERT(list->list_head.list_next == node);
|
|
||||||
ASSERT(list->list_head.list_prev == node);
|
|
||||||
|
|
||||||
node->list_next = node->list_prev = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
list_insert_after(list_t *list, void *object, void *nobject)
|
|
||||||
{
|
|
||||||
if (object == NULL) {
|
|
||||||
list_insert_head(list, nobject);
|
|
||||||
} else {
|
|
||||||
list_node_t *lold = list_d2l(list, object);
|
|
||||||
list_insert_after_node(list, lold, nobject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
list_insert_before(list_t *list, void *object, void *nobject)
|
|
||||||
{
|
|
||||||
if (object == NULL) {
|
|
||||||
list_insert_tail(list, nobject);
|
|
||||||
} else {
|
|
||||||
list_node_t *lold = list_d2l(list, object);
|
|
||||||
list_insert_before_node(list, lold, nobject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
list_insert_head(list_t *list, void *object)
|
|
||||||
{
|
|
||||||
list_node_t *lold = &list->list_head;
|
|
||||||
list_insert_after_node(list, lold, object);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
list_insert_tail(list_t *list, void *object)
|
|
||||||
{
|
|
||||||
list_node_t *lold = &list->list_head;
|
|
||||||
list_insert_before_node(list, lold, object);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
list_remove(list_t *list, void *object)
|
|
||||||
{
|
|
||||||
list_node_t *lold = list_d2l(list, object);
|
|
||||||
ASSERT(!list_empty(list));
|
|
||||||
ASSERT(lold->list_next != NULL);
|
|
||||||
list_remove_node(lold);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
|
||||||
list_remove_head(list_t *list)
|
|
||||||
{
|
|
||||||
list_node_t *head = list->list_head.list_next;
|
|
||||||
if (head == &list->list_head)
|
|
||||||
return (NULL);
|
|
||||||
list_remove_node(head);
|
|
||||||
return (list_object(list, head));
|
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
|
||||||
list_remove_tail(list_t *list)
|
|
||||||
{
|
|
||||||
list_node_t *tail = list->list_head.list_prev;
|
|
||||||
if (tail == &list->list_head)
|
|
||||||
return (NULL);
|
|
||||||
list_remove_node(tail);
|
|
||||||
return (list_object(list, tail));
|
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
|
||||||
list_head(list_t *list)
|
|
||||||
{
|
|
||||||
if (list_empty(list))
|
|
||||||
return (NULL);
|
|
||||||
return (list_object(list, list->list_head.list_next));
|
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
|
||||||
list_tail(list_t *list)
|
|
||||||
{
|
|
||||||
if (list_empty(list))
|
|
||||||
return (NULL);
|
|
||||||
return (list_object(list, list->list_head.list_prev));
|
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
|
||||||
list_next(list_t *list, void *object)
|
|
||||||
{
|
|
||||||
list_node_t *node = list_d2l(list, object);
|
|
||||||
|
|
||||||
if (node->list_next != &list->list_head)
|
|
||||||
return (list_object(list, node->list_next));
|
|
||||||
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
|
||||||
list_prev(list_t *list, void *object)
|
|
||||||
{
|
|
||||||
list_node_t *node = list_d2l(list, object);
|
|
||||||
|
|
||||||
if (node->list_prev != &list->list_head)
|
|
||||||
return (list_object(list, node->list_prev));
|
|
||||||
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Insert src list after dst list. Empty src list thereafter.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
list_move_tail(list_t *dst, list_t *src)
|
|
||||||
{
|
|
||||||
list_node_t *dstnode = &dst->list_head;
|
|
||||||
list_node_t *srcnode = &src->list_head;
|
|
||||||
|
|
||||||
ASSERT(dst->list_size == src->list_size);
|
|
||||||
ASSERT(dst->list_offset == src->list_offset);
|
|
||||||
|
|
||||||
if (list_empty(src))
|
|
||||||
return;
|
|
||||||
|
|
||||||
dstnode->list_prev->list_next = srcnode->list_next;
|
|
||||||
srcnode->list_next->list_prev = dstnode->list_prev;
|
|
||||||
dstnode->list_prev = srcnode->list_prev;
|
|
||||||
srcnode->list_prev->list_next = dstnode;
|
|
||||||
|
|
||||||
/* empty src list */
|
|
||||||
srcnode->list_next = srcnode->list_prev = srcnode;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
list_link_replace(list_node_t *lold, list_node_t *lnew)
|
|
||||||
{
|
|
||||||
ASSERT(list_link_active(lold));
|
|
||||||
ASSERT(!list_link_active(lnew));
|
|
||||||
|
|
||||||
lnew->list_next = lold->list_next;
|
|
||||||
lnew->list_prev = lold->list_prev;
|
|
||||||
lold->list_prev->list_next = lnew;
|
|
||||||
lold->list_next->list_prev = lnew;
|
|
||||||
lold->list_next = lold->list_prev = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
list_link_init(list_node_t *link)
|
|
||||||
{
|
|
||||||
link->list_next = NULL;
|
|
||||||
link->list_prev = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
list_link_active(list_node_t *link)
|
|
||||||
{
|
|
||||||
return (link->list_next != NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
list_is_empty(list_t *list)
|
|
||||||
{
|
|
||||||
return (list_empty(list));
|
|
||||||
}
|
|
|
@ -1,212 +0,0 @@
|
||||||
/*
|
|
||||||
* CDDL HEADER START
|
|
||||||
*
|
|
||||||
* The contents of this file are subject to the terms of the
|
|
||||||
* Common Development and Distribution License (the "License").
|
|
||||||
* You may not use this file except in compliance with the License.
|
|
||||||
*
|
|
||||||
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
|
||||||
* or http://www.opensolaris.org/os/licensing.
|
|
||||||
* See the License for the specific language governing permissions
|
|
||||||
* and limitations under the License.
|
|
||||||
*
|
|
||||||
* When distributing Covered Code, include this CDDL HEADER in each
|
|
||||||
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
|
||||||
* If applicable, add the following below this CDDL HEADER, with the
|
|
||||||
* fields enclosed by brackets "[]" replaced with your own identifying
|
|
||||||
* information: Portions Copyright [yyyy] [name of copyright owner]
|
|
||||||
*
|
|
||||||
* CDDL HEADER END
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Copyright (c) 1988 AT&T */
|
|
||||||
/* All Rights Reserved */
|
|
||||||
|
|
||||||
#pragma ident "%Z%%M% %I% %E% SMI"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Creates directory and it's parents if the parents do not
|
|
||||||
* exist yet.
|
|
||||||
*
|
|
||||||
* Returns -1 if fails for reasons other than non-existing
|
|
||||||
* parents.
|
|
||||||
* Does NOT simplify pathnames with . or .. in them.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <libgen.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
|
|
||||||
static char *simplify(const char *str);
|
|
||||||
|
|
||||||
int
|
|
||||||
mkdirp(const char *d, mode_t mode)
|
|
||||||
{
|
|
||||||
char *endptr, *ptr, *slash, *str;
|
|
||||||
|
|
||||||
str = simplify(d);
|
|
||||||
|
|
||||||
/* If space couldn't be allocated for the simplified names, return. */
|
|
||||||
|
|
||||||
if (str == NULL)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
/* Try to make the directory */
|
|
||||||
|
|
||||||
if (mkdir(str, mode) == 0) {
|
|
||||||
free(str);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
if (errno != ENOENT) {
|
|
||||||
free(str);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
endptr = strrchr(str, '\0');
|
|
||||||
slash = strrchr(str, '/');
|
|
||||||
|
|
||||||
/* Search upward for the non-existing parent */
|
|
||||||
|
|
||||||
while (slash != NULL) {
|
|
||||||
|
|
||||||
ptr = slash;
|
|
||||||
*ptr = '\0';
|
|
||||||
|
|
||||||
/* If reached an existing parent, break */
|
|
||||||
|
|
||||||
if (access(str, F_OK) == 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* If non-existing parent */
|
|
||||||
|
|
||||||
else {
|
|
||||||
slash = strrchr(str, '/');
|
|
||||||
|
|
||||||
/* If under / or current directory, make it. */
|
|
||||||
|
|
||||||
if (slash == NULL || slash == str) {
|
|
||||||
if (mkdir(str, mode) != 0 && errno != EEXIST) {
|
|
||||||
free(str);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Create directories starting from upmost non-existing parent */
|
|
||||||
|
|
||||||
while ((ptr = strchr(str, '\0')) != endptr) {
|
|
||||||
*ptr = '/';
|
|
||||||
if (mkdir(str, mode) != 0 && errno != EEXIST) {
|
|
||||||
/*
|
|
||||||
* If the mkdir fails because str already
|
|
||||||
* exists (EEXIST), then str has the form
|
|
||||||
* "existing-dir/..", and this is really
|
|
||||||
* ok. (Remember, this loop is creating the
|
|
||||||
* portion of the path that didn't exist)
|
|
||||||
*/
|
|
||||||
free(str);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
free(str);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* simplify - given a pathname, simplify that path by removing
|
|
||||||
* duplicate contiguous slashes.
|
|
||||||
*
|
|
||||||
* A simplified copy of the argument is returned to the
|
|
||||||
* caller, or NULL is returned on error.
|
|
||||||
*
|
|
||||||
* The caller should handle error reporting based upon the
|
|
||||||
* returned vlaue, and should free the returned value,
|
|
||||||
* when appropriate.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static char *
|
|
||||||
simplify(const char *str)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
size_t mbPathlen; /* length of multi-byte path */
|
|
||||||
size_t wcPathlen; /* length of wide-character path */
|
|
||||||
wchar_t *wptr; /* scratch pointer */
|
|
||||||
wchar_t *wcPath; /* wide-character version of the path */
|
|
||||||
char *mbPath; /* The copy fo the path to be returned */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* bail out if there is nothing there.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!str)
|
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get a copy of the argument.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ((mbPath = strdup(str)) == NULL) {
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* convert the multi-byte version of the path to a
|
|
||||||
* wide-character rendering, for doing our figuring.
|
|
||||||
*/
|
|
||||||
|
|
||||||
mbPathlen = strlen(mbPath);
|
|
||||||
|
|
||||||
if ((wcPath = calloc(sizeof (wchar_t), mbPathlen+1)) == NULL) {
|
|
||||||
free(mbPath);
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((wcPathlen = mbstowcs(wcPath, mbPath, mbPathlen)) == (size_t)-1) {
|
|
||||||
free(mbPath);
|
|
||||||
free(wcPath);
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* remove duplicate slashes first ("//../" -> "/")
|
|
||||||
*/
|
|
||||||
|
|
||||||
for (wptr = wcPath, i = 0; i < wcPathlen; i++) {
|
|
||||||
*wptr++ = wcPath[i];
|
|
||||||
|
|
||||||
if (wcPath[i] == '/') {
|
|
||||||
i++;
|
|
||||||
|
|
||||||
while (wcPath[i] == '/') {
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
i--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*wptr = '\0';
|
|
||||||
|
|
||||||
/*
|
|
||||||
* now convert back to the multi-byte format.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (wcstombs(mbPath, wcPath, mbPathlen) == (size_t)-1) {
|
|
||||||
free(mbPath);
|
|
||||||
free(wcPath);
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
free(wcPath);
|
|
||||||
return (mbPath);
|
|
||||||
}
|
|
|
@ -1,59 +0,0 @@
|
||||||
/*
|
|
||||||
* CDDL HEADER START
|
|
||||||
*
|
|
||||||
* The contents of this file are subject to the terms of the
|
|
||||||
* Common Development and Distribution License (the "License").
|
|
||||||
* You may not use this file except in compliance with the License.
|
|
||||||
*
|
|
||||||
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
|
||||||
* or http://www.opensolaris.org/os/licensing.
|
|
||||||
* See the License for the specific language governing permissions
|
|
||||||
* and limitations under the License.
|
|
||||||
*
|
|
||||||
* When distributing Covered Code, include this CDDL HEADER in each
|
|
||||||
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
|
||||||
* If applicable, add the following below this CDDL HEADER, with the
|
|
||||||
* fields enclosed by brackets "[]" replaced with your own identifying
|
|
||||||
* information: Portions Copyright [yyyy] [name of copyright owner]
|
|
||||||
*
|
|
||||||
* CDDL HEADER END
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma ident "%Z%%M% %I% %E% SMI"
|
|
||||||
|
|
||||||
#include "lint.h"
|
|
||||||
#include <string.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Appends src to the dstsize buffer at dst. The append will never
|
|
||||||
* overflow the destination buffer and the buffer will always be null
|
|
||||||
* terminated. Never reference beyond &dst[dstsize-1] when computing
|
|
||||||
* the length of the pre-existing string.
|
|
||||||
*/
|
|
||||||
|
|
||||||
size_t
|
|
||||||
strlcat(char *dst, const char *src, size_t dstsize)
|
|
||||||
{
|
|
||||||
char *df = dst;
|
|
||||||
size_t left = dstsize;
|
|
||||||
size_t l1;
|
|
||||||
size_t l2 = strlen(src);
|
|
||||||
size_t copied;
|
|
||||||
|
|
||||||
while (left-- != 0 && *df != '\0')
|
|
||||||
df++;
|
|
||||||
l1 = df - dst;
|
|
||||||
if (dstsize == l1)
|
|
||||||
return (l1 + l2);
|
|
||||||
|
|
||||||
copied = l1 + l2 >= dstsize ? dstsize - l1 - 1 : l2;
|
|
||||||
(void) memcpy(dst + l1, src, copied);
|
|
||||||
dst[l1+copied] = '\0';
|
|
||||||
return (l1 + l2);
|
|
||||||
}
|
|
|
@ -1,55 +0,0 @@
|
||||||
/*
|
|
||||||
* CDDL HEADER START
|
|
||||||
*
|
|
||||||
* The contents of this file are subject to the terms of the
|
|
||||||
* Common Development and Distribution License (the "License").
|
|
||||||
* You may not use this file except in compliance with the License.
|
|
||||||
*
|
|
||||||
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
|
||||||
* or http://www.opensolaris.org/os/licensing.
|
|
||||||
* See the License for the specific language governing permissions
|
|
||||||
* and limitations under the License.
|
|
||||||
*
|
|
||||||
* When distributing Covered Code, include this CDDL HEADER in each
|
|
||||||
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
|
||||||
* If applicable, add the following below this CDDL HEADER, with the
|
|
||||||
* fields enclosed by brackets "[]" replaced with your own identifying
|
|
||||||
* information: Portions Copyright [yyyy] [name of copyright owner]
|
|
||||||
*
|
|
||||||
* CDDL HEADER END
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma ident "%Z%%M% %I% %E% SMI"
|
|
||||||
|
|
||||||
#include "lint.h"
|
|
||||||
#include <string.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copies src to the dstsize buffer at dst. The copy will never
|
|
||||||
* overflow the destination buffer and the buffer will always be null
|
|
||||||
* terminated.
|
|
||||||
*/
|
|
||||||
|
|
||||||
size_t
|
|
||||||
strlcpy(char *dst, const char *src, size_t len)
|
|
||||||
{
|
|
||||||
size_t slen = strlen(src);
|
|
||||||
size_t copied;
|
|
||||||
|
|
||||||
if (len == 0)
|
|
||||||
return (slen);
|
|
||||||
|
|
||||||
if (slen >= len)
|
|
||||||
copied = len - 1;
|
|
||||||
else
|
|
||||||
copied = slen;
|
|
||||||
(void) memcpy(dst, src, copied);
|
|
||||||
dst[copied] = '\0';
|
|
||||||
return (slen);
|
|
||||||
}
|
|
|
@ -1,47 +0,0 @@
|
||||||
/*
|
|
||||||
* CDDL HEADER START
|
|
||||||
*
|
|
||||||
* The contents of this file are subject to the terms of the
|
|
||||||
* Common Development and Distribution License (the "License").
|
|
||||||
* You may not use this file except in compliance with the License.
|
|
||||||
*
|
|
||||||
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
|
||||||
* or http://www.opensolaris.org/os/licensing.
|
|
||||||
* See the License for the specific language governing permissions
|
|
||||||
* and limitations under the License.
|
|
||||||
*
|
|
||||||
* When distributing Covered Code, include this CDDL HEADER in each
|
|
||||||
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
|
||||||
* If applicable, add the following below this CDDL HEADER, with the
|
|
||||||
* fields enclosed by brackets "[]" replaced with your own identifying
|
|
||||||
* information: Portions Copyright [yyyy] [name of copyright owner]
|
|
||||||
*
|
|
||||||
* CDDL HEADER END
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright 2008 Sun Microsystems, Inc.
|
|
||||||
* All rights reserved. Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma ident "%Z%%M% %I% %E% SMI"
|
|
||||||
|
|
||||||
#include "lint.h"
|
|
||||||
#include <string.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Returns the number of non-NULL bytes in string argument,
|
|
||||||
* but not more than maxlen. Does not look past str + maxlen.
|
|
||||||
*/
|
|
||||||
size_t
|
|
||||||
strnlen(const char *str, size_t maxlen)
|
|
||||||
{
|
|
||||||
const char *ptr;
|
|
||||||
|
|
||||||
ptr = memchr(str, 0, maxlen);
|
|
||||||
if (ptr == NULL)
|
|
||||||
return (maxlen);
|
|
||||||
|
|
||||||
return (ptr - str);
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
|
@ -85,17 +85,6 @@ cp ${SRC_ZLIB}/sys/*.h ${DST_MOD}/zfs/include/sys/
|
||||||
rm ${DST_MOD}/zfs/vdev_disk.c
|
rm ${DST_MOD}/zfs/vdev_disk.c
|
||||||
rm ${DST_MOD}/zfs/include/sys/vdev_disk.h
|
rm ${DST_MOD}/zfs/include/sys/vdev_disk.h
|
||||||
|
|
||||||
echo "* lib/libspl"
|
|
||||||
mkdir -p ${DST_LIB}/libspl/include/sys/
|
|
||||||
cp ${SRC_LIB}/libc/port/gen/strlcat.c ${DST_LIB}/libspl/
|
|
||||||
cp ${SRC_LIB}/libc/port/gen/strlcpy.c ${DST_LIB}/libspl/
|
|
||||||
cp ${SRC_LIB}/libc/port/gen/strnlen.c ${DST_LIB}/libspl/
|
|
||||||
cp ${SRC_LIB}/libgen/common/mkdirp.c ${DST_LIB}/libspl/
|
|
||||||
cp ${SRC_CM}/unicode/u8_textprep.c ${DST_LIB}/libspl/
|
|
||||||
cp ${SRC_UCM}/os/list.c ${DST_LIB}/libspl/
|
|
||||||
cp ${SRC_UCM}/sys/list.h ${DST_LIB}/libspl/include/sys/
|
|
||||||
cp ${SRC_UCM}/sys/list_impl.h ${DST_LIB}/libspl/include/sys/
|
|
||||||
|
|
||||||
echo "* lib/libavl"
|
echo "* lib/libavl"
|
||||||
# Full source available in 'module/avl'
|
# Full source available in 'module/avl'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue