Merge commit 'refs/top-bases/fix-dsl_pool_t' into fix-dsl_pool_t
This commit is contained in:
commit
4ad630c929
|
@ -1,59 +1,150 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# WARNING: This script removes the entire zfs subtree and will
|
||||||
|
# repopulate it using the requested OpenSolaris source release.
|
||||||
|
# This script should only be used when rebasing the TopGit tree
|
||||||
|
# against the latest release.
|
||||||
|
#
|
||||||
|
trap die_int INT
|
||||||
|
|
||||||
|
RELEASE=$1
|
||||||
PROG=update-zfs.sh
|
PROG=update-zfs.sh
|
||||||
ZFS_SRC=http://dlc.sun.com/osol/on/downloads/b89/on-src.tar.bz2
|
REMOTE_SRC=http://dlc.sun.com/osol/on/downloads/${RELEASE}/on-src.tar.bz2
|
||||||
|
|
||||||
die() {
|
die() {
|
||||||
rm -Rf $SRC
|
rm -Rf ${SRC}
|
||||||
echo "${PROG}: $1" >&2
|
echo "${PROG}: $1" >&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
DEST=`pwd`
|
die_int() {
|
||||||
if [ `basename $DEST` != "scripts" ]; then
|
die "Ctrl-C abort"
|
||||||
|
}
|
||||||
|
|
||||||
|
DST=`pwd`
|
||||||
|
if [ `basename $DST` != "scripts" ]; then
|
||||||
die "Must be run from scripts directory"
|
die "Must be run from scripts directory"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SRC=`mktemp -d /tmp/zfs.XXXXXXXXXX`
|
SRC=`mktemp -d /tmp/os-${RELEASE}.XXXXXXXXXX`
|
||||||
DEST=`dirname $DEST`
|
DST=`dirname $DST`
|
||||||
DATE=`date +%Y%m%d%H%M%S`
|
|
||||||
|
|
||||||
wget $ZFS_SRC
|
echo "----------------------------------------------------------------------"
|
||||||
|
echo "Remote Source: ${REMOTE_SRC}"
|
||||||
echo "--- Updating ZFS source ---"
|
echo "Local Source: ${SRC}"
|
||||||
|
echo "Local Dest: ${DST}"
|
||||||
echo
|
echo
|
||||||
echo "ZFS_REPO = $ZFS_REPO"
|
echo "------------- Fetching OpenSolaris ${RELEASE} archive ----------------"
|
||||||
echo "ZFS_PATCH_REPO = $ZFS_PATCH_REPO"
|
wget ${REMOTE_SRC} -P ${SRC} ||
|
||||||
echo "SRC = $SRC"
|
die "Error 'wget ${REMOTE_SRC}'"
|
||||||
echo "DEST = $DEST"
|
|
||||||
|
echo "------------- Unpacking OperSolaris ${RELEASE} archive ---------------"
|
||||||
|
tar -xjf ${SRC}/on-src.tar.bz2 -C ${SRC} ||
|
||||||
|
die "Error 'tar -xjf ${SRC}/on-src.tar.bz2 -C ${SRC}'"
|
||||||
|
|
||||||
|
SRC_LIB=${SRC}/usr/src/lib
|
||||||
|
SRC_CMD=${SRC}/usr/src/cmd
|
||||||
|
SRC_CM=${SRC}/usr/src/common
|
||||||
|
SRC_UTS=${SRC}/usr/src/uts
|
||||||
|
SRC_UCM=${SRC}/usr/src/uts/common
|
||||||
|
SRC_ZLIB=${SRC}/usr/src/uts/common/fs/zfs
|
||||||
|
|
||||||
|
DST_LIB=${DST}/zfs/lib
|
||||||
|
DST_CMD=${DST}/zfs/zcmd
|
||||||
|
|
||||||
|
rm -Rf ${DST}/zfs
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "--- Cloning $ZFS_REPO ---"
|
echo "------------- Updating ZFS from OpenSolaris ${RELEASE} ---------------"
|
||||||
cd $SRC || die "Failed to 'cd $SRC'"
|
echo "* zfs/lib/libavl"
|
||||||
hg clone $ZFS_REPO || die "Failed to clone $ZFS_REPO"
|
mkdir -p ${DST_LIB}/libavl/include/sys/
|
||||||
|
cp ${SRC_CM}/avl/avl.c ${DST_LIB}/libavl/
|
||||||
|
cp ${SRC_UCM}/sys/avl.h ${DST_LIB}/libavl/include/sys/
|
||||||
|
cp ${SRC_UCM}/sys/avl_impl.h ${DST_LIB}/libavl/include/sys/
|
||||||
|
|
||||||
echo
|
echo "* zfs/lib/libnvpair"
|
||||||
echo "--- Cloning $ZFS_PATCH_REPO ---"
|
mkdir -p ${DST_LIB}/libnvpair/include/sys/
|
||||||
hg clone $ZFS_PATCH_REPO patches || die "Failed to clone $ZFS_PATCH_REPO"
|
cp ${SRC_CM}/nvpair/nvpair.c ${DST_LIB}/libnvpair/
|
||||||
|
cp ${SRC_LIB}/libnvpair/libnvpair.c ${DST_LIB}/libnvpair/
|
||||||
|
cp ${SRC_UCM}/os/nvpair_alloc_system.c ${DST_LIB}/libnvpair/
|
||||||
|
cp ${SRC_CM}/nvpair/nvpair_alloc_fixed.c ${DST_LIB}/libnvpair/
|
||||||
|
cp ${SRC_LIB}/libnvpair/libnvpair.h ${DST_LIB}/libnvpair/include/
|
||||||
|
cp ${SRC_UCM}/sys/nvpair.h ${DST_LIB}/libnvpair/include/sys/
|
||||||
|
cp ${SRC_UCM}/sys/nvpair_impl.h ${DST_LIB}/libnvpair/include/sys/
|
||||||
|
|
||||||
echo
|
echo "* zfs/lib/libumem"
|
||||||
echo "--- Backing up existing files ---"
|
mkdir -p ${DST_LIB}/libumem/include/
|
||||||
echo "$DEST/zfs -> $DEST/zfs.$DATE"
|
mkdir -p ${DST_LIB}/libumem/sys/
|
||||||
cp -Rf $DEST/zfs $DEST/zfs.$DATE || die "Failed to backup"
|
cp ${SRC_LIB}/libumem/common/*.c ${DST_LIB}/libumem/
|
||||||
echo "$DEST/zfs_patches -> $DEST/zfs_patches.$DATE"
|
cp ${SRC_LIB}/libumem/common/*.h ${DST_LIB}/libumem/include/
|
||||||
cp -Rf $DEST/zfs_patches $DEST/zfs_patches.$DATE || die "Failed to backup"
|
cp ${SRC_LIB}/libumem/common/sys/*.h ${DST_LIB}/libumem/sys/
|
||||||
|
|
||||||
echo
|
echo "* zfs/lib/libuutil"
|
||||||
echo "--- Overwriting $DEST/zfs and $DEST/zfs_patches ---"
|
mkdir -p ${DST_LIB}/libuutil/include/
|
||||||
find $SRC/trunk/src/ -name SConstruct -type f -print | xargs /bin/rm -f
|
cp ${SRC_LIB}/libuutil/common/*.c ${DST_LIB}/libuutil/
|
||||||
find $SRC/trunk/src/ -name SConscript -type f -print | xargs /bin/rm -f
|
cp ${SRC_LIB}/libuutil/common/*.h ${DST_LIB}/libuutil/include/
|
||||||
find $SRC/trunk/src/ -name *.orig -type f -print | xargs /bin/rm -f
|
|
||||||
rm -f $SRC/trunk/src/myconfig.py
|
|
||||||
cp -Rf $SRC/trunk/src/* $DEST/zfs || die "Failed to overwrite"
|
|
||||||
cp -Rf $SRC/patches/*.patch $DEST/zfs_patches/patches/ || die "Failed to overwrite"
|
|
||||||
cp -f $SRC/patches/series $DEST/zfs_patches/series/zfs-lustre
|
|
||||||
|
|
||||||
echo
|
echo "* zfs/lib/libspl"
|
||||||
echo "--- Removing $SRC ---"
|
mkdir -p ${DST_LIB}/libspl/include/sys/
|
||||||
rm -Rf $SRC
|
cp ${SRC_LIB}/libzpool/common/kernel.c ${DST_LIB}/libspl/
|
||||||
|
cp ${SRC_LIB}/libzpool/common/taskq.c ${DST_LIB}/libspl/
|
||||||
|
cp ${SRC_LIB}/libzpool/common/util.c ${DST_LIB}/libspl/
|
||||||
|
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/vmem.h ${DST_LIB}/libspl/include/sys/
|
||||||
|
cp ${SRC_UCM}/sys/list.h ${DST_LIB}/libspl/include/sys/
|
||||||
|
cp ${SRC_UCM}/sys/list_impl.h ${DST_LIB}/libspl/include/sys/
|
||||||
|
|
||||||
|
echo "* zfs/lib/libzcommon"
|
||||||
|
mkdir -p ${DST_LIB}/libzcommon/include/sys/fs/
|
||||||
|
mkdir -p ${DST_LIB}/libzcommon/include/sys/fm/fs/
|
||||||
|
cp ${SRC_CM}/zfs/*.c ${DST_LIB}/libzcommon/
|
||||||
|
cp ${SRC_CM}/zfs/*.h ${DST_LIB}/libzcommon/include/
|
||||||
|
cp ${SRC_UCM}/sys/fs/zfs.h ${DST_LIB}/libzcommon/include/sys/fs/
|
||||||
|
cp ${SRC_UCM}/sys/fm/fs/zfs.h ${DST_LIB}/libzcommon/include/sys/fm/fs/
|
||||||
|
|
||||||
|
echo "* zfs/lib/libzpool"
|
||||||
|
mkdir -p ${DST_LIB}/libzpool/include/sys/
|
||||||
|
cp ${SRC_ZLIB}/*.c ${DST_LIB}/libzpool/
|
||||||
|
cp ${SRC_UTS}/intel/zfs/spa_boot.c ${DST_LIB}/libzpool/
|
||||||
|
cp ${SRC_ZLIB}/sys/*.h ${DST_LIB}/libzpool/include/sys/
|
||||||
|
rm ${DST_LIB}/libzpool/vdev_disk.c
|
||||||
|
rm ${DST_LIB}/libzpool/include/sys/vdev_disk.h
|
||||||
|
|
||||||
|
echo "* zfs/lib/libzfs"
|
||||||
|
mkdir -p ${DST_LIB}/libzfs/include/
|
||||||
|
cp ${SRC_LIB}/libzfs/common/*.c ${DST_LIB}/libzfs/
|
||||||
|
cp ${SRC_LIB}/libzfs/common/*.h ${DST_LIB}/libzfs/include/
|
||||||
|
|
||||||
|
echo "* zfs/zcmd/zpool"
|
||||||
|
mkdir -p ${DST_CMD}/zpool
|
||||||
|
cp ${SRC_CMD}/zpool/*.c ${DST_CMD}/zpool/
|
||||||
|
cp ${SRC_CMD}/zpool/*.h ${DST_CMD}/zpool/
|
||||||
|
|
||||||
|
echo "* zfs/zcmd/zfs"
|
||||||
|
mkdir -p ${DST_CMD}/zfs
|
||||||
|
cp ${SRC_CMD}/zfs/*.c ${DST_CMD}/zfs/
|
||||||
|
cp ${SRC_CMD}/zfs/*.h ${DST_CMD}/zfs/
|
||||||
|
|
||||||
|
echo "* zfs/zcmd/zdb"
|
||||||
|
mkdir -p ${DST_CMD}/zdb/
|
||||||
|
cp ${SRC_CMD}/zdb/*.c ${DST_CMD}/zdb/
|
||||||
|
|
||||||
|
echo "* zfs/zcmd/zdump"
|
||||||
|
mkdir -p ${DST_CMD}/zdump
|
||||||
|
cp ${SRC_CMD}/zdump/*.c ${DST_CMD}/zdump/
|
||||||
|
|
||||||
|
echo "* zfs/zcmd/zinject"
|
||||||
|
mkdir -p ${DST_CMD}/zinject
|
||||||
|
cp ${SRC_CMD}/zinject/*.c ${DST_CMD}/zinject/
|
||||||
|
cp ${SRC_CMD}/zinject/*.h ${DST_CMD}/zinject/
|
||||||
|
|
||||||
|
echo "* zfs/zcmd/ztest"
|
||||||
|
mkdir -p ${DST_CMD}/ztest
|
||||||
|
cp ${SRC_CMD}/ztest/*.c ${DST_CMD}/ztest/
|
||||||
|
|
||||||
|
rm -Rf ${SRC}
|
||||||
|
|
|
@ -19,11 +19,11 @@
|
||||||
* CDDL HEADER END
|
* CDDL HEADER END
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
|
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
||||||
* Use is subject to license terms.
|
* Use is subject to license terms.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#pragma ident "%Z%%M% %I% %E% SMI"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -808,6 +808,64 @@ avl_remove(avl_tree_t *tree, void *data)
|
||||||
} while (parent != NULL);
|
} while (parent != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define AVL_REINSERT(tree, obj) \
|
||||||
|
avl_remove((tree), (obj)); \
|
||||||
|
avl_add((tree), (obj))
|
||||||
|
|
||||||
|
boolean_t
|
||||||
|
avl_update_lt(avl_tree_t *t, void *obj)
|
||||||
|
{
|
||||||
|
void *neighbor;
|
||||||
|
|
||||||
|
ASSERT(((neighbor = AVL_NEXT(t, obj)) == NULL) ||
|
||||||
|
(t->avl_compar(obj, neighbor) <= 0));
|
||||||
|
|
||||||
|
neighbor = AVL_PREV(t, obj);
|
||||||
|
if ((neighbor != NULL) && (t->avl_compar(obj, neighbor) < 0)) {
|
||||||
|
AVL_REINSERT(t, obj);
|
||||||
|
return (B_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (B_FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean_t
|
||||||
|
avl_update_gt(avl_tree_t *t, void *obj)
|
||||||
|
{
|
||||||
|
void *neighbor;
|
||||||
|
|
||||||
|
ASSERT(((neighbor = AVL_PREV(t, obj)) == NULL) ||
|
||||||
|
(t->avl_compar(obj, neighbor) >= 0));
|
||||||
|
|
||||||
|
neighbor = AVL_NEXT(t, obj);
|
||||||
|
if ((neighbor != NULL) && (t->avl_compar(obj, neighbor) > 0)) {
|
||||||
|
AVL_REINSERT(t, obj);
|
||||||
|
return (B_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (B_FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean_t
|
||||||
|
avl_update(avl_tree_t *t, void *obj)
|
||||||
|
{
|
||||||
|
void *neighbor;
|
||||||
|
|
||||||
|
neighbor = AVL_PREV(t, obj);
|
||||||
|
if ((neighbor != NULL) && (t->avl_compar(obj, neighbor) < 0)) {
|
||||||
|
AVL_REINSERT(t, obj);
|
||||||
|
return (B_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
neighbor = AVL_NEXT(t, obj);
|
||||||
|
if ((neighbor != NULL) && (t->avl_compar(obj, neighbor) > 0)) {
|
||||||
|
AVL_REINSERT(t, obj);
|
||||||
|
return (B_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (B_FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* initialize a new AVL tree
|
* initialize a new AVL tree
|
||||||
*/
|
*/
|
||||||
|
@ -853,6 +911,12 @@ avl_numnodes(avl_tree_t *tree)
|
||||||
return (tree->avl_numnodes);
|
return (tree->avl_numnodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean_t
|
||||||
|
avl_is_empty(avl_tree_t *tree)
|
||||||
|
{
|
||||||
|
ASSERT(tree);
|
||||||
|
return (tree->avl_numnodes == 0);
|
||||||
|
}
|
||||||
|
|
||||||
#define CHILDBIT (1L)
|
#define CHILDBIT (1L)
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,8 @@
|
||||||
* CDDL HEADER START
|
* CDDL HEADER START
|
||||||
*
|
*
|
||||||
* The contents of this file are subject to the terms of the
|
* The contents of this file are subject to the terms of the
|
||||||
* Common Development and Distribution License, Version 1.0 only
|
* Common Development and Distribution License (the "License").
|
||||||
* (the "License"). You may not use this file except in compliance
|
* You may not use this file except in compliance with the License.
|
||||||
* with the License.
|
|
||||||
*
|
*
|
||||||
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
||||||
* or http://www.opensolaris.org/os/licensing.
|
* or http://www.opensolaris.org/os/licensing.
|
||||||
|
@ -20,14 +19,14 @@
|
||||||
* CDDL HEADER END
|
* CDDL HEADER END
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
|
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
||||||
* Use is subject to license terms.
|
* Use is subject to license terms.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _AVL_H
|
#ifndef _AVL_H
|
||||||
#define _AVL_H
|
#define _AVL_H
|
||||||
|
|
||||||
|
#pragma ident "%Z%%M% %I% %E% SMI"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is a private header file. Applications should not directly include
|
* This is a private header file. Applications should not directly include
|
||||||
|
@ -38,6 +37,7 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
#include <sys/avl_impl.h>
|
#include <sys/avl_impl.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -128,7 +128,6 @@ typedef uintptr_t avl_index_t;
|
||||||
#define AVL_AFTER (1)
|
#define AVL_AFTER (1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prototypes
|
* Prototypes
|
||||||
*
|
*
|
||||||
|
@ -251,12 +250,26 @@ extern void avl_add(avl_tree_t *tree, void *node);
|
||||||
*/
|
*/
|
||||||
extern void avl_remove(avl_tree_t *tree, void *node);
|
extern void avl_remove(avl_tree_t *tree, void *node);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Reinsert a node only if its order has changed relative to its nearest
|
||||||
|
* neighbors. To optimize performance avl_update_lt() checks only the previous
|
||||||
|
* node and avl_update_gt() checks only the next node. Use avl_update_lt() and
|
||||||
|
* avl_update_gt() only if you know the direction in which the order of the
|
||||||
|
* node may change.
|
||||||
|
*/
|
||||||
|
extern boolean_t avl_update(avl_tree_t *, void *);
|
||||||
|
extern boolean_t avl_update_lt(avl_tree_t *, void *);
|
||||||
|
extern boolean_t avl_update_gt(avl_tree_t *, void *);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return the number of nodes in the tree
|
* Return the number of nodes in the tree
|
||||||
*/
|
*/
|
||||||
extern ulong_t avl_numnodes(avl_tree_t *tree);
|
extern ulong_t avl_numnodes(avl_tree_t *tree);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return B_TRUE if there are zero nodes in the tree, B_FALSE otherwise.
|
||||||
|
*/
|
||||||
|
extern boolean_t avl_is_empty(avl_tree_t *tree);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Used to destroy any remaining nodes in a tree. The cookie argument should
|
* Used to destroy any remaining nodes in a tree. The cookie argument should
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#ifndef _AVL_IMPL_H
|
#ifndef _AVL_IMPL_H
|
||||||
#define _AVL_IMPL_H
|
#define _AVL_IMPL_H
|
||||||
|
|
||||||
|
#pragma ident "%Z%%M% %I% %E% SMI"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is a private header file. Applications should not directly include
|
* This is a private header file. Applications should not directly include
|
||||||
|
|
|
@ -1,263 +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 2008 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <ftw.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/un.h>
|
|
||||||
#include <sys/debug.h>
|
|
||||||
|
|
||||||
#include <sys/dmu_ctl.h>
|
|
||||||
#include <sys/dmu_ctl_impl.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Try to connect to the socket given in path.
|
|
||||||
*
|
|
||||||
* For nftw() convenience, returns 0 if unsuccessful, otherwise
|
|
||||||
* returns the socket descriptor.
|
|
||||||
*/
|
|
||||||
static int try_connect(const char *path)
|
|
||||||
{
|
|
||||||
struct sockaddr_un name;
|
|
||||||
int sock;
|
|
||||||
|
|
||||||
sock = socket(PF_UNIX, SOCK_STREAM, 0);
|
|
||||||
if (sock == -1) {
|
|
||||||
perror("socket");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The socket fd cannot be 0 otherwise nftw() will not interpret the
|
|
||||||
* return code correctly.
|
|
||||||
*/
|
|
||||||
VERIFY(sock != 0);
|
|
||||||
|
|
||||||
name.sun_family = AF_UNIX;
|
|
||||||
strncpy(name.sun_path, path, sizeof(name.sun_path));
|
|
||||||
|
|
||||||
name.sun_path[sizeof(name.sun_path) - 1] = '\0';
|
|
||||||
|
|
||||||
if (connect(sock, (struct sockaddr *) &name, sizeof(name)) == -1) {
|
|
||||||
close(sock);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return sock;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* nftw() callback.
|
|
||||||
*/
|
|
||||||
static int nftw_cb(const char *fpath, const struct stat *sb, int typeflag,
|
|
||||||
struct FTW *ftwbuf)
|
|
||||||
{
|
|
||||||
if (!S_ISSOCK(sb->st_mode))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (strcmp(&fpath[ftwbuf->base], SOCKNAME) != 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return try_connect(fpath);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* For convenience, if check_subdirs is true we walk the directory tree to
|
|
||||||
* find a good socket.
|
|
||||||
*/
|
|
||||||
int dctlc_connect(const char *dir, boolean_t check_subdirs)
|
|
||||||
{
|
|
||||||
char *fpath;
|
|
||||||
int fd;
|
|
||||||
|
|
||||||
if (check_subdirs)
|
|
||||||
fd = nftw(dir, nftw_cb, 10, FTW_PHYS);
|
|
||||||
else {
|
|
||||||
fpath = malloc(strlen(dir) + strlen(SOCKNAME) + 2);
|
|
||||||
if (fpath == NULL)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
strcpy(fpath, dir);
|
|
||||||
strcat(fpath, "/" SOCKNAME);
|
|
||||||
|
|
||||||
fd = try_connect(fpath);
|
|
||||||
|
|
||||||
free(fpath);
|
|
||||||
}
|
|
||||||
|
|
||||||
return fd == 0 ? -1 : fd;
|
|
||||||
}
|
|
||||||
|
|
||||||
void dctlc_disconnect(int fd)
|
|
||||||
{
|
|
||||||
(void) shutdown(fd, SHUT_RDWR);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dctl_reply_copyin(int fd, dctl_cmd_t *cmd)
|
|
||||||
{
|
|
||||||
return dctl_send_data(fd, (void *)(uintptr_t) cmd->u.dcmd_copy.ptr,
|
|
||||||
cmd->u.dcmd_copy.size);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dctl_reply_copyinstr(int fd, dctl_cmd_t *cmd)
|
|
||||||
{
|
|
||||||
dctl_cmd_t reply;
|
|
||||||
char *from;
|
|
||||||
size_t len, buflen, to_copy;
|
|
||||||
int error;
|
|
||||||
|
|
||||||
reply.dcmd_msg = DCTL_GEN_REPLY;
|
|
||||||
|
|
||||||
from = (char *)(uintptr_t) cmd->u.dcmd_copy.ptr;
|
|
||||||
|
|
||||||
buflen = cmd->u.dcmd_copy.size;
|
|
||||||
to_copy = strnlen(from, buflen - 1);
|
|
||||||
|
|
||||||
reply.u.dcmd_reply.rc = from[to_copy] == '\0' ? 0 : ENAMETOOLONG;
|
|
||||||
reply.u.dcmd_reply.size = to_copy;
|
|
||||||
|
|
||||||
error = dctl_send_msg(fd, &reply);
|
|
||||||
|
|
||||||
if (!error && to_copy > 0)
|
|
||||||
error = dctl_send_data(fd, from, to_copy);
|
|
||||||
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dctl_reply_copyout(int fd, dctl_cmd_t *cmd)
|
|
||||||
{
|
|
||||||
return dctl_read_data(fd, (void *)(uintptr_t) cmd->u.dcmd_copy.ptr,
|
|
||||||
cmd->u.dcmd_copy.size);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dctl_reply_fd_read(int fd, dctl_cmd_t *cmd)
|
|
||||||
{
|
|
||||||
dctl_cmd_t reply;
|
|
||||||
void *buf;
|
|
||||||
int error;
|
|
||||||
ssize_t rrc, size = cmd->u.dcmd_fd_io.size;
|
|
||||||
|
|
||||||
buf = malloc(size);
|
|
||||||
if (buf == NULL)
|
|
||||||
return ENOMEM;
|
|
||||||
|
|
||||||
rrc = read(cmd->u.dcmd_fd_io.fd, buf, size);
|
|
||||||
|
|
||||||
reply.dcmd_msg = DCTL_GEN_REPLY;
|
|
||||||
reply.u.dcmd_reply.rc = rrc == -1 ? errno : 0;
|
|
||||||
reply.u.dcmd_reply.size = rrc;
|
|
||||||
|
|
||||||
error = dctl_send_msg(fd, &reply);
|
|
||||||
|
|
||||||
if (!error && rrc > 0)
|
|
||||||
error = dctl_send_data(fd, buf, rrc);
|
|
||||||
|
|
||||||
out:
|
|
||||||
free(buf);
|
|
||||||
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dctl_reply_fd_write(int fd, dctl_cmd_t *cmd)
|
|
||||||
{
|
|
||||||
dctl_cmd_t reply;
|
|
||||||
void *buf;
|
|
||||||
int error;
|
|
||||||
ssize_t wrc, size = cmd->u.dcmd_fd_io.size;
|
|
||||||
|
|
||||||
buf = malloc(size);
|
|
||||||
if (buf == NULL)
|
|
||||||
return ENOMEM;
|
|
||||||
|
|
||||||
error = dctl_read_data(fd, buf, size);
|
|
||||||
if (error)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
wrc = write(cmd->u.dcmd_fd_io.fd, buf, size);
|
|
||||||
|
|
||||||
reply.dcmd_msg = DCTL_GEN_REPLY;
|
|
||||||
reply.u.dcmd_reply.rc = wrc == -1 ? errno : 0;
|
|
||||||
reply.u.dcmd_reply.size = wrc;
|
|
||||||
|
|
||||||
error = dctl_send_msg(fd, &reply);
|
|
||||||
|
|
||||||
out:
|
|
||||||
free(buf);
|
|
||||||
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int dctlc_ioctl(int fd, int32_t request, void *arg)
|
|
||||||
{
|
|
||||||
int error;
|
|
||||||
dctl_cmd_t cmd;
|
|
||||||
|
|
||||||
ASSERT(fd != 0);
|
|
||||||
|
|
||||||
cmd.dcmd_msg = DCTL_IOCTL;
|
|
||||||
|
|
||||||
cmd.u.dcmd_ioctl.cmd = request;
|
|
||||||
cmd.u.dcmd_ioctl.arg = (uintptr_t) arg;
|
|
||||||
|
|
||||||
error = dctl_send_msg(fd, &cmd);
|
|
||||||
|
|
||||||
while (!error && (error = dctl_read_msg(fd, &cmd)) == 0) {
|
|
||||||
switch (cmd.dcmd_msg) {
|
|
||||||
case DCTL_IOCTL_REPLY:
|
|
||||||
error = cmd.u.dcmd_reply.rc;
|
|
||||||
goto out;
|
|
||||||
case DCTL_COPYIN:
|
|
||||||
error = dctl_reply_copyin(fd, &cmd);
|
|
||||||
break;
|
|
||||||
case DCTL_COPYINSTR:
|
|
||||||
error = dctl_reply_copyinstr(fd, &cmd);
|
|
||||||
break;
|
|
||||||
case DCTL_COPYOUT:
|
|
||||||
error = dctl_reply_copyout(fd, &cmd);
|
|
||||||
break;
|
|
||||||
case DCTL_FD_READ:
|
|
||||||
error = dctl_reply_fd_read(fd, &cmd);
|
|
||||||
break;
|
|
||||||
case DCTL_FD_WRITE:
|
|
||||||
error = dctl_reply_fd_write(fd, &cmd);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
fprintf(stderr, "%s(): invalid message "
|
|
||||||
"received.\n", __func__);
|
|
||||||
error = EINVAL;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
out:
|
|
||||||
errno = error;
|
|
||||||
return error ? -1 : 0;
|
|
||||||
}
|
|
|
@ -1,109 +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 2008 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
|
|
||||||
#include <sys/dmu_ctl.h>
|
|
||||||
#include <sys/dmu_ctl_impl.h>
|
|
||||||
|
|
||||||
int dctl_read_msg(int fd, dctl_cmd_t *cmd)
|
|
||||||
{
|
|
||||||
int error;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* First, read only the magic number and the protocol version.
|
|
||||||
*
|
|
||||||
* This prevents blocking forever in case the size of dctl_cmd_t
|
|
||||||
* shrinks in future protocol versions.
|
|
||||||
*/
|
|
||||||
error = dctl_read_data(fd, cmd, DCTL_CMD_HEADER_SIZE);
|
|
||||||
|
|
||||||
if (!error &&cmd->dcmd_magic != DCTL_MAGIC) {
|
|
||||||
fprintf(stderr, "%s(): invalid magic number\n", __func__);
|
|
||||||
error = EIO;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!error && cmd->dcmd_version != DCTL_PROTOCOL_VER) {
|
|
||||||
fprintf(stderr, "%s(): invalid protocol version\n", __func__);
|
|
||||||
error = ENOTSUP;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (error)
|
|
||||||
return error;
|
|
||||||
|
|
||||||
/* Get the rest of the command */
|
|
||||||
return dctl_read_data(fd, (caddr_t) cmd + DCTL_CMD_HEADER_SIZE,
|
|
||||||
sizeof(dctl_cmd_t) - DCTL_CMD_HEADER_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
int dctl_send_msg(int fd, dctl_cmd_t *cmd)
|
|
||||||
{
|
|
||||||
cmd->dcmd_magic = DCTL_MAGIC;
|
|
||||||
cmd->dcmd_version = DCTL_PROTOCOL_VER;
|
|
||||||
|
|
||||||
return dctl_send_data(fd, cmd, sizeof(dctl_cmd_t));
|
|
||||||
}
|
|
||||||
|
|
||||||
int dctl_read_data(int fd, void *ptr, size_t size)
|
|
||||||
{
|
|
||||||
size_t read = 0;
|
|
||||||
size_t left = size;
|
|
||||||
ssize_t rc;
|
|
||||||
|
|
||||||
while (left > 0) {
|
|
||||||
rc = recv(fd, (caddr_t) ptr + read, left, 0);
|
|
||||||
|
|
||||||
/* File descriptor closed */
|
|
||||||
if (rc == 0)
|
|
||||||
return ECONNRESET;
|
|
||||||
|
|
||||||
if (rc == -1) {
|
|
||||||
if (errno == EINTR)
|
|
||||||
continue;
|
|
||||||
return errno;
|
|
||||||
}
|
|
||||||
|
|
||||||
read += rc;
|
|
||||||
left -= rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int dctl_send_data(int fd, const void *ptr, size_t size)
|
|
||||||
{
|
|
||||||
ssize_t rc;
|
|
||||||
|
|
||||||
do {
|
|
||||||
rc = send(fd, ptr, size, MSG_NOSIGNAL);
|
|
||||||
} while(rc == -1 && errno == EINTR);
|
|
||||||
|
|
||||||
return rc == size ? 0 : EIO;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,476 +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 2008 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <limits.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <poll.h>
|
|
||||||
#include <pthread.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/debug.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/un.h>
|
|
||||||
#include <sys/list.h>
|
|
||||||
#include <sys/cred.h>
|
|
||||||
|
|
||||||
#include <sys/dmu_ctl.h>
|
|
||||||
#include <sys/dmu_ctl_impl.h>
|
|
||||||
|
|
||||||
static dctl_sock_info_t ctl_sock = {
|
|
||||||
.dsi_mtx = PTHREAD_MUTEX_INITIALIZER,
|
|
||||||
.dsi_fd = -1
|
|
||||||
};
|
|
||||||
|
|
||||||
static int dctl_create_socket_common();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Routines from zfs_ioctl.c
|
|
||||||
*/
|
|
||||||
extern int zfs_ioctl_init();
|
|
||||||
extern int zfs_ioctl_fini();
|
|
||||||
extern int zfsdev_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr,
|
|
||||||
int *rvalp);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We can't simply put the client file descriptor in wthr_info_t because we
|
|
||||||
* have no way of accessing it from the DMU code without extensive
|
|
||||||
* modifications.
|
|
||||||
*
|
|
||||||
* Therefore each worker thread will have it's own global thread-specific
|
|
||||||
* client_fd variable.
|
|
||||||
*/
|
|
||||||
static __thread int client_fd = -1;
|
|
||||||
|
|
||||||
int dctls_copyin(const void *src, void *dest, size_t size)
|
|
||||||
{
|
|
||||||
dctl_cmd_t cmd;
|
|
||||||
|
|
||||||
VERIFY(client_fd >= 0);
|
|
||||||
|
|
||||||
cmd.dcmd_msg = DCTL_COPYIN;
|
|
||||||
cmd.u.dcmd_copy.ptr = (uintptr_t) src;
|
|
||||||
cmd.u.dcmd_copy.size = size;
|
|
||||||
|
|
||||||
if (dctl_send_msg(client_fd, &cmd) != 0)
|
|
||||||
return EFAULT;
|
|
||||||
|
|
||||||
if (dctl_read_data(client_fd, dest, size) != 0)
|
|
||||||
return EFAULT;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int dctls_copyinstr(const char *from, char *to, size_t max, size_t *len)
|
|
||||||
{
|
|
||||||
dctl_cmd_t msg;
|
|
||||||
size_t copied;
|
|
||||||
|
|
||||||
VERIFY(client_fd >= 0);
|
|
||||||
|
|
||||||
if (max == 0)
|
|
||||||
return ENAMETOOLONG;
|
|
||||||
if (max < 0)
|
|
||||||
return EFAULT;
|
|
||||||
|
|
||||||
msg.dcmd_msg = DCTL_COPYINSTR;
|
|
||||||
msg.u.dcmd_copy.ptr = (uintptr_t) from;
|
|
||||||
msg.u.dcmd_copy.size = max;
|
|
||||||
|
|
||||||
if (dctl_send_msg(client_fd, &msg) != 0)
|
|
||||||
return EFAULT;
|
|
||||||
|
|
||||||
if (dctl_read_msg(client_fd, &msg) != 0)
|
|
||||||
return EFAULT;
|
|
||||||
|
|
||||||
if (msg.dcmd_msg != DCTL_GEN_REPLY)
|
|
||||||
return EFAULT;
|
|
||||||
|
|
||||||
copied = msg.u.dcmd_reply.size;
|
|
||||||
|
|
||||||
if (copied >= max)
|
|
||||||
return EFAULT;
|
|
||||||
|
|
||||||
if (copied > 0)
|
|
||||||
if (dctl_read_data(client_fd, to, copied) != 0)
|
|
||||||
return EFAULT;
|
|
||||||
|
|
||||||
to[copied] = '\0';
|
|
||||||
|
|
||||||
if (len != NULL)
|
|
||||||
*len = copied + 1;
|
|
||||||
|
|
||||||
return msg.u.dcmd_reply.rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
int dctls_copyout(const void *src, void *dest, size_t size)
|
|
||||||
{
|
|
||||||
dctl_cmd_t cmd;
|
|
||||||
|
|
||||||
VERIFY(client_fd >= 0);
|
|
||||||
|
|
||||||
cmd.dcmd_msg = DCTL_COPYOUT;
|
|
||||||
cmd.u.dcmd_copy.ptr = (uintptr_t) dest;
|
|
||||||
cmd.u.dcmd_copy.size = size;
|
|
||||||
|
|
||||||
if (dctl_send_msg(client_fd, &cmd) != 0)
|
|
||||||
return EFAULT;
|
|
||||||
|
|
||||||
if (dctl_send_data(client_fd, src, size) != 0)
|
|
||||||
return EFAULT;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int dctls_fd_read(int fd, void *buf, ssize_t len, ssize_t *residp)
|
|
||||||
{
|
|
||||||
dctl_cmd_t msg;
|
|
||||||
uint64_t dsize;
|
|
||||||
int error;
|
|
||||||
|
|
||||||
VERIFY(client_fd >= 0);
|
|
||||||
|
|
||||||
msg.dcmd_msg = DCTL_FD_READ;
|
|
||||||
msg.u.dcmd_fd_io.fd = fd;
|
|
||||||
msg.u.dcmd_fd_io.size = len;
|
|
||||||
|
|
||||||
if ((error = dctl_send_msg(client_fd, &msg)) != 0)
|
|
||||||
return error;
|
|
||||||
|
|
||||||
if ((error = dctl_read_msg(client_fd, &msg)) != 0)
|
|
||||||
return error;
|
|
||||||
|
|
||||||
if (msg.dcmd_msg != DCTL_GEN_REPLY)
|
|
||||||
return EIO;
|
|
||||||
|
|
||||||
if (msg.u.dcmd_reply.rc != 0)
|
|
||||||
return msg.u.dcmd_reply.rc;
|
|
||||||
|
|
||||||
dsize = msg.u.dcmd_reply.size;
|
|
||||||
|
|
||||||
if (dsize > 0)
|
|
||||||
error = dctl_read_data(client_fd, buf, dsize);
|
|
||||||
|
|
||||||
*residp = len - dsize;
|
|
||||||
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int dctls_fd_write(int fd, const void *src, ssize_t len)
|
|
||||||
{
|
|
||||||
dctl_cmd_t msg;
|
|
||||||
int error;
|
|
||||||
|
|
||||||
VERIFY(client_fd >= 0);
|
|
||||||
|
|
||||||
msg.dcmd_msg = DCTL_FD_WRITE;
|
|
||||||
msg.u.dcmd_fd_io.fd = fd;
|
|
||||||
msg.u.dcmd_fd_io.size = len;
|
|
||||||
|
|
||||||
error = dctl_send_msg(client_fd, &msg);
|
|
||||||
|
|
||||||
if (!error)
|
|
||||||
error = dctl_send_data(client_fd, src, len);
|
|
||||||
|
|
||||||
if (!error)
|
|
||||||
error = dctl_read_msg(client_fd, &msg);
|
|
||||||
|
|
||||||
if (error)
|
|
||||||
return error;
|
|
||||||
|
|
||||||
if (msg.dcmd_msg != DCTL_GEN_REPLY)
|
|
||||||
return EIO;
|
|
||||||
|
|
||||||
if (msg.u.dcmd_reply.rc != 0)
|
|
||||||
return msg.u.dcmd_reply.rc;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We have to do this because the original upstream code
|
|
||||||
* does not check if residp == len.
|
|
||||||
*/
|
|
||||||
if (msg.u.dcmd_reply.size != len)
|
|
||||||
return EIO;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Handle a new connection */
|
|
||||||
static void dctl_handle_conn(int sock_fd)
|
|
||||||
{
|
|
||||||
dctl_cmd_t cmd;
|
|
||||||
dev_t dev = { 0 };
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
client_fd = sock_fd;
|
|
||||||
|
|
||||||
while (dctl_read_msg(sock_fd, &cmd) == 0) {
|
|
||||||
if (cmd.dcmd_msg != DCTL_IOCTL) {
|
|
||||||
fprintf(stderr, "%s(): unexpected message type.\n",
|
|
||||||
__func__);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = zfsdev_ioctl(dev, cmd.u.dcmd_ioctl.cmd,
|
|
||||||
(intptr_t) cmd.u.dcmd_ioctl.arg, 0, NULL, NULL);
|
|
||||||
|
|
||||||
cmd.dcmd_msg = DCTL_IOCTL_REPLY;
|
|
||||||
cmd.u.dcmd_reply.rc = rc;
|
|
||||||
|
|
||||||
if (dctl_send_msg(sock_fd, &cmd) != 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
close(sock_fd);
|
|
||||||
|
|
||||||
client_fd = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Main worker thread loop */
|
|
||||||
static void *dctl_thread(void *arg)
|
|
||||||
{
|
|
||||||
wthr_info_t *thr = arg;
|
|
||||||
struct pollfd fds[1];
|
|
||||||
|
|
||||||
fds[0].events = POLLIN;
|
|
||||||
|
|
||||||
pthread_mutex_lock(&ctl_sock.dsi_mtx);
|
|
||||||
|
|
||||||
while (!thr->wthr_exit) {
|
|
||||||
/* Clean-up dead threads */
|
|
||||||
dctl_thr_join();
|
|
||||||
|
|
||||||
/* The file descriptor might change in the thread lifetime */
|
|
||||||
fds[0].fd = ctl_sock.dsi_fd;
|
|
||||||
|
|
||||||
/* Poll socket with 1-second timeout */
|
|
||||||
int rc = poll(fds, 1, 1000);
|
|
||||||
if (rc == 0 || (rc == -1 && errno == EINTR))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* Recheck the exit flag */
|
|
||||||
if (thr->wthr_exit)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (rc == -1) {
|
|
||||||
/* Unknown error, let's try to recreate the socket */
|
|
||||||
close(ctl_sock.dsi_fd);
|
|
||||||
ctl_sock.dsi_fd = -1;
|
|
||||||
|
|
||||||
if (dctl_create_socket_common() != 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
ASSERT(rc == 1);
|
|
||||||
|
|
||||||
short rev = fds[0].revents;
|
|
||||||
if (rev == 0)
|
|
||||||
continue;
|
|
||||||
ASSERT(rev == POLLIN);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* At this point there should be a connection ready to be
|
|
||||||
* accepted.
|
|
||||||
*/
|
|
||||||
int client_fd = accept(ctl_sock.dsi_fd, NULL, NULL);
|
|
||||||
/* Many possible errors here, we'll just retry */
|
|
||||||
if (client_fd == -1)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Now lets handle the request. This can take a very
|
|
||||||
* long time (hours even), so we'll let other threads
|
|
||||||
* handle new connections.
|
|
||||||
*/
|
|
||||||
pthread_mutex_unlock(&ctl_sock.dsi_mtx);
|
|
||||||
|
|
||||||
dctl_thr_rebalance(thr, B_FALSE);
|
|
||||||
dctl_handle_conn(client_fd);
|
|
||||||
dctl_thr_rebalance(thr, B_TRUE);
|
|
||||||
|
|
||||||
pthread_mutex_lock(&ctl_sock.dsi_mtx);
|
|
||||||
}
|
|
||||||
pthread_mutex_unlock(&ctl_sock.dsi_mtx);
|
|
||||||
|
|
||||||
dctl_thr_die(thr);
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dctl_create_socket_common()
|
|
||||||
{
|
|
||||||
dctl_sock_info_t *s = &ctl_sock;
|
|
||||||
size_t size;
|
|
||||||
int error;
|
|
||||||
|
|
||||||
ASSERT(s->dsi_fd == -1);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Unlink old socket, in case it exists.
|
|
||||||
* We don't care about errors here.
|
|
||||||
*/
|
|
||||||
unlink(s->dsi_path);
|
|
||||||
|
|
||||||
/* Create the socket */
|
|
||||||
s->dsi_fd = socket(PF_UNIX, SOCK_STREAM, 0);
|
|
||||||
if (s->dsi_fd == -1) {
|
|
||||||
error = errno;
|
|
||||||
perror("socket");
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
s->dsi_addr.sun_family = AF_UNIX;
|
|
||||||
|
|
||||||
size = sizeof(s->dsi_addr.sun_path) - 1;
|
|
||||||
strncpy(s->dsi_addr.sun_path, s->dsi_path, size);
|
|
||||||
|
|
||||||
s->dsi_addr.sun_path[size] = '\0';
|
|
||||||
|
|
||||||
if (bind(s->dsi_fd, (struct sockaddr *) &s->dsi_addr,
|
|
||||||
sizeof(s->dsi_addr)) != 0) {
|
|
||||||
error = errno;
|
|
||||||
perror("bind");
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (listen(s->dsi_fd, LISTEN_BACKLOG) != 0) {
|
|
||||||
error = errno;
|
|
||||||
perror("listen");
|
|
||||||
unlink(s->dsi_path);
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dctl_create_socket(const char *cfg_dir)
|
|
||||||
{
|
|
||||||
int error;
|
|
||||||
dctl_sock_info_t *s = &ctl_sock;
|
|
||||||
|
|
||||||
ASSERT(s->dsi_path == NULL);
|
|
||||||
ASSERT(s->dsi_fd == -1);
|
|
||||||
|
|
||||||
int pathsize = strlen(cfg_dir) + strlen(SOCKNAME) + 2;
|
|
||||||
if (pathsize > sizeof(s->dsi_addr.sun_path))
|
|
||||||
return ENAMETOOLONG;
|
|
||||||
|
|
||||||
s->dsi_path = malloc(pathsize);
|
|
||||||
if (s->dsi_path == NULL)
|
|
||||||
return ENOMEM;
|
|
||||||
|
|
||||||
strcpy(s->dsi_path, cfg_dir);
|
|
||||||
strcat(s->dsi_path, "/" SOCKNAME);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* For convenience, create the directory in case it doesn't exist.
|
|
||||||
* We don't care about errors here.
|
|
||||||
*/
|
|
||||||
mkdir(cfg_dir, 0770);
|
|
||||||
|
|
||||||
error = dctl_create_socket_common();
|
|
||||||
|
|
||||||
if (error) {
|
|
||||||
free(s->dsi_path);
|
|
||||||
|
|
||||||
if (s->dsi_fd != -1) {
|
|
||||||
close(s->dsi_fd);
|
|
||||||
s->dsi_fd = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void dctl_destroy_socket()
|
|
||||||
{
|
|
||||||
dctl_sock_info_t *s = &ctl_sock;
|
|
||||||
|
|
||||||
ASSERT(s->dsi_path != NULL);
|
|
||||||
ASSERT(s->dsi_fd != -1);
|
|
||||||
|
|
||||||
close(s->dsi_fd);
|
|
||||||
s->dsi_fd = -1;
|
|
||||||
|
|
||||||
unlink(s->dsi_path);
|
|
||||||
free(s->dsi_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialize the DMU userspace control interface.
|
|
||||||
* This should be called after kernel_init().
|
|
||||||
*
|
|
||||||
* Note that only very rarely we have more than a couple of simultaneous
|
|
||||||
* lzfs/lzpool connections. Since the thread pool grows automatically when all
|
|
||||||
* threads are busy, a good value for min_thr and max_free_thr is 2.
|
|
||||||
*/
|
|
||||||
int dctl_server_init(const char *cfg_dir, int min_thr, int max_free_thr)
|
|
||||||
{
|
|
||||||
int error;
|
|
||||||
|
|
||||||
ASSERT(min_thr > 0);
|
|
||||||
ASSERT(max_free_thr >= min_thr);
|
|
||||||
|
|
||||||
error = zfs_ioctl_init();
|
|
||||||
if (error)
|
|
||||||
return error;
|
|
||||||
|
|
||||||
error = dctl_create_socket(cfg_dir);
|
|
||||||
if (error) {
|
|
||||||
(void) zfs_ioctl_fini();
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
error = dctl_thr_pool_create(min_thr, max_free_thr, dctl_thread);
|
|
||||||
if (error) {
|
|
||||||
(void) zfs_ioctl_fini();
|
|
||||||
dctl_destroy_socket();
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Terminate control interface.
|
|
||||||
* This should be called after closing all objsets, but before calling
|
|
||||||
* kernel_fini().
|
|
||||||
* May return EBUSY if the SPA is busy.
|
|
||||||
*
|
|
||||||
* Thread pool destruction can take a while due to poll()
|
|
||||||
* timeout or due to a thread being busy (e.g. a backup is being taken).
|
|
||||||
*/
|
|
||||||
int dctl_server_fini()
|
|
||||||
{
|
|
||||||
dctl_thr_pool_stop();
|
|
||||||
dctl_destroy_socket();
|
|
||||||
|
|
||||||
return zfs_ioctl_fini();
|
|
||||||
}
|
|
|
@ -1,253 +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 2008 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <pthread.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <sys/list.h>
|
|
||||||
#include <sys/debug.h>
|
|
||||||
|
|
||||||
#include <sys/dmu_ctl.h>
|
|
||||||
#include <sys/dmu_ctl_impl.h>
|
|
||||||
|
|
||||||
static dctl_thr_info_t thr_pool = {
|
|
||||||
.dti_mtx = PTHREAD_MUTEX_INITIALIZER
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Create n threads.
|
|
||||||
* Callers must acquire thr_pool.dti_mtx first.
|
|
||||||
*/
|
|
||||||
static int dctl_thr_create(int n)
|
|
||||||
{
|
|
||||||
dctl_thr_info_t *p = &thr_pool;
|
|
||||||
int error;
|
|
||||||
|
|
||||||
for (int i = 0; i < n; i++) {
|
|
||||||
wthr_info_t *thr = malloc(sizeof(wthr_info_t));
|
|
||||||
if (thr == NULL)
|
|
||||||
return ENOMEM;
|
|
||||||
|
|
||||||
thr->wthr_exit = B_FALSE;
|
|
||||||
thr->wthr_free = B_TRUE;
|
|
||||||
|
|
||||||
error = pthread_create(&thr->wthr_id, NULL, p->dti_thr_func,
|
|
||||||
thr);
|
|
||||||
if (error) {
|
|
||||||
free(thr);
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
p->dti_free++;
|
|
||||||
|
|
||||||
list_insert_tail(&p->dti_list, thr);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Mark the thread as dead.
|
|
||||||
* Must be called right before exiting the main thread function.
|
|
||||||
*/
|
|
||||||
void dctl_thr_die(wthr_info_t *thr)
|
|
||||||
{
|
|
||||||
dctl_thr_info_t *p = &thr_pool;
|
|
||||||
|
|
||||||
thr->wthr_exit = B_TRUE;
|
|
||||||
dctl_thr_rebalance(thr, B_FALSE);
|
|
||||||
|
|
||||||
pthread_mutex_lock(&p->dti_mtx);
|
|
||||||
|
|
||||||
list_remove(&p->dti_list, thr);
|
|
||||||
list_insert_tail(&p->dti_join_list, thr);
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&p->dti_mtx);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Clean-up dead threads.
|
|
||||||
*/
|
|
||||||
void dctl_thr_join()
|
|
||||||
{
|
|
||||||
dctl_thr_info_t *p = &thr_pool;
|
|
||||||
wthr_info_t *thr;
|
|
||||||
|
|
||||||
pthread_mutex_lock(&p->dti_mtx);
|
|
||||||
|
|
||||||
while ((thr = list_head(&p->dti_join_list))) {
|
|
||||||
list_remove(&p->dti_join_list, thr);
|
|
||||||
|
|
||||||
ASSERT(!pthread_equal(thr->wthr_id, pthread_self()));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This should not block because all the threads
|
|
||||||
* on this list should have died already.
|
|
||||||
*
|
|
||||||
* pthread_join() can only return an error if
|
|
||||||
* we made a programming mistake.
|
|
||||||
*/
|
|
||||||
VERIFY(pthread_join(thr->wthr_id, NULL) == 0);
|
|
||||||
|
|
||||||
ASSERT(thr->wthr_exit);
|
|
||||||
ASSERT(!thr->wthr_free);
|
|
||||||
|
|
||||||
free(thr);
|
|
||||||
}
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&p->dti_mtx);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Adjust the number of free threads in the pool and the thread status.
|
|
||||||
*
|
|
||||||
* Callers must acquire thr_pool.dti_mtx first.
|
|
||||||
*/
|
|
||||||
static void dctl_thr_adjust_free(wthr_info_t *thr, boolean_t set_free)
|
|
||||||
{
|
|
||||||
dctl_thr_info_t *p = &thr_pool;
|
|
||||||
|
|
||||||
ASSERT(p->dti_free >= 0);
|
|
||||||
|
|
||||||
if (!thr->wthr_free && set_free)
|
|
||||||
p->dti_free++;
|
|
||||||
else if (thr->wthr_free && !set_free)
|
|
||||||
p->dti_free--;
|
|
||||||
|
|
||||||
ASSERT(p->dti_free >= 0);
|
|
||||||
|
|
||||||
thr->wthr_free = set_free;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Rebalance threads. Also adjusts the free status of the thread.
|
|
||||||
* Will set the thread exit flag if the number of free threads is above
|
|
||||||
* the limit.
|
|
||||||
*/
|
|
||||||
void dctl_thr_rebalance(wthr_info_t *thr, boolean_t set_free)
|
|
||||||
{
|
|
||||||
dctl_thr_info_t *p = &thr_pool;
|
|
||||||
|
|
||||||
pthread_mutex_lock(&p->dti_mtx);
|
|
||||||
|
|
||||||
if (p->dti_exit || p->dti_free > p->dti_max_free)
|
|
||||||
thr->wthr_exit = B_TRUE;
|
|
||||||
|
|
||||||
if (thr->wthr_exit)
|
|
||||||
set_free = B_FALSE;
|
|
||||||
|
|
||||||
dctl_thr_adjust_free(thr, set_free);
|
|
||||||
|
|
||||||
if (!p->dti_exit && p->dti_free == 0)
|
|
||||||
dctl_thr_create(1);
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&p->dti_mtx);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Stop the thread pool.
|
|
||||||
*
|
|
||||||
* This can take a while since it actually waits for all threads to exit.
|
|
||||||
*/
|
|
||||||
void dctl_thr_pool_stop()
|
|
||||||
{
|
|
||||||
dctl_thr_info_t *p = &thr_pool;
|
|
||||||
wthr_info_t *thr;
|
|
||||||
struct timespec ts;
|
|
||||||
|
|
||||||
pthread_mutex_lock(&p->dti_mtx);
|
|
||||||
|
|
||||||
ASSERT(!p->dti_exit);
|
|
||||||
p->dti_exit = B_TRUE;
|
|
||||||
|
|
||||||
/* Let's flag the threads first */
|
|
||||||
thr = list_head(&p->dti_list);
|
|
||||||
while (thr != NULL) {
|
|
||||||
thr->wthr_exit = B_TRUE;
|
|
||||||
dctl_thr_adjust_free(thr, B_FALSE);
|
|
||||||
|
|
||||||
thr = list_next(&p->dti_list, thr);
|
|
||||||
}
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&p->dti_mtx);
|
|
||||||
|
|
||||||
/* Now let's wait for them to exit */
|
|
||||||
ts.tv_sec = 0;
|
|
||||||
ts.tv_nsec = 50000000; /* 50ms */
|
|
||||||
do {
|
|
||||||
nanosleep(&ts, NULL);
|
|
||||||
|
|
||||||
pthread_mutex_lock(&p->dti_mtx);
|
|
||||||
thr = list_head(&p->dti_list);
|
|
||||||
pthread_mutex_unlock(&p->dti_mtx);
|
|
||||||
|
|
||||||
dctl_thr_join();
|
|
||||||
} while(thr != NULL);
|
|
||||||
|
|
||||||
ASSERT(p->dti_free == 0);
|
|
||||||
|
|
||||||
ASSERT(list_is_empty(&p->dti_list));
|
|
||||||
ASSERT(list_is_empty(&p->dti_join_list));
|
|
||||||
|
|
||||||
list_destroy(&p->dti_list);
|
|
||||||
list_destroy(&p->dti_join_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Create thread pool.
|
|
||||||
*
|
|
||||||
* If at least one thread creation fails, it will stop all previous
|
|
||||||
* threads and return a non-zero value.
|
|
||||||
*/
|
|
||||||
int dctl_thr_pool_create(int min_thr, int max_free_thr,
|
|
||||||
thr_func_t *thr_func)
|
|
||||||
{
|
|
||||||
int error;
|
|
||||||
dctl_thr_info_t *p = &thr_pool;
|
|
||||||
|
|
||||||
ASSERT(p->dti_free == 0);
|
|
||||||
|
|
||||||
/* Initialize global variables */
|
|
||||||
p->dti_min = min_thr;
|
|
||||||
p->dti_max_free = max_free_thr;
|
|
||||||
p->dti_exit = B_FALSE;
|
|
||||||
p->dti_thr_func = thr_func;
|
|
||||||
|
|
||||||
list_create(&p->dti_list, sizeof(wthr_info_t), offsetof(wthr_info_t,
|
|
||||||
wthr_node));
|
|
||||||
list_create(&p->dti_join_list, sizeof(wthr_info_t),
|
|
||||||
offsetof(wthr_info_t, wthr_node));
|
|
||||||
|
|
||||||
pthread_mutex_lock(&p->dti_mtx);
|
|
||||||
error = dctl_thr_create(min_thr);
|
|
||||||
pthread_mutex_unlock(&p->dti_mtx);
|
|
||||||
|
|
||||||
if (error)
|
|
||||||
dctl_thr_pool_stop();
|
|
||||||
|
|
||||||
return error;
|
|
||||||
}
|
|
|
@ -1,71 +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 2008 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SYS_DMU_CTL_H
|
|
||||||
#define _SYS_DMU_CTL_H
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
/* Default directory where the clients search for sockets to connect */
|
|
||||||
#define DMU_CTL_DEFAULT_DIR "/var/run/zfs/udmu"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* These functions are called by the server process.
|
|
||||||
*
|
|
||||||
* kernel_init() must be called before dctl_server_init().
|
|
||||||
* kernel_fini() must not be called before dctl_server_fini().
|
|
||||||
*
|
|
||||||
* All objsets must be closed and object references be released before calling
|
|
||||||
* dctl_server_fini(), otherwise it will return EBUSY.
|
|
||||||
*
|
|
||||||
* Note: On Solaris, it is highly recommended to either catch or ignore the
|
|
||||||
* SIGPIPE signal, otherwise the server process will die if the client is
|
|
||||||
* killed.
|
|
||||||
*/
|
|
||||||
int dctl_server_init(const char *cfg_dir, int min_threads,
|
|
||||||
int max_free_threads);
|
|
||||||
int dctl_server_fini();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The following functions are called by the DMU from the server process context
|
|
||||||
* (in the worker threads).
|
|
||||||
*/
|
|
||||||
int dctls_copyin(const void *src, void *dest, size_t size);
|
|
||||||
int dctls_copyinstr(const char *from, char *to, size_t max,
|
|
||||||
size_t *len);
|
|
||||||
int dctls_copyout(const void *src, void *dest, size_t size);
|
|
||||||
int dctls_fd_read(int fd, void *buf, ssize_t len, ssize_t *residp);
|
|
||||||
int dctls_fd_write(int fd, const void *src, ssize_t len);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* These functions are called by the client process (libzfs).
|
|
||||||
*/
|
|
||||||
int dctlc_connect(const char *dir, boolean_t check_subdirs);
|
|
||||||
void dctlc_disconnect(int fd);
|
|
||||||
|
|
||||||
int dctlc_ioctl(int fd, int32_t request, void *arg);
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,144 +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 2008 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SYS_DMU_CTL_IMPL_H
|
|
||||||
#define _SYS_DMU_CTL_IMPL_H
|
|
||||||
|
|
||||||
#include <sys/list.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/un.h>
|
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
#define SOCKNAME "dmu_socket"
|
|
||||||
|
|
||||||
#define DCTL_PROTOCOL_VER 1
|
|
||||||
#define DCTL_MAGIC 0xdc71b1070c01dc71ll
|
|
||||||
|
|
||||||
/* Message types */
|
|
||||||
enum {
|
|
||||||
DCTL_IOCTL,
|
|
||||||
DCTL_IOCTL_REPLY,
|
|
||||||
DCTL_COPYIN,
|
|
||||||
DCTL_COPYINSTR,
|
|
||||||
DCTL_COPYOUT,
|
|
||||||
DCTL_FD_READ,
|
|
||||||
DCTL_FD_WRITE,
|
|
||||||
DCTL_GEN_REPLY /* generic reply */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* On-the-wire message */
|
|
||||||
typedef struct dctl_cmd {
|
|
||||||
uint64_t dcmd_magic;
|
|
||||||
int8_t dcmd_version;
|
|
||||||
int8_t dcmd_msg;
|
|
||||||
uint8_t dcmd_pad[6];
|
|
||||||
union {
|
|
||||||
struct dcmd_ioctl {
|
|
||||||
uint64_t arg;
|
|
||||||
int32_t cmd;
|
|
||||||
uint8_t pad[4];
|
|
||||||
} dcmd_ioctl;
|
|
||||||
|
|
||||||
struct dcmd_copy_req {
|
|
||||||
uint64_t ptr;
|
|
||||||
uint64_t size;
|
|
||||||
} dcmd_copy;
|
|
||||||
|
|
||||||
struct dcmd_fd_req {
|
|
||||||
int64_t size;
|
|
||||||
int32_t fd;
|
|
||||||
uint8_t pad[4];
|
|
||||||
} dcmd_fd_io;
|
|
||||||
|
|
||||||
struct dcmd_reply {
|
|
||||||
uint64_t size; /* used by reply to DCTL_COPYINSTR,
|
|
||||||
DCTL_FD_READ and DCTL_FD_WRITE */
|
|
||||||
int32_t rc; /* return code */
|
|
||||||
uint8_t pad[4];
|
|
||||||
} dcmd_reply;
|
|
||||||
} u;
|
|
||||||
} dctl_cmd_t;
|
|
||||||
|
|
||||||
#define DCTL_CMD_HEADER_SIZE (sizeof(uint64_t) + sizeof(uint8_t))
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The following definitions are only used by the server code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define LISTEN_BACKLOG 5
|
|
||||||
|
|
||||||
/* Worker thread data */
|
|
||||||
typedef struct wthr_info {
|
|
||||||
list_node_t wthr_node;
|
|
||||||
pthread_t wthr_id;
|
|
||||||
boolean_t wthr_exit; /* termination flag */
|
|
||||||
boolean_t wthr_free;
|
|
||||||
} wthr_info_t;
|
|
||||||
|
|
||||||
/* Control socket data */
|
|
||||||
typedef struct dctl_sock_info {
|
|
||||||
pthread_mutex_t dsi_mtx;
|
|
||||||
char *dsi_path;
|
|
||||||
struct sockaddr_un dsi_addr;
|
|
||||||
int dsi_fd;
|
|
||||||
} dctl_sock_info_t;
|
|
||||||
|
|
||||||
typedef void *thr_func_t(void *);
|
|
||||||
|
|
||||||
/* Thread pool data */
|
|
||||||
typedef struct dctl_thr_info {
|
|
||||||
thr_func_t *dti_thr_func;
|
|
||||||
|
|
||||||
pthread_mutex_t dti_mtx; /* protects the thread lists and dti_free */
|
|
||||||
list_t dti_list; /* list of threads in the thread pool */
|
|
||||||
list_t dti_join_list; /* list of threads that are waiting to be
|
|
||||||
joined */
|
|
||||||
int dti_free; /* number of free worker threads */
|
|
||||||
|
|
||||||
int dti_min;
|
|
||||||
int dti_max_free;
|
|
||||||
|
|
||||||
boolean_t dti_exit; /* global termination flag */
|
|
||||||
} dctl_thr_info_t;
|
|
||||||
|
|
||||||
/* Messaging functions functions */
|
|
||||||
int dctl_read_msg(int fd, dctl_cmd_t *cmd);
|
|
||||||
int dctl_send_msg(int fd, dctl_cmd_t *cmd);
|
|
||||||
|
|
||||||
int dctl_read_data(int fd, void *ptr, size_t size);
|
|
||||||
int dctl_send_data(int fd, const void *ptr, size_t size);
|
|
||||||
|
|
||||||
/* Thread pool functions */
|
|
||||||
int dctl_thr_pool_create(int min_thr, int max_free_thr,
|
|
||||||
thr_func_t *thr_func);
|
|
||||||
void dctl_thr_pool_stop();
|
|
||||||
|
|
||||||
void dctl_thr_join();
|
|
||||||
void dctl_thr_die(wthr_info_t *thr);
|
|
||||||
void dctl_thr_rebalance(wthr_info_t *thr, boolean_t set_free);
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -2,9 +2,8 @@
|
||||||
* CDDL HEADER START
|
* CDDL HEADER START
|
||||||
*
|
*
|
||||||
* The contents of this file are subject to the terms of the
|
* The contents of this file are subject to the terms of the
|
||||||
* Common Development and Distribution License, Version 1.0 only
|
* Common Development and Distribution License (the "License").
|
||||||
* (the "License"). You may not use this file except in compliance
|
* You may not use this file except in compliance with the License.
|
||||||
* with the License.
|
|
||||||
*
|
*
|
||||||
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
||||||
* or http://www.opensolaris.org/os/licensing.
|
* or http://www.opensolaris.org/os/licensing.
|
||||||
|
@ -20,24 +19,27 @@
|
||||||
* CDDL HEADER END
|
* CDDL HEADER END
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
|
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
||||||
* Use is subject to license terms.
|
* Use is subject to license terms.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _LIBNVPAIR_H
|
#ifndef _LIBNVPAIR_H
|
||||||
#define _LIBNVPAIR_H
|
#define _LIBNVPAIR_H
|
||||||
|
|
||||||
|
#pragma ident "%Z%%M% %I% %E% SMI"
|
||||||
|
|
||||||
#include <sys/nvpair.h>
|
#include <sys/nvpair.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <regex.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void nvlist_print(FILE *, nvlist_t *);
|
void nvlist_print(FILE *, nvlist_t *);
|
||||||
|
int nvpair_value_match(nvpair_t *, int, char *, char **);
|
||||||
|
int nvpair_value_match_regex(nvpair_t *, int, char *, regex_t *, char **);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,14 +19,14 @@
|
||||||
* CDDL HEADER END
|
* CDDL HEADER END
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
|
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
||||||
* Use is subject to license terms.
|
* Use is subject to license terms.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _SYS_NVPAIR_H
|
#ifndef _SYS_NVPAIR_H
|
||||||
#define _SYS_NVPAIR_H
|
#define _SYS_NVPAIR_H
|
||||||
|
|
||||||
|
#pragma ident "%Z%%M% %I% %E% SMI"
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/errno.h>
|
#include <sys/errno.h>
|
||||||
|
@ -67,7 +67,12 @@ typedef enum {
|
||||||
DATA_TYPE_UINT8,
|
DATA_TYPE_UINT8,
|
||||||
DATA_TYPE_BOOLEAN_ARRAY,
|
DATA_TYPE_BOOLEAN_ARRAY,
|
||||||
DATA_TYPE_INT8_ARRAY,
|
DATA_TYPE_INT8_ARRAY,
|
||||||
|
#if !defined(_KERNEL)
|
||||||
|
DATA_TYPE_UINT8_ARRAY,
|
||||||
|
DATA_TYPE_DOUBLE
|
||||||
|
#else
|
||||||
DATA_TYPE_UINT8_ARRAY
|
DATA_TYPE_UINT8_ARRAY
|
||||||
|
#endif
|
||||||
} data_type_t;
|
} data_type_t;
|
||||||
|
|
||||||
typedef struct nvpair {
|
typedef struct nvpair {
|
||||||
|
@ -188,6 +193,9 @@ int nvlist_add_uint64_array(nvlist_t *, const char *, uint64_t *, uint_t);
|
||||||
int nvlist_add_string_array(nvlist_t *, const char *, char *const *, uint_t);
|
int nvlist_add_string_array(nvlist_t *, const char *, char *const *, uint_t);
|
||||||
int nvlist_add_nvlist_array(nvlist_t *, const char *, nvlist_t **, uint_t);
|
int nvlist_add_nvlist_array(nvlist_t *, const char *, nvlist_t **, uint_t);
|
||||||
int nvlist_add_hrtime(nvlist_t *, const char *, hrtime_t);
|
int nvlist_add_hrtime(nvlist_t *, const char *, hrtime_t);
|
||||||
|
#if !defined(_KERNEL)
|
||||||
|
int nvlist_add_double(nvlist_t *, const char *, double);
|
||||||
|
#endif
|
||||||
|
|
||||||
int nvlist_remove(nvlist_t *, const char *, data_type_t);
|
int nvlist_remove(nvlist_t *, const char *, data_type_t);
|
||||||
int nvlist_remove_all(nvlist_t *, const char *);
|
int nvlist_remove_all(nvlist_t *, const char *);
|
||||||
|
@ -220,15 +228,21 @@ int nvlist_lookup_string_array(nvlist_t *, const char *, char ***, uint_t *);
|
||||||
int nvlist_lookup_nvlist_array(nvlist_t *, const char *,
|
int nvlist_lookup_nvlist_array(nvlist_t *, const char *,
|
||||||
nvlist_t ***, uint_t *);
|
nvlist_t ***, uint_t *);
|
||||||
int nvlist_lookup_hrtime(nvlist_t *, const char *, hrtime_t *);
|
int nvlist_lookup_hrtime(nvlist_t *, const char *, hrtime_t *);
|
||||||
int nvlist_lookup_pairs(nvlist_t *nvl, int, ...);
|
int nvlist_lookup_pairs(nvlist_t *, int, ...);
|
||||||
|
#if !defined(_KERNEL)
|
||||||
|
int nvlist_lookup_double(nvlist_t *, const char *, double *);
|
||||||
|
#endif
|
||||||
|
|
||||||
int nvlist_lookup_nvpair(nvlist_t *nvl, const char *, nvpair_t **);
|
int nvlist_lookup_nvpair(nvlist_t *, const char *, nvpair_t **);
|
||||||
boolean_t nvlist_exists(nvlist_t *nvl, const char *);
|
int nvlist_lookup_nvpair_embedded_index(nvlist_t *, const char *, nvpair_t **,
|
||||||
|
int *, char **);
|
||||||
|
boolean_t nvlist_exists(nvlist_t *, const char *);
|
||||||
|
|
||||||
/* processing nvpair */
|
/* processing nvpair */
|
||||||
nvpair_t *nvlist_next_nvpair(nvlist_t *nvl, nvpair_t *);
|
nvpair_t *nvlist_next_nvpair(nvlist_t *, nvpair_t *);
|
||||||
char *nvpair_name(nvpair_t *);
|
char *nvpair_name(nvpair_t *);
|
||||||
data_type_t nvpair_type(nvpair_t *);
|
data_type_t nvpair_type(nvpair_t *);
|
||||||
|
int nvpair_type_is_array(nvpair_t *);
|
||||||
int nvpair_value_boolean_value(nvpair_t *, boolean_t *);
|
int nvpair_value_boolean_value(nvpair_t *, boolean_t *);
|
||||||
int nvpair_value_byte(nvpair_t *, uchar_t *);
|
int nvpair_value_byte(nvpair_t *, uchar_t *);
|
||||||
int nvpair_value_int8(nvpair_t *, int8_t *);
|
int nvpair_value_int8(nvpair_t *, int8_t *);
|
||||||
|
@ -254,6 +268,9 @@ int nvpair_value_uint64_array(nvpair_t *, uint64_t **, uint_t *);
|
||||||
int nvpair_value_string_array(nvpair_t *, char ***, uint_t *);
|
int nvpair_value_string_array(nvpair_t *, char ***, uint_t *);
|
||||||
int nvpair_value_nvlist_array(nvpair_t *, nvlist_t ***, uint_t *);
|
int nvpair_value_nvlist_array(nvpair_t *, nvlist_t ***, uint_t *);
|
||||||
int nvpair_value_hrtime(nvpair_t *, hrtime_t *);
|
int nvpair_value_hrtime(nvpair_t *, hrtime_t *);
|
||||||
|
#if !defined(_KERNEL)
|
||||||
|
int nvpair_value_double(nvpair_t *, double *);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#ifndef _NVPAIR_IMPL_H
|
#ifndef _NVPAIR_IMPL_H
|
||||||
#define _NVPAIR_IMPL_H
|
#define _NVPAIR_IMPL_H
|
||||||
|
|
||||||
|
#pragma ident "%Z%%M% %I% %E% SMI"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
@ -2,9 +2,8 @@
|
||||||
* CDDL HEADER START
|
* CDDL HEADER START
|
||||||
*
|
*
|
||||||
* The contents of this file are subject to the terms of the
|
* The contents of this file are subject to the terms of the
|
||||||
* Common Development and Distribution License, Version 1.0 only
|
* Common Development and Distribution License (the "License").
|
||||||
* (the "License"). You may not use this file except in compliance
|
* You may not use this file except in compliance with the License.
|
||||||
* with the License.
|
|
||||||
*
|
*
|
||||||
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
||||||
* or http://www.opensolaris.org/os/licensing.
|
* or http://www.opensolaris.org/os/licensing.
|
||||||
|
@ -20,14 +19,16 @@
|
||||||
* CDDL HEADER END
|
* CDDL HEADER END
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
|
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
||||||
* Use is subject to license terms.
|
* Use is subject to license terms.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#pragma ident "%Z%%M% %I% %E% SMI"
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/inttypes.h>
|
||||||
#include "libnvpair.h"
|
#include "libnvpair.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -137,6 +138,12 @@ nvlist_print_with_indent(FILE *fp, nvlist_t *nvl, int depth)
|
||||||
(void) fprintf(fp, " 0x%llx", (u_longlong_t)val);
|
(void) fprintf(fp, " 0x%llx", (u_longlong_t)val);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case DATA_TYPE_DOUBLE: {
|
||||||
|
double val;
|
||||||
|
(void) nvpair_value_double(nvp, &val);
|
||||||
|
(void) fprintf(fp, " 0x%llf", val);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case DATA_TYPE_STRING: {
|
case DATA_TYPE_STRING: {
|
||||||
char *val;
|
char *val;
|
||||||
(void) nvpair_value_string(nvp, &val);
|
(void) nvpair_value_string(nvp, &val);
|
||||||
|
@ -264,3 +271,348 @@ nvlist_print(FILE *fp, nvlist_t *nvl)
|
||||||
{
|
{
|
||||||
nvlist_print_with_indent(fp, nvl, 0);
|
nvlist_print_with_indent(fp, nvl, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Determine if string 'value' matches 'nvp' value. The 'value' string is
|
||||||
|
* converted, depending on the type of 'nvp', prior to match. For numeric
|
||||||
|
* types, a radix independent sscanf conversion of 'value' is used. If 'nvp'
|
||||||
|
* is an array type, 'ai' is the index into the array against which we are
|
||||||
|
* checking for match. If nvp is of DATA_TYPE_STRING*, the caller can pass
|
||||||
|
* in a regex_t compilation of value in 'value_regex' to trigger regular
|
||||||
|
* expression string match instead of simple strcmp().
|
||||||
|
*
|
||||||
|
* Return 1 on match, 0 on no-match, and -1 on error. If the error is
|
||||||
|
* related to value syntax error and 'ep' is non-NULL, *ep will point into
|
||||||
|
* the 'value' string at the location where the error exists.
|
||||||
|
*
|
||||||
|
* NOTE: It may be possible to move the non-regex_t version of this into
|
||||||
|
* common code used by library/kernel/boot.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
nvpair_value_match_regex(nvpair_t *nvp, int ai,
|
||||||
|
char *value, regex_t *value_regex, char **ep)
|
||||||
|
{
|
||||||
|
char *evalue;
|
||||||
|
uint_t a_len;
|
||||||
|
int sr;
|
||||||
|
|
||||||
|
if (ep)
|
||||||
|
*ep = NULL;
|
||||||
|
|
||||||
|
if ((nvp == NULL) || (value == NULL))
|
||||||
|
return (-1); /* error fail match - invalid args */
|
||||||
|
|
||||||
|
/* make sure array and index combination make sense */
|
||||||
|
if ((nvpair_type_is_array(nvp) && (ai < 0)) ||
|
||||||
|
(!nvpair_type_is_array(nvp) && (ai >= 0)))
|
||||||
|
return (-1); /* error fail match - bad index */
|
||||||
|
|
||||||
|
/* non-string values should be single 'chunk' */
|
||||||
|
if ((nvpair_type(nvp) != DATA_TYPE_STRING) &&
|
||||||
|
(nvpair_type(nvp) != DATA_TYPE_STRING_ARRAY)) {
|
||||||
|
value += strspn(value, " \t");
|
||||||
|
evalue = value + strcspn(value, " \t");
|
||||||
|
if (*evalue) {
|
||||||
|
if (ep)
|
||||||
|
*ep = evalue;
|
||||||
|
return (-1); /* error fail match - syntax */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sr = EOF;
|
||||||
|
switch (nvpair_type(nvp)) {
|
||||||
|
case DATA_TYPE_STRING: {
|
||||||
|
char *val;
|
||||||
|
|
||||||
|
/* check string value for match */
|
||||||
|
if (nvpair_value_string(nvp, &val) == 0) {
|
||||||
|
if (value_regex) {
|
||||||
|
if (regexec(value_regex, val,
|
||||||
|
(size_t)0, NULL, 0) == 0)
|
||||||
|
return (1); /* match */
|
||||||
|
} else {
|
||||||
|
if (strcmp(value, val) == 0)
|
||||||
|
return (1); /* match */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DATA_TYPE_STRING_ARRAY: {
|
||||||
|
char **val_array;
|
||||||
|
|
||||||
|
/* check indexed string value of array for match */
|
||||||
|
if ((nvpair_value_string_array(nvp, &val_array, &a_len) == 0) &&
|
||||||
|
(ai < a_len)) {
|
||||||
|
if (value_regex) {
|
||||||
|
if (regexec(value_regex, val_array[ai],
|
||||||
|
(size_t)0, NULL, 0) == 0)
|
||||||
|
return (1);
|
||||||
|
} else {
|
||||||
|
if (strcmp(value, val_array[ai]) == 0)
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DATA_TYPE_BYTE: {
|
||||||
|
uchar_t val, val_arg;
|
||||||
|
|
||||||
|
/* scanf uchar_t from value and check for match */
|
||||||
|
sr = sscanf(value, "%c", &val_arg);
|
||||||
|
if ((sr == 1) && (nvpair_value_byte(nvp, &val) == 0) &&
|
||||||
|
(val == val_arg))
|
||||||
|
return (1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DATA_TYPE_BYTE_ARRAY: {
|
||||||
|
uchar_t *val_array, val_arg;
|
||||||
|
|
||||||
|
|
||||||
|
/* check indexed value of array for match */
|
||||||
|
sr = sscanf(value, "%c", &val_arg);
|
||||||
|
if ((sr == 1) &&
|
||||||
|
(nvpair_value_byte_array(nvp, &val_array, &a_len) == 0) &&
|
||||||
|
(ai < a_len) &&
|
||||||
|
(val_array[ai] == val_arg))
|
||||||
|
return (1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DATA_TYPE_INT8: {
|
||||||
|
int8_t val, val_arg;
|
||||||
|
|
||||||
|
/* scanf int8_t from value and check for match */
|
||||||
|
sr = sscanf(value, "%"SCNi8, &val_arg);
|
||||||
|
if ((sr == 1) &&
|
||||||
|
(nvpair_value_int8(nvp, &val) == 0) &&
|
||||||
|
(val == val_arg))
|
||||||
|
return (1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DATA_TYPE_INT8_ARRAY: {
|
||||||
|
int8_t *val_array, val_arg;
|
||||||
|
|
||||||
|
/* check indexed value of array for match */
|
||||||
|
sr = sscanf(value, "%"SCNi8, &val_arg);
|
||||||
|
if ((sr == 1) &&
|
||||||
|
(nvpair_value_int8_array(nvp, &val_array, &a_len) == 0) &&
|
||||||
|
(ai < a_len) &&
|
||||||
|
(val_array[ai] == val_arg))
|
||||||
|
return (1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DATA_TYPE_UINT8: {
|
||||||
|
uint8_t val, val_arg;
|
||||||
|
|
||||||
|
/* scanf uint8_t from value and check for match */
|
||||||
|
sr = sscanf(value, "%"SCNi8, (int8_t *)&val_arg);
|
||||||
|
if ((sr == 1) &&
|
||||||
|
(nvpair_value_uint8(nvp, &val) == 0) &&
|
||||||
|
(val == val_arg))
|
||||||
|
return (1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DATA_TYPE_UINT8_ARRAY: {
|
||||||
|
uint8_t *val_array, val_arg;
|
||||||
|
|
||||||
|
/* check indexed value of array for match */
|
||||||
|
sr = sscanf(value, "%"SCNi8, (int8_t *)&val_arg);
|
||||||
|
if ((sr == 1) &&
|
||||||
|
(nvpair_value_uint8_array(nvp, &val_array, &a_len) == 0) &&
|
||||||
|
(ai < a_len) &&
|
||||||
|
(val_array[ai] == val_arg))
|
||||||
|
return (1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DATA_TYPE_INT16: {
|
||||||
|
int16_t val, val_arg;
|
||||||
|
|
||||||
|
/* scanf int16_t from value and check for match */
|
||||||
|
sr = sscanf(value, "%"SCNi16, &val_arg);
|
||||||
|
if ((sr == 1) &&
|
||||||
|
(nvpair_value_int16(nvp, &val) == 0) &&
|
||||||
|
(val == val_arg))
|
||||||
|
return (1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DATA_TYPE_INT16_ARRAY: {
|
||||||
|
int16_t *val_array, val_arg;
|
||||||
|
|
||||||
|
/* check indexed value of array for match */
|
||||||
|
sr = sscanf(value, "%"SCNi16, &val_arg);
|
||||||
|
if ((sr == 1) &&
|
||||||
|
(nvpair_value_int16_array(nvp, &val_array, &a_len) == 0) &&
|
||||||
|
(ai < a_len) &&
|
||||||
|
(val_array[ai] == val_arg))
|
||||||
|
return (1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DATA_TYPE_UINT16: {
|
||||||
|
uint16_t val, val_arg;
|
||||||
|
|
||||||
|
/* scanf uint16_t from value and check for match */
|
||||||
|
sr = sscanf(value, "%"SCNi16, (int16_t *)&val_arg);
|
||||||
|
if ((sr == 1) &&
|
||||||
|
(nvpair_value_uint16(nvp, &val) == 0) &&
|
||||||
|
(val == val_arg))
|
||||||
|
return (1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DATA_TYPE_UINT16_ARRAY: {
|
||||||
|
uint16_t *val_array, val_arg;
|
||||||
|
|
||||||
|
/* check indexed value of array for match */
|
||||||
|
sr = sscanf(value, "%"SCNi16, (int16_t *)&val_arg);
|
||||||
|
if ((sr == 1) &&
|
||||||
|
(nvpair_value_uint16_array(nvp, &val_array, &a_len) == 0) &&
|
||||||
|
(ai < a_len) &&
|
||||||
|
(val_array[ai] == val_arg))
|
||||||
|
return (1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DATA_TYPE_INT32: {
|
||||||
|
int32_t val, val_arg;
|
||||||
|
|
||||||
|
/* scanf int32_t from value and check for match */
|
||||||
|
sr = sscanf(value, "%"SCNi32, &val_arg);
|
||||||
|
if ((sr == 1) &&
|
||||||
|
(nvpair_value_int32(nvp, &val) == 0) &&
|
||||||
|
(val == val_arg))
|
||||||
|
return (1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DATA_TYPE_INT32_ARRAY: {
|
||||||
|
int32_t *val_array, val_arg;
|
||||||
|
|
||||||
|
/* check indexed value of array for match */
|
||||||
|
sr = sscanf(value, "%"SCNi32, &val_arg);
|
||||||
|
if ((sr == 1) &&
|
||||||
|
(nvpair_value_int32_array(nvp, &val_array, &a_len) == 0) &&
|
||||||
|
(ai < a_len) &&
|
||||||
|
(val_array[ai] == val_arg))
|
||||||
|
return (1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DATA_TYPE_UINT32: {
|
||||||
|
uint32_t val, val_arg;
|
||||||
|
|
||||||
|
/* scanf uint32_t from value and check for match */
|
||||||
|
sr = sscanf(value, "%"SCNi32, (int32_t *)&val_arg);
|
||||||
|
if ((sr == 1) &&
|
||||||
|
(nvpair_value_uint32(nvp, &val) == 0) &&
|
||||||
|
(val == val_arg))
|
||||||
|
return (1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DATA_TYPE_UINT32_ARRAY: {
|
||||||
|
uint32_t *val_array, val_arg;
|
||||||
|
|
||||||
|
/* check indexed value of array for match */
|
||||||
|
sr = sscanf(value, "%"SCNi32, (int32_t *)&val_arg);
|
||||||
|
if ((sr == 1) &&
|
||||||
|
(nvpair_value_uint32_array(nvp, &val_array, &a_len) == 0) &&
|
||||||
|
(ai < a_len) &&
|
||||||
|
(val_array[ai] == val_arg))
|
||||||
|
return (1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DATA_TYPE_INT64: {
|
||||||
|
int64_t val, val_arg;
|
||||||
|
|
||||||
|
/* scanf int64_t from value and check for match */
|
||||||
|
sr = sscanf(value, "%"SCNi64, &val_arg);
|
||||||
|
if ((sr == 1) &&
|
||||||
|
(nvpair_value_int64(nvp, &val) == 0) &&
|
||||||
|
(val == val_arg))
|
||||||
|
return (1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DATA_TYPE_INT64_ARRAY: {
|
||||||
|
int64_t *val_array, val_arg;
|
||||||
|
|
||||||
|
/* check indexed value of array for match */
|
||||||
|
sr = sscanf(value, "%"SCNi64, &val_arg);
|
||||||
|
if ((sr == 1) &&
|
||||||
|
(nvpair_value_int64_array(nvp, &val_array, &a_len) == 0) &&
|
||||||
|
(ai < a_len) &&
|
||||||
|
(val_array[ai] == val_arg))
|
||||||
|
return (1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DATA_TYPE_UINT64: {
|
||||||
|
uint64_t val_arg, val;
|
||||||
|
|
||||||
|
/* scanf uint64_t from value and check for match */
|
||||||
|
sr = sscanf(value, "%"SCNi64, (int64_t *)&val_arg);
|
||||||
|
if ((sr == 1) &&
|
||||||
|
(nvpair_value_uint64(nvp, &val) == 0) &&
|
||||||
|
(val == val_arg))
|
||||||
|
return (1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DATA_TYPE_UINT64_ARRAY: {
|
||||||
|
uint64_t *val_array, val_arg;
|
||||||
|
|
||||||
|
/* check indexed value of array for match */
|
||||||
|
sr = sscanf(value, "%"SCNi64, (int64_t *)&val_arg);
|
||||||
|
if ((sr == 1) &&
|
||||||
|
(nvpair_value_uint64_array(nvp, &val_array, &a_len) == 0) &&
|
||||||
|
(ai < a_len) &&
|
||||||
|
(val_array[ai] == val_arg))
|
||||||
|
return (1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DATA_TYPE_BOOLEAN_VALUE: {
|
||||||
|
boolean_t val, val_arg;
|
||||||
|
|
||||||
|
/* scanf boolean_t from value and check for match */
|
||||||
|
sr = sscanf(value, "%"SCNi32, &val_arg);
|
||||||
|
if ((sr == 1) &&
|
||||||
|
(nvpair_value_boolean_value(nvp, &val) == 0) &&
|
||||||
|
(val == val_arg))
|
||||||
|
return (1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DATA_TYPE_BOOLEAN_ARRAY: {
|
||||||
|
boolean_t *val_array, val_arg;
|
||||||
|
|
||||||
|
/* check indexed value of array for match */
|
||||||
|
sr = sscanf(value, "%"SCNi32, &val_arg);
|
||||||
|
if ((sr == 1) &&
|
||||||
|
(nvpair_value_boolean_array(nvp,
|
||||||
|
&val_array, &a_len) == 0) &&
|
||||||
|
(ai < a_len) &&
|
||||||
|
(val_array[ai] == val_arg))
|
||||||
|
return (1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DATA_TYPE_HRTIME:
|
||||||
|
case DATA_TYPE_NVLIST:
|
||||||
|
case DATA_TYPE_NVLIST_ARRAY:
|
||||||
|
case DATA_TYPE_BOOLEAN:
|
||||||
|
case DATA_TYPE_DOUBLE:
|
||||||
|
case DATA_TYPE_UNKNOWN:
|
||||||
|
default:
|
||||||
|
/*
|
||||||
|
* unknown/unsupported data type
|
||||||
|
*/
|
||||||
|
return (-1); /* error fail match */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* check to see if sscanf failed conversion, return approximate
|
||||||
|
* pointer to problem
|
||||||
|
*/
|
||||||
|
if (sr != 1) {
|
||||||
|
if (ep)
|
||||||
|
*ep = value;
|
||||||
|
return (-1); /* error fail match - syntax */
|
||||||
|
}
|
||||||
|
|
||||||
|
return (0); /* fail match */
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
nvpair_value_match(nvpair_t *nvp, int ai, char *value, char **ep)
|
||||||
|
{
|
||||||
|
return (nvpair_value_match_regex(nvp, ai, value, NULL, ep));
|
||||||
|
}
|
||||||
|
|
|
@ -20,11 +20,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
|
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
||||||
* Use is subject to license terms.
|
* Use is subject to license terms.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#pragma ident "%Z%%M% %I% %E% SMI"
|
||||||
|
|
||||||
#include <sys/stropts.h>
|
#include <sys/stropts.h>
|
||||||
#include <sys/debug.h>
|
#include <sys/debug.h>
|
||||||
|
@ -37,15 +37,19 @@
|
||||||
|
|
||||||
#if defined(_KERNEL) && !defined(_BOOT)
|
#if defined(_KERNEL) && !defined(_BOOT)
|
||||||
#include <sys/varargs.h>
|
#include <sys/varargs.h>
|
||||||
|
#include <sys/ddi.h>
|
||||||
|
#include <sys/sunddi.h>
|
||||||
#else
|
#else
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef offsetof
|
#ifndef offsetof
|
||||||
#define offsetof(s, m) ((size_t)(&(((s *)0)->m)))
|
#define offsetof(s, m) ((size_t)(&(((s *)0)->m)))
|
||||||
#endif
|
#endif
|
||||||
|
#define skip_whitespace(p) while ((*(p) == ' ') || (*(p) == '\t')) p++
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* nvpair.c - Provides kernel & userland interfaces for manipulating
|
* nvpair.c - Provides kernel & userland interfaces for manipulating
|
||||||
|
@ -204,7 +208,7 @@ nv_mem_free(nvpriv_t *nvp, void *buf, size_t size)
|
||||||
static void
|
static void
|
||||||
nv_priv_init(nvpriv_t *priv, nv_alloc_t *nva, uint32_t stat)
|
nv_priv_init(nvpriv_t *priv, nv_alloc_t *nva, uint32_t stat)
|
||||||
{
|
{
|
||||||
bzero(priv, sizeof (priv));
|
bzero(priv, sizeof (nvpriv_t));
|
||||||
|
|
||||||
priv->nvp_nva = nva;
|
priv->nvp_nva = nva;
|
||||||
priv->nvp_stat = stat;
|
priv->nvp_stat = stat;
|
||||||
|
@ -398,6 +402,9 @@ i_validate_type_nelem(data_type_t type, uint_t nelem)
|
||||||
case DATA_TYPE_STRING:
|
case DATA_TYPE_STRING:
|
||||||
case DATA_TYPE_HRTIME:
|
case DATA_TYPE_HRTIME:
|
||||||
case DATA_TYPE_NVLIST:
|
case DATA_TYPE_NVLIST:
|
||||||
|
#if !defined(_KERNEL)
|
||||||
|
case DATA_TYPE_DOUBLE:
|
||||||
|
#endif
|
||||||
if (nelem != 1)
|
if (nelem != 1)
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
break;
|
break;
|
||||||
|
@ -736,6 +743,11 @@ i_get_value_size(data_type_t type, const void *data, uint_t nelem)
|
||||||
case DATA_TYPE_UINT64:
|
case DATA_TYPE_UINT64:
|
||||||
value_sz = sizeof (uint64_t);
|
value_sz = sizeof (uint64_t);
|
||||||
break;
|
break;
|
||||||
|
#if !defined(_KERNEL)
|
||||||
|
case DATA_TYPE_DOUBLE:
|
||||||
|
value_sz = sizeof (double);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
case DATA_TYPE_STRING:
|
case DATA_TYPE_STRING:
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
value_sz = 0;
|
value_sz = 0;
|
||||||
|
@ -1020,6 +1032,14 @@ nvlist_add_uint64(nvlist_t *nvl, const char *name, uint64_t val)
|
||||||
return (nvlist_add_common(nvl, name, DATA_TYPE_UINT64, 1, &val));
|
return (nvlist_add_common(nvl, name, DATA_TYPE_UINT64, 1, &val));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(_KERNEL)
|
||||||
|
int
|
||||||
|
nvlist_add_double(nvlist_t *nvl, const char *name, double val)
|
||||||
|
{
|
||||||
|
return (nvlist_add_common(nvl, name, DATA_TYPE_DOUBLE, 1, &val));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int
|
int
|
||||||
nvlist_add_string(nvlist_t *nvl, const char *name, const char *val)
|
nvlist_add_string(nvlist_t *nvl, const char *name, const char *val)
|
||||||
{
|
{
|
||||||
|
@ -1154,6 +1174,27 @@ nvpair_type(nvpair_t *nvp)
|
||||||
return (NVP_TYPE(nvp));
|
return (NVP_TYPE(nvp));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
nvpair_type_is_array(nvpair_t *nvp)
|
||||||
|
{
|
||||||
|
data_type_t type = NVP_TYPE(nvp);
|
||||||
|
|
||||||
|
if ((type == DATA_TYPE_BYTE_ARRAY) ||
|
||||||
|
(type == DATA_TYPE_UINT8_ARRAY) ||
|
||||||
|
(type == DATA_TYPE_INT16_ARRAY) ||
|
||||||
|
(type == DATA_TYPE_UINT16_ARRAY) ||
|
||||||
|
(type == DATA_TYPE_INT32_ARRAY) ||
|
||||||
|
(type == DATA_TYPE_UINT32_ARRAY) ||
|
||||||
|
(type == DATA_TYPE_INT64_ARRAY) ||
|
||||||
|
(type == DATA_TYPE_UINT64_ARRAY) ||
|
||||||
|
(type == DATA_TYPE_BOOLEAN_ARRAY) ||
|
||||||
|
(type == DATA_TYPE_STRING_ARRAY) ||
|
||||||
|
(type == DATA_TYPE_NVLIST_ARRAY))
|
||||||
|
return (1);
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
nvpair_value_common(nvpair_t *nvp, data_type_t type, uint_t *nelem, void *data)
|
nvpair_value_common(nvpair_t *nvp, data_type_t type, uint_t *nelem, void *data)
|
||||||
{
|
{
|
||||||
|
@ -1181,6 +1222,9 @@ nvpair_value_common(nvpair_t *nvp, data_type_t type, uint_t *nelem, void *data)
|
||||||
case DATA_TYPE_INT64:
|
case DATA_TYPE_INT64:
|
||||||
case DATA_TYPE_UINT64:
|
case DATA_TYPE_UINT64:
|
||||||
case DATA_TYPE_HRTIME:
|
case DATA_TYPE_HRTIME:
|
||||||
|
#if !defined(_KERNEL)
|
||||||
|
case DATA_TYPE_DOUBLE:
|
||||||
|
#endif
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
bcopy(NVP_VALUE(nvp), data,
|
bcopy(NVP_VALUE(nvp), data,
|
||||||
|
@ -1317,6 +1361,14 @@ nvlist_lookup_uint64(nvlist_t *nvl, const char *name, uint64_t *val)
|
||||||
return (nvlist_lookup_common(nvl, name, DATA_TYPE_UINT64, NULL, val));
|
return (nvlist_lookup_common(nvl, name, DATA_TYPE_UINT64, NULL, val));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(_KERNEL)
|
||||||
|
int
|
||||||
|
nvlist_lookup_double(nvlist_t *nvl, const char *name, double *val)
|
||||||
|
{
|
||||||
|
return (nvlist_lookup_common(nvl, name, DATA_TYPE_DOUBLE, NULL, val));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int
|
int
|
||||||
nvlist_lookup_string(nvlist_t *nvl, const char *name, char **val)
|
nvlist_lookup_string(nvlist_t *nvl, const char *name, char **val)
|
||||||
{
|
{
|
||||||
|
@ -1451,6 +1503,9 @@ nvlist_lookup_pairs(nvlist_t *nvl, int flag, ...)
|
||||||
case DATA_TYPE_HRTIME:
|
case DATA_TYPE_HRTIME:
|
||||||
case DATA_TYPE_STRING:
|
case DATA_TYPE_STRING:
|
||||||
case DATA_TYPE_NVLIST:
|
case DATA_TYPE_NVLIST:
|
||||||
|
#if !defined(_KERNEL)
|
||||||
|
case DATA_TYPE_DOUBLE:
|
||||||
|
#endif
|
||||||
val = va_arg(ap, void *);
|
val = va_arg(ap, void *);
|
||||||
ret = nvlist_lookup_common(nvl, name, type, NULL, val);
|
ret = nvlist_lookup_common(nvl, name, type, NULL, val);
|
||||||
break;
|
break;
|
||||||
|
@ -1484,30 +1539,201 @@ nvlist_lookup_pairs(nvlist_t *nvl, int flag, ...)
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
/*
|
||||||
nvlist_lookup_nvpair(nvlist_t *nvl, const char *name, nvpair_t **ret)
|
* Find the 'name'ed nvpair in the nvlist 'nvl'. If 'name' found, the function
|
||||||
|
* returns zero and a pointer to the matching nvpair is returned in '*ret'
|
||||||
|
* (given 'ret' is non-NULL). If 'sep' is specified then 'name' will penitrate
|
||||||
|
* multiple levels of embedded nvlists, with 'sep' as the separator. As an
|
||||||
|
* example, if sep is '.', name might look like: "a" or "a.b" or "a.c[3]" or
|
||||||
|
* "a.d[3].e[1]". This matches the C syntax for array embed (for convience,
|
||||||
|
* code also supports "a.d[3]e[1]" syntax).
|
||||||
|
*
|
||||||
|
* If 'ip' is non-NULL and the last name component is an array, return the
|
||||||
|
* value of the "...[index]" array index in *ip. For an array reference that
|
||||||
|
* is not indexed, *ip will be returned as -1. If there is a syntax error in
|
||||||
|
* 'name', and 'ep' is non-NULL then *ep will be set to point to the location
|
||||||
|
* inside the 'name' string where the syntax error was detected.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
nvlist_lookup_nvpair_ei_sep(nvlist_t *nvl, const char *name, const char sep,
|
||||||
|
nvpair_t **ret, int *ip, char **ep)
|
||||||
{
|
{
|
||||||
nvpriv_t *priv;
|
|
||||||
nvpair_t *nvp;
|
nvpair_t *nvp;
|
||||||
i_nvp_t *curr;
|
const char *np;
|
||||||
|
char *sepp;
|
||||||
|
char *idxp, *idxep;
|
||||||
|
nvlist_t **nva;
|
||||||
|
long idx;
|
||||||
|
int n;
|
||||||
|
|
||||||
if (name == NULL || nvl == NULL ||
|
if (ip)
|
||||||
(priv = (nvpriv_t *)(uintptr_t)nvl->nvl_priv) == NULL)
|
*ip = -1; /* not indexed */
|
||||||
|
if (ep)
|
||||||
|
*ep = NULL;
|
||||||
|
|
||||||
|
if ((nvl == NULL) || (name == NULL))
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
|
|
||||||
|
/* step through components of name */
|
||||||
|
for (np = name; np && *np; np = sepp) {
|
||||||
|
/* ensure unique names */
|
||||||
if (!(nvl->nvl_nvflag & NV_UNIQUE_NAME))
|
if (!(nvl->nvl_nvflag & NV_UNIQUE_NAME))
|
||||||
return (ENOTSUP);
|
return (ENOTSUP);
|
||||||
|
|
||||||
for (curr = priv->nvp_list; curr != NULL; curr = curr->nvi_next) {
|
/* skip white space */
|
||||||
nvp = &curr->nvi_nvp;
|
skip_whitespace(np);
|
||||||
|
if (*np == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
if (strcmp(name, NVP_NAME(nvp)) == 0) {
|
/* set 'sepp' to end of current component 'np' */
|
||||||
|
if (sep)
|
||||||
|
sepp = strchr(np, sep);
|
||||||
|
else
|
||||||
|
sepp = NULL;
|
||||||
|
|
||||||
|
/* find start of next "[ index ]..." */
|
||||||
|
idxp = strchr(np, '[');
|
||||||
|
|
||||||
|
/* if sepp comes first, set idxp to NULL */
|
||||||
|
if (sepp && idxp && (sepp < idxp))
|
||||||
|
idxp = NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* At this point 'idxp' is set if there is an index
|
||||||
|
* expected for the current component.
|
||||||
|
*/
|
||||||
|
if (idxp) {
|
||||||
|
/* set 'n' to length of current 'np' name component */
|
||||||
|
n = idxp++ - np;
|
||||||
|
|
||||||
|
/* keep sepp up to date for *ep use as we advance */
|
||||||
|
skip_whitespace(idxp);
|
||||||
|
sepp = idxp;
|
||||||
|
|
||||||
|
/* determine the index value */
|
||||||
|
#if defined(_KERNEL) && !defined(_BOOT)
|
||||||
|
if (ddi_strtol(idxp, &idxep, 0, &idx))
|
||||||
|
goto fail;
|
||||||
|
#else
|
||||||
|
idx = strtol(idxp, &idxep, 0);
|
||||||
|
#endif
|
||||||
|
if (idxep == idxp)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
/* keep sepp up to date for *ep use as we advance */
|
||||||
|
sepp = idxep;
|
||||||
|
|
||||||
|
/* skip white space index value and check for ']' */
|
||||||
|
skip_whitespace(sepp);
|
||||||
|
if (*sepp++ != ']')
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
/* for embedded arrays, support C syntax: "a[1].b" */
|
||||||
|
skip_whitespace(sepp);
|
||||||
|
if (sep && (*sepp == sep))
|
||||||
|
sepp++;
|
||||||
|
} else if (sepp) {
|
||||||
|
n = sepp++ - np;
|
||||||
|
} else {
|
||||||
|
n = strlen(np);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* trim trailing whitespace by reducing length of 'np' */
|
||||||
|
if (n == 0)
|
||||||
|
goto fail;
|
||||||
|
for (n--; (np[n] == ' ') || (np[n] == '\t'); n--)
|
||||||
|
;
|
||||||
|
n++;
|
||||||
|
|
||||||
|
/* skip whitespace, and set sepp to NULL if complete */
|
||||||
|
if (sepp) {
|
||||||
|
skip_whitespace(sepp);
|
||||||
|
if (*sepp == 0)
|
||||||
|
sepp = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* At this point:
|
||||||
|
* o 'n' is the length of current 'np' component.
|
||||||
|
* o 'idxp' is set if there was an index, and value 'idx'.
|
||||||
|
* o 'sepp' is set to the beginning of the next component,
|
||||||
|
* and set to NULL if we have no more components.
|
||||||
|
*
|
||||||
|
* Search for nvpair with matching component name.
|
||||||
|
*/
|
||||||
|
for (nvp = nvlist_next_nvpair(nvl, NULL); nvp != NULL;
|
||||||
|
nvp = nvlist_next_nvpair(nvl, nvp)) {
|
||||||
|
|
||||||
|
/* continue if no match on name */
|
||||||
|
if (strncmp(np, nvpair_name(nvp), n) ||
|
||||||
|
(strlen(nvpair_name(nvp)) != n))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* if indexed, verify type is array oriented */
|
||||||
|
if (idxp && !nvpair_type_is_array(nvp))
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Full match found, return nvp and idx if this
|
||||||
|
* was the last component.
|
||||||
|
*/
|
||||||
|
if (sepp == NULL) {
|
||||||
|
if (ret)
|
||||||
*ret = nvp;
|
*ret = nvp;
|
||||||
return (0);
|
if (ip && idxp)
|
||||||
}
|
*ip = (int)idx; /* return index */
|
||||||
|
return (0); /* found */
|
||||||
}
|
}
|
||||||
|
|
||||||
return (ENOENT);
|
/*
|
||||||
|
* More components: current match must be
|
||||||
|
* of DATA_TYPE_NVLIST or DATA_TYPE_NVLIST_ARRAY
|
||||||
|
* to support going deeper.
|
||||||
|
*/
|
||||||
|
if (nvpair_type(nvp) == DATA_TYPE_NVLIST) {
|
||||||
|
nvl = EMBEDDED_NVL(nvp);
|
||||||
|
break;
|
||||||
|
} else if (nvpair_type(nvp) == DATA_TYPE_NVLIST_ARRAY) {
|
||||||
|
(void) nvpair_value_nvlist_array(nvp,
|
||||||
|
&nva, (uint_t *)&n);
|
||||||
|
if ((n < 0) || (idx >= n))
|
||||||
|
goto fail;
|
||||||
|
nvl = nva[idx];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* type does not support more levels */
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
if (nvp == NULL)
|
||||||
|
goto fail; /* 'name' not found */
|
||||||
|
|
||||||
|
/* search for match of next component in embedded 'nvl' list */
|
||||||
|
}
|
||||||
|
|
||||||
|
fail: if (ep && sepp)
|
||||||
|
*ep = sepp;
|
||||||
|
return (EINVAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return pointer to nvpair with specified 'name'.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
nvlist_lookup_nvpair(nvlist_t *nvl, const char *name, nvpair_t **ret)
|
||||||
|
{
|
||||||
|
return (nvlist_lookup_nvpair_ei_sep(nvl, name, 0, ret, NULL, NULL));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Determine if named nvpair exists in nvlist (use embedded separator of '.'
|
||||||
|
* and return array index). See nvlist_lookup_nvpair_ei_sep for more detailed
|
||||||
|
* description.
|
||||||
|
*/
|
||||||
|
int nvlist_lookup_nvpair_embedded_index(nvlist_t *nvl,
|
||||||
|
const char *name, nvpair_t **ret, int *ip, char **ep)
|
||||||
|
{
|
||||||
|
return (nvlist_lookup_nvpair_ei_sep(nvl, name, '.', ret, ip, ep));
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean_t
|
boolean_t
|
||||||
|
@ -1591,6 +1817,14 @@ nvpair_value_uint64(nvpair_t *nvp, uint64_t *val)
|
||||||
return (nvpair_value_common(nvp, DATA_TYPE_UINT64, NULL, val));
|
return (nvpair_value_common(nvp, DATA_TYPE_UINT64, NULL, val));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(_KERNEL)
|
||||||
|
int
|
||||||
|
nvpair_value_double(nvpair_t *nvp, double *val)
|
||||||
|
{
|
||||||
|
return (nvpair_value_common(nvp, DATA_TYPE_DOUBLE, NULL, val));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int
|
int
|
||||||
nvpair_value_string(nvpair_t *nvp, char **val)
|
nvpair_value_string(nvpair_t *nvp, char **val)
|
||||||
{
|
{
|
||||||
|
@ -2728,7 +2962,11 @@ nvs_xdr_nvp_op(nvstream_t *nvs, nvpair_t *nvp)
|
||||||
*/
|
*/
|
||||||
ret = xdr_longlong_t(xdr, (void *)buf);
|
ret = xdr_longlong_t(xdr, (void *)buf);
|
||||||
break;
|
break;
|
||||||
|
#if !defined(_KERNEL)
|
||||||
|
case DATA_TYPE_DOUBLE:
|
||||||
|
ret = xdr_double(xdr, (void *)buf);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
case DATA_TYPE_STRING:
|
case DATA_TYPE_STRING:
|
||||||
ret = xdr_string(xdr, &buf, buflen - 1);
|
ret = xdr_string(xdr, &buf, buflen - 1);
|
||||||
break;
|
break;
|
||||||
|
@ -2834,6 +3072,9 @@ nvs_xdr_nvp_size(nvstream_t *nvs, nvpair_t *nvp, size_t *size)
|
||||||
case DATA_TYPE_INT64:
|
case DATA_TYPE_INT64:
|
||||||
case DATA_TYPE_UINT64:
|
case DATA_TYPE_UINT64:
|
||||||
case DATA_TYPE_HRTIME:
|
case DATA_TYPE_HRTIME:
|
||||||
|
#if !defined(_KERNEL)
|
||||||
|
case DATA_TYPE_DOUBLE:
|
||||||
|
#endif
|
||||||
nvp_sz += 8;
|
nvp_sz += 8;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
* Use is subject to license terms.
|
* Use is subject to license terms.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#pragma ident "%Z%%M% %I% %E% SMI"
|
||||||
|
|
||||||
#include <sys/stropts.h>
|
#include <sys/stropts.h>
|
||||||
#include <sys/isa_defs.h>
|
#include <sys/isa_defs.h>
|
||||||
|
|
|
@ -24,26 +24,25 @@
|
||||||
* Use is subject to license terms.
|
* Use is subject to license terms.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#pragma ident "%Z%%M% %I% %E% SMI"
|
||||||
|
|
||||||
|
#include <rpc/types.h>
|
||||||
#include <sys/nvpair.h>
|
#include <sys/nvpair.h>
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
/*ARGSUSED*/
|
|
||||||
static void *
|
static void *
|
||||||
nv_alloc_sys(nv_alloc_t *nva, size_t size)
|
nv_alloc_sys(nv_alloc_t *nva, size_t size)
|
||||||
{
|
{
|
||||||
return (malloc(size));
|
return (kmem_alloc(size, (int)(uintptr_t)nva->nva_arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*ARGSUSED*/
|
/*ARGSUSED*/
|
||||||
static void
|
static void
|
||||||
nv_free_sys(nv_alloc_t *nva, void *buf, size_t size)
|
nv_free_sys(nv_alloc_t *nva, void *buf, size_t size)
|
||||||
{
|
{
|
||||||
free(buf);
|
kmem_free(buf, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
const nv_alloc_ops_t system_ops_def = {
|
static const nv_alloc_ops_t system_ops = {
|
||||||
NULL, /* nv_ao_init() */
|
NULL, /* nv_ao_init() */
|
||||||
NULL, /* nv_ao_fini() */
|
NULL, /* nv_ao_fini() */
|
||||||
nv_alloc_sys, /* nv_ao_alloc() */
|
nv_alloc_sys, /* nv_ao_alloc() */
|
||||||
|
@ -51,9 +50,15 @@ const nv_alloc_ops_t system_ops_def = {
|
||||||
NULL /* nv_ao_reset() */
|
NULL /* nv_ao_reset() */
|
||||||
};
|
};
|
||||||
|
|
||||||
nv_alloc_t nv_alloc_nosleep_def = {
|
nv_alloc_t nv_alloc_sleep_def = {
|
||||||
&system_ops_def,
|
&system_ops,
|
||||||
NULL
|
(void *)KM_SLEEP
|
||||||
};
|
};
|
||||||
|
|
||||||
|
nv_alloc_t nv_alloc_nosleep_def = {
|
||||||
|
&system_ops,
|
||||||
|
(void *)KM_NOSLEEP
|
||||||
|
};
|
||||||
|
|
||||||
|
nv_alloc_t *nv_alloc_sleep = &nv_alloc_sleep_def;
|
||||||
nv_alloc_t *nv_alloc_nosleep = &nv_alloc_nosleep_def;
|
nv_alloc_t *nv_alloc_nosleep = &nv_alloc_nosleep_def;
|
||||||
|
|
|
@ -1,41 +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 _PORT_FAKE_IOCTL_H
|
|
||||||
#define _PORT_FAKE_IOCTL_H
|
|
||||||
|
|
||||||
static inline int real_ioctl(int fd, int request, void *arg)
|
|
||||||
{
|
|
||||||
return ioctl(fd, request, arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef WANT_FAKE_IOCTL
|
|
||||||
|
|
||||||
#include <sys/dmu_ctl.h>
|
|
||||||
#define ioctl(fd,req,arg) dctlc_ioctl(fd,req,arg)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _PORT_FAKE_IOCTL_H */
|
|
|
@ -1,278 +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 2007 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "zfs_config.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_LIBDISKMGT_H
|
|
||||||
#include_next <libdiskmgt.h>
|
|
||||||
#else
|
|
||||||
|
|
||||||
#ifndef _LIBDISKMGT_H
|
|
||||||
#define _LIBDISKMGT_H
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <libnvpair.h>
|
|
||||||
#include <sys/swap.h>
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Holds all the data regarding the device.
|
|
||||||
* Private to libdiskmgt. Must use dm_xxx functions to set/get data.
|
|
||||||
*/
|
|
||||||
typedef uint64_t dm_descriptor_t;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
DM_WHO_MKFS = 0,
|
|
||||||
DM_WHO_ZPOOL,
|
|
||||||
DM_WHO_ZPOOL_FORCE,
|
|
||||||
DM_WHO_FORMAT,
|
|
||||||
DM_WHO_SWAP,
|
|
||||||
DM_WHO_DUMP,
|
|
||||||
DM_WHO_ZPOOL_SPARE
|
|
||||||
} dm_who_type_t;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
DM_DRIVE = 0,
|
|
||||||
DM_CONTROLLER,
|
|
||||||
DM_MEDIA,
|
|
||||||
DM_SLICE,
|
|
||||||
DM_PARTITION,
|
|
||||||
DM_PATH,
|
|
||||||
DM_ALIAS,
|
|
||||||
DM_BUS
|
|
||||||
} dm_desc_type_t;
|
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
DM_DT_UNKNOWN = 0,
|
|
||||||
DM_DT_FIXED,
|
|
||||||
DM_DT_ZIP,
|
|
||||||
DM_DT_JAZ,
|
|
||||||
DM_DT_FLOPPY,
|
|
||||||
DM_DT_MO_ERASABLE,
|
|
||||||
DM_DT_MO_WRITEONCE,
|
|
||||||
DM_DT_AS_MO,
|
|
||||||
DM_DT_CDROM,
|
|
||||||
DM_DT_CDR,
|
|
||||||
DM_DT_CDRW,
|
|
||||||
DM_DT_DVDROM,
|
|
||||||
DM_DT_DVDR,
|
|
||||||
DM_DT_DVDRAM,
|
|
||||||
DM_DT_DVDRW,
|
|
||||||
DM_DT_DDCDROM,
|
|
||||||
DM_DT_DDCDR,
|
|
||||||
DM_DT_DDCDRW
|
|
||||||
} dm_drive_type_t;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
DM_MT_UNKNOWN = 0,
|
|
||||||
DM_MT_FIXED,
|
|
||||||
DM_MT_FLOPPY,
|
|
||||||
DM_MT_CDROM,
|
|
||||||
DM_MT_ZIP,
|
|
||||||
DM_MT_JAZ,
|
|
||||||
DM_MT_CDR,
|
|
||||||
DM_MT_CDRW,
|
|
||||||
DM_MT_DVDROM,
|
|
||||||
DM_MT_DVDR,
|
|
||||||
DM_MT_DVDRAM,
|
|
||||||
DM_MT_MO_ERASABLE,
|
|
||||||
DM_MT_MO_WRITEONCE,
|
|
||||||
DM_MT_AS_MO
|
|
||||||
} dm_media_type_t;
|
|
||||||
|
|
||||||
#define DM_FILTER_END -1
|
|
||||||
|
|
||||||
/* drive stat name */
|
|
||||||
typedef enum {
|
|
||||||
DM_DRV_STAT_PERFORMANCE = 0,
|
|
||||||
DM_DRV_STAT_DIAGNOSTIC,
|
|
||||||
DM_DRV_STAT_TEMPERATURE
|
|
||||||
} dm_drive_stat_t;
|
|
||||||
|
|
||||||
/* slice stat name */
|
|
||||||
typedef enum {
|
|
||||||
DM_SLICE_STAT_USE = 0
|
|
||||||
} dm_slice_stat_t;
|
|
||||||
|
|
||||||
/* attribute definitions */
|
|
||||||
|
|
||||||
/* drive */
|
|
||||||
#define DM_DISK_UP 1
|
|
||||||
#define DM_DISK_DOWN 0
|
|
||||||
|
|
||||||
#define DM_CLUSTERED "clustered"
|
|
||||||
#define DM_DRVTYPE "drvtype"
|
|
||||||
#define DM_FAILING "failing"
|
|
||||||
#define DM_LOADED "loaded" /* also in media */
|
|
||||||
#define DM_NDNRERRS "ndevice_not_ready_errors"
|
|
||||||
#define DM_NBYTESREAD "nbytes_read"
|
|
||||||
#define DM_NBYTESWRITTEN "nbytes_written"
|
|
||||||
#define DM_NHARDERRS "nhard_errors"
|
|
||||||
#define DM_NILLREQERRS "nillegal_req_errors"
|
|
||||||
#define DM_NMEDIAERRS "nmedia_errors"
|
|
||||||
#define DM_NNODEVERRS "nno_dev_errors"
|
|
||||||
#define DM_NREADOPS "nread_ops"
|
|
||||||
#define DM_NRECOVERRS "nrecoverable_errors"
|
|
||||||
#define DM_NSOFTERRS "nsoft_errors"
|
|
||||||
#define DM_NTRANSERRS "ntransport_errors"
|
|
||||||
#define DM_NWRITEOPS "nwrite_ops"
|
|
||||||
#define DM_OPATH "opath"
|
|
||||||
#define DM_PRODUCT_ID "product_id"
|
|
||||||
#define DM_REMOVABLE "removable" /* also in media */
|
|
||||||
#define DM_RPM "rpm"
|
|
||||||
#define DM_STATUS "status"
|
|
||||||
#define DM_SYNC_SPEED "sync_speed"
|
|
||||||
#define DM_TEMPERATURE "temperature"
|
|
||||||
#define DM_VENDOR_ID "vendor_id"
|
|
||||||
#define DM_WIDE "wide" /* also on controller */
|
|
||||||
#define DM_WWN "wwn"
|
|
||||||
|
|
||||||
/* bus */
|
|
||||||
#define DM_BTYPE "btype"
|
|
||||||
#define DM_CLOCK "clock" /* also on controller */
|
|
||||||
#define DM_PNAME "pname"
|
|
||||||
|
|
||||||
/* controller */
|
|
||||||
#define DM_FAST "fast"
|
|
||||||
#define DM_FAST20 "fast20"
|
|
||||||
#define DM_FAST40 "fast40"
|
|
||||||
#define DM_FAST80 "fast80"
|
|
||||||
#define DM_MULTIPLEX "multiplex"
|
|
||||||
#define DM_PATH_STATE "path_state"
|
|
||||||
|
|
||||||
#define DM_CTYPE_ATA "ata"
|
|
||||||
#define DM_CTYPE_SCSI "scsi"
|
|
||||||
#define DM_CTYPE_FIBRE "fibre channel"
|
|
||||||
#define DM_CTYPE_USB "usb"
|
|
||||||
#define DM_CTYPE_UNKNOWN "unknown"
|
|
||||||
|
|
||||||
/* media */
|
|
||||||
#define DM_BLOCKSIZE "blocksize"
|
|
||||||
#define DM_FDISK "fdisk"
|
|
||||||
#define DM_MTYPE "mtype"
|
|
||||||
#define DM_NACTUALCYLINDERS "nactual_cylinders"
|
|
||||||
#define DM_NALTCYLINDERS "nalt_cylinders"
|
|
||||||
#define DM_NCYLINDERS "ncylinders"
|
|
||||||
#define DM_NHEADS "nheads"
|
|
||||||
#define DM_NPHYSCYLINDERS "nphys_cylinders"
|
|
||||||
#define DM_NSECTORS "nsectors" /* also in partition */
|
|
||||||
#define DM_SIZE "size" /* also in slice */
|
|
||||||
#define DM_NACCESSIBLE "naccessible"
|
|
||||||
#define DM_LABEL "label"
|
|
||||||
|
|
||||||
/* partition */
|
|
||||||
#define DM_BCYL "bcyl"
|
|
||||||
#define DM_BHEAD "bhead"
|
|
||||||
#define DM_BOOTID "bootid"
|
|
||||||
#define DM_BSECT "bsect"
|
|
||||||
#define DM_ECYL "ecyl"
|
|
||||||
#define DM_EHEAD "ehead"
|
|
||||||
#define DM_ESECT "esect"
|
|
||||||
#define DM_PTYPE "ptype"
|
|
||||||
#define DM_RELSECT "relsect"
|
|
||||||
|
|
||||||
/* slice */
|
|
||||||
#define DM_DEVICEID "deviceid"
|
|
||||||
#define DM_DEVT "devt"
|
|
||||||
#define DM_INDEX "index"
|
|
||||||
#define DM_EFI_NAME "name"
|
|
||||||
#define DM_MOUNTPOINT "mountpoint"
|
|
||||||
#define DM_LOCALNAME "localname"
|
|
||||||
#define DM_START "start"
|
|
||||||
#define DM_TAG "tag"
|
|
||||||
#define DM_FLAG "flag"
|
|
||||||
#define DM_EFI "efi" /* also on media */
|
|
||||||
#define DM_USED_BY "used_by"
|
|
||||||
#define DM_USED_NAME "used_name"
|
|
||||||
#define DM_USE_MOUNT "mount"
|
|
||||||
#define DM_USE_SVM "svm"
|
|
||||||
#define DM_USE_LU "lu"
|
|
||||||
#define DM_USE_DUMP "dump"
|
|
||||||
#define DM_USE_VXVM "vxvm"
|
|
||||||
#define DM_USE_FS "fs"
|
|
||||||
#define DM_USE_VFSTAB "vfstab"
|
|
||||||
#define DM_USE_EXPORTED_ZPOOL "exported_zpool"
|
|
||||||
#define DM_USE_ACTIVE_ZPOOL "active_zpool"
|
|
||||||
#define DM_USE_SPARE_ZPOOL "spare_zpool"
|
|
||||||
#define DM_USE_L2CACHE_ZPOOL "l2cache_zpool"
|
|
||||||
|
|
||||||
/* event */
|
|
||||||
#define DM_EV_NAME "name"
|
|
||||||
#define DM_EV_DTYPE "edtype"
|
|
||||||
#define DM_EV_TYPE "evtype"
|
|
||||||
#define DM_EV_TADD "add"
|
|
||||||
#define DM_EV_TREMOVE "remove"
|
|
||||||
#define DM_EV_TCHANGE "change"
|
|
||||||
|
|
||||||
/* findisks */
|
|
||||||
#define DM_CTYPE "ctype"
|
|
||||||
#define DM_LUN "lun"
|
|
||||||
#define DM_TARGET "target"
|
|
||||||
|
|
||||||
#define NOINUSE_SET getenv("NOINUSE_CHECK") != NULL
|
|
||||||
|
|
||||||
void dm_free_descriptors(dm_descriptor_t *desc_list);
|
|
||||||
void dm_free_descriptor(dm_descriptor_t desc);
|
|
||||||
void dm_free_name(char *name);
|
|
||||||
void dm_free_swapentries(swaptbl_t *);
|
|
||||||
|
|
||||||
dm_descriptor_t *dm_get_descriptors(dm_desc_type_t type, int filter[],
|
|
||||||
int *errp);
|
|
||||||
dm_descriptor_t *dm_get_associated_descriptors(dm_descriptor_t desc,
|
|
||||||
dm_desc_type_t type, int *errp);
|
|
||||||
dm_desc_type_t *dm_get_associated_types(dm_desc_type_t type);
|
|
||||||
dm_descriptor_t dm_get_descriptor_by_name(dm_desc_type_t desc_type,
|
|
||||||
char *name, int *errp);
|
|
||||||
char *dm_get_name(dm_descriptor_t desc, int *errp);
|
|
||||||
dm_desc_type_t dm_get_type(dm_descriptor_t desc);
|
|
||||||
nvlist_t *dm_get_attributes(dm_descriptor_t desc, int *errp);
|
|
||||||
nvlist_t *dm_get_stats(dm_descriptor_t desc, int stat_type,
|
|
||||||
int *errp);
|
|
||||||
void dm_init_event_queue(void(*callback)(nvlist_t *, int),
|
|
||||||
int *errp);
|
|
||||||
nvlist_t *dm_get_event(int *errp);
|
|
||||||
void dm_get_slices(char *drive, dm_descriptor_t **slices,
|
|
||||||
int *errp);
|
|
||||||
void dm_get_slice_stats(char *slice, nvlist_t **dev_stats,
|
|
||||||
int *errp);
|
|
||||||
int dm_get_swapentries(swaptbl_t **, int *);
|
|
||||||
void dm_get_usage_string(char *who, char *data, char **msg);
|
|
||||||
int dm_inuse(char *dev_name, char **msg, dm_who_type_t who,
|
|
||||||
int *errp);
|
|
||||||
int dm_inuse_swap(const char *dev_name, int *errp);
|
|
||||||
int dm_isoverlapping(char *dev_name, char **msg, int *errp);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _LIBDISKMGT_H */
|
|
||||||
#endif /* HAVE_LIBDISKMGT_H */
|
|
|
@ -1,287 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* basic API declarations for share management
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "zfs_config.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_LIBSHARE
|
|
||||||
#include_next <libshare.h>
|
|
||||||
#else
|
|
||||||
|
|
||||||
#ifndef _LIBSHARE_H
|
|
||||||
#define _LIBSHARE_H
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Basic datatypes for most functions
|
|
||||||
*/
|
|
||||||
typedef void *sa_group_t;
|
|
||||||
typedef void *sa_share_t;
|
|
||||||
typedef void *sa_property_t;
|
|
||||||
typedef void *sa_optionset_t;
|
|
||||||
typedef void *sa_security_t;
|
|
||||||
typedef void *sa_protocol_properties_t;
|
|
||||||
typedef void *sa_resource_t;
|
|
||||||
|
|
||||||
typedef void *sa_handle_t; /* opaque handle to access core functions */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* defined error values
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define SA_OK 0
|
|
||||||
#define SA_NO_SUCH_PATH 1 /* provided path doesn't exist */
|
|
||||||
#define SA_NO_MEMORY 2 /* no memory for data structures */
|
|
||||||
#define SA_DUPLICATE_NAME 3 /* object name is already in use */
|
|
||||||
#define SA_BAD_PATH 4 /* not a full path */
|
|
||||||
#define SA_NO_SUCH_GROUP 5 /* group is not defined */
|
|
||||||
#define SA_CONFIG_ERR 6 /* system configuration error */
|
|
||||||
#define SA_SYSTEM_ERR 7 /* system error, use errno */
|
|
||||||
#define SA_SYNTAX_ERR 8 /* syntax error on command line */
|
|
||||||
#define SA_NO_PERMISSION 9 /* no permission for operation */
|
|
||||||
#define SA_BUSY 10 /* resource is busy */
|
|
||||||
#define SA_NO_SUCH_PROP 11 /* property doesn't exist */
|
|
||||||
#define SA_INVALID_NAME 12 /* name of object is invalid */
|
|
||||||
#define SA_INVALID_PROTOCOL 13 /* specified protocol not valid */
|
|
||||||
#define SA_NOT_ALLOWED 14 /* operation not allowed */
|
|
||||||
#define SA_BAD_VALUE 15 /* bad value for property */
|
|
||||||
#define SA_INVALID_SECURITY 16 /* invalid security type */
|
|
||||||
#define SA_NO_SUCH_SECURITY 17 /* security set not found */
|
|
||||||
#define SA_VALUE_CONFLICT 18 /* property value conflict */
|
|
||||||
#define SA_NOT_IMPLEMENTED 19 /* plugin interface not implemented */
|
|
||||||
#define SA_INVALID_PATH 20 /* path is sub-dir of existing share */
|
|
||||||
#define SA_NOT_SUPPORTED 21 /* operation not supported for proto */
|
|
||||||
#define SA_PROP_SHARE_ONLY 22 /* property valid on share only */
|
|
||||||
#define SA_NOT_SHARED 23 /* path is not shared */
|
|
||||||
#define SA_NO_SUCH_RESOURCE 24 /* resource not found */
|
|
||||||
#define SA_RESOURCE_REQUIRED 25 /* resource name is required */
|
|
||||||
#define SA_MULTIPLE_ERROR 26 /* multiple protocols reported error */
|
|
||||||
#define SA_PATH_IS_SUBDIR 27 /* check_path found path is subdir */
|
|
||||||
#define SA_PATH_IS_PARENTDIR 28 /* check_path found path is parent */
|
|
||||||
#define SA_NO_SECTION 29 /* protocol requires section info */
|
|
||||||
#define SA_NO_SUCH_SECTION 30 /* no section found */
|
|
||||||
#define SA_NO_PROPERTIES 31 /* no properties found */
|
|
||||||
#define SA_PASSWORD_ENC 32 /* passwords must be encrypted */
|
|
||||||
|
|
||||||
/* API Initialization */
|
|
||||||
#define SA_INIT_SHARE_API 0x0001 /* init share specific interface */
|
|
||||||
#define SA_INIT_CONTROL_API 0x0002 /* init control specific interface */
|
|
||||||
|
|
||||||
/* not part of API returns */
|
|
||||||
#define SA_LEGACY_ERR 32 /* share/unshare error return */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* other defined values
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define SA_MAX_NAME_LEN 100 /* must fit service instance name */
|
|
||||||
#define SA_MAX_RESOURCE_NAME 255 /* Maximum length of resource name */
|
|
||||||
|
|
||||||
/* Used in calls to sa_add_share() and sa_add_resource() */
|
|
||||||
#define SA_SHARE_TRANSIENT 0 /* shared but not across reboot */
|
|
||||||
#define SA_SHARE_LEGACY 1 /* share is in dfstab only */
|
|
||||||
#define SA_SHARE_PERMANENT 2 /* share goes to repository */
|
|
||||||
|
|
||||||
/* sa_check_path() related */
|
|
||||||
#define SA_CHECK_NORMAL 0 /* only check against active shares */
|
|
||||||
#define SA_CHECK_STRICT 1 /* check against all shares */
|
|
||||||
|
|
||||||
/* RBAC related */
|
|
||||||
#define SA_RBAC_MANAGE "solaris.smf.manage.shares"
|
|
||||||
#define SA_RBAC_VALUE "solaris.smf.value.shares"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Feature set bit definitions
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define SA_FEATURE_NONE 0x0000 /* no feature flags set */
|
|
||||||
#define SA_FEATURE_RESOURCE 0x0001 /* resource names are required */
|
|
||||||
#define SA_FEATURE_DFSTAB 0x0002 /* need to manage in dfstab */
|
|
||||||
#define SA_FEATURE_ALLOWSUBDIRS 0x0004 /* allow subdirs to be shared */
|
|
||||||
#define SA_FEATURE_ALLOWPARDIRS 0x0008 /* allow parent dirs to be shared */
|
|
||||||
#define SA_FEATURE_HAS_SECTIONS 0x0010 /* protocol supports sections */
|
|
||||||
#define SA_FEATURE_ADD_PROPERTIES 0x0020 /* can add properties */
|
|
||||||
#define SA_FEATURE_SERVER 0x0040 /* protocol supports server mode */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* legacy files
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define SA_LEGACY_DFSTAB "/etc/dfs/dfstab"
|
|
||||||
#define SA_LEGACY_SHARETAB "/etc/dfs/sharetab"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* SMF related
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define SA_SVC_FMRI_BASE "svc:/network/shares/group"
|
|
||||||
|
|
||||||
/* initialization */
|
|
||||||
extern sa_handle_t sa_init(int);
|
|
||||||
extern void sa_fini(sa_handle_t);
|
|
||||||
extern int sa_update_config(sa_handle_t);
|
|
||||||
extern char *sa_errorstr(int);
|
|
||||||
|
|
||||||
/* protocol names */
|
|
||||||
extern int sa_get_protocols(char ***);
|
|
||||||
extern int sa_valid_protocol(char *);
|
|
||||||
|
|
||||||
/* group control (create, remove, etc) */
|
|
||||||
extern sa_group_t sa_create_group(sa_handle_t, char *, int *);
|
|
||||||
extern int sa_remove_group(sa_group_t);
|
|
||||||
extern sa_group_t sa_get_group(sa_handle_t, char *);
|
|
||||||
extern sa_group_t sa_get_next_group(sa_group_t);
|
|
||||||
extern char *sa_get_group_attr(sa_group_t, char *);
|
|
||||||
extern int sa_set_group_attr(sa_group_t, char *, char *);
|
|
||||||
extern sa_group_t sa_get_sub_group(sa_group_t);
|
|
||||||
extern int sa_valid_group_name(char *);
|
|
||||||
|
|
||||||
/* share control */
|
|
||||||
extern sa_share_t sa_add_share(sa_group_t, char *, int, int *);
|
|
||||||
extern int sa_check_path(sa_group_t, char *, int);
|
|
||||||
extern int sa_move_share(sa_group_t, sa_share_t);
|
|
||||||
extern int sa_remove_share(sa_share_t);
|
|
||||||
extern sa_share_t sa_get_share(sa_group_t, char *);
|
|
||||||
extern sa_share_t sa_find_share(sa_handle_t, char *);
|
|
||||||
extern sa_share_t sa_get_next_share(sa_share_t);
|
|
||||||
extern char *sa_get_share_attr(sa_share_t, char *);
|
|
||||||
extern char *sa_get_share_description(sa_share_t);
|
|
||||||
extern sa_group_t sa_get_parent_group(sa_share_t);
|
|
||||||
extern int sa_set_share_attr(sa_share_t, char *, char *);
|
|
||||||
extern int sa_set_share_description(sa_share_t, char *);
|
|
||||||
extern int sa_enable_share(sa_group_t, char *);
|
|
||||||
extern int sa_disable_share(sa_share_t, char *);
|
|
||||||
extern int sa_is_share(void *);
|
|
||||||
|
|
||||||
/* resource name related */
|
|
||||||
extern sa_resource_t sa_find_resource(sa_handle_t, char *);
|
|
||||||
extern sa_resource_t sa_get_resource(sa_group_t, char *);
|
|
||||||
extern sa_resource_t sa_get_next_resource(sa_resource_t);
|
|
||||||
extern sa_share_t sa_get_resource_parent(sa_resource_t);
|
|
||||||
extern sa_resource_t sa_get_share_resource(sa_share_t, char *);
|
|
||||||
extern sa_resource_t sa_add_resource(sa_share_t, char *, int, int *);
|
|
||||||
extern int sa_remove_resource(sa_resource_t);
|
|
||||||
extern char *sa_get_resource_attr(sa_resource_t, char *);
|
|
||||||
extern int sa_set_resource_attr(sa_resource_t, char *, char *);
|
|
||||||
extern int sa_set_resource_description(sa_resource_t, char *);
|
|
||||||
extern char *sa_get_resource_description(sa_resource_t);
|
|
||||||
extern int sa_enable_resource(sa_resource_t, char *);
|
|
||||||
extern int sa_disable_resource(sa_resource_t, char *);
|
|
||||||
extern int sa_rename_resource(sa_resource_t, char *);
|
|
||||||
extern void sa_fix_resource_name(char *);
|
|
||||||
|
|
||||||
/* data structure free calls */
|
|
||||||
extern void sa_free_attr_string(char *);
|
|
||||||
extern void sa_free_share_description(char *);
|
|
||||||
|
|
||||||
/* optionset control */
|
|
||||||
extern sa_optionset_t sa_get_optionset(sa_group_t, char *);
|
|
||||||
extern sa_optionset_t sa_get_next_optionset(sa_group_t);
|
|
||||||
extern char *sa_get_optionset_attr(sa_optionset_t, char *);
|
|
||||||
extern void sa_set_optionset_attr(sa_optionset_t, char *, char *);
|
|
||||||
extern sa_optionset_t sa_create_optionset(sa_group_t, char *);
|
|
||||||
extern int sa_destroy_optionset(sa_optionset_t);
|
|
||||||
extern sa_optionset_t sa_get_derived_optionset(void *, char *, int);
|
|
||||||
extern void sa_free_derived_optionset(sa_optionset_t);
|
|
||||||
|
|
||||||
/* property functions */
|
|
||||||
extern sa_property_t sa_get_property(sa_optionset_t, char *);
|
|
||||||
extern sa_property_t sa_get_next_property(sa_group_t);
|
|
||||||
extern char *sa_get_property_attr(sa_property_t, char *);
|
|
||||||
extern sa_property_t sa_create_section(char *, char *);
|
|
||||||
extern void sa_set_section_attr(sa_property_t, char *, char *);
|
|
||||||
extern sa_property_t sa_create_property(char *, char *);
|
|
||||||
extern int sa_add_property(void *, sa_property_t);
|
|
||||||
extern int sa_update_property(sa_property_t, char *);
|
|
||||||
extern int sa_remove_property(sa_property_t);
|
|
||||||
extern int sa_commit_properties(sa_optionset_t, int);
|
|
||||||
extern int sa_valid_property(void *, char *, sa_property_t);
|
|
||||||
extern int sa_is_persistent(void *);
|
|
||||||
|
|
||||||
/* security control */
|
|
||||||
extern sa_security_t sa_get_security(sa_group_t, char *, char *);
|
|
||||||
extern sa_security_t sa_get_next_security(sa_security_t);
|
|
||||||
extern char *sa_get_security_attr(sa_optionset_t, char *);
|
|
||||||
extern sa_security_t sa_create_security(sa_group_t, char *, char *);
|
|
||||||
extern int sa_destroy_security(sa_security_t);
|
|
||||||
extern void sa_set_security_attr(sa_security_t, char *, char *);
|
|
||||||
extern sa_optionset_t sa_get_all_security_types(void *, char *, int);
|
|
||||||
extern sa_security_t sa_get_derived_security(void *, char *, char *, int);
|
|
||||||
extern void sa_free_derived_security(sa_security_t);
|
|
||||||
|
|
||||||
/* protocol specific interfaces */
|
|
||||||
extern int sa_parse_legacy_options(sa_group_t, char *, char *);
|
|
||||||
extern char *sa_proto_legacy_format(char *, sa_group_t, int);
|
|
||||||
extern int sa_is_security(char *, char *);
|
|
||||||
extern sa_protocol_properties_t sa_proto_get_properties(char *);
|
|
||||||
extern uint64_t sa_proto_get_featureset(char *);
|
|
||||||
extern sa_property_t sa_get_protocol_section(sa_protocol_properties_t, char *);
|
|
||||||
extern sa_property_t sa_get_next_protocol_section(sa_property_t, char *);
|
|
||||||
extern sa_property_t sa_get_protocol_property(sa_protocol_properties_t, char *);
|
|
||||||
extern sa_property_t sa_get_next_protocol_property(sa_property_t, char *);
|
|
||||||
extern int sa_set_protocol_property(sa_property_t, char *, char *);
|
|
||||||
extern char *sa_get_protocol_status(char *);
|
|
||||||
extern void sa_format_free(char *);
|
|
||||||
extern sa_protocol_properties_t sa_create_protocol_properties(char *);
|
|
||||||
extern int sa_add_protocol_property(sa_protocol_properties_t, sa_property_t);
|
|
||||||
extern int sa_proto_valid_prop(char *, sa_property_t, sa_optionset_t);
|
|
||||||
extern int sa_proto_valid_space(char *, char *);
|
|
||||||
extern char *sa_proto_space_alias(char *, char *);
|
|
||||||
extern int sa_proto_get_transients(sa_handle_t, char *);
|
|
||||||
extern int sa_proto_notify_resource(sa_resource_t, char *);
|
|
||||||
extern int sa_proto_change_notify(sa_share_t, char *);
|
|
||||||
extern int sa_proto_delete_section(char *, char *);
|
|
||||||
|
|
||||||
/* handle legacy (dfstab/sharetab) files */
|
|
||||||
extern int sa_delete_legacy(sa_share_t, char *);
|
|
||||||
extern int sa_update_legacy(sa_share_t, char *);
|
|
||||||
extern int sa_update_sharetab(sa_share_t, char *);
|
|
||||||
extern int sa_delete_sharetab(sa_handle_t, char *, char *);
|
|
||||||
|
|
||||||
/* ZFS functions */
|
|
||||||
extern int sa_zfs_is_shared(sa_handle_t, char *);
|
|
||||||
extern int sa_group_is_zfs(sa_group_t);
|
|
||||||
extern int sa_path_is_zfs(char *);
|
|
||||||
|
|
||||||
/* SA Handle specific functions */
|
|
||||||
extern sa_handle_t sa_find_group_handle(sa_group_t);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _LIBSHARE_H */
|
|
||||||
#endif /* HAVE_LIBSHARE */
|
|
|
@ -1,35 +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 2007 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include_next <mntent.h>
|
|
||||||
|
|
||||||
#ifndef _PORT_MNTENT_H
|
|
||||||
#define _PORT_MNTENT_H
|
|
||||||
|
|
||||||
/* For HAVE_SETMNTENT */
|
|
||||||
#include "zfs_config.h"
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,38 +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 2007 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include_next <stdlib.h>
|
|
||||||
|
|
||||||
#ifndef _PORT_STDLIB_H
|
|
||||||
#define _PORT_STDLIB_H
|
|
||||||
|
|
||||||
#include "zfs_config.h"
|
|
||||||
|
|
||||||
#ifndef HAVE_GETEXECNAME
|
|
||||||
extern const char *getexecname();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,46 +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 2007 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include_next <string.h>
|
|
||||||
|
|
||||||
#ifndef _PORT_STRING_H
|
|
||||||
#define _PORT_STRING_H
|
|
||||||
|
|
||||||
#include "zfs_config.h"
|
|
||||||
|
|
||||||
#ifndef HAVE_STRLCPY
|
|
||||||
extern size_t strlcpy(char *dst, const char *src, size_t len);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef HAVE_STRLCAT
|
|
||||||
extern size_t strlcat(char *, const char *, size_t);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef HAVE_STRNLEN
|
|
||||||
extern size_t strnlen(const char *src, size_t maxlen);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,38 +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 2007 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include_next <strings.h>
|
|
||||||
|
|
||||||
#ifndef _PORT_STRINGS_H
|
|
||||||
#define _PORT_STRINGS_H
|
|
||||||
|
|
||||||
#include "zfs_config.h"
|
|
||||||
|
|
||||||
#ifndef HAVE_STRCMP_IN_STRINGS_H
|
|
||||||
#include <string.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,37 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include_next <stropts.h>
|
|
||||||
|
|
||||||
#ifndef _PORT_STROPTS_H
|
|
||||||
#define _PORT_STROPTS_H
|
|
||||||
|
|
||||||
#include "zfs_config.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_IOCTL_IN_STROPTS_H
|
|
||||||
#include <fake_ioctl.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _PORT_STROPTS_H */
|
|
|
@ -1,31 +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 2007 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "zfs_config.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_BYTEORDER_H
|
|
||||||
#include_next <sys/byteorder.h>
|
|
||||||
#endif
|
|
|
@ -1,47 +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 2008 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _PORT_SYS_DEBUG_H
|
|
||||||
#define _PORT_SYS_DEBUG_H
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
/* This definition is copied from assert.h. */
|
|
||||||
#if defined(__STDC__)
|
|
||||||
#if __STDC_VERSION__ - 0 >= 199901L
|
|
||||||
#define zp_verify(EX) (void)((EX) || \
|
|
||||||
(__assert_c99(#EX, __FILE__, __LINE__, __func__), 0))
|
|
||||||
#else
|
|
||||||
#define zp_verify(EX) (void)((EX) || (__assert(#EX, __FILE__, __LINE__), 0))
|
|
||||||
#endif /* __STDC_VERSION__ - 0 >= 199901L */
|
|
||||||
#else
|
|
||||||
#define zp_verify(EX) (void)((EX) || (_assert("EX", __FILE__, __LINE__), 0))
|
|
||||||
#endif /* __STDC__ */
|
|
||||||
|
|
||||||
#define VERIFY(EX) zp_verify(EX)
|
|
||||||
#define ASSERT(EX) assert(EX)
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,37 +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 2007 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "zfs_config.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_LIBEFI
|
|
||||||
|
|
||||||
#include_next <sys/efi_partition.h>
|
|
||||||
|
|
||||||
#ifndef EFI_MIN_RESV_SIZE
|
|
||||||
#define EFI_MIN_RESV_SIZE (16 * 1024)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,37 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include_next <sys/ioctl.h>
|
|
||||||
|
|
||||||
#ifndef _PORT_SYS_IOCTL_H
|
|
||||||
#define _PORT_SYS_IOCTL_H
|
|
||||||
|
|
||||||
#include "zfs_config.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_IOCTL_IN_SYS_IOCTL_H
|
|
||||||
#include <fake_ioctl.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _PORT_SYS_IOCTL_H */
|
|
|
@ -1,31 +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 2007 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "zfs_config.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_ISA_DEFS_H
|
|
||||||
#include_next <sys/isa_defs.h>
|
|
||||||
#endif
|
|
|
@ -1,40 +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 2008 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _PORT_SYS_POLICY_H
|
|
||||||
#define _PORT_SYS_POLICY_H
|
|
||||||
|
|
||||||
#ifdef WANT_KERNEL_EMUL
|
|
||||||
|
|
||||||
#define secpolicy_fs_unmount(c,vfs) (0)
|
|
||||||
#define secpolicy_nfs(c) (0)
|
|
||||||
#define secpolicy_sys_config(c,co) (0)
|
|
||||||
#define secpolicy_zfs(c) (0)
|
|
||||||
#define secpolicy_zinject(c) (0)
|
|
||||||
|
|
||||||
#endif /* WANT_KERNEL_EMUL */
|
|
||||||
|
|
||||||
#endif /* _PORT_SYS_POLICY_H */
|
|
|
@ -1,37 +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 2008 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include_next <sys/socket.h>
|
|
||||||
|
|
||||||
#ifndef _PORT_SYS_SOCKET_H
|
|
||||||
#define _PORT_SYS_SOCKET_H
|
|
||||||
|
|
||||||
/* Solaris doesn't have MSG_NOSIGNAL */
|
|
||||||
#ifndef MSG_NOSIGNAL
|
|
||||||
#define MSG_NOSIGNAL 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,32 +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 2007 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _PORT_SYS_SWAP_H
|
|
||||||
#define _PORT_SYS_SWAP_H
|
|
||||||
|
|
||||||
typedef int swaptbl_t;
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,40 +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 2007 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "zfs_config.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_SYSTEMINFO_H
|
|
||||||
#include_next <sys/systeminfo.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _PORT_SYS_SYSTEMINFO_H
|
|
||||||
#define _PORT_SYS_SYSTEMINFO_H
|
|
||||||
|
|
||||||
#ifndef HAVE_SYSINFO_IN_SYSTEMINFO_H
|
|
||||||
#define sysinfo(cmd,buf,cnt) (-1)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,40 +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 2008 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _PORT_SYS_SYSTM_H
|
|
||||||
#define _PORT_SYS_SYSTM_H
|
|
||||||
|
|
||||||
#ifdef WANT_KERNEL_EMUL
|
|
||||||
|
|
||||||
#include <sys/dmu_ctl.h>
|
|
||||||
|
|
||||||
#define copyinstr(from,to,max,len) dctls_copyinstr(from,to,max,len)
|
|
||||||
#define xcopyin(src,dest,size) dctls_copyin(src,dest,size)
|
|
||||||
#define xcopyout(src,dest,size) dctls_copyout(src,dest,size)
|
|
||||||
|
|
||||||
#endif /* WANT_KERNEL_EMUL */
|
|
||||||
|
|
||||||
#endif /* _PORT_SYS_SYSM_H */
|
|
|
@ -1,31 +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 2007 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include_next <sys/time.h>
|
|
||||||
|
|
||||||
#ifndef NANOSEC
|
|
||||||
#define NANOSEC 1000000000
|
|
||||||
#endif
|
|
|
@ -1,49 +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 2007 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include_next <sys/types.h>
|
|
||||||
|
|
||||||
#ifndef _PORT_SYS_TYPES_H
|
|
||||||
#define _PORT_SYS_TYPES_H
|
|
||||||
|
|
||||||
#include "zfs_config.h"
|
|
||||||
|
|
||||||
#ifndef HAVE_INTTYPES
|
|
||||||
#include <inttypes.h>
|
|
||||||
|
|
||||||
typedef enum boolean { B_FALSE, B_TRUE } boolean_t;
|
|
||||||
|
|
||||||
typedef unsigned char uchar_t;
|
|
||||||
typedef unsigned short ushort_t;
|
|
||||||
typedef unsigned int uint_t;
|
|
||||||
typedef unsigned long ulong_t;
|
|
||||||
|
|
||||||
typedef long long longlong_t;
|
|
||||||
typedef unsigned long long u_longlong_t;
|
|
||||||
|
|
||||||
#endif /* HAVE_INTTYPES */
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,119 +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 2007 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "zfs_config.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_UNICODE
|
|
||||||
#include_next <sys/u8_textprep.h>
|
|
||||||
#else
|
|
||||||
|
|
||||||
#ifndef _SYS_U8_TEXTPREP_H
|
|
||||||
#define _SYS_U8_TEXTPREP_H
|
|
||||||
|
|
||||||
#include <sys/isa_defs.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/errno.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Unicode encoding conversion functions and their macros.
|
|
||||||
*/
|
|
||||||
#define UCONV_IN_BIG_ENDIAN 0x0001
|
|
||||||
#define UCONV_OUT_BIG_ENDIAN 0x0002
|
|
||||||
#define UCONV_IN_SYSTEM_ENDIAN 0x0004
|
|
||||||
#define UCONV_OUT_SYSTEM_ENDIAN 0x0008
|
|
||||||
#define UCONV_IN_LITTLE_ENDIAN 0x0010
|
|
||||||
#define UCONV_OUT_LITTLE_ENDIAN 0x0020
|
|
||||||
#define UCONV_IGNORE_NULL 0x0040
|
|
||||||
#define UCONV_IN_ACCEPT_BOM 0x0080
|
|
||||||
#define UCONV_OUT_EMIT_BOM 0x0100
|
|
||||||
|
|
||||||
extern int uconv_u16tou32(const uint16_t *, size_t *, uint32_t *, size_t *,
|
|
||||||
int);
|
|
||||||
extern int uconv_u16tou8(const uint16_t *, size_t *, uchar_t *, size_t *, int);
|
|
||||||
extern int uconv_u32tou16(const uint32_t *, size_t *, uint16_t *, size_t *,
|
|
||||||
int);
|
|
||||||
extern int uconv_u32tou8(const uint32_t *, size_t *, uchar_t *, size_t *, int);
|
|
||||||
extern int uconv_u8tou16(const uchar_t *, size_t *, uint16_t *, size_t *, int);
|
|
||||||
extern int uconv_u8tou32(const uchar_t *, size_t *, uint32_t *, size_t *, int);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* UTF-8 text preparation functions and their macros.
|
|
||||||
*
|
|
||||||
* Among the macros defined, U8_CANON_DECOMP, U8_COMPAT_DECOMP, and
|
|
||||||
* U8_CANON_COMP are not public interfaces and must not be used directly
|
|
||||||
* at the flag input argument.
|
|
||||||
*/
|
|
||||||
#define U8_STRCMP_CS (0x00000001)
|
|
||||||
#define U8_STRCMP_CI_UPPER (0x00000002)
|
|
||||||
#define U8_STRCMP_CI_LOWER (0x00000004)
|
|
||||||
|
|
||||||
#define U8_CANON_DECOMP (0x00000010)
|
|
||||||
#define U8_COMPAT_DECOMP (0x00000020)
|
|
||||||
#define U8_CANON_COMP (0x00000040)
|
|
||||||
|
|
||||||
#define U8_STRCMP_NFD (U8_CANON_DECOMP)
|
|
||||||
#define U8_STRCMP_NFC (U8_CANON_DECOMP | U8_CANON_COMP)
|
|
||||||
#define U8_STRCMP_NFKD (U8_COMPAT_DECOMP)
|
|
||||||
#define U8_STRCMP_NFKC (U8_COMPAT_DECOMP | U8_CANON_COMP)
|
|
||||||
|
|
||||||
#define U8_TEXTPREP_TOUPPER (U8_STRCMP_CI_UPPER)
|
|
||||||
#define U8_TEXTPREP_TOLOWER (U8_STRCMP_CI_LOWER)
|
|
||||||
|
|
||||||
#define U8_TEXTPREP_NFD (U8_STRCMP_NFD)
|
|
||||||
#define U8_TEXTPREP_NFC (U8_STRCMP_NFC)
|
|
||||||
#define U8_TEXTPREP_NFKD (U8_STRCMP_NFKD)
|
|
||||||
#define U8_TEXTPREP_NFKC (U8_STRCMP_NFKC)
|
|
||||||
|
|
||||||
#define U8_TEXTPREP_IGNORE_NULL (0x00010000)
|
|
||||||
#define U8_TEXTPREP_IGNORE_INVALID (0x00020000)
|
|
||||||
#define U8_TEXTPREP_NOWAIT (0x00040000)
|
|
||||||
|
|
||||||
#define U8_UNICODE_320 (0)
|
|
||||||
#define U8_UNICODE_500 (1)
|
|
||||||
#define U8_UNICODE_LATEST (U8_UNICODE_500)
|
|
||||||
|
|
||||||
#define U8_VALIDATE_ENTIRE (0x00100000)
|
|
||||||
#define U8_VALIDATE_CHECK_ADDITIONAL (0x00200000)
|
|
||||||
#define U8_VALIDATE_UCS2_RANGE (0x00400000)
|
|
||||||
|
|
||||||
#define U8_ILLEGAL_CHAR (-1)
|
|
||||||
#define U8_OUT_OF_RANGE_CHAR (-2)
|
|
||||||
|
|
||||||
extern int u8_validate(char *, size_t, char **, int, int *);
|
|
||||||
extern int u8_strcmp(const char *, const char *, size_t, int, size_t, int *);
|
|
||||||
extern size_t u8_textprep_str(char *, size_t *, char *, size_t *, int, size_t,
|
|
||||||
int *);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* HAVE_UNICODE */
|
|
||||||
|
|
||||||
#endif /* _SYS_U8_TEXTPREP_H */
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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 2008 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include_next <unistd.h>
|
|
||||||
|
|
||||||
#ifndef _PORT_UNISTD_H
|
|
||||||
#define _PORT_UNISTD_H
|
|
||||||
|
|
||||||
#include "zfs_config.h"
|
|
||||||
|
|
||||||
#ifndef HAVE_ISSETUGID
|
|
||||||
#include <sys/types.h>
|
|
||||||
#define issetugid() (geteuid() == 0 || getegid() == 0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_IOCTL_IN_UNISTD_H
|
|
||||||
#include <fake_ioctl.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(__sun__) && !defined(__sun)
|
|
||||||
/* It seems Solaris only returns positive host ids */
|
|
||||||
static inline long fake_gethostid()
|
|
||||||
{
|
|
||||||
long id = gethostid();
|
|
||||||
return id >= 0 ? id : -id;
|
|
||||||
}
|
|
||||||
#define gethostid() fake_gethostid()
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _PORT_UNISTD_H */
|
|
|
@ -1,63 +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 2007 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <pthread.h>
|
|
||||||
#include <limits.h>
|
|
||||||
|
|
||||||
#include "zfs_config.h"
|
|
||||||
|
|
||||||
#ifndef HAVE_GETEXECNAME
|
|
||||||
|
|
||||||
const char *getexecname()
|
|
||||||
{
|
|
||||||
#ifdef __linux__
|
|
||||||
static char execname[PATH_MAX + 1];
|
|
||||||
/* Must be MT-safe */
|
|
||||||
static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER;
|
|
||||||
|
|
||||||
pthread_mutex_lock(&mtx);
|
|
||||||
|
|
||||||
if (strlen(execname) == 0) {
|
|
||||||
ssize_t rc = readlink("/proc/self/exe", execname, sizeof(execname - 1));
|
|
||||||
if (rc == -1) {
|
|
||||||
execname[0] = '\0';
|
|
||||||
pthread_mutex_unlock(&mtx);
|
|
||||||
return NULL;
|
|
||||||
} else
|
|
||||||
execname[rc] = '\0';
|
|
||||||
}
|
|
||||||
pthread_mutex_unlock(&mtx);
|
|
||||||
|
|
||||||
return execname;
|
|
||||||
#else
|
|
||||||
return NULL;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,617 +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 2007 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
.ident "%Z%%M% %I% %E% SMI"
|
|
||||||
|
|
||||||
.file "%M%"
|
|
||||||
|
|
||||||
#define _ASM
|
|
||||||
#include <sys/asm_linkage.h>
|
|
||||||
|
|
||||||
#if defined(_KERNEL)
|
|
||||||
/*
|
|
||||||
* Legacy kernel interfaces; they will go away (eventually).
|
|
||||||
*/
|
|
||||||
ANSI_PRAGMA_WEAK2(cas8,atomic_cas_8,function)
|
|
||||||
ANSI_PRAGMA_WEAK2(cas32,atomic_cas_32,function)
|
|
||||||
ANSI_PRAGMA_WEAK2(cas64,atomic_cas_64,function)
|
|
||||||
ANSI_PRAGMA_WEAK2(caslong,atomic_cas_ulong,function)
|
|
||||||
ANSI_PRAGMA_WEAK2(casptr,atomic_cas_ptr,function)
|
|
||||||
ANSI_PRAGMA_WEAK2(atomic_and_long,atomic_and_ulong,function)
|
|
||||||
ANSI_PRAGMA_WEAK2(atomic_or_long,atomic_or_ulong,function)
|
|
||||||
#else
|
|
||||||
/*
|
|
||||||
* Include the definitions for the libc weak aliases.
|
|
||||||
*/
|
|
||||||
#include "../atomic_asm_weak.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ENTRY(atomic_inc_8)
|
|
||||||
ALTENTRY(atomic_inc_uchar)
|
|
||||||
lock
|
|
||||||
incb (%rdi)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_inc_uchar)
|
|
||||||
SET_SIZE(atomic_inc_8)
|
|
||||||
|
|
||||||
ENTRY(atomic_inc_16)
|
|
||||||
ALTENTRY(atomic_inc_ushort)
|
|
||||||
lock
|
|
||||||
incw (%rdi)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_inc_ushort)
|
|
||||||
SET_SIZE(atomic_inc_16)
|
|
||||||
|
|
||||||
ENTRY(atomic_inc_32)
|
|
||||||
ALTENTRY(atomic_inc_uint)
|
|
||||||
lock
|
|
||||||
incl (%rdi)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_inc_uint)
|
|
||||||
SET_SIZE(atomic_inc_32)
|
|
||||||
|
|
||||||
ENTRY(atomic_inc_64)
|
|
||||||
ALTENTRY(atomic_inc_ulong)
|
|
||||||
lock
|
|
||||||
incq (%rdi)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_inc_ulong)
|
|
||||||
SET_SIZE(atomic_inc_64)
|
|
||||||
|
|
||||||
ENTRY(atomic_inc_8_nv)
|
|
||||||
ALTENTRY(atomic_inc_uchar_nv)
|
|
||||||
movb (%rdi), %al
|
|
||||||
1:
|
|
||||||
leaq 1(%rax), %rcx
|
|
||||||
lock
|
|
||||||
cmpxchgb %cl, (%rdi)
|
|
||||||
jne 1b
|
|
||||||
movzbl %cl, %eax
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_inc_uchar_nv)
|
|
||||||
SET_SIZE(atomic_inc_8_nv)
|
|
||||||
|
|
||||||
ENTRY(atomic_inc_16_nv)
|
|
||||||
ALTENTRY(atomic_inc_ushort_nv)
|
|
||||||
movw (%rdi), %ax
|
|
||||||
1:
|
|
||||||
leaq 1(%rax), %rcx
|
|
||||||
lock
|
|
||||||
cmpxchgw %cx, (%rdi)
|
|
||||||
jne 1b
|
|
||||||
movzwl %cx, %eax
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_inc_ushort_nv)
|
|
||||||
SET_SIZE(atomic_inc_16_nv)
|
|
||||||
|
|
||||||
ENTRY(atomic_inc_32_nv)
|
|
||||||
ALTENTRY(atomic_inc_uint_nv)
|
|
||||||
movl (%rdi), %eax
|
|
||||||
1:
|
|
||||||
leaq 1(%rax), %rcx
|
|
||||||
lock
|
|
||||||
cmpxchgl %ecx, (%rdi)
|
|
||||||
jne 1b
|
|
||||||
movl %ecx, %eax
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_inc_uint_nv)
|
|
||||||
SET_SIZE(atomic_inc_32_nv)
|
|
||||||
|
|
||||||
ENTRY(atomic_inc_64_nv)
|
|
||||||
ALTENTRY(atomic_inc_ulong_nv)
|
|
||||||
movq (%rdi), %rax
|
|
||||||
1:
|
|
||||||
leaq 1(%rax), %rcx
|
|
||||||
lock
|
|
||||||
cmpxchgq %rcx, (%rdi)
|
|
||||||
jne 1b
|
|
||||||
movq %rcx, %rax
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_inc_ulong_nv)
|
|
||||||
SET_SIZE(atomic_inc_64_nv)
|
|
||||||
|
|
||||||
ENTRY(atomic_dec_8)
|
|
||||||
ALTENTRY(atomic_dec_uchar)
|
|
||||||
lock
|
|
||||||
decb (%rdi)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_dec_uchar)
|
|
||||||
SET_SIZE(atomic_dec_8)
|
|
||||||
|
|
||||||
ENTRY(atomic_dec_16)
|
|
||||||
ALTENTRY(atomic_dec_ushort)
|
|
||||||
lock
|
|
||||||
decw (%rdi)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_dec_ushort)
|
|
||||||
SET_SIZE(atomic_dec_16)
|
|
||||||
|
|
||||||
ENTRY(atomic_dec_32)
|
|
||||||
ALTENTRY(atomic_dec_uint)
|
|
||||||
lock
|
|
||||||
decl (%rdi)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_dec_uint)
|
|
||||||
SET_SIZE(atomic_dec_32)
|
|
||||||
|
|
||||||
ENTRY(atomic_dec_64)
|
|
||||||
ALTENTRY(atomic_dec_ulong)
|
|
||||||
lock
|
|
||||||
decq (%rdi)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_dec_ulong)
|
|
||||||
SET_SIZE(atomic_dec_64)
|
|
||||||
|
|
||||||
ENTRY(atomic_dec_8_nv)
|
|
||||||
ALTENTRY(atomic_dec_uchar_nv)
|
|
||||||
movb (%rdi), %al
|
|
||||||
1:
|
|
||||||
leaq -1(%rax), %rcx
|
|
||||||
lock
|
|
||||||
cmpxchgb %cl, (%rdi)
|
|
||||||
jne 1b
|
|
||||||
movzbl %cl, %eax
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_dec_uchar_nv)
|
|
||||||
SET_SIZE(atomic_dec_8_nv)
|
|
||||||
|
|
||||||
ENTRY(atomic_dec_16_nv)
|
|
||||||
ALTENTRY(atomic_dec_ushort_nv)
|
|
||||||
movw (%rdi), %ax
|
|
||||||
1:
|
|
||||||
leaq -1(%rax), %rcx
|
|
||||||
lock
|
|
||||||
cmpxchgw %cx, (%rdi)
|
|
||||||
jne 1b
|
|
||||||
movzwl %cx, %eax
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_dec_ushort_nv)
|
|
||||||
SET_SIZE(atomic_dec_16_nv)
|
|
||||||
|
|
||||||
ENTRY(atomic_dec_32_nv)
|
|
||||||
ALTENTRY(atomic_dec_uint_nv)
|
|
||||||
movl (%rdi), %eax
|
|
||||||
1:
|
|
||||||
leaq -1(%rax), %rcx
|
|
||||||
lock
|
|
||||||
cmpxchgl %ecx, (%rdi)
|
|
||||||
jne 1b
|
|
||||||
movl %ecx, %eax
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_dec_uint_nv)
|
|
||||||
SET_SIZE(atomic_dec_32_nv)
|
|
||||||
|
|
||||||
ENTRY(atomic_dec_64_nv)
|
|
||||||
ALTENTRY(atomic_dec_ulong_nv)
|
|
||||||
movq (%rdi), %rax
|
|
||||||
1:
|
|
||||||
leaq -1(%rax), %rcx
|
|
||||||
lock
|
|
||||||
cmpxchgq %rcx, (%rdi)
|
|
||||||
jne 1b
|
|
||||||
movq %rcx, %rax
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_dec_ulong_nv)
|
|
||||||
SET_SIZE(atomic_dec_64_nv)
|
|
||||||
|
|
||||||
ENTRY(atomic_add_8)
|
|
||||||
ALTENTRY(atomic_add_char)
|
|
||||||
lock
|
|
||||||
addb %sil, (%rdi)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_add_char)
|
|
||||||
SET_SIZE(atomic_add_8)
|
|
||||||
|
|
||||||
ENTRY(atomic_add_16)
|
|
||||||
ALTENTRY(atomic_add_short)
|
|
||||||
lock
|
|
||||||
addw %si, (%rdi)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_add_short)
|
|
||||||
SET_SIZE(atomic_add_16)
|
|
||||||
|
|
||||||
ENTRY(atomic_add_32)
|
|
||||||
ALTENTRY(atomic_add_int)
|
|
||||||
lock
|
|
||||||
addl %esi, (%rdi)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_add_int)
|
|
||||||
SET_SIZE(atomic_add_32)
|
|
||||||
|
|
||||||
ENTRY(atomic_add_64)
|
|
||||||
ALTENTRY(atomic_add_ptr)
|
|
||||||
ALTENTRY(atomic_add_long)
|
|
||||||
lock
|
|
||||||
addq %rsi, (%rdi)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_add_long)
|
|
||||||
SET_SIZE(atomic_add_ptr)
|
|
||||||
SET_SIZE(atomic_add_64)
|
|
||||||
|
|
||||||
ENTRY(atomic_or_8)
|
|
||||||
ALTENTRY(atomic_or_uchar)
|
|
||||||
lock
|
|
||||||
orb %sil, (%rdi)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_or_uchar)
|
|
||||||
SET_SIZE(atomic_or_8)
|
|
||||||
|
|
||||||
ENTRY(atomic_or_16)
|
|
||||||
ALTENTRY(atomic_or_ushort)
|
|
||||||
lock
|
|
||||||
orw %si, (%rdi)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_or_ushort)
|
|
||||||
SET_SIZE(atomic_or_16)
|
|
||||||
|
|
||||||
ENTRY(atomic_or_32)
|
|
||||||
ALTENTRY(atomic_or_uint)
|
|
||||||
lock
|
|
||||||
orl %esi, (%rdi)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_or_uint)
|
|
||||||
SET_SIZE(atomic_or_32)
|
|
||||||
|
|
||||||
ENTRY(atomic_or_64)
|
|
||||||
ALTENTRY(atomic_or_ulong)
|
|
||||||
lock
|
|
||||||
orq %rsi, (%rdi)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_or_ulong)
|
|
||||||
SET_SIZE(atomic_or_64)
|
|
||||||
|
|
||||||
ENTRY(atomic_and_8)
|
|
||||||
ALTENTRY(atomic_and_uchar)
|
|
||||||
lock
|
|
||||||
andb %sil, (%rdi)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_and_uchar)
|
|
||||||
SET_SIZE(atomic_and_8)
|
|
||||||
|
|
||||||
ENTRY(atomic_and_16)
|
|
||||||
ALTENTRY(atomic_and_ushort)
|
|
||||||
lock
|
|
||||||
andw %si, (%rdi)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_and_ushort)
|
|
||||||
SET_SIZE(atomic_and_16)
|
|
||||||
|
|
||||||
ENTRY(atomic_and_32)
|
|
||||||
ALTENTRY(atomic_and_uint)
|
|
||||||
lock
|
|
||||||
andl %esi, (%rdi)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_and_uint)
|
|
||||||
SET_SIZE(atomic_and_32)
|
|
||||||
|
|
||||||
ENTRY(atomic_and_64)
|
|
||||||
ALTENTRY(atomic_and_ulong)
|
|
||||||
lock
|
|
||||||
andq %rsi, (%rdi)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_and_ulong)
|
|
||||||
SET_SIZE(atomic_and_64)
|
|
||||||
|
|
||||||
ENTRY(atomic_add_8_nv)
|
|
||||||
ALTENTRY(atomic_add_char_nv)
|
|
||||||
movb (%rdi), %al
|
|
||||||
1:
|
|
||||||
movb %sil, %cl
|
|
||||||
addb %al, %cl
|
|
||||||
lock
|
|
||||||
cmpxchgb %cl, (%rdi)
|
|
||||||
jne 1b
|
|
||||||
movzbl %cl, %eax
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_add_char_nv)
|
|
||||||
SET_SIZE(atomic_add_8_nv)
|
|
||||||
|
|
||||||
ENTRY(atomic_add_16_nv)
|
|
||||||
ALTENTRY(atomic_add_short_nv)
|
|
||||||
movw (%rdi), %ax
|
|
||||||
1:
|
|
||||||
movw %si, %cx
|
|
||||||
addw %ax, %cx
|
|
||||||
lock
|
|
||||||
cmpxchgw %cx, (%rdi)
|
|
||||||
jne 1b
|
|
||||||
movzwl %cx, %eax
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_add_short_nv)
|
|
||||||
SET_SIZE(atomic_add_16_nv)
|
|
||||||
|
|
||||||
ENTRY(atomic_add_32_nv)
|
|
||||||
ALTENTRY(atomic_add_int_nv)
|
|
||||||
movl (%rdi), %eax
|
|
||||||
1:
|
|
||||||
movl %esi, %ecx
|
|
||||||
addl %eax, %ecx
|
|
||||||
lock
|
|
||||||
cmpxchgl %ecx, (%rdi)
|
|
||||||
jne 1b
|
|
||||||
movl %ecx, %eax
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_add_int_nv)
|
|
||||||
SET_SIZE(atomic_add_32_nv)
|
|
||||||
|
|
||||||
ENTRY(atomic_add_64_nv)
|
|
||||||
ALTENTRY(atomic_add_ptr_nv)
|
|
||||||
ALTENTRY(atomic_add_long_nv)
|
|
||||||
movq (%rdi), %rax
|
|
||||||
1:
|
|
||||||
movq %rsi, %rcx
|
|
||||||
addq %rax, %rcx
|
|
||||||
lock
|
|
||||||
cmpxchgq %rcx, (%rdi)
|
|
||||||
jne 1b
|
|
||||||
movq %rcx, %rax
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_add_long_nv)
|
|
||||||
SET_SIZE(atomic_add_ptr_nv)
|
|
||||||
SET_SIZE(atomic_add_64_nv)
|
|
||||||
|
|
||||||
ENTRY(atomic_and_8_nv)
|
|
||||||
ALTENTRY(atomic_and_uchar_nv)
|
|
||||||
movb (%rdi), %al
|
|
||||||
1:
|
|
||||||
movb %sil, %cl
|
|
||||||
andb %al, %cl
|
|
||||||
lock
|
|
||||||
cmpxchgb %cl, (%rdi)
|
|
||||||
jne 1b
|
|
||||||
movzbl %cl, %eax
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_and_uchar_nv)
|
|
||||||
SET_SIZE(atomic_and_8_nv)
|
|
||||||
|
|
||||||
ENTRY(atomic_and_16_nv)
|
|
||||||
ALTENTRY(atomic_and_ushort_nv)
|
|
||||||
movw (%rdi), %ax
|
|
||||||
1:
|
|
||||||
movw %si, %cx
|
|
||||||
andw %ax, %cx
|
|
||||||
lock
|
|
||||||
cmpxchgw %cx, (%rdi)
|
|
||||||
jne 1b
|
|
||||||
movzwl %cx, %eax
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_and_ushort_nv)
|
|
||||||
SET_SIZE(atomic_and_16_nv)
|
|
||||||
|
|
||||||
ENTRY(atomic_and_32_nv)
|
|
||||||
ALTENTRY(atomic_and_uint_nv)
|
|
||||||
movl (%rdi), %eax
|
|
||||||
1:
|
|
||||||
movl %esi, %ecx
|
|
||||||
andl %eax, %ecx
|
|
||||||
lock
|
|
||||||
cmpxchgl %ecx, (%rdi)
|
|
||||||
jne 1b
|
|
||||||
movl %ecx, %eax
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_and_uint_nv)
|
|
||||||
SET_SIZE(atomic_and_32_nv)
|
|
||||||
|
|
||||||
ENTRY(atomic_and_64_nv)
|
|
||||||
ALTENTRY(atomic_and_ulong_nv)
|
|
||||||
movq (%rdi), %rax
|
|
||||||
1:
|
|
||||||
movq %rsi, %rcx
|
|
||||||
andq %rax, %rcx
|
|
||||||
lock
|
|
||||||
cmpxchgq %rcx, (%rdi)
|
|
||||||
jne 1b
|
|
||||||
movq %rcx, %rax
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_and_ulong_nv)
|
|
||||||
SET_SIZE(atomic_and_64_nv)
|
|
||||||
|
|
||||||
ENTRY(atomic_or_8_nv)
|
|
||||||
ALTENTRY(atomic_or_uchar_nv)
|
|
||||||
movb (%rdi), %al
|
|
||||||
1:
|
|
||||||
movb %sil, %cl
|
|
||||||
orb %al, %cl
|
|
||||||
lock
|
|
||||||
cmpxchgb %cl, (%rdi)
|
|
||||||
jne 1b
|
|
||||||
movzbl %cl, %eax
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_and_uchar_nv)
|
|
||||||
SET_SIZE(atomic_and_8_nv)
|
|
||||||
|
|
||||||
ENTRY(atomic_or_16_nv)
|
|
||||||
ALTENTRY(atomic_or_ushort_nv)
|
|
||||||
movw (%rdi), %ax
|
|
||||||
1:
|
|
||||||
movw %si, %cx
|
|
||||||
orw %ax, %cx
|
|
||||||
lock
|
|
||||||
cmpxchgw %cx, (%rdi)
|
|
||||||
jne 1b
|
|
||||||
movzwl %cx, %eax
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_or_ushort_nv)
|
|
||||||
SET_SIZE(atomic_or_16_nv)
|
|
||||||
|
|
||||||
ENTRY(atomic_or_32_nv)
|
|
||||||
ALTENTRY(atomic_or_uint_nv)
|
|
||||||
movl (%rdi), %eax
|
|
||||||
1:
|
|
||||||
movl %esi, %ecx
|
|
||||||
orl %eax, %ecx
|
|
||||||
lock
|
|
||||||
cmpxchgl %ecx, (%rdi)
|
|
||||||
jne 1b
|
|
||||||
movl %ecx, %eax
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_or_uint_nv)
|
|
||||||
SET_SIZE(atomic_or_32_nv)
|
|
||||||
|
|
||||||
ENTRY(atomic_or_64_nv)
|
|
||||||
ALTENTRY(atomic_or_ulong_nv)
|
|
||||||
movq (%rdi), %rax
|
|
||||||
1:
|
|
||||||
movq %rsi, %rcx
|
|
||||||
orq %rax, %rcx
|
|
||||||
lock
|
|
||||||
cmpxchgq %rcx, (%rdi)
|
|
||||||
jne 1b
|
|
||||||
movq %rcx, %rax
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_or_ulong_nv)
|
|
||||||
SET_SIZE(atomic_or_64_nv)
|
|
||||||
|
|
||||||
ENTRY(atomic_cas_8)
|
|
||||||
ALTENTRY(atomic_cas_uchar)
|
|
||||||
movzbl %sil, %eax
|
|
||||||
lock
|
|
||||||
cmpxchgb %dl, (%rdi)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_cas_uchar)
|
|
||||||
SET_SIZE(atomic_cas_8)
|
|
||||||
|
|
||||||
ENTRY(atomic_cas_16)
|
|
||||||
ALTENTRY(atomic_cas_ushort)
|
|
||||||
movzwl %si, %eax
|
|
||||||
lock
|
|
||||||
cmpxchgw %dx, (%rdi)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_cas_ushort)
|
|
||||||
SET_SIZE(atomic_cas_16)
|
|
||||||
|
|
||||||
ENTRY(atomic_cas_32)
|
|
||||||
ALTENTRY(atomic_cas_uint)
|
|
||||||
movl %esi, %eax
|
|
||||||
lock
|
|
||||||
cmpxchgl %edx, (%rdi)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_cas_uint)
|
|
||||||
SET_SIZE(atomic_cas_32)
|
|
||||||
|
|
||||||
ENTRY(atomic_cas_64)
|
|
||||||
ALTENTRY(atomic_cas_ulong)
|
|
||||||
ALTENTRY(atomic_cas_ptr)
|
|
||||||
movq %rsi, %rax
|
|
||||||
lock
|
|
||||||
cmpxchgq %rdx, (%rdi)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_cas_ptr)
|
|
||||||
SET_SIZE(atomic_cas_ulong)
|
|
||||||
SET_SIZE(atomic_cas_64)
|
|
||||||
|
|
||||||
ENTRY(atomic_swap_8)
|
|
||||||
ALTENTRY(atomic_swap_uchar)
|
|
||||||
movzbl %sil, %eax
|
|
||||||
lock
|
|
||||||
xchgb %al, (%rdi)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_swap_uchar)
|
|
||||||
SET_SIZE(atomic_swap_8)
|
|
||||||
|
|
||||||
ENTRY(atomic_swap_16)
|
|
||||||
ALTENTRY(atomic_swap_ushort)
|
|
||||||
movzwl %si, %eax
|
|
||||||
lock
|
|
||||||
xchgw %ax, (%rdi)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_swap_ushort)
|
|
||||||
SET_SIZE(atomic_swap_16)
|
|
||||||
|
|
||||||
ENTRY(atomic_swap_32)
|
|
||||||
ALTENTRY(atomic_swap_uint)
|
|
||||||
movl %esi, %eax
|
|
||||||
lock
|
|
||||||
xchgl %eax, (%rdi)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_swap_uint)
|
|
||||||
SET_SIZE(atomic_swap_32)
|
|
||||||
|
|
||||||
ENTRY(atomic_swap_64)
|
|
||||||
ALTENTRY(atomic_swap_ulong)
|
|
||||||
ALTENTRY(atomic_swap_ptr)
|
|
||||||
movq %rsi, %rax
|
|
||||||
lock
|
|
||||||
xchgq %rax, (%rdi)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_swap_ptr)
|
|
||||||
SET_SIZE(atomic_swap_ulong)
|
|
||||||
SET_SIZE(atomic_swap_64)
|
|
||||||
|
|
||||||
ENTRY(atomic_set_long_excl)
|
|
||||||
xorl %eax, %eax
|
|
||||||
lock
|
|
||||||
btsq %rsi, (%rdi)
|
|
||||||
jnc 1f
|
|
||||||
decl %eax
|
|
||||||
1:
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_set_long_excl)
|
|
||||||
|
|
||||||
ENTRY(atomic_clear_long_excl)
|
|
||||||
xorl %eax, %eax
|
|
||||||
lock
|
|
||||||
btrq %rsi, (%rdi)
|
|
||||||
jc 1f
|
|
||||||
decl %eax
|
|
||||||
1:
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_clear_long_excl)
|
|
||||||
|
|
||||||
#if !defined(_KERNEL)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NOTE: membar_enter, and membar_exit are identical routines.
|
|
||||||
* We define them separately, instead of using an ALTENTRY
|
|
||||||
* definitions to alias them together, so that DTrace and
|
|
||||||
* debuggers will see a unique address for them, allowing
|
|
||||||
* more accurate tracing.
|
|
||||||
*/
|
|
||||||
|
|
||||||
ENTRY(membar_enter)
|
|
||||||
mfence
|
|
||||||
ret
|
|
||||||
SET_SIZE(membar_enter)
|
|
||||||
|
|
||||||
ENTRY(membar_exit)
|
|
||||||
mfence
|
|
||||||
ret
|
|
||||||
SET_SIZE(membar_exit)
|
|
||||||
|
|
||||||
ENTRY(membar_producer)
|
|
||||||
sfence
|
|
||||||
ret
|
|
||||||
SET_SIZE(membar_producer)
|
|
||||||
|
|
||||||
ENTRY(membar_consumer)
|
|
||||||
lfence
|
|
||||||
ret
|
|
||||||
SET_SIZE(membar_consumer)
|
|
||||||
|
|
||||||
#endif /* !_KERNEL */
|
|
||||||
|
|
||||||
#ifdef __ELF__
|
|
||||||
.section .note.GNU-stack,"",%progbits
|
|
||||||
#endif
|
|
|
@ -1,94 +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 2005 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Copyright 2006 Ricardo Correia. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Copyright (c) 1988 AT&T */
|
|
||||||
/* All Rights Reserved */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <mntent.h>
|
|
||||||
#include <sys/mnttab.h>
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#define BUFSIZE (MNT_LINE_MAX + 2)
|
|
||||||
|
|
||||||
__thread char buf[BUFSIZE];
|
|
||||||
|
|
||||||
#define DIFF(xx) (mrefp->xx != NULL && (mgetp->xx == NULL || strcmp(mrefp->xx, mgetp->xx) != 0))
|
|
||||||
|
|
||||||
int
|
|
||||||
getmntany(FILE *fp, struct mnttab *mgetp, struct mnttab *mrefp)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
while ((ret = _sol_getmntent(fp, mgetp)) == 0 && (DIFF(mnt_special) || DIFF(mnt_mountp) || DIFF(mnt_fstype) || DIFF(mnt_mntopts)));
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int _sol_getmntent(FILE *fp, struct mnttab *mgetp)
|
|
||||||
{
|
|
||||||
struct mntent mntbuf;
|
|
||||||
struct mntent *ret;
|
|
||||||
|
|
||||||
ret = getmntent_r(fp, &mntbuf, buf, BUFSIZE);
|
|
||||||
|
|
||||||
if(ret != NULL) {
|
|
||||||
mgetp->mnt_special = mntbuf.mnt_fsname;
|
|
||||||
mgetp->mnt_mountp = mntbuf.mnt_dir;
|
|
||||||
mgetp->mnt_fstype = mntbuf.mnt_type;
|
|
||||||
mgetp->mnt_mntopts = mntbuf.mnt_opts;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(feof(fp))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
return MNT_TOOLONG;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getextmntent(FILE *fp, struct extmnttab *mp, int len)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
struct stat64 st;
|
|
||||||
|
|
||||||
ret = _sol_getmntent(fp, (struct mnttab *) mp);
|
|
||||||
if(ret == 0) {
|
|
||||||
if(stat64(mp->mnt_mountp, &st) != 0) {
|
|
||||||
mp->mnt_major = 0;
|
|
||||||
mp->mnt_minor = 0;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
mp->mnt_major = major(st.st_dev);
|
|
||||||
mp->mnt_minor = minor(st.st_dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
|
@ -1,752 +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 2007 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
.ident "%Z%%M% %I% %E% SMI"
|
|
||||||
|
|
||||||
.file "%M%"
|
|
||||||
|
|
||||||
#define _ASM
|
|
||||||
#include <sys/asm_linkage.h>
|
|
||||||
|
|
||||||
#if defined(_KERNEL)
|
|
||||||
/*
|
|
||||||
* Legacy kernel interfaces; they will go away (eventually).
|
|
||||||
*/
|
|
||||||
ANSI_PRAGMA_WEAK2(cas8,atomic_cas_8,function)
|
|
||||||
ANSI_PRAGMA_WEAK2(cas32,atomic_cas_32,function)
|
|
||||||
ANSI_PRAGMA_WEAK2(cas64,atomic_cas_64,function)
|
|
||||||
ANSI_PRAGMA_WEAK2(caslong,atomic_cas_ulong,function)
|
|
||||||
ANSI_PRAGMA_WEAK2(casptr,atomic_cas_ptr,function)
|
|
||||||
ANSI_PRAGMA_WEAK2(atomic_and_long,atomic_and_ulong,function)
|
|
||||||
ANSI_PRAGMA_WEAK2(atomic_or_long,atomic_or_ulong,function)
|
|
||||||
#else
|
|
||||||
/*
|
|
||||||
* Include the definitions for the libc weak aliases.
|
|
||||||
*/
|
|
||||||
#include "../atomic_asm_weak.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ENTRY(atomic_inc_8)
|
|
||||||
ALTENTRY(atomic_inc_uchar)
|
|
||||||
movl 4(%esp), %eax
|
|
||||||
lock
|
|
||||||
incb (%eax)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_inc_uchar)
|
|
||||||
SET_SIZE(atomic_inc_8)
|
|
||||||
|
|
||||||
ENTRY(atomic_inc_16)
|
|
||||||
ALTENTRY(atomic_inc_ushort)
|
|
||||||
movl 4(%esp), %eax
|
|
||||||
lock
|
|
||||||
incw (%eax)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_inc_ushort)
|
|
||||||
SET_SIZE(atomic_inc_16)
|
|
||||||
|
|
||||||
ENTRY(atomic_inc_32)
|
|
||||||
ALTENTRY(atomic_inc_uint)
|
|
||||||
ALTENTRY(atomic_inc_ulong)
|
|
||||||
movl 4(%esp), %eax
|
|
||||||
lock
|
|
||||||
incl (%eax)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_inc_ulong)
|
|
||||||
SET_SIZE(atomic_inc_uint)
|
|
||||||
SET_SIZE(atomic_inc_32)
|
|
||||||
|
|
||||||
ENTRY(atomic_inc_8_nv)
|
|
||||||
ALTENTRY(atomic_inc_uchar_nv)
|
|
||||||
movl 4(%esp), %edx
|
|
||||||
movb (%edx), %al
|
|
||||||
1:
|
|
||||||
leal 1(%eax), %ecx
|
|
||||||
lock
|
|
||||||
cmpxchgb %cl, (%edx)
|
|
||||||
jne 1b
|
|
||||||
movzbl %cl, %eax
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_inc_uchar_nv)
|
|
||||||
SET_SIZE(atomic_inc_8_nv)
|
|
||||||
|
|
||||||
ENTRY(atomic_inc_16_nv)
|
|
||||||
ALTENTRY(atomic_inc_ushort_nv)
|
|
||||||
movl 4(%esp), %edx
|
|
||||||
movw (%edx), %ax
|
|
||||||
1:
|
|
||||||
leal 1(%eax), %ecx
|
|
||||||
lock
|
|
||||||
cmpxchgw %cx, (%edx)
|
|
||||||
jne 1b
|
|
||||||
movzwl %cx, %eax
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_inc_ushort_nv)
|
|
||||||
SET_SIZE(atomic_inc_16_nv)
|
|
||||||
|
|
||||||
ENTRY(atomic_inc_32_nv)
|
|
||||||
ALTENTRY(atomic_inc_uint_nv)
|
|
||||||
ALTENTRY(atomic_inc_ulong_nv)
|
|
||||||
movl 4(%esp), %edx
|
|
||||||
movl (%edx), %eax
|
|
||||||
1:
|
|
||||||
leal 1(%eax), %ecx
|
|
||||||
lock
|
|
||||||
cmpxchgl %ecx, (%edx)
|
|
||||||
jne 1b
|
|
||||||
movl %ecx, %eax
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_inc_ulong_nv)
|
|
||||||
SET_SIZE(atomic_inc_uint_nv)
|
|
||||||
SET_SIZE(atomic_inc_32_nv)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NOTE: If atomic_inc_64 and atomic_inc_64_nv are ever
|
|
||||||
* separated, you need to also edit the libc i386 platform
|
|
||||||
* specific mapfile and remove the NODYNSORT attribute
|
|
||||||
* from atomic_inc_64_nv.
|
|
||||||
*/
|
|
||||||
ENTRY(atomic_inc_64)
|
|
||||||
ALTENTRY(atomic_inc_64_nv)
|
|
||||||
pushl %edi
|
|
||||||
pushl %ebx
|
|
||||||
movl 12(%esp), %edi
|
|
||||||
movl (%edi), %eax
|
|
||||||
movl 4(%edi), %edx
|
|
||||||
1:
|
|
||||||
xorl %ebx, %ebx
|
|
||||||
xorl %ecx, %ecx
|
|
||||||
incl %ebx
|
|
||||||
addl %eax, %ebx
|
|
||||||
adcl %edx, %ecx
|
|
||||||
lock
|
|
||||||
cmpxchg8b (%edi)
|
|
||||||
jne 1b
|
|
||||||
movl %ebx, %eax
|
|
||||||
movl %ecx, %edx
|
|
||||||
popl %ebx
|
|
||||||
popl %edi
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_inc_64_nv)
|
|
||||||
SET_SIZE(atomic_inc_64)
|
|
||||||
|
|
||||||
ENTRY(atomic_dec_8)
|
|
||||||
ALTENTRY(atomic_dec_uchar)
|
|
||||||
movl 4(%esp), %eax
|
|
||||||
lock
|
|
||||||
decb (%eax)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_dec_uchar)
|
|
||||||
SET_SIZE(atomic_dec_8)
|
|
||||||
|
|
||||||
ENTRY(atomic_dec_16)
|
|
||||||
ALTENTRY(atomic_dec_ushort)
|
|
||||||
movl 4(%esp), %eax
|
|
||||||
lock
|
|
||||||
decw (%eax)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_dec_ushort)
|
|
||||||
SET_SIZE(atomic_dec_16)
|
|
||||||
|
|
||||||
ENTRY(atomic_dec_32)
|
|
||||||
ALTENTRY(atomic_dec_uint)
|
|
||||||
ALTENTRY(atomic_dec_ulong)
|
|
||||||
movl 4(%esp), %eax
|
|
||||||
lock
|
|
||||||
decl (%eax)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_dec_ulong)
|
|
||||||
SET_SIZE(atomic_dec_uint)
|
|
||||||
SET_SIZE(atomic_dec_32)
|
|
||||||
|
|
||||||
ENTRY(atomic_dec_8_nv)
|
|
||||||
ALTENTRY(atomic_dec_uchar_nv)
|
|
||||||
movl 4(%esp), %edx
|
|
||||||
movb (%edx), %al
|
|
||||||
1:
|
|
||||||
leal -1(%eax), %ecx
|
|
||||||
lock
|
|
||||||
cmpxchgb %cl, (%edx)
|
|
||||||
jne 1b
|
|
||||||
movzbl %cl, %eax
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_dec_uchar_nv)
|
|
||||||
SET_SIZE(atomic_dec_8_nv)
|
|
||||||
|
|
||||||
ENTRY(atomic_dec_16_nv)
|
|
||||||
ALTENTRY(atomic_dec_ushort_nv)
|
|
||||||
movl 4(%esp), %edx
|
|
||||||
movw (%edx), %ax
|
|
||||||
1:
|
|
||||||
leal -1(%eax), %ecx
|
|
||||||
lock
|
|
||||||
cmpxchgw %cx, (%edx)
|
|
||||||
jne 1b
|
|
||||||
movzwl %cx, %eax
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_dec_ushort_nv)
|
|
||||||
SET_SIZE(atomic_dec_16_nv)
|
|
||||||
|
|
||||||
ENTRY(atomic_dec_32_nv)
|
|
||||||
ALTENTRY(atomic_dec_uint_nv)
|
|
||||||
ALTENTRY(atomic_dec_ulong_nv)
|
|
||||||
movl 4(%esp), %edx
|
|
||||||
movl (%edx), %eax
|
|
||||||
1:
|
|
||||||
leal -1(%eax), %ecx
|
|
||||||
lock
|
|
||||||
cmpxchgl %ecx, (%edx)
|
|
||||||
jne 1b
|
|
||||||
movl %ecx, %eax
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_dec_ulong_nv)
|
|
||||||
SET_SIZE(atomic_dec_uint_nv)
|
|
||||||
SET_SIZE(atomic_dec_32_nv)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NOTE: If atomic_dec_64 and atomic_dec_64_nv are ever
|
|
||||||
* separated, it is important to edit the libc i386 platform
|
|
||||||
* specific mapfile and remove the NODYNSORT attribute
|
|
||||||
* from atomic_dec_64_nv.
|
|
||||||
*/
|
|
||||||
ENTRY(atomic_dec_64)
|
|
||||||
ALTENTRY(atomic_dec_64_nv)
|
|
||||||
pushl %edi
|
|
||||||
pushl %ebx
|
|
||||||
movl 12(%esp), %edi
|
|
||||||
movl (%edi), %eax
|
|
||||||
movl 4(%edi), %edx
|
|
||||||
1:
|
|
||||||
xorl %ebx, %ebx
|
|
||||||
xorl %ecx, %ecx
|
|
||||||
not %ecx
|
|
||||||
not %ebx
|
|
||||||
addl %eax, %ebx
|
|
||||||
adcl %edx, %ecx
|
|
||||||
lock
|
|
||||||
cmpxchg8b (%edi)
|
|
||||||
jne 1b
|
|
||||||
movl %ebx, %eax
|
|
||||||
movl %ecx, %edx
|
|
||||||
popl %ebx
|
|
||||||
popl %edi
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_dec_64_nv)
|
|
||||||
SET_SIZE(atomic_dec_64)
|
|
||||||
|
|
||||||
ENTRY(atomic_add_8)
|
|
||||||
ALTENTRY(atomic_add_char)
|
|
||||||
movl 4(%esp), %eax
|
|
||||||
movl 8(%esp), %ecx
|
|
||||||
lock
|
|
||||||
addb %cl, (%eax)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_add_char)
|
|
||||||
SET_SIZE(atomic_add_8)
|
|
||||||
|
|
||||||
ENTRY(atomic_add_16)
|
|
||||||
ALTENTRY(atomic_add_short)
|
|
||||||
movl 4(%esp), %eax
|
|
||||||
movl 8(%esp), %ecx
|
|
||||||
lock
|
|
||||||
addw %cx, (%eax)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_add_short)
|
|
||||||
SET_SIZE(atomic_add_16)
|
|
||||||
|
|
||||||
ENTRY(atomic_add_32)
|
|
||||||
ALTENTRY(atomic_add_int)
|
|
||||||
ALTENTRY(atomic_add_ptr)
|
|
||||||
ALTENTRY(atomic_add_long)
|
|
||||||
movl 4(%esp), %eax
|
|
||||||
movl 8(%esp), %ecx
|
|
||||||
lock
|
|
||||||
addl %ecx, (%eax)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_add_long)
|
|
||||||
SET_SIZE(atomic_add_ptr)
|
|
||||||
SET_SIZE(atomic_add_int)
|
|
||||||
SET_SIZE(atomic_add_32)
|
|
||||||
|
|
||||||
ENTRY(atomic_or_8)
|
|
||||||
ALTENTRY(atomic_or_uchar)
|
|
||||||
movl 4(%esp), %eax
|
|
||||||
movb 8(%esp), %cl
|
|
||||||
lock
|
|
||||||
orb %cl, (%eax)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_or_uchar)
|
|
||||||
SET_SIZE(atomic_or_8)
|
|
||||||
|
|
||||||
ENTRY(atomic_or_16)
|
|
||||||
ALTENTRY(atomic_or_ushort)
|
|
||||||
movl 4(%esp), %eax
|
|
||||||
movw 8(%esp), %cx
|
|
||||||
lock
|
|
||||||
orw %cx, (%eax)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_or_ushort)
|
|
||||||
SET_SIZE(atomic_or_16)
|
|
||||||
|
|
||||||
ENTRY(atomic_or_32)
|
|
||||||
ALTENTRY(atomic_or_uint)
|
|
||||||
ALTENTRY(atomic_or_ulong)
|
|
||||||
movl 4(%esp), %eax
|
|
||||||
movl 8(%esp), %ecx
|
|
||||||
lock
|
|
||||||
orl %ecx, (%eax)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_or_ulong)
|
|
||||||
SET_SIZE(atomic_or_uint)
|
|
||||||
SET_SIZE(atomic_or_32)
|
|
||||||
|
|
||||||
ENTRY(atomic_and_8)
|
|
||||||
ALTENTRY(atomic_and_uchar)
|
|
||||||
movl 4(%esp), %eax
|
|
||||||
movb 8(%esp), %cl
|
|
||||||
lock
|
|
||||||
andb %cl, (%eax)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_and_uchar)
|
|
||||||
SET_SIZE(atomic_and_8)
|
|
||||||
|
|
||||||
ENTRY(atomic_and_16)
|
|
||||||
ALTENTRY(atomic_and_ushort)
|
|
||||||
movl 4(%esp), %eax
|
|
||||||
movw 8(%esp), %cx
|
|
||||||
lock
|
|
||||||
andw %cx, (%eax)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_and_ushort)
|
|
||||||
SET_SIZE(atomic_and_16)
|
|
||||||
|
|
||||||
ENTRY(atomic_and_32)
|
|
||||||
ALTENTRY(atomic_and_uint)
|
|
||||||
ALTENTRY(atomic_and_ulong)
|
|
||||||
movl 4(%esp), %eax
|
|
||||||
movl 8(%esp), %ecx
|
|
||||||
lock
|
|
||||||
andl %ecx, (%eax)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_and_ulong)
|
|
||||||
SET_SIZE(atomic_and_uint)
|
|
||||||
SET_SIZE(atomic_and_32)
|
|
||||||
|
|
||||||
ENTRY(atomic_add_8_nv)
|
|
||||||
ALTENTRY(atomic_add_char_nv)
|
|
||||||
movl 4(%esp), %edx
|
|
||||||
movb (%edx), %al
|
|
||||||
1:
|
|
||||||
movl 8(%esp), %ecx
|
|
||||||
addb %al, %cl
|
|
||||||
lock
|
|
||||||
cmpxchgb %cl, (%edx)
|
|
||||||
jne 1b
|
|
||||||
movzbl %cl, %eax
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_add_char_nv)
|
|
||||||
SET_SIZE(atomic_add_8_nv)
|
|
||||||
|
|
||||||
ENTRY(atomic_add_16_nv)
|
|
||||||
ALTENTRY(atomic_add_short_nv)
|
|
||||||
movl 4(%esp), %edx
|
|
||||||
movw (%edx), %ax
|
|
||||||
1:
|
|
||||||
movl 8(%esp), %ecx
|
|
||||||
addw %ax, %cx
|
|
||||||
lock
|
|
||||||
cmpxchgw %cx, (%edx)
|
|
||||||
jne 1b
|
|
||||||
movzwl %cx, %eax
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_add_short_nv)
|
|
||||||
SET_SIZE(atomic_add_16_nv)
|
|
||||||
|
|
||||||
ENTRY(atomic_add_32_nv)
|
|
||||||
ALTENTRY(atomic_add_int_nv)
|
|
||||||
ALTENTRY(atomic_add_ptr_nv)
|
|
||||||
ALTENTRY(atomic_add_long_nv)
|
|
||||||
movl 4(%esp), %edx
|
|
||||||
movl (%edx), %eax
|
|
||||||
1:
|
|
||||||
movl 8(%esp), %ecx
|
|
||||||
addl %eax, %ecx
|
|
||||||
lock
|
|
||||||
cmpxchgl %ecx, (%edx)
|
|
||||||
jne 1b
|
|
||||||
movl %ecx, %eax
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_add_long_nv)
|
|
||||||
SET_SIZE(atomic_add_ptr_nv)
|
|
||||||
SET_SIZE(atomic_add_int_nv)
|
|
||||||
SET_SIZE(atomic_add_32_nv)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NOTE: If atomic_add_64 and atomic_add_64_nv are ever
|
|
||||||
* separated, it is important to edit the libc i386 platform
|
|
||||||
* specific mapfile and remove the NODYNSORT attribute
|
|
||||||
* from atomic_add_64_nv.
|
|
||||||
*/
|
|
||||||
ENTRY(atomic_add_64)
|
|
||||||
ALTENTRY(atomic_add_64_nv)
|
|
||||||
pushl %edi
|
|
||||||
pushl %ebx
|
|
||||||
movl 12(%esp), %edi
|
|
||||||
movl (%edi), %eax
|
|
||||||
movl 4(%edi), %edx
|
|
||||||
1:
|
|
||||||
movl 16(%esp), %ebx
|
|
||||||
movl 20(%esp), %ecx
|
|
||||||
addl %eax, %ebx
|
|
||||||
adcl %edx, %ecx
|
|
||||||
lock
|
|
||||||
cmpxchg8b (%edi)
|
|
||||||
jne 1b
|
|
||||||
movl %ebx, %eax
|
|
||||||
movl %ecx, %edx
|
|
||||||
popl %ebx
|
|
||||||
popl %edi
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_add_64_nv)
|
|
||||||
SET_SIZE(atomic_add_64)
|
|
||||||
|
|
||||||
ENTRY(atomic_or_8_nv)
|
|
||||||
ALTENTRY(atomic_or_uchar_nv)
|
|
||||||
movl 4(%esp), %edx
|
|
||||||
movb (%edx), %al
|
|
||||||
1:
|
|
||||||
movl 8(%esp), %ecx
|
|
||||||
orb %al, %cl
|
|
||||||
lock
|
|
||||||
cmpxchgb %cl, (%edx)
|
|
||||||
jne 1b
|
|
||||||
movzbl %cl, %eax
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_or_uchar_nv)
|
|
||||||
SET_SIZE(atomic_or_8_nv)
|
|
||||||
|
|
||||||
ENTRY(atomic_or_16_nv)
|
|
||||||
ALTENTRY(atomic_or_ushort_nv)
|
|
||||||
movl 4(%esp), %edx
|
|
||||||
movw (%edx), %ax
|
|
||||||
1:
|
|
||||||
movl 8(%esp), %ecx
|
|
||||||
orw %ax, %cx
|
|
||||||
lock
|
|
||||||
cmpxchgw %cx, (%edx)
|
|
||||||
jne 1b
|
|
||||||
movzwl %cx, %eax
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_or_ushort_nv)
|
|
||||||
SET_SIZE(atomic_or_16_nv)
|
|
||||||
|
|
||||||
ENTRY(atomic_or_32_nv)
|
|
||||||
ALTENTRY(atomic_or_uint_nv)
|
|
||||||
ALTENTRY(atomic_or_ulong_nv)
|
|
||||||
movl 4(%esp), %edx
|
|
||||||
movl (%edx), %eax
|
|
||||||
1:
|
|
||||||
movl 8(%esp), %ecx
|
|
||||||
orl %eax, %ecx
|
|
||||||
lock
|
|
||||||
cmpxchgl %ecx, (%edx)
|
|
||||||
jne 1b
|
|
||||||
movl %ecx, %eax
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_or_ulong_nv)
|
|
||||||
SET_SIZE(atomic_or_uint_nv)
|
|
||||||
SET_SIZE(atomic_or_32_nv)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NOTE: If atomic_or_64 and atomic_or_64_nv are ever
|
|
||||||
* separated, it is important to edit the libc i386 platform
|
|
||||||
* specific mapfile and remove the NODYNSORT attribute
|
|
||||||
* from atomic_or_64_nv.
|
|
||||||
*/
|
|
||||||
ENTRY(atomic_or_64)
|
|
||||||
ALTENTRY(atomic_or_64_nv)
|
|
||||||
pushl %edi
|
|
||||||
pushl %ebx
|
|
||||||
movl 12(%esp), %edi
|
|
||||||
movl (%edi), %eax
|
|
||||||
movl 4(%edi), %edx
|
|
||||||
1:
|
|
||||||
movl 16(%esp), %ebx
|
|
||||||
movl 20(%esp), %ecx
|
|
||||||
orl %eax, %ebx
|
|
||||||
orl %edx, %ecx
|
|
||||||
lock
|
|
||||||
cmpxchg8b (%edi)
|
|
||||||
jne 1b
|
|
||||||
movl %ebx, %eax
|
|
||||||
movl %ecx, %edx
|
|
||||||
popl %ebx
|
|
||||||
popl %edi
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_or_64_nv)
|
|
||||||
SET_SIZE(atomic_or_64)
|
|
||||||
|
|
||||||
ENTRY(atomic_and_8_nv)
|
|
||||||
ALTENTRY(atomic_and_uchar_nv)
|
|
||||||
movl 4(%esp), %edx
|
|
||||||
movb (%edx), %al
|
|
||||||
1:
|
|
||||||
movl 8(%esp), %ecx
|
|
||||||
andb %al, %cl
|
|
||||||
lock
|
|
||||||
cmpxchgb %cl, (%edx)
|
|
||||||
jne 1b
|
|
||||||
movzbl %cl, %eax
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_and_uchar_nv)
|
|
||||||
SET_SIZE(atomic_and_8_nv)
|
|
||||||
|
|
||||||
ENTRY(atomic_and_16_nv)
|
|
||||||
ALTENTRY(atomic_and_ushort_nv)
|
|
||||||
movl 4(%esp), %edx
|
|
||||||
movw (%edx), %ax
|
|
||||||
1:
|
|
||||||
movl 8(%esp), %ecx
|
|
||||||
andw %ax, %cx
|
|
||||||
lock
|
|
||||||
cmpxchgw %cx, (%edx)
|
|
||||||
jne 1b
|
|
||||||
movzwl %cx, %eax
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_and_ushort_nv)
|
|
||||||
SET_SIZE(atomic_and_16_nv)
|
|
||||||
|
|
||||||
ENTRY(atomic_and_32_nv)
|
|
||||||
ALTENTRY(atomic_and_uint_nv)
|
|
||||||
ALTENTRY(atomic_and_ulong_nv)
|
|
||||||
movl 4(%esp), %edx
|
|
||||||
movl (%edx), %eax
|
|
||||||
1:
|
|
||||||
movl 8(%esp), %ecx
|
|
||||||
andl %eax, %ecx
|
|
||||||
lock
|
|
||||||
cmpxchgl %ecx, (%edx)
|
|
||||||
jne 1b
|
|
||||||
movl %ecx, %eax
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_and_ulong_nv)
|
|
||||||
SET_SIZE(atomic_and_uint_nv)
|
|
||||||
SET_SIZE(atomic_and_32_nv)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NOTE: If atomic_and_64 and atomic_and_64_nv are ever
|
|
||||||
* separated, it is important to edit the libc i386 platform
|
|
||||||
* specific mapfile and remove the NODYNSORT attribute
|
|
||||||
* from atomic_and_64_nv.
|
|
||||||
*/
|
|
||||||
ENTRY(atomic_and_64)
|
|
||||||
ALTENTRY(atomic_and_64_nv)
|
|
||||||
pushl %edi
|
|
||||||
pushl %ebx
|
|
||||||
movl 12(%esp), %edi
|
|
||||||
movl (%edi), %eax
|
|
||||||
movl 4(%edi), %edx
|
|
||||||
1:
|
|
||||||
movl 16(%esp), %ebx
|
|
||||||
movl 20(%esp), %ecx
|
|
||||||
andl %eax, %ebx
|
|
||||||
andl %edx, %ecx
|
|
||||||
lock
|
|
||||||
cmpxchg8b (%edi)
|
|
||||||
jne 1b
|
|
||||||
movl %ebx, %eax
|
|
||||||
movl %ecx, %edx
|
|
||||||
popl %ebx
|
|
||||||
popl %edi
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_and_64_nv)
|
|
||||||
SET_SIZE(atomic_and_64)
|
|
||||||
|
|
||||||
ENTRY(atomic_cas_8)
|
|
||||||
ALTENTRY(atomic_cas_uchar)
|
|
||||||
movl 4(%esp), %edx
|
|
||||||
movzbl 8(%esp), %eax
|
|
||||||
movb 12(%esp), %cl
|
|
||||||
lock
|
|
||||||
cmpxchgb %cl, (%edx)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_cas_uchar)
|
|
||||||
SET_SIZE(atomic_cas_8)
|
|
||||||
|
|
||||||
ENTRY(atomic_cas_16)
|
|
||||||
ALTENTRY(atomic_cas_ushort)
|
|
||||||
movl 4(%esp), %edx
|
|
||||||
movzwl 8(%esp), %eax
|
|
||||||
movw 12(%esp), %cx
|
|
||||||
lock
|
|
||||||
cmpxchgw %cx, (%edx)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_cas_ushort)
|
|
||||||
SET_SIZE(atomic_cas_16)
|
|
||||||
|
|
||||||
ENTRY(atomic_cas_32)
|
|
||||||
ALTENTRY(atomic_cas_uint)
|
|
||||||
ALTENTRY(atomic_cas_ulong)
|
|
||||||
ALTENTRY(atomic_cas_ptr)
|
|
||||||
movl 4(%esp), %edx
|
|
||||||
movl 8(%esp), %eax
|
|
||||||
movl 12(%esp), %ecx
|
|
||||||
lock
|
|
||||||
cmpxchgl %ecx, (%edx)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_cas_ptr)
|
|
||||||
SET_SIZE(atomic_cas_ulong)
|
|
||||||
SET_SIZE(atomic_cas_uint)
|
|
||||||
SET_SIZE(atomic_cas_32)
|
|
||||||
|
|
||||||
ENTRY(atomic_cas_64)
|
|
||||||
pushl %ebx
|
|
||||||
pushl %esi
|
|
||||||
movl 12(%esp), %esi
|
|
||||||
movl 16(%esp), %eax
|
|
||||||
movl 20(%esp), %edx
|
|
||||||
movl 24(%esp), %ebx
|
|
||||||
movl 28(%esp), %ecx
|
|
||||||
lock
|
|
||||||
cmpxchg8b (%esi)
|
|
||||||
popl %esi
|
|
||||||
popl %ebx
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_cas_64)
|
|
||||||
|
|
||||||
ENTRY(atomic_swap_8)
|
|
||||||
ALTENTRY(atomic_swap_uchar)
|
|
||||||
movl 4(%esp), %edx
|
|
||||||
movzbl 8(%esp), %eax
|
|
||||||
lock
|
|
||||||
xchgb %al, (%edx)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_swap_uchar)
|
|
||||||
SET_SIZE(atomic_swap_8)
|
|
||||||
|
|
||||||
ENTRY(atomic_swap_16)
|
|
||||||
ALTENTRY(atomic_swap_ushort)
|
|
||||||
movl 4(%esp), %edx
|
|
||||||
movzwl 8(%esp), %eax
|
|
||||||
lock
|
|
||||||
xchgw %ax, (%edx)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_swap_ushort)
|
|
||||||
SET_SIZE(atomic_swap_16)
|
|
||||||
|
|
||||||
ENTRY(atomic_swap_32)
|
|
||||||
ALTENTRY(atomic_swap_uint)
|
|
||||||
ALTENTRY(atomic_swap_ptr)
|
|
||||||
ALTENTRY(atomic_swap_ulong)
|
|
||||||
movl 4(%esp), %edx
|
|
||||||
movl 8(%esp), %eax
|
|
||||||
lock
|
|
||||||
xchgl %eax, (%edx)
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_swap_ulong)
|
|
||||||
SET_SIZE(atomic_swap_ptr)
|
|
||||||
SET_SIZE(atomic_swap_uint)
|
|
||||||
SET_SIZE(atomic_swap_32)
|
|
||||||
|
|
||||||
ENTRY(atomic_swap_64)
|
|
||||||
pushl %esi
|
|
||||||
pushl %ebx
|
|
||||||
movl 12(%esp), %esi
|
|
||||||
movl 16(%esp), %ebx
|
|
||||||
movl 20(%esp), %ecx
|
|
||||||
movl (%esi), %eax
|
|
||||||
movl 4(%esi), %edx
|
|
||||||
1:
|
|
||||||
lock
|
|
||||||
cmpxchg8b (%esi)
|
|
||||||
jne 1b
|
|
||||||
popl %ebx
|
|
||||||
popl %esi
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_swap_64)
|
|
||||||
|
|
||||||
ENTRY(atomic_set_long_excl)
|
|
||||||
movl 4(%esp), %edx
|
|
||||||
movl 8(%esp), %ecx
|
|
||||||
xorl %eax, %eax
|
|
||||||
lock
|
|
||||||
btsl %ecx, (%edx)
|
|
||||||
jnc 1f
|
|
||||||
decl %eax
|
|
||||||
1:
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_set_long_excl)
|
|
||||||
|
|
||||||
ENTRY(atomic_clear_long_excl)
|
|
||||||
movl 4(%esp), %edx
|
|
||||||
movl 8(%esp), %ecx
|
|
||||||
xorl %eax, %eax
|
|
||||||
lock
|
|
||||||
btrl %ecx, (%edx)
|
|
||||||
jc 1f
|
|
||||||
decl %eax
|
|
||||||
1:
|
|
||||||
ret
|
|
||||||
SET_SIZE(atomic_clear_long_excl)
|
|
||||||
|
|
||||||
#if !defined(_KERNEL)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NOTE: membar_enter, membar_exit, membar_producer, and
|
|
||||||
* membar_consumer are all identical routines. We define them
|
|
||||||
* separately, instead of using ALTENTRY definitions to alias them
|
|
||||||
* together, so that DTrace and debuggers will see a unique address
|
|
||||||
* for them, allowing more accurate tracing.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
ENTRY(membar_enter)
|
|
||||||
lock
|
|
||||||
xorl $0, (%esp)
|
|
||||||
ret
|
|
||||||
SET_SIZE(membar_enter)
|
|
||||||
|
|
||||||
ENTRY(membar_exit)
|
|
||||||
lock
|
|
||||||
xorl $0, (%esp)
|
|
||||||
ret
|
|
||||||
SET_SIZE(membar_exit)
|
|
||||||
|
|
||||||
ENTRY(membar_producer)
|
|
||||||
lock
|
|
||||||
xorl $0, (%esp)
|
|
||||||
ret
|
|
||||||
SET_SIZE(membar_producer)
|
|
||||||
|
|
||||||
ENTRY(membar_consumer)
|
|
||||||
lock
|
|
||||||
xorl $0, (%esp)
|
|
||||||
ret
|
|
||||||
SET_SIZE(membar_consumer)
|
|
||||||
|
|
||||||
#endif /* !_KERNEL */
|
|
||||||
|
|
||||||
#ifdef __ELF__
|
|
||||||
.section .note.GNU-stack,"",%progbits
|
|
||||||
#endif
|
|
|
@ -1,5 +0,0 @@
|
||||||
#ifndef __amd64
|
|
||||||
#define __amd64
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <ia32/sys/asm_linkage.h>
|
|
|
@ -1,42 +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 2007 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SOL_ASSERT_H
|
|
||||||
#define _SOL_ASSERT_H
|
|
||||||
|
|
||||||
#include_next <assert.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#ifndef __assert_c99
|
|
||||||
static inline void __assert_c99(const char *expr, const char *file, int line, const char *func)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "%s:%i: %s: Assertion `%s` failed.\n", file, line, func, expr);
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,438 +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 2005 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SYS_ATOMIC_H
|
|
||||||
#define _SYS_ATOMIC_H
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/inttypes.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(_KERNEL) && defined(__GNUC__) && defined(_ASM_INLINES) && \
|
|
||||||
(defined(__i386) || defined(__amd64))
|
|
||||||
#include <asm/atomic.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(_KERNEL) || defined(__STDC__)
|
|
||||||
/*
|
|
||||||
* Increment target.
|
|
||||||
*/
|
|
||||||
extern void atomic_inc_8(volatile uint8_t *);
|
|
||||||
extern void atomic_inc_uchar(volatile uchar_t *);
|
|
||||||
extern void atomic_inc_16(volatile uint16_t *);
|
|
||||||
extern void atomic_inc_ushort(volatile ushort_t *);
|
|
||||||
extern void atomic_inc_32(volatile uint32_t *);
|
|
||||||
extern void atomic_inc_uint(volatile uint_t *);
|
|
||||||
extern void atomic_inc_ulong(volatile ulong_t *);
|
|
||||||
#if defined(_KERNEL) || defined(_INT64_TYPE)
|
|
||||||
extern void atomic_inc_64(volatile uint64_t *);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Decrement target
|
|
||||||
*/
|
|
||||||
extern void atomic_dec_8(volatile uint8_t *);
|
|
||||||
extern void atomic_dec_uchar(volatile uchar_t *);
|
|
||||||
extern void atomic_dec_16(volatile uint16_t *);
|
|
||||||
extern void atomic_dec_ushort(volatile ushort_t *);
|
|
||||||
extern void atomic_dec_32(volatile uint32_t *);
|
|
||||||
extern void atomic_dec_uint(volatile uint_t *);
|
|
||||||
extern void atomic_dec_ulong(volatile ulong_t *);
|
|
||||||
#if defined(_KERNEL) || defined(_INT64_TYPE)
|
|
||||||
extern void atomic_dec_64(volatile uint64_t *);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Add delta to target
|
|
||||||
*/
|
|
||||||
extern void atomic_add_8(volatile uint8_t *, int8_t);
|
|
||||||
extern void atomic_add_char(volatile uchar_t *, signed char);
|
|
||||||
extern void atomic_add_16(volatile uint16_t *, int16_t);
|
|
||||||
extern void atomic_add_short(volatile ushort_t *, short);
|
|
||||||
extern void atomic_add_32(volatile uint32_t *, int32_t);
|
|
||||||
extern void atomic_add_int(volatile uint_t *, int);
|
|
||||||
extern void atomic_add_ptr(volatile void *, ssize_t);
|
|
||||||
extern void atomic_add_long(volatile ulong_t *, long);
|
|
||||||
#if defined(_KERNEL) || defined(_INT64_TYPE)
|
|
||||||
extern void atomic_add_64(volatile uint64_t *, int64_t);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* logical OR bits with target
|
|
||||||
*/
|
|
||||||
extern void atomic_or_8(volatile uint8_t *, uint8_t);
|
|
||||||
extern void atomic_or_uchar(volatile uchar_t *, uchar_t);
|
|
||||||
extern void atomic_or_16(volatile uint16_t *, uint16_t);
|
|
||||||
extern void atomic_or_ushort(volatile ushort_t *, ushort_t);
|
|
||||||
extern void atomic_or_32(volatile uint32_t *, uint32_t);
|
|
||||||
extern void atomic_or_uint(volatile uint_t *, uint_t);
|
|
||||||
extern void atomic_or_ulong(volatile ulong_t *, ulong_t);
|
|
||||||
#if defined(_KERNEL) || defined(_INT64_TYPE)
|
|
||||||
extern void atomic_or_64(volatile uint64_t *, uint64_t);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* logical AND bits with target
|
|
||||||
*/
|
|
||||||
extern void atomic_and_8(volatile uint8_t *, uint8_t);
|
|
||||||
extern void atomic_and_uchar(volatile uchar_t *, uchar_t);
|
|
||||||
extern void atomic_and_16(volatile uint16_t *, uint16_t);
|
|
||||||
extern void atomic_and_ushort(volatile ushort_t *, ushort_t);
|
|
||||||
extern void atomic_and_32(volatile uint32_t *, uint32_t);
|
|
||||||
extern void atomic_and_uint(volatile uint_t *, uint_t);
|
|
||||||
extern void atomic_and_ulong(volatile ulong_t *, ulong_t);
|
|
||||||
#if defined(_KERNEL) || defined(_INT64_TYPE)
|
|
||||||
extern void atomic_and_64(volatile uint64_t *, uint64_t);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* As above, but return the new value. Note that these _nv() variants are
|
|
||||||
* substantially more expensive on some platforms than the no-return-value
|
|
||||||
* versions above, so don't use them unless you really need to know the
|
|
||||||
* new value *atomically* (e.g. when decrementing a reference count and
|
|
||||||
* checking whether it went to zero).
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Increment target and return new value.
|
|
||||||
*/
|
|
||||||
extern uint8_t atomic_inc_8_nv(volatile uint8_t *);
|
|
||||||
extern uchar_t atomic_inc_uchar_nv(volatile uchar_t *);
|
|
||||||
extern uint16_t atomic_inc_16_nv(volatile uint16_t *);
|
|
||||||
extern ushort_t atomic_inc_ushort_nv(volatile ushort_t *);
|
|
||||||
extern uint32_t atomic_inc_32_nv(volatile uint32_t *);
|
|
||||||
extern uint_t atomic_inc_uint_nv(volatile uint_t *);
|
|
||||||
extern ulong_t atomic_inc_ulong_nv(volatile ulong_t *);
|
|
||||||
#if defined(_KERNEL) || defined(_INT64_TYPE)
|
|
||||||
extern uint64_t atomic_inc_64_nv(volatile uint64_t *);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Decrement target and return new value.
|
|
||||||
*/
|
|
||||||
extern uint8_t atomic_dec_8_nv(volatile uint8_t *);
|
|
||||||
extern uchar_t atomic_dec_uchar_nv(volatile uchar_t *);
|
|
||||||
extern uint16_t atomic_dec_16_nv(volatile uint16_t *);
|
|
||||||
extern ushort_t atomic_dec_ushort_nv(volatile ushort_t *);
|
|
||||||
extern uint32_t atomic_dec_32_nv(volatile uint32_t *);
|
|
||||||
extern uint_t atomic_dec_uint_nv(volatile uint_t *);
|
|
||||||
extern ulong_t atomic_dec_ulong_nv(volatile ulong_t *);
|
|
||||||
#if defined(_KERNEL) || defined(_INT64_TYPE)
|
|
||||||
extern uint64_t atomic_dec_64_nv(volatile uint64_t *);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Add delta to target
|
|
||||||
*/
|
|
||||||
extern uint8_t atomic_add_8_nv(volatile uint8_t *, int8_t);
|
|
||||||
extern uchar_t atomic_add_char_nv(volatile uchar_t *, signed char);
|
|
||||||
extern uint16_t atomic_add_16_nv(volatile uint16_t *, int16_t);
|
|
||||||
extern ushort_t atomic_add_short_nv(volatile ushort_t *, short);
|
|
||||||
extern uint32_t atomic_add_32_nv(volatile uint32_t *, int32_t);
|
|
||||||
extern uint_t atomic_add_int_nv(volatile uint_t *, int);
|
|
||||||
extern void *atomic_add_ptr_nv(volatile void *, ssize_t);
|
|
||||||
extern ulong_t atomic_add_long_nv(volatile ulong_t *, long);
|
|
||||||
#if defined(_KERNEL) || defined(_INT64_TYPE)
|
|
||||||
extern uint64_t atomic_add_64_nv(volatile uint64_t *, int64_t);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* logical OR bits with target and return new value.
|
|
||||||
*/
|
|
||||||
extern uint8_t atomic_or_8_nv(volatile uint8_t *, uint8_t);
|
|
||||||
extern uchar_t atomic_or_uchar_nv(volatile uchar_t *, uchar_t);
|
|
||||||
extern uint16_t atomic_or_16_nv(volatile uint16_t *, uint16_t);
|
|
||||||
extern ushort_t atomic_or_ushort_nv(volatile ushort_t *, ushort_t);
|
|
||||||
extern uint32_t atomic_or_32_nv(volatile uint32_t *, uint32_t);
|
|
||||||
extern uint_t atomic_or_uint_nv(volatile uint_t *, uint_t);
|
|
||||||
extern ulong_t atomic_or_ulong_nv(volatile ulong_t *, ulong_t);
|
|
||||||
#if defined(_KERNEL) || defined(_INT64_TYPE)
|
|
||||||
extern uint64_t atomic_or_64_nv(volatile uint64_t *, uint64_t);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* logical AND bits with target and return new value.
|
|
||||||
*/
|
|
||||||
extern uint8_t atomic_and_8_nv(volatile uint8_t *, uint8_t);
|
|
||||||
extern uchar_t atomic_and_uchar_nv(volatile uchar_t *, uchar_t);
|
|
||||||
extern uint16_t atomic_and_16_nv(volatile uint16_t *, uint16_t);
|
|
||||||
extern ushort_t atomic_and_ushort_nv(volatile ushort_t *, ushort_t);
|
|
||||||
extern uint32_t atomic_and_32_nv(volatile uint32_t *, uint32_t);
|
|
||||||
extern uint_t atomic_and_uint_nv(volatile uint_t *, uint_t);
|
|
||||||
extern ulong_t atomic_and_ulong_nv(volatile ulong_t *, ulong_t);
|
|
||||||
#if defined(_KERNEL) || defined(_INT64_TYPE)
|
|
||||||
extern uint64_t atomic_and_64_nv(volatile uint64_t *, uint64_t);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If *arg1 == arg2, set *arg1 = arg3; return old value
|
|
||||||
*/
|
|
||||||
extern uint8_t atomic_cas_8(volatile uint8_t *, uint8_t, uint8_t);
|
|
||||||
extern uchar_t atomic_cas_uchar(volatile uchar_t *, uchar_t, uchar_t);
|
|
||||||
extern uint16_t atomic_cas_16(volatile uint16_t *, uint16_t, uint16_t);
|
|
||||||
extern ushort_t atomic_cas_ushort(volatile ushort_t *, ushort_t, ushort_t);
|
|
||||||
extern uint32_t atomic_cas_32(volatile uint32_t *, uint32_t, uint32_t);
|
|
||||||
extern uint_t atomic_cas_uint(volatile uint_t *, uint_t, uint_t);
|
|
||||||
extern void *atomic_cas_ptr(volatile void *, void *, void *);
|
|
||||||
extern ulong_t atomic_cas_ulong(volatile ulong_t *, ulong_t, ulong_t);
|
|
||||||
#if defined(_KERNEL) || defined(_INT64_TYPE)
|
|
||||||
extern uint64_t atomic_cas_64(volatile uint64_t *, uint64_t, uint64_t);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Swap target and return old value
|
|
||||||
*/
|
|
||||||
extern uint8_t atomic_swap_8(volatile uint8_t *, uint8_t);
|
|
||||||
extern uchar_t atomic_swap_uchar(volatile uchar_t *, uchar_t);
|
|
||||||
extern uint16_t atomic_swap_16(volatile uint16_t *, uint16_t);
|
|
||||||
extern ushort_t atomic_swap_ushort(volatile ushort_t *, ushort_t);
|
|
||||||
extern uint32_t atomic_swap_32(volatile uint32_t *, uint32_t);
|
|
||||||
extern uint_t atomic_swap_uint(volatile uint_t *, uint_t);
|
|
||||||
extern void *atomic_swap_ptr(volatile void *, void *);
|
|
||||||
extern ulong_t atomic_swap_ulong(volatile ulong_t *, ulong_t);
|
|
||||||
#if defined(_KERNEL) || defined(_INT64_TYPE)
|
|
||||||
extern uint64_t atomic_swap_64(volatile uint64_t *, uint64_t);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Perform an exclusive atomic bit set/clear on a target.
|
|
||||||
* Returns 0 if bit was sucessfully set/cleared, or -1
|
|
||||||
* if the bit was already set/cleared.
|
|
||||||
*/
|
|
||||||
extern int atomic_set_long_excl(volatile ulong_t *, uint_t);
|
|
||||||
extern int atomic_clear_long_excl(volatile ulong_t *, uint_t);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Generic memory barrier used during lock entry, placed after the
|
|
||||||
* memory operation that acquires the lock to guarantee that the lock
|
|
||||||
* protects its data. No stores from after the memory barrier will
|
|
||||||
* reach visibility, and no loads from after the barrier will be
|
|
||||||
* resolved, before the lock acquisition reaches global visibility.
|
|
||||||
*/
|
|
||||||
extern void membar_enter(void);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Generic memory barrier used during lock exit, placed before the
|
|
||||||
* memory operation that releases the lock to guarantee that the lock
|
|
||||||
* protects its data. All loads and stores issued before the barrier
|
|
||||||
* will be resolved before the subsequent lock update reaches visibility.
|
|
||||||
*/
|
|
||||||
extern void membar_exit(void);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Arrange that all stores issued before this point in the code reach
|
|
||||||
* global visibility before any stores that follow; useful in producer
|
|
||||||
* modules that update a data item, then set a flag that it is available.
|
|
||||||
* The memory barrier guarantees that the available flag is not visible
|
|
||||||
* earlier than the updated data, i.e. it imposes store ordering.
|
|
||||||
*/
|
|
||||||
extern void membar_producer(void);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Arrange that all loads issued before this point in the code are
|
|
||||||
* completed before any subsequent loads; useful in consumer modules
|
|
||||||
* that check to see if data is available and read the data.
|
|
||||||
* The memory barrier guarantees that the data is not sampled until
|
|
||||||
* after the available flag has been seen, i.e. it imposes load ordering.
|
|
||||||
*/
|
|
||||||
extern void membar_consumer(void);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(_KERNEL) && !defined(__STDC__)
|
|
||||||
extern void atomic_inc_8();
|
|
||||||
extern void atomic_inc_uchar();
|
|
||||||
extern void atomic_inc_16();
|
|
||||||
extern void atomic_inc_ushort();
|
|
||||||
extern void atomic_inc_32();
|
|
||||||
extern void atomic_inc_uint();
|
|
||||||
extern void atomic_inc_ulong();
|
|
||||||
#if defined(_INT64_TYPE)
|
|
||||||
extern void atomic_inc_64();
|
|
||||||
#endif /* defined(_INT64_TYPE) */
|
|
||||||
extern void atomic_dec_8();
|
|
||||||
extern void atomic_dec_uchar();
|
|
||||||
extern void atomic_dec_16();
|
|
||||||
extern void atomic_dec_ushort();
|
|
||||||
extern void atomic_dec_32();
|
|
||||||
extern void atomic_dec_uint();
|
|
||||||
extern void atomic_dec_ulong();
|
|
||||||
#if defined(_INT64_TYPE)
|
|
||||||
extern void atomic_dec_64();
|
|
||||||
#endif /* defined(_INT64_TYPE) */
|
|
||||||
extern void atomic_add_8();
|
|
||||||
extern void atomic_add_char();
|
|
||||||
extern void atomic_add_16();
|
|
||||||
extern void atomic_add_short();
|
|
||||||
extern void atomic_add_32();
|
|
||||||
extern void atomic_add_int();
|
|
||||||
extern void atomic_add_ptr();
|
|
||||||
extern void atomic_add_long();
|
|
||||||
#if defined(_INT64_TYPE)
|
|
||||||
extern void atomic_add_64();
|
|
||||||
#endif /* defined(_INT64_TYPE) */
|
|
||||||
extern void atomic_or_8();
|
|
||||||
extern void atomic_or_uchar();
|
|
||||||
extern void atomic_or_16();
|
|
||||||
extern void atomic_or_ushort();
|
|
||||||
extern void atomic_or_32();
|
|
||||||
extern void atomic_or_uint();
|
|
||||||
extern void atomic_or_ulong();
|
|
||||||
#if defined(_INT64_TYPE)
|
|
||||||
extern void atomic_or_64();
|
|
||||||
#endif /* defined(_INT64_TYPE) */
|
|
||||||
extern void atomic_and_8();
|
|
||||||
extern void atomic_and_uchar();
|
|
||||||
extern void atomic_and_16();
|
|
||||||
extern void atomic_and_ushort();
|
|
||||||
extern void atomic_and_32();
|
|
||||||
extern void atomic_and_uint();
|
|
||||||
extern void atomic_and_ulong();
|
|
||||||
#if defined(_INT64_TYPE)
|
|
||||||
extern void atomic_and_64();
|
|
||||||
#endif /* defined(_INT64_TYPE) */
|
|
||||||
extern uint8_t atomic_inc_8_nv();
|
|
||||||
extern uchar_t atomic_inc_uchar_nv();
|
|
||||||
extern uint16_t atomic_inc_16_nv();
|
|
||||||
extern ushort_t atomic_inc_ushort_nv();
|
|
||||||
extern uint32_t atomic_inc_32_nv();
|
|
||||||
extern uint_t atomic_inc_uint_nv();
|
|
||||||
extern ulong_t atomic_inc_ulong_nv();
|
|
||||||
#if defined(_INT64_TYPE)
|
|
||||||
extern uint64_t atomic_inc_64_nv();
|
|
||||||
#endif /* defined(_INT64_TYPE) */
|
|
||||||
extern uint8_t atomic_dec_8_nv();
|
|
||||||
extern uchar_t atomic_dec_uchar_nv();
|
|
||||||
extern uint16_t atomic_dec_16_nv();
|
|
||||||
extern ushort_t atomic_dec_ushort_nv();
|
|
||||||
extern uint32_t atomic_dec_32_nv();
|
|
||||||
extern uint_t atomic_dec_uint_nv();
|
|
||||||
extern ulong_t atomic_dec_ulong_nv();
|
|
||||||
#if defined(_INT64_TYPE)
|
|
||||||
extern uint64_t atomic_dec_64_nv();
|
|
||||||
#endif /* defined(_INT64_TYPE) */
|
|
||||||
extern uint8_t atomic_add_8_nv();
|
|
||||||
extern uchar_t atomic_add_char_nv();
|
|
||||||
extern uint16_t atomic_add_16_nv();
|
|
||||||
extern ushort_t atomic_add_short_nv();
|
|
||||||
extern uint32_t atomic_add_32_nv();
|
|
||||||
extern uint_t atomic_add_int_nv();
|
|
||||||
extern void *atomic_add_ptr_nv();
|
|
||||||
extern ulong_t atomic_add_long_nv();
|
|
||||||
#if defined(_INT64_TYPE)
|
|
||||||
extern uint64_t atomic_add_64_nv();
|
|
||||||
#endif /* defined(_INT64_TYPE) */
|
|
||||||
extern uint8_t atomic_or_8_nv();
|
|
||||||
extern uchar_t atomic_or_uchar_nv();
|
|
||||||
extern uint16_t atomic_or_16_nv();
|
|
||||||
extern ushort_t atomic_or_ushort_nv();
|
|
||||||
extern uint32_t atomic_or_32_nv();
|
|
||||||
extern uint_t atomic_or_uint_nv();
|
|
||||||
extern ulong_t atomic_or_ulong_nv();
|
|
||||||
#if defined(_INT64_TYPE)
|
|
||||||
extern uint64_t atomic_or_64_nv();
|
|
||||||
#endif /* defined(_INT64_TYPE) */
|
|
||||||
extern uint8_t atomic_and_8_nv();
|
|
||||||
extern uchar_t atomic_and_uchar_nv();
|
|
||||||
extern uint16_t atomic_and_16_nv();
|
|
||||||
extern ushort_t atomic_and_ushort_nv();
|
|
||||||
extern uint32_t atomic_and_32_nv();
|
|
||||||
extern uint_t atomic_and_uint_nv();
|
|
||||||
extern ulong_t atomic_and_ulong_nv();
|
|
||||||
#if defined(_INT64_TYPE)
|
|
||||||
extern uint64_t atomic_and_64_nv();
|
|
||||||
#endif /* defined(_INT64_TYPE) */
|
|
||||||
extern uint8_t atomic_cas_8();
|
|
||||||
extern uchar_t atomic_cas_uchar();
|
|
||||||
extern uint16_t atomic_cas_16();
|
|
||||||
extern ushort_t atomic_cas_ushort();
|
|
||||||
extern uint32_t atomic_cas_32();
|
|
||||||
extern uint_t atomic_cas_uint();
|
|
||||||
extern void *atomic_cas_ptr();
|
|
||||||
extern ulong_t atomic_cas_ulong();
|
|
||||||
#if defined(_INT64_TYPE)
|
|
||||||
extern uint64_t atomic_cas_64();
|
|
||||||
#endif /* defined(_INT64_TYPE) */
|
|
||||||
extern uint8_t atomic_swap_8();
|
|
||||||
extern uchar_t atomic_swap_uchar();
|
|
||||||
extern uint16_t atomic_swap_16();
|
|
||||||
extern ushort_t atomic_swap_ushort();
|
|
||||||
extern uint32_t atomic_swap_32();
|
|
||||||
extern uint_t atomic_swap_uint();
|
|
||||||
extern void *atomic_swap_ptr();
|
|
||||||
extern ulong_t atomic_swap_ulong();
|
|
||||||
#if defined(_INT64_TYPE)
|
|
||||||
extern uint64_t atomic_swap_64();
|
|
||||||
#endif /* defined(_INT64_TYPE) */
|
|
||||||
|
|
||||||
|
|
||||||
extern int atomic_set_long_excl();
|
|
||||||
extern int atomic_clear_long_excl();
|
|
||||||
|
|
||||||
extern void membar_enter();
|
|
||||||
extern void membar_exit();
|
|
||||||
extern void membar_producer();
|
|
||||||
extern void membar_consumer();
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(_KERNEL)
|
|
||||||
|
|
||||||
#if defined(_LP64) || defined(_ILP32)
|
|
||||||
#define atomic_add_ip atomic_add_long
|
|
||||||
#define atomic_add_ip_nv atomic_add_long_nv
|
|
||||||
#define casip atomic_cas_ulong
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__sparc)
|
|
||||||
extern uint8_t ldstub(uint8_t *);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Legacy kernel interfaces; they will go away (eventually).
|
|
||||||
*/
|
|
||||||
extern uint8_t cas8(uint8_t *, uint8_t, uint8_t);
|
|
||||||
extern uint32_t cas32(uint32_t *, uint32_t, uint32_t);
|
|
||||||
extern uint64_t cas64(uint64_t *, uint64_t, uint64_t);
|
|
||||||
extern ulong_t caslong(ulong_t *, ulong_t, ulong_t);
|
|
||||||
extern void *casptr(void *, void *, void *);
|
|
||||||
extern void atomic_and_long(ulong_t *, ulong_t);
|
|
||||||
extern void atomic_or_long(ulong_t *, ulong_t);
|
|
||||||
#if defined(__sparc)
|
|
||||||
extern uint32_t swapl(uint32_t *, uint32_t);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _KERNEL */
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _SYS_ATOMIC_H */
|
|
|
@ -1,48 +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 2006 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _DEVID_H
|
|
||||||
#define _DEVID_H
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
typedef int ddi_devid_t;
|
|
||||||
|
|
||||||
typedef struct devid_nmlist {
|
|
||||||
char *devname;
|
|
||||||
dev_t dev;
|
|
||||||
} devid_nmlist_t;
|
|
||||||
|
|
||||||
static inline int devid_str_decode(char *devidstr, ddi_devid_t *retdevid, char **retminor_name) { abort(); }
|
|
||||||
static inline int devid_deviceid_to_nmlist(char *search_path, ddi_devid_t devid, char *minor_name, devid_nmlist_t **retlist) { abort(); }
|
|
||||||
static inline void devid_str_free(char *str) { abort(); }
|
|
||||||
static inline void devid_free(ddi_devid_t devid) { abort(); }
|
|
||||||
static inline void devid_free_nmlist(devid_nmlist_t *list) { abort(); }
|
|
||||||
static inline int devid_get(int fd, ddi_devid_t *retdevid) { return -1; }
|
|
||||||
static inline int devid_get_minor_name(int fd, char **retminor_name) { abort(); }
|
|
||||||
static inline char *devid_str_encode(ddi_devid_t devid, char *minor_name) { abort(); }
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,36 +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 2007 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SOL_DIRENT_H
|
|
||||||
#define _SOL_DIRENT_H
|
|
||||||
|
|
||||||
#include_next <dirent.h>
|
|
||||||
|
|
||||||
#ifdef IFTODT
|
|
||||||
#undef IFTODT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,5 +0,0 @@
|
||||||
#ifndef __i386
|
|
||||||
#define __i386
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <ia32/sys/asm_linkage.h>
|
|
|
@ -1,307 +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 2004 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _IA32_SYS_ASM_LINKAGE_H
|
|
||||||
#define _IA32_SYS_ASM_LINKAGE_H
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <sys/stack.h>
|
|
||||||
#include <sys/trap.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _ASM /* The remainder of this file is only for assembly files */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* make annoying differences in assembler syntax go away
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* D16 and A16 are used to insert instructions prefixes; the
|
|
||||||
* macros help the assembler code be slightly more portable.
|
|
||||||
*/
|
|
||||||
#if !defined(__GNUC_AS__)
|
|
||||||
/*
|
|
||||||
* /usr/ccs/bin/as prefixes are parsed as separate instructions
|
|
||||||
*/
|
|
||||||
#define D16 data16;
|
|
||||||
#define A16 addr16;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (There are some weird constructs in constant expressions)
|
|
||||||
*/
|
|
||||||
#define _CONST(const) [const]
|
|
||||||
#define _BITNOT(const) -1!_CONST(const)
|
|
||||||
#define _MUL(a, b) _CONST(a \* b)
|
|
||||||
|
|
||||||
#else
|
|
||||||
/*
|
|
||||||
* Why not use the 'data16' and 'addr16' prefixes .. well, the
|
|
||||||
* assembler doesn't quite believe in real mode, and thus argues with
|
|
||||||
* us about what we're trying to do.
|
|
||||||
*/
|
|
||||||
#define D16 .byte 0x66;
|
|
||||||
#define A16 .byte 0x67;
|
|
||||||
|
|
||||||
#define _CONST(const) (const)
|
|
||||||
#define _BITNOT(const) ~_CONST(const)
|
|
||||||
#define _MUL(a, b) _CONST(a * b)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* C pointers are different sizes between i386 and amd64.
|
|
||||||
* These constants can be used to compute offsets into pointer arrays.
|
|
||||||
*/
|
|
||||||
#if defined(__amd64)
|
|
||||||
#define CLONGSHIFT 3
|
|
||||||
#define CLONGSIZE 8
|
|
||||||
#define CLONGMASK 7
|
|
||||||
#elif defined(__i386)
|
|
||||||
#define CLONGSHIFT 2
|
|
||||||
#define CLONGSIZE 4
|
|
||||||
#define CLONGMASK 3
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Since we know we're either ILP32 or LP64 ..
|
|
||||||
*/
|
|
||||||
#define CPTRSHIFT CLONGSHIFT
|
|
||||||
#define CPTRSIZE CLONGSIZE
|
|
||||||
#define CPTRMASK CLONGMASK
|
|
||||||
|
|
||||||
#if CPTRSIZE != (1 << CPTRSHIFT) || CLONGSIZE != (1 << CLONGSHIFT)
|
|
||||||
#error "inconsistent shift constants"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if CPTRMASK != (CPTRSIZE - 1) || CLONGMASK != (CLONGSIZE - 1)
|
|
||||||
#error "inconsistent mask constants"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ASM_ENTRY_ALIGN 16
|
|
||||||
|
|
||||||
/*
|
|
||||||
* SSE register alignment and save areas
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define XMM_SIZE 16
|
|
||||||
#define XMM_ALIGN 16
|
|
||||||
|
|
||||||
#if defined(__amd64)
|
|
||||||
|
|
||||||
#define SAVE_XMM_PROLOG(sreg, nreg) \
|
|
||||||
subq $_CONST(_MUL(XMM_SIZE, nreg)), %rsp; \
|
|
||||||
movq %rsp, sreg
|
|
||||||
|
|
||||||
#define RSTOR_XMM_EPILOG(sreg, nreg) \
|
|
||||||
addq $_CONST(_MUL(XMM_SIZE, nreg)), %rsp
|
|
||||||
|
|
||||||
#elif defined(__i386)
|
|
||||||
|
|
||||||
#define SAVE_XMM_PROLOG(sreg, nreg) \
|
|
||||||
subl $_CONST(_MUL(XMM_SIZE, nreg) + XMM_ALIGN), %esp; \
|
|
||||||
movl %esp, sreg; \
|
|
||||||
addl $XMM_ALIGN, sreg; \
|
|
||||||
andl $_BITNOT(XMM_ALIGN-1), sreg
|
|
||||||
|
|
||||||
#define RSTOR_XMM_EPILOG(sreg, nreg) \
|
|
||||||
addl $_CONST(_MUL(XMM_SIZE, nreg) + XMM_ALIGN), %esp;
|
|
||||||
|
|
||||||
#endif /* __i386 */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* profiling causes definitions of the MCOUNT and RTMCOUNT
|
|
||||||
* particular to the type
|
|
||||||
*/
|
|
||||||
#ifdef GPROF
|
|
||||||
|
|
||||||
#define MCOUNT(x) \
|
|
||||||
pushl %ebp; \
|
|
||||||
movl %esp, %ebp; \
|
|
||||||
call _mcount; \
|
|
||||||
popl %ebp
|
|
||||||
|
|
||||||
#endif /* GPROF */
|
|
||||||
|
|
||||||
#ifdef PROF
|
|
||||||
|
|
||||||
#define MCOUNT(x) \
|
|
||||||
/* CSTYLED */ \
|
|
||||||
.lcomm .L_/**/x/**/1, 4, 4; \
|
|
||||||
pushl %ebp; \
|
|
||||||
movl %esp, %ebp; \
|
|
||||||
/* CSTYLED */ \
|
|
||||||
movl $.L_/**/x/**/1, %edx; \
|
|
||||||
call _mcount; \
|
|
||||||
popl %ebp
|
|
||||||
|
|
||||||
#endif /* PROF */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* if we are not profiling, MCOUNT should be defined to nothing
|
|
||||||
*/
|
|
||||||
#if !defined(PROF) && !defined(GPROF)
|
|
||||||
#define MCOUNT(x)
|
|
||||||
#endif /* !defined(PROF) && !defined(GPROF) */
|
|
||||||
|
|
||||||
#define RTMCOUNT(x) MCOUNT(x)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Macro to define weak symbol aliases. These are similar to the ANSI-C
|
|
||||||
* #pragma weak name = _name
|
|
||||||
* except a compiler can determine type. The assembler must be told. Hence,
|
|
||||||
* the second parameter must be the type of the symbol (i.e.: function,...)
|
|
||||||
*/
|
|
||||||
#define ANSI_PRAGMA_WEAK(sym, stype) \
|
|
||||||
.weak sym; \
|
|
||||||
.type sym, @stype; \
|
|
||||||
/* CSTYLED */ \
|
|
||||||
sym = _/**/sym
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Like ANSI_PRAGMA_WEAK(), but for unrelated names, as in:
|
|
||||||
* #pragma weak sym1 = sym2
|
|
||||||
*/
|
|
||||||
#define ANSI_PRAGMA_WEAK2(sym1, sym2, stype) \
|
|
||||||
.weak sym1; \
|
|
||||||
.type sym1, @stype; \
|
|
||||||
sym1 = sym2
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ENTRY provides the standard procedure entry code and an easy way to
|
|
||||||
* insert the calls to mcount for profiling. ENTRY_NP is identical, but
|
|
||||||
* never calls mcount.
|
|
||||||
*/
|
|
||||||
#define ENTRY(x) \
|
|
||||||
.text; \
|
|
||||||
.align ASM_ENTRY_ALIGN; \
|
|
||||||
.globl x; \
|
|
||||||
.type x, @function; \
|
|
||||||
x: MCOUNT(x)
|
|
||||||
|
|
||||||
#define ENTRY_NP(x) \
|
|
||||||
.text; \
|
|
||||||
.align ASM_ENTRY_ALIGN; \
|
|
||||||
.globl x; \
|
|
||||||
.type x, @function; \
|
|
||||||
x:
|
|
||||||
|
|
||||||
#define RTENTRY(x) \
|
|
||||||
.text; \
|
|
||||||
.align ASM_ENTRY_ALIGN; \
|
|
||||||
.globl x; \
|
|
||||||
.type x, @function; \
|
|
||||||
x: RTMCOUNT(x)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ENTRY2 is identical to ENTRY but provides two labels for the entry point.
|
|
||||||
*/
|
|
||||||
#define ENTRY2(x, y) \
|
|
||||||
.text; \
|
|
||||||
.align ASM_ENTRY_ALIGN; \
|
|
||||||
.globl x, y; \
|
|
||||||
.type x, @function; \
|
|
||||||
.type y, @function; \
|
|
||||||
/* CSTYLED */ \
|
|
||||||
x: ; \
|
|
||||||
y: MCOUNT(x)
|
|
||||||
|
|
||||||
#define ENTRY_NP2(x, y) \
|
|
||||||
.text; \
|
|
||||||
.align ASM_ENTRY_ALIGN; \
|
|
||||||
.globl x, y; \
|
|
||||||
.type x, @function; \
|
|
||||||
.type y, @function; \
|
|
||||||
/* CSTYLED */ \
|
|
||||||
x: ; \
|
|
||||||
y:
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ALTENTRY provides for additional entry points.
|
|
||||||
*/
|
|
||||||
#define ALTENTRY(x) \
|
|
||||||
.globl x; \
|
|
||||||
.type x, @function; \
|
|
||||||
x:
|
|
||||||
|
|
||||||
/*
|
|
||||||
* DGDEF and DGDEF2 provide global data declarations.
|
|
||||||
*
|
|
||||||
* DGDEF provides a word aligned word of storage.
|
|
||||||
*
|
|
||||||
* DGDEF2 allocates "sz" bytes of storage with **NO** alignment. This
|
|
||||||
* implies this macro is best used for byte arrays.
|
|
||||||
*
|
|
||||||
* DGDEF3 allocates "sz" bytes of storage with "algn" alignment.
|
|
||||||
*/
|
|
||||||
#define DGDEF2(name, sz) \
|
|
||||||
.data; \
|
|
||||||
.globl name; \
|
|
||||||
.type name, @object; \
|
|
||||||
.size name, sz; \
|
|
||||||
name:
|
|
||||||
|
|
||||||
#define DGDEF3(name, sz, algn) \
|
|
||||||
.data; \
|
|
||||||
.align algn; \
|
|
||||||
.globl name; \
|
|
||||||
.type name, @object; \
|
|
||||||
.size name, sz; \
|
|
||||||
name:
|
|
||||||
|
|
||||||
#define DGDEF(name) DGDEF3(name, 4, 4)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* SET_SIZE trails a function and set the size for the ELF symbol table.
|
|
||||||
*/
|
|
||||||
#define SET_SIZE(x) \
|
|
||||||
.size x, [.-x]
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NWORD provides native word value.
|
|
||||||
*/
|
|
||||||
#if defined(__amd64)
|
|
||||||
|
|
||||||
/*CSTYLED*/
|
|
||||||
#define NWORD quad
|
|
||||||
|
|
||||||
#elif defined(__i386)
|
|
||||||
|
|
||||||
#define NWORD long
|
|
||||||
|
|
||||||
#endif /* __i386 */
|
|
||||||
|
|
||||||
#endif /* _ASM */
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _IA32_SYS_ASM_LINKAGE_H */
|
|
|
@ -1,35 +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 2006 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SOL_LIBGEN_H
|
|
||||||
#define _SOL_LIBGEN_H
|
|
||||||
|
|
||||||
#include_next <libgen.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
extern int mkdirp(const char *path, mode_t mode);
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,37 +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 2006 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _PRIV_H
|
|
||||||
#define _PRIV_H
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
/* Couldn't find this definition in OpenGrok */
|
|
||||||
#define PRIV_SYS_CONFIG "sys_config"
|
|
||||||
|
|
||||||
static inline boolean_t priv_ineffect(const char *priv) { return B_TRUE; }
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,118 +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 2005 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
|
|
||||||
/* All Rights Reserved */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Portions of this source code were derived from Berkeley 4.3 BSD
|
|
||||||
* under license from the Regents of the University of California.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SOL_RPC_XDR_H_
|
|
||||||
#define _SOL_RPC_XDR_H_
|
|
||||||
|
|
||||||
#include_next <rpc/xdr.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Strangely, my glibc version (2.3.6) doesn't have xdr_control(), so
|
|
||||||
* we have to hack it in here (source taken from OpenSolaris).
|
|
||||||
* By the way, it is assumed the xdrmem implementation is used.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define xdr_control(a,b,c) xdrmem_control(a,b,c)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* These are XDR control operators
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define XDR_GET_BYTES_AVAIL 1
|
|
||||||
|
|
||||||
struct xdr_bytesrec {
|
|
||||||
bool_t xc_is_last_record;
|
|
||||||
size_t xc_num_avail;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct xdr_bytesrec xdr_bytesrec;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* These are the request arguments to XDR_CONTROL.
|
|
||||||
*
|
|
||||||
* XDR_PEEK - returns the contents of the next XDR unit on the XDR stream.
|
|
||||||
* XDR_SKIPBYTES - skips the next N bytes in the XDR stream.
|
|
||||||
* XDR_RDMAGET - for xdr implementation over RDMA, gets private flags from
|
|
||||||
* the XDR stream being moved over RDMA
|
|
||||||
* XDR_RDMANOCHUNK - for xdr implementaion over RDMA, sets private flags in
|
|
||||||
* the XDR stream moving over RDMA.
|
|
||||||
*/
|
|
||||||
#define XDR_PEEK 2
|
|
||||||
#define XDR_SKIPBYTES 3
|
|
||||||
#define XDR_RDMAGET 4
|
|
||||||
#define XDR_RDMASET 5
|
|
||||||
|
|
||||||
/* FIXME: probably doesn't work */
|
|
||||||
static bool_t
|
|
||||||
xdrmem_control(XDR *xdrs, int request, void *info)
|
|
||||||
{
|
|
||||||
xdr_bytesrec *xptr;
|
|
||||||
int32_t *int32p;
|
|
||||||
int len;
|
|
||||||
|
|
||||||
switch (request) {
|
|
||||||
|
|
||||||
case XDR_GET_BYTES_AVAIL:
|
|
||||||
xptr = (xdr_bytesrec *)info;
|
|
||||||
xptr->xc_is_last_record = TRUE;
|
|
||||||
xptr->xc_num_avail = xdrs->x_handy;
|
|
||||||
return (TRUE);
|
|
||||||
|
|
||||||
case XDR_PEEK:
|
|
||||||
/*
|
|
||||||
* Return the next 4 byte unit in the XDR stream.
|
|
||||||
*/
|
|
||||||
if (xdrs->x_handy < sizeof (int32_t))
|
|
||||||
return (FALSE);
|
|
||||||
int32p = (int32_t *)info;
|
|
||||||
*int32p = (int32_t)ntohl((uint32_t)
|
|
||||||
(*((int32_t *)(xdrs->x_private))));
|
|
||||||
return (TRUE);
|
|
||||||
|
|
||||||
case XDR_SKIPBYTES:
|
|
||||||
/*
|
|
||||||
* Skip the next N bytes in the XDR stream.
|
|
||||||
*/
|
|
||||||
int32p = (int32_t *)info;
|
|
||||||
len = RNDUP((int)(*int32p));
|
|
||||||
if ((xdrs->x_handy -= len) < 0)
|
|
||||||
return (FALSE);
|
|
||||||
xdrs->x_private += len;
|
|
||||||
return (TRUE);
|
|
||||||
|
|
||||||
}
|
|
||||||
return (FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,247 +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 2004 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SYS_ASM_LINKAGE_H
|
|
||||||
#define _SYS_ASM_LINKAGE_H
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <sys/stack.h>
|
|
||||||
#include <sys/trap.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _ASM /* The remainder of this file is only for assembly files */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* C pointers are different sizes between V8 and V9.
|
|
||||||
* These constants can be used to compute offsets into pointer arrays.
|
|
||||||
*/
|
|
||||||
#ifdef __sparcv9
|
|
||||||
#define CPTRSHIFT 3
|
|
||||||
#define CLONGSHIFT 3
|
|
||||||
#else
|
|
||||||
#define CPTRSHIFT 2
|
|
||||||
#define CLONGSHIFT 2
|
|
||||||
#endif
|
|
||||||
#define CPTRSIZE (1<<CPTRSHIFT)
|
|
||||||
#define CLONGSIZE (1<<CLONGSHIFT)
|
|
||||||
#define CPTRMASK (CPTRSIZE - 1)
|
|
||||||
#define CLONGMASK (CLONGSIZE - 1)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Symbolic section definitions.
|
|
||||||
*/
|
|
||||||
#define RODATA ".rodata"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* profiling causes defintions of the MCOUNT and RTMCOUNT
|
|
||||||
* particular to the type
|
|
||||||
*/
|
|
||||||
#ifdef GPROF
|
|
||||||
|
|
||||||
#define MCOUNT_SIZE (4*4) /* 4 instructions */
|
|
||||||
#define MCOUNT(x) \
|
|
||||||
save %sp, -SA(MINFRAME), %sp; \
|
|
||||||
call _mcount; \
|
|
||||||
nop; \
|
|
||||||
restore;
|
|
||||||
|
|
||||||
#endif /* GPROF */
|
|
||||||
|
|
||||||
#ifdef PROF
|
|
||||||
|
|
||||||
#if defined(__sparcv9)
|
|
||||||
|
|
||||||
#define MCOUNT_SIZE (9*4) /* 9 instructions */
|
|
||||||
#define MCOUNT(x) \
|
|
||||||
save %sp, -SA(MINFRAME), %sp; \
|
|
||||||
/* CSTYLED */ \
|
|
||||||
sethi %hh(.L_/**/x/**/1), %o0; \
|
|
||||||
/* CSTYLED */ \
|
|
||||||
sethi %lm(.L_/**/x/**/1), %o1; \
|
|
||||||
/* CSTYLED */ \
|
|
||||||
or %o0, %hm(.L_/**/x/**/1), %o0; \
|
|
||||||
/* CSTYLED */ \
|
|
||||||
or %o1, %lo(.L_/**/x/**/1), %o1; \
|
|
||||||
sllx %o0, 32, %o0; \
|
|
||||||
call _mcount; \
|
|
||||||
or %o0, %o1, %o0; \
|
|
||||||
restore; \
|
|
||||||
/* CSTYLED */ \
|
|
||||||
.common .L_/**/x/**/1, 8, 8
|
|
||||||
|
|
||||||
#else /* __sparcv9 */
|
|
||||||
|
|
||||||
#define MCOUNT_SIZE (5*4) /* 5 instructions */
|
|
||||||
#define MCOUNT(x) \
|
|
||||||
save %sp, -SA(MINFRAME), %sp; \
|
|
||||||
/* CSTYLED */ \
|
|
||||||
sethi %hi(.L_/**/x/**/1), %o0; \
|
|
||||||
call _mcount; \
|
|
||||||
/* CSTYLED */ \
|
|
||||||
or %o0, %lo(.L_/**/x/**/1), %o0; \
|
|
||||||
restore; \
|
|
||||||
/* CSTYLED */ \
|
|
||||||
.common .L_/**/x/**/1, 4, 4
|
|
||||||
|
|
||||||
#endif /* __sparcv9 */
|
|
||||||
|
|
||||||
#endif /* PROF */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* if we are not profiling, MCOUNT should be defined to nothing
|
|
||||||
*/
|
|
||||||
#if !defined(PROF) && !defined(GPROF)
|
|
||||||
#define MCOUNT_SIZE 0 /* no instructions inserted */
|
|
||||||
#define MCOUNT(x)
|
|
||||||
#endif /* !defined(PROF) && !defined(GPROF) */
|
|
||||||
|
|
||||||
#define RTMCOUNT(x) MCOUNT(x)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Macro to define weak symbol aliases. These are similar to the ANSI-C
|
|
||||||
* #pragma weak name = _name
|
|
||||||
* except a compiler can determine type. The assembler must be told. Hence,
|
|
||||||
* the second parameter must be the type of the symbol (i.e.: function,...)
|
|
||||||
*/
|
|
||||||
#define ANSI_PRAGMA_WEAK(sym, stype) \
|
|
||||||
.weak sym; \
|
|
||||||
.type sym, #stype; \
|
|
||||||
/* CSTYLED */ \
|
|
||||||
sym = _/**/sym
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Like ANSI_PRAGMA_WEAK(), but for unrelated names, as in:
|
|
||||||
* #pragma weak sym1 = sym2
|
|
||||||
*/
|
|
||||||
#define ANSI_PRAGMA_WEAK2(sym1, sym2, stype) \
|
|
||||||
.weak sym1; \
|
|
||||||
.type sym1, #stype; \
|
|
||||||
sym1 = sym2
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ENTRY provides the standard procedure entry code and an easy way to
|
|
||||||
* insert the calls to mcount for profiling. ENTRY_NP is identical, but
|
|
||||||
* never calls mcount.
|
|
||||||
*/
|
|
||||||
#define ENTRY(x) \
|
|
||||||
.section ".text"; \
|
|
||||||
.align 4; \
|
|
||||||
.global x; \
|
|
||||||
.type x, #function; \
|
|
||||||
x: MCOUNT(x)
|
|
||||||
|
|
||||||
#define ENTRY_SIZE MCOUNT_SIZE
|
|
||||||
|
|
||||||
#define ENTRY_NP(x) \
|
|
||||||
.section ".text"; \
|
|
||||||
.align 4; \
|
|
||||||
.global x; \
|
|
||||||
.type x, #function; \
|
|
||||||
x:
|
|
||||||
|
|
||||||
#define RTENTRY(x) \
|
|
||||||
.section ".text"; \
|
|
||||||
.align 4; \
|
|
||||||
.global x; \
|
|
||||||
.type x, #function; \
|
|
||||||
x: RTMCOUNT(x)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ENTRY2 is identical to ENTRY but provides two labels for the entry point.
|
|
||||||
*/
|
|
||||||
#define ENTRY2(x, y) \
|
|
||||||
.section ".text"; \
|
|
||||||
.align 4; \
|
|
||||||
.global x, y; \
|
|
||||||
.type x, #function; \
|
|
||||||
.type y, #function; \
|
|
||||||
/* CSTYLED */ \
|
|
||||||
x: ; \
|
|
||||||
y: MCOUNT(x)
|
|
||||||
|
|
||||||
#define ENTRY_NP2(x, y) \
|
|
||||||
.section ".text"; \
|
|
||||||
.align 4; \
|
|
||||||
.global x, y; \
|
|
||||||
.type x, #function; \
|
|
||||||
.type y, #function; \
|
|
||||||
/* CSTYLED */ \
|
|
||||||
x: ; \
|
|
||||||
y:
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ALTENTRY provides for additional entry points.
|
|
||||||
*/
|
|
||||||
#define ALTENTRY(x) \
|
|
||||||
.global x; \
|
|
||||||
.type x, #function; \
|
|
||||||
x:
|
|
||||||
|
|
||||||
/*
|
|
||||||
* DGDEF and DGDEF2 provide global data declarations.
|
|
||||||
*
|
|
||||||
* DGDEF provides a word aligned word of storage.
|
|
||||||
*
|
|
||||||
* DGDEF2 allocates "sz" bytes of storage with **NO** alignment. This
|
|
||||||
* implies this macro is best used for byte arrays.
|
|
||||||
*
|
|
||||||
* DGDEF3 allocates "sz" bytes of storage with "algn" alignment.
|
|
||||||
*/
|
|
||||||
#define DGDEF2(name, sz) \
|
|
||||||
.section ".data"; \
|
|
||||||
.global name; \
|
|
||||||
.type name, #object; \
|
|
||||||
.size name, sz; \
|
|
||||||
name:
|
|
||||||
|
|
||||||
#define DGDEF3(name, sz, algn) \
|
|
||||||
.section ".data"; \
|
|
||||||
.align algn; \
|
|
||||||
.global name; \
|
|
||||||
.type name, #object; \
|
|
||||||
.size name, sz; \
|
|
||||||
name:
|
|
||||||
|
|
||||||
#define DGDEF(name) DGDEF3(name, 4, 4)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* SET_SIZE trails a function and set the size for the ELF symbol table.
|
|
||||||
*/
|
|
||||||
#define SET_SIZE(x) \
|
|
||||||
.size x, (.-x)
|
|
||||||
|
|
||||||
#endif /* _ASM */
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _SYS_ASM_LINKAGE_H */
|
|
|
@ -1,37 +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 2006 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
//#define __need___va_list
|
|
||||||
#include_next <stdarg.h>
|
|
||||||
|
|
||||||
#ifndef _SOL_STDARG_H
|
|
||||||
#define _SOL_STDARG_H
|
|
||||||
|
|
||||||
#ifndef __va_list
|
|
||||||
typedef __gnuc_va_list __va_list;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,32 +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 2006 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _STDIO_EXT_H
|
|
||||||
#define _STDIO_EXT_H
|
|
||||||
|
|
||||||
#define enable_extended_FILE_stdio(x,y) (0)
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,33 +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 2006 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SOL_STRINGS_H
|
|
||||||
#define _SOL_STRINGS_H
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include_next <strings.h>
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,289 +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 2007 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SYS_ACL_H
|
|
||||||
#define _SYS_ACL_H
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/acl_impl.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MAX_ACL_ENTRIES (1024) /* max entries of each type */
|
|
||||||
typedef struct acl {
|
|
||||||
int a_type; /* the type of ACL entry */
|
|
||||||
uid_t a_id; /* the entry in -uid or gid */
|
|
||||||
o_mode_t a_perm; /* the permission field */
|
|
||||||
} aclent_t;
|
|
||||||
|
|
||||||
typedef struct ace {
|
|
||||||
uid_t a_who; /* uid or gid */
|
|
||||||
uint32_t a_access_mask; /* read,write,... */
|
|
||||||
uint16_t a_flags; /* see below */
|
|
||||||
uint16_t a_type; /* allow or deny */
|
|
||||||
} ace_t;
|
|
||||||
|
|
||||||
typedef struct acl_info acl_t;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The following are Defined types for an aclent_t.
|
|
||||||
*/
|
|
||||||
#define USER_OBJ (0x01) /* object owner */
|
|
||||||
#define USER (0x02) /* additional users */
|
|
||||||
#define GROUP_OBJ (0x04) /* owning group of the object */
|
|
||||||
#define GROUP (0x08) /* additional groups */
|
|
||||||
#define CLASS_OBJ (0x10) /* file group class and mask entry */
|
|
||||||
#define OTHER_OBJ (0x20) /* other entry for the object */
|
|
||||||
#define ACL_DEFAULT (0x1000) /* default flag */
|
|
||||||
/* default object owner */
|
|
||||||
#define DEF_USER_OBJ (ACL_DEFAULT | USER_OBJ)
|
|
||||||
/* default additional users */
|
|
||||||
#define DEF_USER (ACL_DEFAULT | USER)
|
|
||||||
/* default owning group */
|
|
||||||
#define DEF_GROUP_OBJ (ACL_DEFAULT | GROUP_OBJ)
|
|
||||||
/* default additional groups */
|
|
||||||
#define DEF_GROUP (ACL_DEFAULT | GROUP)
|
|
||||||
/* default mask entry */
|
|
||||||
#define DEF_CLASS_OBJ (ACL_DEFAULT | CLASS_OBJ)
|
|
||||||
/* default other entry */
|
|
||||||
#define DEF_OTHER_OBJ (ACL_DEFAULT | OTHER_OBJ)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The following are defined for ace_t.
|
|
||||||
*/
|
|
||||||
#define ACE_READ_DATA 0x00000001
|
|
||||||
#define ACE_LIST_DIRECTORY 0x00000001
|
|
||||||
#define ACE_WRITE_DATA 0x00000002
|
|
||||||
#define ACE_ADD_FILE 0x00000002
|
|
||||||
#define ACE_APPEND_DATA 0x00000004
|
|
||||||
#define ACE_ADD_SUBDIRECTORY 0x00000004
|
|
||||||
#define ACE_READ_NAMED_ATTRS 0x00000008
|
|
||||||
#define ACE_WRITE_NAMED_ATTRS 0x00000010
|
|
||||||
#define ACE_EXECUTE 0x00000020
|
|
||||||
#define ACE_DELETE_CHILD 0x00000040
|
|
||||||
#define ACE_READ_ATTRIBUTES 0x00000080
|
|
||||||
#define ACE_WRITE_ATTRIBUTES 0x00000100
|
|
||||||
#define ACE_DELETE 0x00010000
|
|
||||||
#define ACE_READ_ACL 0x00020000
|
|
||||||
#define ACE_WRITE_ACL 0x00040000
|
|
||||||
#define ACE_WRITE_OWNER 0x00080000
|
|
||||||
#define ACE_SYNCHRONIZE 0x00100000
|
|
||||||
|
|
||||||
#define ACE_FILE_INHERIT_ACE 0x0001
|
|
||||||
#define ACE_DIRECTORY_INHERIT_ACE 0x0002
|
|
||||||
#define ACE_NO_PROPAGATE_INHERIT_ACE 0x0004
|
|
||||||
#define ACE_INHERIT_ONLY_ACE 0x0008
|
|
||||||
#define ACE_SUCCESSFUL_ACCESS_ACE_FLAG 0x0010
|
|
||||||
#define ACE_FAILED_ACCESS_ACE_FLAG 0x0020
|
|
||||||
#define ACE_IDENTIFIER_GROUP 0x0040
|
|
||||||
#define ACE_INHERITED_ACE 0x0080
|
|
||||||
#define ACE_OWNER 0x1000
|
|
||||||
#define ACE_GROUP 0x2000
|
|
||||||
#define ACE_EVERYONE 0x4000
|
|
||||||
|
|
||||||
#define ACE_ACCESS_ALLOWED_ACE_TYPE 0x0000
|
|
||||||
#define ACE_ACCESS_DENIED_ACE_TYPE 0x0001
|
|
||||||
#define ACE_SYSTEM_AUDIT_ACE_TYPE 0x0002
|
|
||||||
#define ACE_SYSTEM_ALARM_ACE_TYPE 0x0003
|
|
||||||
|
|
||||||
#define ACL_AUTO_INHERIT 0x0001
|
|
||||||
#define ACL_PROTECTED 0x0002
|
|
||||||
#define ACL_DEFAULTED 0x0004
|
|
||||||
#define ACL_FLAGS_ALL (ACL_AUTO_INHERIT|ACL_PROTECTED| \
|
|
||||||
ACL_DEFAULTED)
|
|
||||||
|
|
||||||
#ifdef _KERNEL
|
|
||||||
|
|
||||||
/*
|
|
||||||
* These are only applicable in a CIFS context.
|
|
||||||
*/
|
|
||||||
#define ACE_ACCESS_ALLOWED_COMPOUND_ACE_TYPE 0x04
|
|
||||||
#define ACE_ACCESS_ALLOWED_OBJECT_ACE_TYPE 0x05
|
|
||||||
#define ACE_ACCESS_DENIED_OBJECT_ACE_TYPE 0x06
|
|
||||||
#define ACE_SYSTEM_AUDIT_OBJECT_ACE_TYPE 0x07
|
|
||||||
#define ACE_SYSTEM_ALARM_OBJECT_ACE_TYPE 0x08
|
|
||||||
#define ACE_ACCESS_ALLOWED_CALLBACK_ACE_TYPE 0x09
|
|
||||||
#define ACE_ACCESS_DENIED_CALLBACK_ACE_TYPE 0x0A
|
|
||||||
#define ACE_ACCESS_ALLOWED_CALLBACK_OBJECT_ACE_TYPE 0x0B
|
|
||||||
#define ACE_ACCESS_DENIED_CALLBACK_OBJECT_ACE_TYPE 0x0C
|
|
||||||
#define ACE_SYSTEM_AUDIT_CALLBACK_ACE_TYPE 0x0D
|
|
||||||
#define ACE_SYSTEM_ALARM_CALLBACK_ACE_TYPE 0x0E
|
|
||||||
#define ACE_SYSTEM_AUDIT_CALLBACK_OBJECT_ACE_TYPE 0x0F
|
|
||||||
#define ACE_SYSTEM_ALARM_CALLBACK_OBJECT_ACE_TYPE 0x10
|
|
||||||
|
|
||||||
#define ACE_ALL_TYPES 0x001F
|
|
||||||
|
|
||||||
typedef struct ace_object {
|
|
||||||
uid_t a_who; /* uid or gid */
|
|
||||||
uint32_t a_access_mask; /* read,write,... */
|
|
||||||
uint16_t a_flags; /* see below */
|
|
||||||
uint16_t a_type; /* allow or deny */
|
|
||||||
uint8_t a_obj_type[16]; /* obj type */
|
|
||||||
uint8_t a_inherit_obj_type[16]; /* inherit obj */
|
|
||||||
} ace_object_t;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ACE_ALL_PERMS (ACE_READ_DATA|ACE_LIST_DIRECTORY|ACE_WRITE_DATA| \
|
|
||||||
ACE_ADD_FILE|ACE_APPEND_DATA|ACE_ADD_SUBDIRECTORY|ACE_READ_NAMED_ATTRS| \
|
|
||||||
ACE_WRITE_NAMED_ATTRS|ACE_EXECUTE|ACE_DELETE_CHILD|ACE_READ_ATTRIBUTES| \
|
|
||||||
ACE_WRITE_ATTRIBUTES|ACE_DELETE|ACE_READ_ACL|ACE_WRITE_ACL| \
|
|
||||||
ACE_WRITE_OWNER|ACE_SYNCHRONIZE)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The following flags are supported by both NFSv4 ACLs and ace_t.
|
|
||||||
*/
|
|
||||||
#define ACE_NFSV4_SUP_FLAGS (ACE_FILE_INHERIT_ACE | \
|
|
||||||
ACE_DIRECTORY_INHERIT_ACE | \
|
|
||||||
ACE_NO_PROPAGATE_INHERIT_ACE | \
|
|
||||||
ACE_INHERIT_ONLY_ACE | \
|
|
||||||
ACE_IDENTIFIER_GROUP)
|
|
||||||
|
|
||||||
#define ACE_TYPE_FLAGS (ACE_OWNER|ACE_GROUP|ACE_EVERYONE| \
|
|
||||||
ACE_IDENTIFIER_GROUP)
|
|
||||||
#define ACE_INHERIT_FLAGS (ACE_FILE_INHERIT_ACE| \
|
|
||||||
ACE_DIRECTORY_INHERIT_ACE|ACE_NO_PROPAGATE_INHERIT_ACE|ACE_INHERIT_ONLY_ACE)
|
|
||||||
|
|
||||||
/* cmd args to acl(2) for aclent_t */
|
|
||||||
#define GETACL 1
|
|
||||||
#define SETACL 2
|
|
||||||
#define GETACLCNT 3
|
|
||||||
|
|
||||||
/* cmd's to manipulate ace acls. */
|
|
||||||
#define ACE_GETACL 4
|
|
||||||
#define ACE_SETACL 5
|
|
||||||
#define ACE_GETACLCNT 6
|
|
||||||
|
|
||||||
/* minimal acl entries from GETACLCNT */
|
|
||||||
#define MIN_ACL_ENTRIES 4
|
|
||||||
|
|
||||||
#if !defined(_KERNEL)
|
|
||||||
|
|
||||||
/* acl check errors */
|
|
||||||
#define GRP_ERROR 1
|
|
||||||
#define USER_ERROR 2
|
|
||||||
#define OTHER_ERROR 3
|
|
||||||
#define CLASS_ERROR 4
|
|
||||||
#define DUPLICATE_ERROR 5
|
|
||||||
#define MISS_ERROR 6
|
|
||||||
#define MEM_ERROR 7
|
|
||||||
#define ENTRY_ERROR 8
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* similar to ufs_acl.h: changed to char type for user commands (tar, cpio)
|
|
||||||
* Attribute types
|
|
||||||
*/
|
|
||||||
#define UFSD_FREE ('0') /* Free entry */
|
|
||||||
#define UFSD_ACL ('1') /* Access Control Lists */
|
|
||||||
#define UFSD_DFACL ('2') /* reserved for future use */
|
|
||||||
#define ACE_ACL ('3') /* ace_t style acls */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* flag to [f]acl_get()
|
|
||||||
* controls whether a trivial acl should be returned.
|
|
||||||
*/
|
|
||||||
#define ACL_NO_TRIVIAL 0x2
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Flags to control acl_totext()
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define ACL_APPEND_ID 0x1 /* append uid/gid to user/group entries */
|
|
||||||
#define ACL_COMPACT_FMT 0x2 /* build ACL in ls -V format */
|
|
||||||
#define ACL_NORESOLVE 0x4 /* don't do name service lookups */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Legacy aclcheck errors for aclent_t ACLs
|
|
||||||
*/
|
|
||||||
#define EACL_GRP_ERROR GRP_ERROR
|
|
||||||
#define EACL_USER_ERROR USER_ERROR
|
|
||||||
#define EACL_OTHER_ERROR OTHER_ERROR
|
|
||||||
#define EACL_CLASS_ERROR CLASS_ERROR
|
|
||||||
#define EACL_DUPLICATE_ERROR DUPLICATE_ERROR
|
|
||||||
#define EACL_MISS_ERROR MISS_ERROR
|
|
||||||
#define EACL_MEM_ERROR MEM_ERROR
|
|
||||||
#define EACL_ENTRY_ERROR ENTRY_ERROR
|
|
||||||
|
|
||||||
#define EACL_INHERIT_ERROR 9 /* invalid inherit flags */
|
|
||||||
#define EACL_FLAGS_ERROR 10 /* unknown flag value */
|
|
||||||
#define EACL_PERM_MASK_ERROR 11 /* unknown permission */
|
|
||||||
#define EACL_COUNT_ERROR 12 /* invalid acl count */
|
|
||||||
|
|
||||||
#define EACL_INVALID_SLOT 13 /* invalid acl slot */
|
|
||||||
#define EACL_NO_ACL_ENTRY 14 /* Entry doesn't exist */
|
|
||||||
#define EACL_DIFF_TYPE 15 /* acls aren't same type */
|
|
||||||
|
|
||||||
#define EACL_INVALID_USER_GROUP 16 /* need user/group name */
|
|
||||||
#define EACL_INVALID_STR 17 /* invalid acl string */
|
|
||||||
#define EACL_FIELD_NOT_BLANK 18 /* can't have blank field */
|
|
||||||
#define EACL_INVALID_ACCESS_TYPE 19 /* invalid access type */
|
|
||||||
#define EACL_UNKNOWN_DATA 20 /* Unrecognized data in ACL */
|
|
||||||
#define EACL_MISSING_FIELDS 21 /* missing fields in acl */
|
|
||||||
|
|
||||||
#define EACL_INHERIT_NOTDIR 22 /* Need dir for inheritance */
|
|
||||||
|
|
||||||
extern int aclcheck(aclent_t *, int, int *);
|
|
||||||
extern int acltomode(aclent_t *, int, mode_t *);
|
|
||||||
extern int aclfrommode(aclent_t *, int, mode_t *);
|
|
||||||
extern int aclsort(int, int, aclent_t *);
|
|
||||||
extern char *acltotext(aclent_t *, int);
|
|
||||||
extern aclent_t *aclfromtext(char *, int *);
|
|
||||||
extern void acl_free(acl_t *);
|
|
||||||
extern int acl_get(const char *, int, acl_t **);
|
|
||||||
extern int facl_get(int, int, acl_t **);
|
|
||||||
extern int acl_set(const char *, acl_t *acl);
|
|
||||||
extern int facl_set(int, acl_t *acl);
|
|
||||||
extern int acl_strip(const char *, uid_t, gid_t, mode_t);
|
|
||||||
extern int acl_trivial(const char *);
|
|
||||||
extern char *acl_totext(acl_t *, int);
|
|
||||||
extern int acl_fromtext(const char *, acl_t **);
|
|
||||||
extern int acl_check(acl_t *, int);
|
|
||||||
|
|
||||||
#else /* !defined(_KERNEL) */
|
|
||||||
|
|
||||||
extern void ksort(caddr_t, int, int, int (*)(void *, void *));
|
|
||||||
extern int cmp2acls(void *, void *);
|
|
||||||
|
|
||||||
#endif /* !defined(_KERNEL) */
|
|
||||||
|
|
||||||
#if defined(__STDC__)
|
|
||||||
extern int acl(const char *path, int cmd, int cnt, void *buf);
|
|
||||||
extern int facl(int fd, int cmd, int cnt, void *buf);
|
|
||||||
#else /* !__STDC__ */
|
|
||||||
extern int acl();
|
|
||||||
extern int facl();
|
|
||||||
#endif /* defined(__STDC__) */
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _SYS_ACL_H */
|
|
|
@ -1,61 +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 2007 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SYS_ACL_IMPL_H
|
|
||||||
#define _SYS_ACL_IMPL_H
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* acl flags
|
|
||||||
*
|
|
||||||
* ACL_AUTO_INHERIT, ACL_PROTECTED and ACL_DEFAULTED
|
|
||||||
* flags can also be stored in this field.
|
|
||||||
*/
|
|
||||||
#define ACL_IS_TRIVIAL 0x10000
|
|
||||||
#define ACL_IS_DIR 0x20000
|
|
||||||
|
|
||||||
typedef enum acl_type {
|
|
||||||
ACLENT_T = 0,
|
|
||||||
ACE_T = 1
|
|
||||||
} acl_type_t;
|
|
||||||
|
|
||||||
struct acl_info {
|
|
||||||
acl_type_t acl_type; /* style of acl */
|
|
||||||
int acl_cnt; /* number of acl entries */
|
|
||||||
int acl_entry_size; /* sizeof acl entry */
|
|
||||||
int acl_flags; /* special flags about acl */
|
|
||||||
void *acl_aclp; /* the acl */
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _SYS_ACL_IMPL_H */
|
|
|
@ -1,199 +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 2007 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
|
|
||||||
/* All Rights Reserved */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* University Copyright- Copyright (c) 1982, 1986, 1988
|
|
||||||
* The Regents of the University of California
|
|
||||||
* All Rights Reserved
|
|
||||||
*
|
|
||||||
* University Acknowledgment- Portions of this document are derived from
|
|
||||||
* software developed by the University of California, Berkeley, and its
|
|
||||||
* contributors.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SYS_BYTEORDER_H
|
|
||||||
#define _SYS_BYTEORDER_H
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <sys/isa_defs.h>
|
|
||||||
#include <sys/int_types.h>
|
|
||||||
|
|
||||||
#if defined(__GNUC__) && defined(_ASM_INLINES) && \
|
|
||||||
(defined(__i386) || defined(__amd64))
|
|
||||||
#include <asm/byteorder.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* macros for conversion between host and (internet) network byte order
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(_BIG_ENDIAN) && !defined(ntohl) && !defined(__lint)
|
|
||||||
/* big-endian */
|
|
||||||
#define ntohl(x) (x)
|
|
||||||
#define ntohs(x) (x)
|
|
||||||
#define htonl(x) (x)
|
|
||||||
#define htons(x) (x)
|
|
||||||
|
|
||||||
#elif !defined(ntohl) /* little-endian */
|
|
||||||
|
|
||||||
#ifndef _IN_PORT_T
|
|
||||||
#define _IN_PORT_T
|
|
||||||
typedef uint16_t in_port_t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _IN_ADDR_T
|
|
||||||
#define _IN_ADDR_T
|
|
||||||
typedef uint32_t in_addr_t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(_XPG4_2) || defined(__EXTENSIONS__) || defined(_XPG5)
|
|
||||||
extern uint32_t htonl(uint32_t);
|
|
||||||
extern uint16_t htons(uint16_t);
|
|
||||||
extern uint32_t ntohl(uint32_t);
|
|
||||||
extern uint16_t ntohs(uint16_t);
|
|
||||||
#else
|
|
||||||
extern in_addr_t htonl(in_addr_t);
|
|
||||||
extern in_port_t htons(in_port_t);
|
|
||||||
extern in_addr_t ntohl(in_addr_t);
|
|
||||||
extern in_port_t ntohs(in_port_t);
|
|
||||||
#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) || defined(_XPG5) */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Macros to reverse byte order
|
|
||||||
*/
|
|
||||||
#define BSWAP_8(x) ((x) & 0xff)
|
|
||||||
#define BSWAP_16(x) ((BSWAP_8(x) << 8) | BSWAP_8((x) >> 8))
|
|
||||||
#define BSWAP_32(x) ((BSWAP_16(x) << 16) | BSWAP_16((x) >> 16))
|
|
||||||
#define BSWAP_64(x) ((BSWAP_32(x) << 32) | BSWAP_32((x) >> 32))
|
|
||||||
|
|
||||||
#define BMASK_8(x) ((x) & 0xff)
|
|
||||||
#define BMASK_16(x) ((x) & 0xffff)
|
|
||||||
#define BMASK_32(x) ((x) & 0xffffffff)
|
|
||||||
#define BMASK_64(x) (x)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Macros to convert from a specific byte order to/from native byte order
|
|
||||||
*/
|
|
||||||
#ifdef _BIG_ENDIAN
|
|
||||||
#define BE_8(x) BMASK_8(x)
|
|
||||||
#define BE_16(x) BMASK_16(x)
|
|
||||||
#define BE_32(x) BMASK_32(x)
|
|
||||||
#define BE_64(x) BMASK_64(x)
|
|
||||||
#define LE_8(x) BSWAP_8(x)
|
|
||||||
#define LE_16(x) BSWAP_16(x)
|
|
||||||
#define LE_32(x) BSWAP_32(x)
|
|
||||||
#define LE_64(x) BSWAP_64(x)
|
|
||||||
#else
|
|
||||||
#define LE_8(x) BMASK_8(x)
|
|
||||||
#define LE_16(x) BMASK_16(x)
|
|
||||||
#define LE_32(x) BMASK_32(x)
|
|
||||||
#define LE_64(x) BMASK_64(x)
|
|
||||||
#define BE_8(x) BSWAP_8(x)
|
|
||||||
#define BE_16(x) BSWAP_16(x)
|
|
||||||
#define BE_32(x) BSWAP_32(x)
|
|
||||||
#define BE_64(x) BSWAP_64(x)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Macros to read unaligned values from a specific byte order to
|
|
||||||
* native byte order
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define BE_IN8(xa) \
|
|
||||||
*((uint8_t *)(xa))
|
|
||||||
|
|
||||||
#define BE_IN16(xa) \
|
|
||||||
(((uint16_t)BE_IN8(xa) << 8) | BE_IN8((uint8_t *)(xa)+1))
|
|
||||||
|
|
||||||
#define BE_IN32(xa) \
|
|
||||||
(((uint32_t)BE_IN16(xa) << 16) | BE_IN16((uint8_t *)(xa)+2))
|
|
||||||
|
|
||||||
#define BE_IN64(xa) \
|
|
||||||
(((uint64_t)BE_IN32(xa) << 32) | BE_IN32((uint8_t *)(xa)+4))
|
|
||||||
|
|
||||||
#define LE_IN8(xa) \
|
|
||||||
*((uint8_t *)(xa))
|
|
||||||
|
|
||||||
#define LE_IN16(xa) \
|
|
||||||
(((uint16_t)LE_IN8((uint8_t *)(xa) + 1) << 8) | LE_IN8(xa))
|
|
||||||
|
|
||||||
#define LE_IN32(xa) \
|
|
||||||
(((uint32_t)LE_IN16((uint8_t *)(xa) + 2) << 16) | LE_IN16(xa))
|
|
||||||
|
|
||||||
#define LE_IN64(xa) \
|
|
||||||
(((uint64_t)LE_IN32((uint8_t *)(xa) + 4) << 32) | LE_IN32(xa))
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Macros to write unaligned values from native byte order to a specific byte
|
|
||||||
* order.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define BE_OUT8(xa, yv) *((uint8_t *)(xa)) = (uint8_t)(yv);
|
|
||||||
|
|
||||||
#define BE_OUT16(xa, yv) \
|
|
||||||
BE_OUT8((uint8_t *)(xa) + 1, yv); \
|
|
||||||
BE_OUT8((uint8_t *)(xa), (yv) >> 8);
|
|
||||||
|
|
||||||
#define BE_OUT32(xa, yv) \
|
|
||||||
BE_OUT16((uint8_t *)(xa) + 2, yv); \
|
|
||||||
BE_OUT16((uint8_t *)(xa), (yv) >> 16);
|
|
||||||
|
|
||||||
#define BE_OUT64(xa, yv) \
|
|
||||||
BE_OUT32((uint8_t *)(xa) + 4, yv); \
|
|
||||||
BE_OUT32((uint8_t *)(xa), (yv) >> 32);
|
|
||||||
|
|
||||||
#define LE_OUT8(xa, yv) *((uint8_t *)(xa)) = (uint8_t)(yv);
|
|
||||||
|
|
||||||
#define LE_OUT16(xa, yv) \
|
|
||||||
LE_OUT8((uint8_t *)(xa), yv); \
|
|
||||||
LE_OUT8((uint8_t *)(xa) + 1, (yv) >> 8);
|
|
||||||
|
|
||||||
#define LE_OUT32(xa, yv) \
|
|
||||||
LE_OUT16((uint8_t *)(xa), yv); \
|
|
||||||
LE_OUT16((uint8_t *)(xa) + 2, (yv) >> 16);
|
|
||||||
|
|
||||||
#define LE_OUT64(xa, yv) \
|
|
||||||
LE_OUT32((uint8_t *)(xa), yv); \
|
|
||||||
LE_OUT32((uint8_t *)(xa) + 4, (yv) >> 32);
|
|
||||||
|
|
||||||
#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _SYS_BYTEORDER_H */
|
|
|
@ -1,32 +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 2006 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SOL_SYS_CRED_H
|
|
||||||
#define _SOL_SYS_CRED_H
|
|
||||||
|
|
||||||
typedef struct cred cred_t;
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,484 +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 2007 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SYS_DKIO_H
|
|
||||||
#define _SYS_DKIO_H
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <sys/dklabel.h> /* Needed for NDKMAP define */
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Structures and definitions for disk io control commands
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Structures used as data by ioctl calls.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define DK_DEVLEN 16 /* device name max length, including */
|
|
||||||
/* unit # & NULL (ie - "xyc1") */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Used for controller info
|
|
||||||
*/
|
|
||||||
struct dk_cinfo {
|
|
||||||
char dki_cname[DK_DEVLEN]; /* controller name (no unit #) */
|
|
||||||
ushort_t dki_ctype; /* controller type */
|
|
||||||
ushort_t dki_flags; /* flags */
|
|
||||||
ushort_t dki_cnum; /* controller number */
|
|
||||||
uint_t dki_addr; /* controller address */
|
|
||||||
uint_t dki_space; /* controller bus type */
|
|
||||||
uint_t dki_prio; /* interrupt priority */
|
|
||||||
uint_t dki_vec; /* interrupt vector */
|
|
||||||
char dki_dname[DK_DEVLEN]; /* drive name (no unit #) */
|
|
||||||
uint_t dki_unit; /* unit number */
|
|
||||||
uint_t dki_slave; /* slave number */
|
|
||||||
ushort_t dki_partition; /* partition number */
|
|
||||||
ushort_t dki_maxtransfer; /* max. transfer size in DEV_BSIZE */
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Controller types
|
|
||||||
*/
|
|
||||||
#define DKC_UNKNOWN 0
|
|
||||||
#define DKC_CDROM 1 /* CD-ROM, SCSI or otherwise */
|
|
||||||
#define DKC_WDC2880 2
|
|
||||||
#define DKC_XXX_0 3 /* unassigned */
|
|
||||||
#define DKC_XXX_1 4 /* unassigned */
|
|
||||||
#define DKC_DSD5215 5
|
|
||||||
#define DKC_ACB4000 7
|
|
||||||
#define DKC_MD21 8
|
|
||||||
#define DKC_XXX_2 9 /* unassigned */
|
|
||||||
#define DKC_NCRFLOPPY 10
|
|
||||||
#define DKC_SMSFLOPPY 12
|
|
||||||
#define DKC_SCSI_CCS 13 /* SCSI CCS compatible */
|
|
||||||
#define DKC_INTEL82072 14 /* native floppy chip */
|
|
||||||
#define DKC_MD 16 /* meta-disk (virtual-disk) driver */
|
|
||||||
#define DKC_INTEL82077 19 /* 82077 floppy disk controller */
|
|
||||||
#define DKC_DIRECT 20 /* Intel direct attached device i.e. IDE */
|
|
||||||
#define DKC_PCMCIA_MEM 21 /* PCMCIA memory disk-like type */
|
|
||||||
#define DKC_PCMCIA_ATA 22 /* PCMCIA AT Attached type */
|
|
||||||
#define DKC_VBD 23 /* virtual block device */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Sun reserves up through 1023
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define DKC_CUSTOMER_BASE 1024
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Flags
|
|
||||||
*/
|
|
||||||
#define DKI_BAD144 0x01 /* use DEC std 144 bad sector fwding */
|
|
||||||
#define DKI_MAPTRK 0x02 /* controller does track mapping */
|
|
||||||
#define DKI_FMTTRK 0x04 /* formats only full track at a time */
|
|
||||||
#define DKI_FMTVOL 0x08 /* formats only full volume at a time */
|
|
||||||
#define DKI_FMTCYL 0x10 /* formats only full cylinders at a time */
|
|
||||||
#define DKI_HEXUNIT 0x20 /* unit number is printed as 3 hex digits */
|
|
||||||
#define DKI_PCMCIA_PFD 0x40 /* PCMCIA pseudo-floppy memory card */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Used for all partitions
|
|
||||||
*/
|
|
||||||
struct dk_allmap {
|
|
||||||
struct dk_map dka_map[NDKMAP];
|
|
||||||
};
|
|
||||||
|
|
||||||
#if defined(_SYSCALL32)
|
|
||||||
struct dk_allmap32 {
|
|
||||||
struct dk_map32 dka_map[NDKMAP];
|
|
||||||
};
|
|
||||||
#endif /* _SYSCALL32 */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Definition of a disk's geometry
|
|
||||||
*/
|
|
||||||
struct dk_geom {
|
|
||||||
unsigned short dkg_ncyl; /* # of data cylinders */
|
|
||||||
unsigned short dkg_acyl; /* # of alternate cylinders */
|
|
||||||
unsigned short dkg_bcyl; /* cyl offset (for fixed head area) */
|
|
||||||
unsigned short dkg_nhead; /* # of heads */
|
|
||||||
unsigned short dkg_obs1; /* obsolete */
|
|
||||||
unsigned short dkg_nsect; /* # of data sectors per track */
|
|
||||||
unsigned short dkg_intrlv; /* interleave factor */
|
|
||||||
unsigned short dkg_obs2; /* obsolete */
|
|
||||||
unsigned short dkg_obs3; /* obsolete */
|
|
||||||
unsigned short dkg_apc; /* alternates per cyl (SCSI only) */
|
|
||||||
unsigned short dkg_rpm; /* revolutions per minute */
|
|
||||||
unsigned short dkg_pcyl; /* # of physical cylinders */
|
|
||||||
unsigned short dkg_write_reinstruct; /* # sectors to skip, writes */
|
|
||||||
unsigned short dkg_read_reinstruct; /* # sectors to skip, reads */
|
|
||||||
unsigned short dkg_extra[7]; /* for compatible expansion */
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* These defines are for historic compatibility with old drivers.
|
|
||||||
*/
|
|
||||||
#define dkg_bhead dkg_obs1 /* used to be head offset */
|
|
||||||
#define dkg_gap1 dkg_obs2 /* used to be gap1 */
|
|
||||||
#define dkg_gap2 dkg_obs3 /* used to be gap2 */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Disk io control commands
|
|
||||||
* Warning: some other ioctls with the DIOC prefix exist elsewhere.
|
|
||||||
* The Generic DKIOC numbers are from 0 - 50.
|
|
||||||
* The Floppy Driver uses 51 - 100.
|
|
||||||
* The Hard Disk (except SCSI) 101 - 106. (these are obsolete)
|
|
||||||
* The CDROM Driver 151 - 200.
|
|
||||||
* The USCSI ioctl 201 - 250.
|
|
||||||
*/
|
|
||||||
#define DKIOC (0x04 << 8)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The following ioctls are generic in nature and need to be
|
|
||||||
* suported as appropriate by all disk drivers
|
|
||||||
*/
|
|
||||||
#define DKIOCGGEOM (DKIOC|1) /* Get geometry */
|
|
||||||
#define DKIOCINFO (DKIOC|3) /* Get info */
|
|
||||||
#define DKIOCEJECT (DKIOC|6) /* Generic 'eject' */
|
|
||||||
#define DKIOCGVTOC (DKIOC|11) /* Get VTOC */
|
|
||||||
#define DKIOCSVTOC (DKIOC|12) /* Set VTOC & Write to Disk */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Disk Cache Controls. These ioctls should be supported by
|
|
||||||
* all disk drivers.
|
|
||||||
*
|
|
||||||
* DKIOCFLUSHWRITECACHE when used from user-mode ignores the ioctl
|
|
||||||
* argument, but it should be passed as NULL to allow for future
|
|
||||||
* reinterpretation. From user-mode, this ioctl request is synchronous.
|
|
||||||
*
|
|
||||||
* When invoked from within the kernel, the arg can be NULL to indicate
|
|
||||||
* a synchronous request or can be the address of a struct dk_callback
|
|
||||||
* to request an asynchronous callback when the flush request is complete.
|
|
||||||
* In this case, the flag to the ioctl must include FKIOCTL and the
|
|
||||||
* dkc_callback field of the pointed to struct must be non-null or the
|
|
||||||
* request is made synchronously.
|
|
||||||
*
|
|
||||||
* In the callback case: if the ioctl returns 0, a callback WILL be performed.
|
|
||||||
* If the ioctl returns non-zero, a callback will NOT be performed.
|
|
||||||
* NOTE: In some cases, the callback may be done BEFORE the ioctl call
|
|
||||||
* returns. The caller's locking strategy should be prepared for this case.
|
|
||||||
*/
|
|
||||||
#define DKIOCFLUSHWRITECACHE (DKIOC|34) /* flush cache to phys medium */
|
|
||||||
|
|
||||||
struct dk_callback {
|
|
||||||
void (*dkc_callback)(void *dkc_cookie, int error);
|
|
||||||
void *dkc_cookie;
|
|
||||||
int dkc_flag;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* bit flag definitions for dkc_flag */
|
|
||||||
#define FLUSH_VOLATILE 0x1 /* Bit 0: if set, only flush */
|
|
||||||
/* volatile cache; otherwise, flush */
|
|
||||||
/* volatile and non-volatile cache */
|
|
||||||
|
|
||||||
#define DKIOCGETWCE (DKIOC|36) /* Get current write cache */
|
|
||||||
/* enablement status */
|
|
||||||
#define DKIOCSETWCE (DKIOC|37) /* Enable/Disable write cache */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The following ioctls are used by Sun drivers to communicate
|
|
||||||
* with their associated format routines. Support of these ioctls
|
|
||||||
* is not required of foreign drivers
|
|
||||||
*/
|
|
||||||
#define DKIOCSGEOM (DKIOC|2) /* Set geometry */
|
|
||||||
#define DKIOCSAPART (DKIOC|4) /* Set all partitions */
|
|
||||||
#define DKIOCGAPART (DKIOC|5) /* Get all partitions */
|
|
||||||
#define DKIOCG_PHYGEOM (DKIOC|32) /* get physical geometry */
|
|
||||||
#define DKIOCG_VIRTGEOM (DKIOC|33) /* get virtual geometry */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The following ioctl's are removable media support
|
|
||||||
*/
|
|
||||||
#define DKIOCLOCK (DKIOC|7) /* Generic 'lock' */
|
|
||||||
#define DKIOCUNLOCK (DKIOC|8) /* Generic 'unlock' */
|
|
||||||
#define DKIOCSTATE (DKIOC|13) /* Inquire insert/eject state */
|
|
||||||
#define DKIOCREMOVABLE (DKIOC|16) /* is media removable */
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ioctl for hotpluggable devices
|
|
||||||
*/
|
|
||||||
#define DKIOCHOTPLUGGABLE (DKIOC|35) /* is hotpluggable */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Ioctl to force driver to re-read the alternate partition and rebuild
|
|
||||||
* the internal defect map.
|
|
||||||
*/
|
|
||||||
#define DKIOCADDBAD (DKIOC|20) /* Re-read the alternate map (IDE) */
|
|
||||||
#define DKIOCGETDEF (DKIOC|21) /* read defect list (IDE) */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Used by applications to get disk defect information from IDE
|
|
||||||
* drives.
|
|
||||||
*/
|
|
||||||
#ifdef _SYSCALL32
|
|
||||||
struct defect_header32 {
|
|
||||||
int head;
|
|
||||||
caddr32_t buffer;
|
|
||||||
};
|
|
||||||
#endif /* _SYSCALL32 */
|
|
||||||
|
|
||||||
struct defect_header {
|
|
||||||
int head;
|
|
||||||
caddr_t buffer;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define DKIOCPARTINFO (DKIOC|22) /* Get partition or slice parameters */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Used by applications to get partition or slice information
|
|
||||||
*/
|
|
||||||
#ifdef _SYSCALL32
|
|
||||||
struct part_info32 {
|
|
||||||
daddr32_t p_start;
|
|
||||||
int p_length;
|
|
||||||
};
|
|
||||||
#endif /* _SYSCALL32 */
|
|
||||||
|
|
||||||
struct part_info {
|
|
||||||
daddr_t p_start;
|
|
||||||
int p_length;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* The following ioctls are for Optical Memory Device */
|
|
||||||
#define DKIOC_EBP_ENABLE (DKIOC|40) /* enable by pass erase on write */
|
|
||||||
#define DKIOC_EBP_DISABLE (DKIOC|41) /* disable by pass erase on write */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This state enum is the argument passed to the DKIOCSTATE ioctl.
|
|
||||||
*/
|
|
||||||
enum dkio_state { DKIO_NONE, DKIO_EJECTED, DKIO_INSERTED, DKIO_DEV_GONE };
|
|
||||||
|
|
||||||
#define DKIOCGMEDIAINFO (DKIOC|42) /* get information about the media */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ioctls to read/write mboot info.
|
|
||||||
*/
|
|
||||||
#define DKIOCGMBOOT (DKIOC|43) /* get mboot info */
|
|
||||||
#define DKIOCSMBOOT (DKIOC|44) /* set mboot info */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ioctl to get the device temperature.
|
|
||||||
*/
|
|
||||||
#define DKIOCGTEMPERATURE (DKIOC|45) /* get temperature */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Used for providing the temperature.
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct dk_temperature {
|
|
||||||
uint_t dkt_flags; /* Flags */
|
|
||||||
short dkt_cur_temp; /* Current disk temperature */
|
|
||||||
short dkt_ref_temp; /* reference disk temperature */
|
|
||||||
};
|
|
||||||
|
|
||||||
#define DKT_BYPASS_PM 0x1
|
|
||||||
#define DKT_INVALID_TEMP 0xFFFF
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Used for Media info or the current profile info
|
|
||||||
*/
|
|
||||||
struct dk_minfo {
|
|
||||||
uint_t dki_media_type; /* Media type or profile info */
|
|
||||||
uint_t dki_lbsize; /* Logical blocksize of media */
|
|
||||||
diskaddr_t dki_capacity; /* Capacity as # of dki_lbsize blks */
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Media types or profiles known
|
|
||||||
*/
|
|
||||||
#define DK_UNKNOWN 0x00 /* Media inserted - type unknown */
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* SFF 8090 Specification Version 3, media types 0x01 - 0xfffe are retained to
|
|
||||||
* maintain compatibility with SFF8090. The following define the
|
|
||||||
* optical media type.
|
|
||||||
*/
|
|
||||||
#define DK_REMOVABLE_DISK 0x02 /* Removable Disk */
|
|
||||||
#define DK_MO_ERASABLE 0x03 /* MO Erasable */
|
|
||||||
#define DK_MO_WRITEONCE 0x04 /* MO Write once */
|
|
||||||
#define DK_AS_MO 0x05 /* AS MO */
|
|
||||||
#define DK_CDROM 0x08 /* CDROM */
|
|
||||||
#define DK_CDR 0x09 /* CD-R */
|
|
||||||
#define DK_CDRW 0x0A /* CD-RW */
|
|
||||||
#define DK_DVDROM 0x10 /* DVD-ROM */
|
|
||||||
#define DK_DVDR 0x11 /* DVD-R */
|
|
||||||
#define DK_DVDRAM 0x12 /* DVD_RAM or DVD-RW */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Media types for other rewritable magnetic media
|
|
||||||
*/
|
|
||||||
#define DK_FIXED_DISK 0x10001 /* Fixed disk SCSI or otherwise */
|
|
||||||
#define DK_FLOPPY 0x10002 /* Floppy media */
|
|
||||||
#define DK_ZIP 0x10003 /* IOMEGA ZIP media */
|
|
||||||
#define DK_JAZ 0x10004 /* IOMEGA JAZ media */
|
|
||||||
|
|
||||||
#define DKIOCSETEFI (DKIOC|17) /* Set EFI info */
|
|
||||||
#define DKIOCGETEFI (DKIOC|18) /* Get EFI info */
|
|
||||||
|
|
||||||
#define DKIOCPARTITION (DKIOC|9) /* Get partition info */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Ioctls to get/set volume capabilities related to Logical Volume Managers.
|
|
||||||
* They include the ability to get/set capabilities and to issue a read to a
|
|
||||||
* specific underlying device of a replicated device.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define DKIOCGETVOLCAP (DKIOC | 25) /* Get volume capabilities */
|
|
||||||
#define DKIOCSETVOLCAP (DKIOC | 26) /* Set volume capabilities */
|
|
||||||
#define DKIOCDMR (DKIOC | 27) /* Issue a directed read */
|
|
||||||
|
|
||||||
typedef uint_t volcapinfo_t;
|
|
||||||
|
|
||||||
typedef uint_t volcapset_t;
|
|
||||||
|
|
||||||
#define DKV_ABR_CAP 0x00000001 /* Support Appl.Based Recovery */
|
|
||||||
#define DKV_DMR_CAP 0x00000002 /* Support Directed Mirror Read */
|
|
||||||
|
|
||||||
typedef struct volcap {
|
|
||||||
volcapinfo_t vc_info; /* Capabilities available */
|
|
||||||
volcapset_t vc_set; /* Capabilities set */
|
|
||||||
} volcap_t;
|
|
||||||
|
|
||||||
#define VOL_SIDENAME 256
|
|
||||||
|
|
||||||
typedef struct vol_directed_rd {
|
|
||||||
int vdr_flags;
|
|
||||||
offset_t vdr_offset;
|
|
||||||
size_t vdr_nbytes;
|
|
||||||
size_t vdr_bytesread;
|
|
||||||
void *vdr_data;
|
|
||||||
int vdr_side;
|
|
||||||
char vdr_side_name[VOL_SIDENAME];
|
|
||||||
} vol_directed_rd_t;
|
|
||||||
|
|
||||||
#define DKV_SIDE_INIT (-1)
|
|
||||||
#define DKV_DMR_NEXT_SIDE 0x00000001
|
|
||||||
#define DKV_DMR_DONE 0x00000002
|
|
||||||
#define DKV_DMR_ERROR 0x00000004
|
|
||||||
#define DKV_DMR_SUCCESS 0x00000008
|
|
||||||
#define DKV_DMR_SHORT 0x00000010
|
|
||||||
|
|
||||||
#ifdef _MULTI_DATAMODEL
|
|
||||||
#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
|
|
||||||
#pragma pack(4)
|
|
||||||
#endif
|
|
||||||
typedef struct vol_directed_rd32 {
|
|
||||||
int32_t vdr_flags;
|
|
||||||
offset_t vdr_offset; /* 64-bit element on 32-bit alignment */
|
|
||||||
size32_t vdr_nbytes;
|
|
||||||
size32_t vdr_bytesread;
|
|
||||||
caddr32_t vdr_data;
|
|
||||||
int32_t vdr_side;
|
|
||||||
char vdr_side_name[VOL_SIDENAME];
|
|
||||||
} vol_directed_rd32_t;
|
|
||||||
#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
|
|
||||||
#pragma pack()
|
|
||||||
#endif
|
|
||||||
#endif /* _MULTI_DATAMODEL */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The ioctl is used to fetch disk's device type, vendor ID,
|
|
||||||
* model number/product ID, firmware revision and serial number together.
|
|
||||||
*
|
|
||||||
* Currently there are two device types - DKD_ATA_TYPE which means the
|
|
||||||
* disk is driven by cmdk/ata or dad/uata driver, and DKD_SCSI_TYPE
|
|
||||||
* which means the disk is driven by sd/scsi hba driver.
|
|
||||||
*/
|
|
||||||
#define DKIOC_GETDISKID (DKIOC|46)
|
|
||||||
|
|
||||||
/* These two labels are for dkd_dtype of dk_disk_id_t */
|
|
||||||
#define DKD_ATA_TYPE 0x01 /* ATA disk or legacy mode SATA disk */
|
|
||||||
#define DKD_SCSI_TYPE 0x02 /* SCSI disk or native mode SATA disk */
|
|
||||||
|
|
||||||
#define DKD_ATA_MODEL 40 /* model number length */
|
|
||||||
#define DKD_ATA_FWVER 8 /* firmware revision length */
|
|
||||||
#define DKD_ATA_SERIAL 20 /* serial number length */
|
|
||||||
|
|
||||||
#define DKD_SCSI_VENDOR 8 /* vendor ID length */
|
|
||||||
#define DKD_SCSI_PRODUCT 16 /* product ID length */
|
|
||||||
#define DKD_SCSI_REVLEVEL 4 /* revision level length */
|
|
||||||
#define DKD_SCSI_SERIAL 12 /* serial number length */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The argument type for DKIOC_GETDISKID ioctl.
|
|
||||||
*/
|
|
||||||
typedef struct dk_disk_id {
|
|
||||||
uint_t dkd_dtype;
|
|
||||||
union {
|
|
||||||
struct {
|
|
||||||
char dkd_amodel[DKD_ATA_MODEL]; /* 40 bytes */
|
|
||||||
char dkd_afwver[DKD_ATA_FWVER]; /* 8 bytes */
|
|
||||||
char dkd_aserial[DKD_ATA_SERIAL]; /* 20 bytes */
|
|
||||||
} ata_disk_id;
|
|
||||||
struct {
|
|
||||||
char dkd_svendor[DKD_SCSI_VENDOR]; /* 8 bytes */
|
|
||||||
char dkd_sproduct[DKD_SCSI_PRODUCT]; /* 16 bytes */
|
|
||||||
char dkd_sfwver[DKD_SCSI_REVLEVEL]; /* 4 bytes */
|
|
||||||
char dkd_sserial[DKD_SCSI_SERIAL]; /* 12 bytes */
|
|
||||||
} scsi_disk_id;
|
|
||||||
} disk_id;
|
|
||||||
} dk_disk_id_t;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The ioctl is used to update the firmware of device.
|
|
||||||
*/
|
|
||||||
#define DKIOC_UPDATEFW (DKIOC|47)
|
|
||||||
|
|
||||||
/* The argument type for DKIOC_UPDATEFW ioctl */
|
|
||||||
typedef struct dk_updatefw {
|
|
||||||
caddr_t dku_ptrbuf; /* pointer to firmware buf */
|
|
||||||
uint_t dku_size; /* firmware buf length */
|
|
||||||
uint8_t dku_type; /* firmware update type */
|
|
||||||
} dk_updatefw_t;
|
|
||||||
|
|
||||||
#ifdef _SYSCALL32
|
|
||||||
typedef struct dk_updatefw_32 {
|
|
||||||
caddr32_t dku_ptrbuf; /* pointer to firmware buf */
|
|
||||||
uint_t dku_size; /* firmware buf length */
|
|
||||||
uint8_t dku_type; /* firmware update type */
|
|
||||||
} dk_updatefw_32_t;
|
|
||||||
#endif /* _SYSCALL32 */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* firmware update type - temporary or permanent use
|
|
||||||
*/
|
|
||||||
#define FW_TYPE_TEMP 0x0 /* temporary use */
|
|
||||||
#define FW_TYPE_PERM 0x1 /* permanent use */
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _SYS_DKIO_H */
|
|
|
@ -1,268 +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 1990-2002 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SYS_DKLABEL_H
|
|
||||||
#define _SYS_DKLABEL_H
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <sys/isa_defs.h>
|
|
||||||
#include <sys/types32.h>
|
|
||||||
#include <sys/isa_defs.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Miscellaneous defines
|
|
||||||
*/
|
|
||||||
#define DKL_MAGIC 0xDABE /* magic number */
|
|
||||||
#define FKL_MAGIC 0xff /* magic number for DOS floppies */
|
|
||||||
|
|
||||||
#if defined(_SUNOS_VTOC_16)
|
|
||||||
#define NDKMAP 16 /* # of logical partitions */
|
|
||||||
#define DK_LABEL_LOC 1 /* location of disk label */
|
|
||||||
#elif defined(_SUNOS_VTOC_8)
|
|
||||||
#define NDKMAP 8 /* # of logical partitions */
|
|
||||||
#define DK_LABEL_LOC 0 /* location of disk label */
|
|
||||||
#else
|
|
||||||
#error "No VTOC format defined."
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define LEN_DKL_ASCII 128 /* length of dkl_asciilabel */
|
|
||||||
#define LEN_DKL_VVOL 8 /* length of v_volume */
|
|
||||||
#define DK_LABEL_SIZE 512 /* size of disk label */
|
|
||||||
#define DK_MAX_BLOCKS 0x7fffffff /* max # of blocks handled */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Reserve two cylinders on SCSI disks.
|
|
||||||
* One is for the backup disk label and the other is for the deviceid.
|
|
||||||
*
|
|
||||||
* IPI disks only reserve one cylinder, but they will go away soon.
|
|
||||||
* CDROMs do not reserve any cylinders.
|
|
||||||
*/
|
|
||||||
#define DK_ACYL 2
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Format of a Sun disk label.
|
|
||||||
* Resides in cylinder 0, head 0, sector 0.
|
|
||||||
*
|
|
||||||
* sizeof (struct dk_label) should be 512 (the current sector size),
|
|
||||||
* but should the sector size increase, this structure should remain
|
|
||||||
* at the beginning of the sector.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* partition headers: section 1
|
|
||||||
* Returned in struct dk_allmap by ioctl DKIOC[SG]APART (dkio(7I))
|
|
||||||
*/
|
|
||||||
struct dk_map {
|
|
||||||
daddr_t dkl_cylno; /* starting cylinder */
|
|
||||||
daddr_t dkl_nblk; /* number of blocks; if == 0, */
|
|
||||||
/* partition is undefined */
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* partition headers: section 1
|
|
||||||
* Fixed size for on-disk dk_label
|
|
||||||
*/
|
|
||||||
struct dk_map32 {
|
|
||||||
daddr32_t dkl_cylno; /* starting cylinder */
|
|
||||||
daddr32_t dkl_nblk; /* number of blocks; if == 0, */
|
|
||||||
/* partition is undefined */
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* partition headers: section 2,
|
|
||||||
* brought over from AT&T SVr4 vtoc structure.
|
|
||||||
*/
|
|
||||||
struct dk_map2 {
|
|
||||||
uint16_t p_tag; /* ID tag of partition */
|
|
||||||
uint16_t p_flag; /* permission flag */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct dkl_partition {
|
|
||||||
uint16_t p_tag; /* ID tag of partition */
|
|
||||||
uint16_t p_flag; /* permision flags */
|
|
||||||
daddr32_t p_start; /* start sector no of partition */
|
|
||||||
int32_t p_size; /* # of blocks in partition */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* VTOC inclusions from AT&T SVr4
|
|
||||||
* Fixed sized types for on-disk VTOC
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct dk_vtoc {
|
|
||||||
#if defined(_SUNOS_VTOC_16)
|
|
||||||
uint32_t v_bootinfo[3]; /* info for mboot (unsupported) */
|
|
||||||
uint32_t v_sanity; /* to verify vtoc sanity */
|
|
||||||
uint32_t v_version; /* layout version */
|
|
||||||
char v_volume[LEN_DKL_VVOL]; /* volume name */
|
|
||||||
uint16_t v_sectorsz; /* sector size in bytes */
|
|
||||||
uint16_t v_nparts; /* number of partitions */
|
|
||||||
uint32_t v_reserved[10]; /* free space */
|
|
||||||
struct dkl_partition v_part[NDKMAP]; /* partition headers */
|
|
||||||
time32_t timestamp[NDKMAP]; /* partition timestamp (unsupported) */
|
|
||||||
char v_asciilabel[LEN_DKL_ASCII]; /* for compatibility */
|
|
||||||
#elif defined(_SUNOS_VTOC_8)
|
|
||||||
uint32_t v_version; /* layout version */
|
|
||||||
char v_volume[LEN_DKL_VVOL]; /* volume name */
|
|
||||||
uint16_t v_nparts; /* number of partitions */
|
|
||||||
struct dk_map2 v_part[NDKMAP]; /* partition hdrs, sec 2 */
|
|
||||||
uint32_t v_bootinfo[3]; /* info needed by mboot */
|
|
||||||
uint32_t v_sanity; /* to verify vtoc sanity */
|
|
||||||
uint32_t v_reserved[10]; /* free space */
|
|
||||||
time32_t v_timestamp[NDKMAP]; /* partition timestamp */
|
|
||||||
#else
|
|
||||||
#error "No VTOC format defined."
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* define the amount of disk label padding needed to make
|
|
||||||
* the entire structure occupy 512 bytes.
|
|
||||||
*/
|
|
||||||
#if defined(_SUNOS_VTOC_16)
|
|
||||||
#define LEN_DKL_PAD (DK_LABEL_SIZE - \
|
|
||||||
((sizeof (struct dk_vtoc) + \
|
|
||||||
(4 * sizeof (uint32_t)) + \
|
|
||||||
(12 * sizeof (uint16_t)) + \
|
|
||||||
(2 * (sizeof (uint16_t))))))
|
|
||||||
#elif defined(_SUNOS_VTOC_8)
|
|
||||||
#define LEN_DKL_PAD (DK_LABEL_SIZE \
|
|
||||||
- ((LEN_DKL_ASCII) + \
|
|
||||||
(sizeof (struct dk_vtoc)) + \
|
|
||||||
(sizeof (struct dk_map32) * NDKMAP) + \
|
|
||||||
(14 * (sizeof (uint16_t))) + \
|
|
||||||
(2 * (sizeof (uint16_t)))))
|
|
||||||
#else
|
|
||||||
#error "No VTOC format defined."
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
struct dk_label {
|
|
||||||
#if defined(_SUNOS_VTOC_16)
|
|
||||||
struct dk_vtoc dkl_vtoc; /* vtoc inclusions from AT&T SVr4 */
|
|
||||||
uint32_t dkl_pcyl; /* # of physical cylinders */
|
|
||||||
uint32_t dkl_ncyl; /* # of data cylinders */
|
|
||||||
uint16_t dkl_acyl; /* # of alternate cylinders */
|
|
||||||
uint16_t dkl_bcyl; /* cyl offset (for fixed head area) */
|
|
||||||
uint32_t dkl_nhead; /* # of heads */
|
|
||||||
uint32_t dkl_nsect; /* # of data sectors per track */
|
|
||||||
uint16_t dkl_intrlv; /* interleave factor */
|
|
||||||
uint16_t dkl_skew; /* skew factor */
|
|
||||||
uint16_t dkl_apc; /* alternates per cyl (SCSI only) */
|
|
||||||
uint16_t dkl_rpm; /* revolutions per minute */
|
|
||||||
uint16_t dkl_write_reinstruct; /* # sectors to skip, writes */
|
|
||||||
uint16_t dkl_read_reinstruct; /* # sectors to skip, reads */
|
|
||||||
uint16_t dkl_extra[4]; /* for compatible expansion */
|
|
||||||
char dkl_pad[LEN_DKL_PAD]; /* unused part of 512 bytes */
|
|
||||||
#elif defined(_SUNOS_VTOC_8)
|
|
||||||
char dkl_asciilabel[LEN_DKL_ASCII]; /* for compatibility */
|
|
||||||
struct dk_vtoc dkl_vtoc; /* vtoc inclusions from AT&T SVr4 */
|
|
||||||
uint16_t dkl_write_reinstruct; /* # sectors to skip, writes */
|
|
||||||
uint16_t dkl_read_reinstruct; /* # sectors to skip, reads */
|
|
||||||
char dkl_pad[LEN_DKL_PAD]; /* unused part of 512 bytes */
|
|
||||||
uint16_t dkl_rpm; /* rotations per minute */
|
|
||||||
uint16_t dkl_pcyl; /* # physical cylinders */
|
|
||||||
uint16_t dkl_apc; /* alternates per cylinder */
|
|
||||||
uint16_t dkl_obs1; /* obsolete */
|
|
||||||
uint16_t dkl_obs2; /* obsolete */
|
|
||||||
uint16_t dkl_intrlv; /* interleave factor */
|
|
||||||
uint16_t dkl_ncyl; /* # of data cylinders */
|
|
||||||
uint16_t dkl_acyl; /* # of alternate cylinders */
|
|
||||||
uint16_t dkl_nhead; /* # of heads in this partition */
|
|
||||||
uint16_t dkl_nsect; /* # of 512 byte sectors per track */
|
|
||||||
uint16_t dkl_obs3; /* obsolete */
|
|
||||||
uint16_t dkl_obs4; /* obsolete */
|
|
||||||
struct dk_map32 dkl_map[NDKMAP]; /* logical partition headers */
|
|
||||||
#else
|
|
||||||
#error "No VTOC format defined."
|
|
||||||
#endif
|
|
||||||
uint16_t dkl_magic; /* identifies this label format */
|
|
||||||
uint16_t dkl_cksum; /* xor checksum of sector */
|
|
||||||
};
|
|
||||||
|
|
||||||
#if defined(_SUNOS_VTOC_16)
|
|
||||||
#define dkl_asciilabel dkl_vtoc.v_asciilabel
|
|
||||||
#define v_timestamp timestamp
|
|
||||||
|
|
||||||
#elif defined(_SUNOS_VTOC_8)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* These defines are for historic compatibility with old drivers.
|
|
||||||
*/
|
|
||||||
#define dkl_gap1 dkl_obs1 /* used to be gap1 */
|
|
||||||
#define dkl_gap2 dkl_obs2 /* used to be gap2 */
|
|
||||||
#define dkl_bhead dkl_obs3 /* used to be label head offset */
|
|
||||||
#define dkl_ppart dkl_obs4 /* used to by physical partition */
|
|
||||||
#else
|
|
||||||
#error "No VTOC format defined."
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct fk_label { /* DOS floppy label */
|
|
||||||
uchar_t fkl_type;
|
|
||||||
uchar_t fkl_magich;
|
|
||||||
uchar_t fkl_magicl;
|
|
||||||
uchar_t filler;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Layout of stored fabricated device id (on-disk)
|
|
||||||
*/
|
|
||||||
#define DK_DEVID_BLKSIZE (512)
|
|
||||||
#define DK_DEVID_SIZE (DK_DEVID_BLKSIZE - ((sizeof (uchar_t) * 7)))
|
|
||||||
#define DK_DEVID_REV_MSB (0)
|
|
||||||
#define DK_DEVID_REV_LSB (1)
|
|
||||||
|
|
||||||
struct dk_devid {
|
|
||||||
uchar_t dkd_rev_hi; /* revision (MSB) */
|
|
||||||
uchar_t dkd_rev_lo; /* revision (LSB) */
|
|
||||||
uchar_t dkd_flags; /* flags (not used yet) */
|
|
||||||
uchar_t dkd_devid[DK_DEVID_SIZE]; /* devid stored here */
|
|
||||||
uchar_t dkd_checksum3; /* checksum (MSB) */
|
|
||||||
uchar_t dkd_checksum2;
|
|
||||||
uchar_t dkd_checksum1;
|
|
||||||
uchar_t dkd_checksum0; /* checksum (LSB) */
|
|
||||||
};
|
|
||||||
|
|
||||||
#define DKD_GETCHKSUM(dkd) ((dkd)->dkd_checksum3 << 24) + \
|
|
||||||
((dkd)->dkd_checksum2 << 16) + \
|
|
||||||
((dkd)->dkd_checksum1 << 8) + \
|
|
||||||
((dkd)->dkd_checksum0)
|
|
||||||
|
|
||||||
#define DKD_FORMCHKSUM(c, dkd) (dkd)->dkd_checksum3 = hibyte(hiword((c))); \
|
|
||||||
(dkd)->dkd_checksum2 = lobyte(hiword((c))); \
|
|
||||||
(dkd)->dkd_checksum1 = hibyte(loword((c))); \
|
|
||||||
(dkd)->dkd_checksum0 = lobyte(loword((c)));
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _SYS_DKLABEL_H */
|
|
|
@ -1,32 +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 2006 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SYS_FEATURE_TESTS_H
|
|
||||||
#define _SYS_FEATURE_TESTS_H
|
|
||||||
|
|
||||||
#define __NORETURN __attribute__((__noreturn__))
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,50 +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 2006 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SOL_SYS_FILE_H
|
|
||||||
#define _SOL_SYS_FILE_H
|
|
||||||
|
|
||||||
#include_next <sys/file.h>
|
|
||||||
|
|
||||||
#include <sys/user.h>
|
|
||||||
|
|
||||||
#define FREAD 1
|
|
||||||
#define FWRITE 2
|
|
||||||
//#define FAPPEND 8
|
|
||||||
|
|
||||||
#define FCREAT O_CREAT
|
|
||||||
#define FTRUNC O_TRUNC
|
|
||||||
#define FOFFMAX O_LARGEFILE
|
|
||||||
#define FSYNC O_SYNC
|
|
||||||
#define FDSYNC O_DSYNC
|
|
||||||
#define FRSYNC O_RSYNC
|
|
||||||
#define FEXCL O_EXCL
|
|
||||||
|
|
||||||
#define FNODSYNC 0x10000 /* fsync pseudo flag */
|
|
||||||
#define FNOFOLLOW 0x20000 /* don't follow symlinks */
|
|
||||||
#define FIGNORECASE 0x80000 /* request case-insensitive lookups */
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,87 +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_IDMAP_H
|
|
||||||
#define _SYS_IDMAP_H
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Idmap status codes */
|
|
||||||
#define IDMAP_SUCCESS 0
|
|
||||||
#define IDMAP_NEXT 1
|
|
||||||
#define IDMAP_ERR_OTHER -10000
|
|
||||||
#define IDMAP_ERR_INTERNAL -9999
|
|
||||||
#define IDMAP_ERR_MEMORY -9998
|
|
||||||
#define IDMAP_ERR_NORESULT -9997
|
|
||||||
#define IDMAP_ERR_NOTUSER -9996
|
|
||||||
#define IDMAP_ERR_NOTGROUP -9995
|
|
||||||
#define IDMAP_ERR_NOTSUPPORTED -9994
|
|
||||||
#define IDMAP_ERR_W2U_NAMERULE -9993
|
|
||||||
#define IDMAP_ERR_U2W_NAMERULE -9992
|
|
||||||
#define IDMAP_ERR_CACHE -9991
|
|
||||||
#define IDMAP_ERR_DB -9990
|
|
||||||
#define IDMAP_ERR_ARG -9989
|
|
||||||
#define IDMAP_ERR_SID -9988
|
|
||||||
#define IDMAP_ERR_IDTYPE -9987
|
|
||||||
#define IDMAP_ERR_RPC_HANDLE -9986
|
|
||||||
#define IDMAP_ERR_RPC -9985
|
|
||||||
#define IDMAP_ERR_CLIENT_HANDLE -9984
|
|
||||||
#define IDMAP_ERR_BUSY -9983
|
|
||||||
#define IDMAP_ERR_PERMISSION_DENIED -9982
|
|
||||||
#define IDMAP_ERR_NOMAPPING -9981
|
|
||||||
#define IDMAP_ERR_NEW_ID_ALLOC_REQD -9980
|
|
||||||
#define IDMAP_ERR_DOMAIN -9979
|
|
||||||
#define IDMAP_ERR_SECURITY -9978
|
|
||||||
#define IDMAP_ERR_NOTFOUND -9977
|
|
||||||
#define IDMAP_ERR_DOMAIN_NOTFOUND -9976
|
|
||||||
#define IDMAP_ERR_UPDATE_NOTALLOWED -9975
|
|
||||||
#define IDMAP_ERR_CFG -9974
|
|
||||||
#define IDMAP_ERR_CFG_CHANGE -9973
|
|
||||||
#define IDMAP_ERR_NOTMAPPED_WELLKNOWN -9972
|
|
||||||
#define IDMAP_ERR_RETRIABLE_NET_ERR -9971
|
|
||||||
#define IDMAP_ERR_W2U_NAMERULE_CONFLICT -9970
|
|
||||||
#define IDMAP_ERR_U2W_NAMERULE_CONFLICT -9969
|
|
||||||
#define IDMAP_ERR_BAD_UTF8 -9968
|
|
||||||
|
|
||||||
/* Reserved GIDs for some well-known SIDs */
|
|
||||||
#define IDMAP_WK_LOCAL_SYSTEM_GID 2147483648U
|
|
||||||
#define IDMAP_WK_CREATOR_GROUP_GID 2147483649U
|
|
||||||
#define IDMAP_WK__MAX_GID 2147483649U
|
|
||||||
|
|
||||||
/* Reserved UIDs for some well-known SIDs */
|
|
||||||
#define IDMAP_WK_CREATOR_OWNER_UID 2147483648U
|
|
||||||
#define IDMAP_WK__MAX_UID 2147483648U
|
|
||||||
|
|
||||||
/* Reserved SIDs */
|
|
||||||
#define IDMAP_WK_CREATOR_SID_AUTHORITY "S-1-3"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Max door RPC size for ID mapping (can't be too large relative to the
|
|
||||||
* default user-land thread stack size, since clnt_door_call()
|
|
||||||
* alloca()s). See libidmap:idmap_init().
|
|
||||||
*/
|
|
||||||
#define IDMAP_MAX_DOOR_RPC (256 * 1024)
|
|
||||||
|
|
||||||
#endif /* _SYS_IDMAP_H */
|
|
|
@ -1 +0,0 @@
|
||||||
#include <inttypes.h>
|
|
|
@ -1,34 +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 2006 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SOL_SYS_INTTYPES_H
|
|
||||||
#define _SOL_SYS_INTTYPES_H
|
|
||||||
|
|
||||||
#include <inttypes.h>
|
|
||||||
|
|
||||||
#define _INT64_TYPE
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,482 +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 2007 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SYS_ISA_DEFS_H
|
|
||||||
#define _SYS_ISA_DEFS_H
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This header file serves to group a set of well known defines and to
|
|
||||||
* set these for each instruction set architecture. These defines may
|
|
||||||
* be divided into two groups; characteristics of the processor and
|
|
||||||
* implementation choices for Solaris on a processor.
|
|
||||||
*
|
|
||||||
* Processor Characteristics:
|
|
||||||
*
|
|
||||||
* _LITTLE_ENDIAN / _BIG_ENDIAN:
|
|
||||||
* The natural byte order of the processor. A pointer to an int points
|
|
||||||
* to the least/most significant byte of that int.
|
|
||||||
*
|
|
||||||
* _STACK_GROWS_UPWARD / _STACK_GROWS_DOWNWARD:
|
|
||||||
* The processor specific direction of stack growth. A push onto the
|
|
||||||
* stack increases/decreases the stack pointer, so it stores data at
|
|
||||||
* successively higher/lower addresses. (Stackless machines ignored
|
|
||||||
* without regrets).
|
|
||||||
*
|
|
||||||
* _LONG_LONG_HTOL / _LONG_LONG_LTOH:
|
|
||||||
* A pointer to a long long points to the most/least significant long
|
|
||||||
* within that long long.
|
|
||||||
*
|
|
||||||
* _BIT_FIELDS_HTOL / _BIT_FIELDS_LTOH:
|
|
||||||
* The C compiler assigns bit fields from the high/low to the low/high end
|
|
||||||
* of an int (most to least significant vs. least to most significant).
|
|
||||||
*
|
|
||||||
* _IEEE_754:
|
|
||||||
* The processor (or supported implementations of the processor)
|
|
||||||
* supports the ieee-754 floating point standard. No other floating
|
|
||||||
* point standards are supported (or significant). Any other supported
|
|
||||||
* floating point formats are expected to be cased on the ISA processor
|
|
||||||
* symbol.
|
|
||||||
*
|
|
||||||
* _CHAR_IS_UNSIGNED / _CHAR_IS_SIGNED:
|
|
||||||
* The C Compiler implements objects of type `char' as `unsigned' or
|
|
||||||
* `signed' respectively. This is really an implementation choice of
|
|
||||||
* the compiler writer, but it is specified in the ABI and tends to
|
|
||||||
* be uniform across compilers for an instruction set architecture.
|
|
||||||
* Hence, it has the properties of a processor characteristic.
|
|
||||||
*
|
|
||||||
* _CHAR_ALIGNMENT / _SHORT_ALIGNMENT / _INT_ALIGNMENT / _LONG_ALIGNMENT /
|
|
||||||
* _LONG_LONG_ALIGNMENT / _DOUBLE_ALIGNMENT / _LONG_DOUBLE_ALIGNMENT /
|
|
||||||
* _POINTER_ALIGNMENT / _FLOAT_ALIGNMENT:
|
|
||||||
* The ABI defines alignment requirements of each of the primitive
|
|
||||||
* object types. Some, if not all, may be hardware requirements as
|
|
||||||
* well. The values are expressed in "byte-alignment" units.
|
|
||||||
*
|
|
||||||
* _MAX_ALIGNMENT:
|
|
||||||
* The most stringent alignment requirement as specified by the ABI.
|
|
||||||
* Equal to the maximum of all the above _XXX_ALIGNMENT values.
|
|
||||||
*
|
|
||||||
* _ALIGNMENT_REQUIRED:
|
|
||||||
* True or false (1 or 0) whether or not the hardware requires the ABI
|
|
||||||
* alignment.
|
|
||||||
*
|
|
||||||
* _LONG_LONG_ALIGNMENT_32
|
|
||||||
* The 32-bit ABI supported by a 64-bit kernel may have different
|
|
||||||
* alignment requirements for primitive object types. The value of this
|
|
||||||
* identifier is expressed in "byte-alignment" units.
|
|
||||||
*
|
|
||||||
* _HAVE_CPUID_INSN
|
|
||||||
* This indicates that the architecture supports the 'cpuid'
|
|
||||||
* instruction as defined by Intel. (Intel allows other vendors
|
|
||||||
* to extend the instruction for their own purposes.)
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Implementation Choices:
|
|
||||||
*
|
|
||||||
* _ILP32 / _LP64:
|
|
||||||
* This specifies the compiler data type implementation as specified in
|
|
||||||
* the relevant ABI. The choice between these is strongly influenced
|
|
||||||
* by the underlying hardware, but is not absolutely tied to it.
|
|
||||||
* Currently only two data type models are supported:
|
|
||||||
*
|
|
||||||
* _ILP32:
|
|
||||||
* Int/Long/Pointer are 32 bits. This is the historical UNIX
|
|
||||||
* and Solaris implementation. Due to its historical standing,
|
|
||||||
* this is the default case.
|
|
||||||
*
|
|
||||||
* _LP64:
|
|
||||||
* Long/Pointer are 64 bits, Int is 32 bits. This is the chosen
|
|
||||||
* implementation for 64-bit ABIs such as SPARC V9.
|
|
||||||
*
|
|
||||||
* _I32LPx:
|
|
||||||
* A compilation environment where 'int' is 32-bit, and
|
|
||||||
* longs and pointers are simply the same size.
|
|
||||||
*
|
|
||||||
* In all cases, Char is 8 bits and Short is 16 bits.
|
|
||||||
*
|
|
||||||
* _SUNOS_VTOC_8 / _SUNOS_VTOC_16 / _SVR4_VTOC_16:
|
|
||||||
* This specifies the form of the disk VTOC (or label):
|
|
||||||
*
|
|
||||||
* _SUNOS_VTOC_8:
|
|
||||||
* This is a VTOC form which is upwardly compatible with the
|
|
||||||
* SunOS 4.x disk label and allows 8 partitions per disk.
|
|
||||||
*
|
|
||||||
* _SUNOS_VTOC_16:
|
|
||||||
* In this format the incore vtoc image matches the ondisk
|
|
||||||
* version. It allows 16 slices per disk, and is not
|
|
||||||
* compatible with the SunOS 4.x disk label.
|
|
||||||
*
|
|
||||||
* Note that these are not the only two VTOC forms possible and
|
|
||||||
* additional forms may be added. One possible form would be the
|
|
||||||
* SVr4 VTOC form. The symbol for that is reserved now, although
|
|
||||||
* it is not implemented.
|
|
||||||
*
|
|
||||||
* _SVR4_VTOC_16:
|
|
||||||
* This VTOC form is compatible with the System V Release 4
|
|
||||||
* VTOC (as implemented on the SVr4 Intel and 3b ports) with
|
|
||||||
* 16 partitions per disk.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* _DMA_USES_PHYSADDR / _DMA_USES_VIRTADDR
|
|
||||||
* This describes the type of addresses used by system DMA:
|
|
||||||
*
|
|
||||||
* _DMA_USES_PHYSADDR:
|
|
||||||
* This type of DMA, used in the x86 implementation,
|
|
||||||
* requires physical addresses for DMA buffers. The 24-bit
|
|
||||||
* addresses used by some legacy boards is the source of the
|
|
||||||
* "low-memory" (<16MB) requirement for some devices using DMA.
|
|
||||||
*
|
|
||||||
* _DMA_USES_VIRTADDR:
|
|
||||||
* This method of DMA allows the use of virtual addresses for
|
|
||||||
* DMA transfers.
|
|
||||||
*
|
|
||||||
* _FIRMWARE_NEEDS_FDISK / _NO_FDISK_PRESENT
|
|
||||||
* This indicates the presence/absence of an fdisk table.
|
|
||||||
*
|
|
||||||
* _FIRMWARE_NEEDS_FDISK
|
|
||||||
* The fdisk table is required by system firmware. If present,
|
|
||||||
* it allows a disk to be subdivided into multiple fdisk
|
|
||||||
* partitions, each of which is equivalent to a separate,
|
|
||||||
* virtual disk. This enables the co-existence of multiple
|
|
||||||
* operating systems on a shared hard disk.
|
|
||||||
*
|
|
||||||
* _NO_FDISK_PRESENT
|
|
||||||
* If the fdisk table is absent, it is assumed that the entire
|
|
||||||
* media is allocated for a single operating system.
|
|
||||||
*
|
|
||||||
* _HAVE_TEM_FIRMWARE
|
|
||||||
* Defined if this architecture has the (fallback) option of
|
|
||||||
* using prom_* calls for doing I/O if a suitable kernel driver
|
|
||||||
* is not available to do it.
|
|
||||||
*
|
|
||||||
* _DONT_USE_1275_GENERIC_NAMES
|
|
||||||
* Controls whether or not device tree node names should
|
|
||||||
* comply with the IEEE 1275 "Generic Names" Recommended
|
|
||||||
* Practice. With _DONT_USE_GENERIC_NAMES, device-specific
|
|
||||||
* names identifying the particular device will be used.
|
|
||||||
*
|
|
||||||
* __i386_COMPAT
|
|
||||||
* This indicates whether the i386 ABI is supported as a *non-native*
|
|
||||||
* mode for the platform. When this symbol is defined:
|
|
||||||
* - 32-bit xstat-style system calls are enabled
|
|
||||||
* - 32-bit xmknod-style system calls are enabled
|
|
||||||
* - 32-bit system calls use i386 sizes -and- alignments
|
|
||||||
*
|
|
||||||
* Note that this is NOT defined for the i386 native environment!
|
|
||||||
*
|
|
||||||
* __x86
|
|
||||||
* This is ONLY a synonym for defined(__i386) || defined(__amd64)
|
|
||||||
* which is useful only insofar as these two architectures share
|
|
||||||
* common attributes. Analogous to __sparc.
|
|
||||||
*
|
|
||||||
* _PSM_MODULES
|
|
||||||
* This indicates whether or not the implementation uses PSM
|
|
||||||
* modules for processor support, reading /etc/mach from inside
|
|
||||||
* the kernel to extract a list.
|
|
||||||
*
|
|
||||||
* _RTC_CONFIG
|
|
||||||
* This indicates whether or not the implementation uses /etc/rtc_config
|
|
||||||
* to configure the real-time clock in the kernel.
|
|
||||||
*
|
|
||||||
* _UNIX_KRTLD
|
|
||||||
* This indicates that the implementation uses a dynamically
|
|
||||||
* linked unix + krtld to form the core kernel image at boot
|
|
||||||
* time, or (in the absence of this symbol) a prelinked kernel image.
|
|
||||||
*
|
|
||||||
* _OBP
|
|
||||||
* This indicates the firmware interface is OBP.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The following set of definitions characterize Solaris on AMD's
|
|
||||||
* 64-bit systems.
|
|
||||||
*/
|
|
||||||
#if defined(__x86_64) || defined(__amd64)
|
|
||||||
|
|
||||||
#if !defined(__amd64)
|
|
||||||
#define __amd64 /* preferred guard */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(__x86)
|
|
||||||
#define __x86
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Define the appropriate "processor characteristics"
|
|
||||||
*/
|
|
||||||
#define _LITTLE_ENDIAN
|
|
||||||
#define _STACK_GROWS_DOWNWARD
|
|
||||||
#define _LONG_LONG_LTOH
|
|
||||||
#define _BIT_FIELDS_LTOH
|
|
||||||
#define _IEEE_754
|
|
||||||
#define _CHAR_IS_SIGNED
|
|
||||||
#define _BOOL_ALIGNMENT 1
|
|
||||||
#define _CHAR_ALIGNMENT 1
|
|
||||||
#define _SHORT_ALIGNMENT 2
|
|
||||||
#define _INT_ALIGNMENT 4
|
|
||||||
#define _FLOAT_ALIGNMENT 4
|
|
||||||
#define _FLOAT_COMPLEX_ALIGNMENT 4
|
|
||||||
#define _LONG_ALIGNMENT 8
|
|
||||||
#define _LONG_LONG_ALIGNMENT 8
|
|
||||||
#define _DOUBLE_ALIGNMENT 8
|
|
||||||
#define _DOUBLE_COMPLEX_ALIGNMENT 8
|
|
||||||
#define _LONG_DOUBLE_ALIGNMENT 16
|
|
||||||
#define _LONG_DOUBLE_COMPLEX_ALIGNMENT 16
|
|
||||||
#define _POINTER_ALIGNMENT 8
|
|
||||||
#define _MAX_ALIGNMENT 16
|
|
||||||
#define _ALIGNMENT_REQUIRED 1
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Different alignment constraints for the i386 ABI in compatibility mode
|
|
||||||
*/
|
|
||||||
#define _LONG_LONG_ALIGNMENT_32 4
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Define the appropriate "implementation choices".
|
|
||||||
*/
|
|
||||||
#if !defined(_LP64)
|
|
||||||
#define _LP64
|
|
||||||
#endif
|
|
||||||
#if !defined(_I32LPx) && defined(_KERNEL)
|
|
||||||
#define _I32LPx
|
|
||||||
#endif
|
|
||||||
#define _MULTI_DATAMODEL
|
|
||||||
#define _SUNOS_VTOC_16
|
|
||||||
#define _DMA_USES_PHYSADDR
|
|
||||||
#define _FIRMWARE_NEEDS_FDISK
|
|
||||||
#define __i386_COMPAT
|
|
||||||
#define _PSM_MODULES
|
|
||||||
#define _RTC_CONFIG
|
|
||||||
#define _DONT_USE_1275_GENERIC_NAMES
|
|
||||||
#define _HAVE_CPUID_INSN
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The feature test macro __i386 is generic for all processors implementing
|
|
||||||
* the Intel 386 instruction set or a superset of it. Specifically, this
|
|
||||||
* includes all members of the 386, 486, and Pentium family of processors.
|
|
||||||
*/
|
|
||||||
#elif defined(__i386) || defined(__i386__)
|
|
||||||
|
|
||||||
#if !defined(__i386)
|
|
||||||
#define __i386
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(__x86)
|
|
||||||
#define __x86
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Define the appropriate "processor characteristics"
|
|
||||||
*/
|
|
||||||
#define _LITTLE_ENDIAN
|
|
||||||
#define _STACK_GROWS_DOWNWARD
|
|
||||||
#define _LONG_LONG_LTOH
|
|
||||||
#define _BIT_FIELDS_LTOH
|
|
||||||
#define _IEEE_754
|
|
||||||
#define _CHAR_IS_SIGNED
|
|
||||||
#define _BOOL_ALIGNMENT 1
|
|
||||||
#define _CHAR_ALIGNMENT 1
|
|
||||||
#define _SHORT_ALIGNMENT 2
|
|
||||||
#define _INT_ALIGNMENT 4
|
|
||||||
#define _FLOAT_ALIGNMENT 4
|
|
||||||
#define _FLOAT_COMPLEX_ALIGNMENT 4
|
|
||||||
#define _LONG_ALIGNMENT 4
|
|
||||||
#define _LONG_LONG_ALIGNMENT 4
|
|
||||||
#define _DOUBLE_ALIGNMENT 4
|
|
||||||
#define _DOUBLE_COMPLEX_ALIGNMENT 4
|
|
||||||
#define _LONG_DOUBLE_ALIGNMENT 4
|
|
||||||
#define _LONG_DOUBLE_COMPLEX_ALIGNMENT 4
|
|
||||||
#define _POINTER_ALIGNMENT 4
|
|
||||||
#define _MAX_ALIGNMENT 4
|
|
||||||
#define _ALIGNMENT_REQUIRED 0
|
|
||||||
|
|
||||||
#define _LONG_LONG_ALIGNMENT_32 _LONG_LONG_ALIGNMENT
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Define the appropriate "implementation choices".
|
|
||||||
*/
|
|
||||||
#define _ILP32
|
|
||||||
#if !defined(_I32LPx) && defined(_KERNEL)
|
|
||||||
#define _I32LPx
|
|
||||||
#endif
|
|
||||||
#define _SUNOS_VTOC_16
|
|
||||||
#define _DMA_USES_PHYSADDR
|
|
||||||
#define _FIRMWARE_NEEDS_FDISK
|
|
||||||
#define _PSM_MODULES
|
|
||||||
#define _RTC_CONFIG
|
|
||||||
#define _DONT_USE_1275_GENERIC_NAMES
|
|
||||||
#define _HAVE_CPUID_INSN
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The following set of definitions characterize the Solaris on SPARC systems.
|
|
||||||
*
|
|
||||||
* The symbol __sparc indicates any of the SPARC family of processor
|
|
||||||
* architectures. This includes SPARC V7, SPARC V8 and SPARC V9.
|
|
||||||
*
|
|
||||||
* The symbol __sparcv8 indicates the 32-bit SPARC V8 architecture as defined
|
|
||||||
* by Version 8 of the SPARC Architecture Manual. (SPARC V7 is close enough
|
|
||||||
* to SPARC V8 for the former to be subsumed into the latter definition.)
|
|
||||||
*
|
|
||||||
* The symbol __sparcv9 indicates the 64-bit SPARC V9 architecture as defined
|
|
||||||
* by Version 9 of the SPARC Architecture Manual.
|
|
||||||
*
|
|
||||||
* The symbols __sparcv8 and __sparcv9 are mutually exclusive, and are only
|
|
||||||
* relevant when the symbol __sparc is defined.
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* XXX Due to the existence of 5110166, "defined(__sparcv9)" needs to be added
|
|
||||||
* to support backwards builds. This workaround should be removed in s10_71.
|
|
||||||
*/
|
|
||||||
#elif defined(__sparc) || defined(__sparcv9) || defined(__sparc__)
|
|
||||||
#if !defined(__sparc)
|
|
||||||
#define __sparc
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* You can be 32-bit or 64-bit, but not both at the same time.
|
|
||||||
*/
|
|
||||||
#if defined(__sparcv8) && defined(__sparcv9)
|
|
||||||
#error "SPARC Versions 8 and 9 are mutually exclusive choices"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Existing compilers do not set __sparcv8. Years will transpire before
|
|
||||||
* the compilers can be depended on to set the feature test macro. In
|
|
||||||
* the interim, we'll set it here on the basis of historical behaviour;
|
|
||||||
* if you haven't asked for SPARC V9, then you must've meant SPARC V8.
|
|
||||||
*/
|
|
||||||
#if !defined(__sparcv9) && !defined(__sparcv8)
|
|
||||||
#define __sparcv8
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Define the appropriate "processor characteristics" shared between
|
|
||||||
* all Solaris on SPARC systems.
|
|
||||||
*/
|
|
||||||
#define _BIG_ENDIAN
|
|
||||||
#define _STACK_GROWS_DOWNWARD
|
|
||||||
#define _LONG_LONG_HTOL
|
|
||||||
#define _BIT_FIELDS_HTOL
|
|
||||||
#define _IEEE_754
|
|
||||||
#define _CHAR_IS_SIGNED
|
|
||||||
#define _BOOL_ALIGNMENT 1
|
|
||||||
#define _CHAR_ALIGNMENT 1
|
|
||||||
#define _SHORT_ALIGNMENT 2
|
|
||||||
#define _INT_ALIGNMENT 4
|
|
||||||
#define _FLOAT_ALIGNMENT 4
|
|
||||||
#define _FLOAT_COMPLEX_ALIGNMENT 4
|
|
||||||
#define _LONG_LONG_ALIGNMENT 8
|
|
||||||
#define _DOUBLE_ALIGNMENT 8
|
|
||||||
#define _DOUBLE_COMPLEX_ALIGNMENT 8
|
|
||||||
#define _ALIGNMENT_REQUIRED 1
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Define the appropriate "implementation choices" shared between versions.
|
|
||||||
*/
|
|
||||||
#define _SUNOS_VTOC_8
|
|
||||||
#define _DMA_USES_VIRTADDR
|
|
||||||
#define _NO_FDISK_PRESENT
|
|
||||||
#define _HAVE_TEM_FIRMWARE
|
|
||||||
#define _OBP
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The following set of definitions characterize the implementation of
|
|
||||||
* 32-bit Solaris on SPARC V8 systems.
|
|
||||||
*/
|
|
||||||
#if defined(__sparcv8)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Define the appropriate "processor characteristics"
|
|
||||||
*/
|
|
||||||
#define _LONG_ALIGNMENT 4
|
|
||||||
#define _LONG_DOUBLE_ALIGNMENT 8
|
|
||||||
#define _LONG_DOUBLE_COMPLEX_ALIGNMENT 8
|
|
||||||
#define _POINTER_ALIGNMENT 4
|
|
||||||
#define _MAX_ALIGNMENT 8
|
|
||||||
|
|
||||||
#define _LONG_LONG_ALIGNMENT_32 _LONG_LONG_ALIGNMENT
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Define the appropriate "implementation choices"
|
|
||||||
*/
|
|
||||||
#define _ILP32
|
|
||||||
#if !defined(_I32LPx) && defined(_KERNEL)
|
|
||||||
#define _I32LPx
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The following set of definitions characterize the implementation of
|
|
||||||
* 64-bit Solaris on SPARC V9 systems.
|
|
||||||
*/
|
|
||||||
#elif defined(__sparcv9)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Define the appropriate "processor characteristics"
|
|
||||||
*/
|
|
||||||
#define _LONG_ALIGNMENT 8
|
|
||||||
#define _LONG_DOUBLE_ALIGNMENT 16
|
|
||||||
#define _LONG_DOUBLE_COMPLEX_ALIGNMENT 16
|
|
||||||
#define _POINTER_ALIGNMENT 8
|
|
||||||
#define _MAX_ALIGNMENT 16
|
|
||||||
|
|
||||||
#define _LONG_LONG_ALIGNMENT_32 _LONG_LONG_ALIGMENT
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Define the appropriate "implementation choices"
|
|
||||||
*/
|
|
||||||
#if !defined(_LP64)
|
|
||||||
#define _LP64
|
|
||||||
#endif
|
|
||||||
#if !defined(_I32LPx)
|
|
||||||
#define _I32LPx
|
|
||||||
#endif
|
|
||||||
#define _MULTI_DATAMODEL
|
|
||||||
|
|
||||||
#else
|
|
||||||
#error "unknown SPARC version"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* #error is strictly ansi-C, but works as well as anything for K&R systems.
|
|
||||||
*/
|
|
||||||
#else
|
|
||||||
#error "ISA not supported"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(_ILP32) && defined(_LP64)
|
|
||||||
#error "Both _ILP32 and _LP64 are defined"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _SYS_ISA_DEFS_H */
|
|
|
@ -1,820 +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 2006 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SYS_KSTAT_H
|
|
||||||
#define _SYS_KSTAT_H
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Definition of general kernel statistics structures and /dev/kstat ioctls
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef int kid_t; /* unique kstat id */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Kernel statistics driver (/dev/kstat) ioctls
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define KSTAT_IOC_BASE ('K' << 8)
|
|
||||||
|
|
||||||
#define KSTAT_IOC_CHAIN_ID KSTAT_IOC_BASE | 0x01
|
|
||||||
#define KSTAT_IOC_READ KSTAT_IOC_BASE | 0x02
|
|
||||||
#define KSTAT_IOC_WRITE KSTAT_IOC_BASE | 0x03
|
|
||||||
|
|
||||||
/*
|
|
||||||
* /dev/kstat ioctl usage (kd denotes /dev/kstat descriptor):
|
|
||||||
*
|
|
||||||
* kcid = ioctl(kd, KSTAT_IOC_CHAIN_ID, NULL);
|
|
||||||
* kcid = ioctl(kd, KSTAT_IOC_READ, kstat_t *);
|
|
||||||
* kcid = ioctl(kd, KSTAT_IOC_WRITE, kstat_t *);
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define KSTAT_STRLEN 31 /* 30 chars + NULL; must be 16 * n - 1 */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The generic kstat header
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct kstat {
|
|
||||||
/*
|
|
||||||
* Fields relevant to both kernel and user
|
|
||||||
*/
|
|
||||||
hrtime_t ks_crtime; /* creation time (from gethrtime()) */
|
|
||||||
struct kstat *ks_next; /* kstat chain linkage */
|
|
||||||
kid_t ks_kid; /* unique kstat ID */
|
|
||||||
char ks_module[KSTAT_STRLEN]; /* provider module name */
|
|
||||||
uchar_t ks_resv; /* reserved, currently just padding */
|
|
||||||
int ks_instance; /* provider module's instance */
|
|
||||||
char ks_name[KSTAT_STRLEN]; /* kstat name */
|
|
||||||
uchar_t ks_type; /* kstat data type */
|
|
||||||
char ks_class[KSTAT_STRLEN]; /* kstat class */
|
|
||||||
uchar_t ks_flags; /* kstat flags */
|
|
||||||
void *ks_data; /* kstat type-specific data */
|
|
||||||
uint_t ks_ndata; /* # of type-specific data records */
|
|
||||||
size_t ks_data_size; /* total size of kstat data section */
|
|
||||||
hrtime_t ks_snaptime; /* time of last data shapshot */
|
|
||||||
/*
|
|
||||||
* Fields relevant to kernel only
|
|
||||||
*/
|
|
||||||
int (*ks_update)(struct kstat *, int); /* dynamic update */
|
|
||||||
void *ks_private; /* arbitrary provider-private data */
|
|
||||||
int (*ks_snapshot)(struct kstat *, void *, int);
|
|
||||||
void *ks_lock; /* protects this kstat's data */
|
|
||||||
} kstat_t;
|
|
||||||
|
|
||||||
#ifdef _SYSCALL32
|
|
||||||
|
|
||||||
typedef int32_t kid32_t;
|
|
||||||
|
|
||||||
typedef struct kstat32 {
|
|
||||||
/*
|
|
||||||
* Fields relevant to both kernel and user
|
|
||||||
*/
|
|
||||||
hrtime_t ks_crtime;
|
|
||||||
caddr32_t ks_next; /* struct kstat pointer */
|
|
||||||
kid32_t ks_kid;
|
|
||||||
char ks_module[KSTAT_STRLEN];
|
|
||||||
uint8_t ks_resv;
|
|
||||||
int32_t ks_instance;
|
|
||||||
char ks_name[KSTAT_STRLEN];
|
|
||||||
uint8_t ks_type;
|
|
||||||
char ks_class[KSTAT_STRLEN];
|
|
||||||
uint8_t ks_flags;
|
|
||||||
caddr32_t ks_data; /* type-specific data */
|
|
||||||
uint32_t ks_ndata;
|
|
||||||
size32_t ks_data_size;
|
|
||||||
hrtime_t ks_snaptime;
|
|
||||||
/*
|
|
||||||
* Fields relevant to kernel only (only needed here for padding)
|
|
||||||
*/
|
|
||||||
int32_t _ks_update;
|
|
||||||
caddr32_t _ks_private;
|
|
||||||
int32_t _ks_snapshot;
|
|
||||||
caddr32_t _ks_lock;
|
|
||||||
} kstat32_t;
|
|
||||||
|
|
||||||
#endif /* _SYSCALL32 */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* kstat structure and locking strategy
|
|
||||||
*
|
|
||||||
* Each kstat consists of a header section (a kstat_t) and a data section.
|
|
||||||
* The system maintains a set of kstats, protected by kstat_chain_lock.
|
|
||||||
* kstat_chain_lock protects all additions to/deletions from this set,
|
|
||||||
* as well as all changes to kstat headers. kstat data sections are
|
|
||||||
* *optionally* protected by the per-kstat ks_lock. If ks_lock is non-NULL,
|
|
||||||
* kstat clients (e.g. /dev/kstat) will acquire this lock for all of their
|
|
||||||
* operations on that kstat. It is up to the kstat provider to decide whether
|
|
||||||
* guaranteeing consistent data to kstat clients is sufficiently important
|
|
||||||
* to justify the locking cost. Note, however, that most statistic updates
|
|
||||||
* already occur under one of the provider's mutexes, so if the provider sets
|
|
||||||
* ks_lock to point to that mutex, then kstat data locking is free.
|
|
||||||
*
|
|
||||||
* NOTE: variable-size kstats MUST employ kstat data locking, to prevent
|
|
||||||
* data-size races with kstat clients.
|
|
||||||
*
|
|
||||||
* NOTE: ks_lock is really of type (kmutex_t *); it is declared as (void *)
|
|
||||||
* in the kstat header so that users don't have to be exposed to all of the
|
|
||||||
* kernel's lock-related data structures.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(_KERNEL)
|
|
||||||
|
|
||||||
#define KSTAT_ENTER(k) \
|
|
||||||
{ kmutex_t *lp = (k)->ks_lock; if (lp) mutex_enter(lp); }
|
|
||||||
|
|
||||||
#define KSTAT_EXIT(k) \
|
|
||||||
{ kmutex_t *lp = (k)->ks_lock; if (lp) mutex_exit(lp); }
|
|
||||||
|
|
||||||
#define KSTAT_UPDATE(k, rw) (*(k)->ks_update)((k), (rw))
|
|
||||||
|
|
||||||
#define KSTAT_SNAPSHOT(k, buf, rw) (*(k)->ks_snapshot)((k), (buf), (rw))
|
|
||||||
|
|
||||||
#endif /* defined(_KERNEL) */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* kstat time
|
|
||||||
*
|
|
||||||
* All times associated with kstats (e.g. creation time, snapshot time,
|
|
||||||
* kstat_timer_t and kstat_io_t timestamps, etc.) are 64-bit nanosecond values,
|
|
||||||
* as returned by gethrtime(). The accuracy of these timestamps is machine
|
|
||||||
* dependent, but the precision (units) is the same across all platforms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* kstat identity (KID)
|
|
||||||
*
|
|
||||||
* Each kstat is assigned a unique KID (kstat ID) when it is added to the
|
|
||||||
* global kstat chain. The KID is used as a cookie by /dev/kstat to
|
|
||||||
* request information about the corresponding kstat. There is also
|
|
||||||
* an identity associated with the entire kstat chain, kstat_chain_id,
|
|
||||||
* which is bumped each time a kstat is added or deleted. /dev/kstat uses
|
|
||||||
* the chain ID to detect changes in the kstat chain (e.g., a new disk
|
|
||||||
* coming online) between ioctl()s.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* kstat module, kstat instance
|
|
||||||
*
|
|
||||||
* ks_module and ks_instance contain the name and instance of the module
|
|
||||||
* that created the kstat. In cases where there can only be one instance,
|
|
||||||
* ks_instance is 0. The kernel proper (/kernel/unix) uses "unix" as its
|
|
||||||
* module name.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* kstat name
|
|
||||||
*
|
|
||||||
* ks_name gives a meaningful name to a kstat. The full kstat namespace
|
|
||||||
* is module.instance.name, so the name only need be unique within a
|
|
||||||
* module. kstat_create() will fail if you try to create a kstat with
|
|
||||||
* an already-used (ks_module, ks_instance, ks_name) triplet. Spaces are
|
|
||||||
* allowed in kstat names, but strongly discouraged, since they hinder
|
|
||||||
* awk-style processing at user level.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* kstat type
|
|
||||||
*
|
|
||||||
* The kstat mechanism provides several flavors of kstat data, defined
|
|
||||||
* below. The "raw" kstat type is just treated as an array of bytes; you
|
|
||||||
* can use this to export any kind of data you want.
|
|
||||||
*
|
|
||||||
* Some kstat types allow multiple data structures per kstat, e.g.
|
|
||||||
* KSTAT_TYPE_NAMED; others do not. This is part of the spec for each
|
|
||||||
* kstat data type.
|
|
||||||
*
|
|
||||||
* User-level tools should *not* rely on the #define KSTAT_NUM_TYPES. To
|
|
||||||
* get this information, read out the standard system kstat "kstat_types".
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define KSTAT_TYPE_RAW 0 /* can be anything */
|
|
||||||
/* ks_ndata >= 1 */
|
|
||||||
#define KSTAT_TYPE_NAMED 1 /* name/value pair */
|
|
||||||
/* ks_ndata >= 1 */
|
|
||||||
#define KSTAT_TYPE_INTR 2 /* interrupt statistics */
|
|
||||||
/* ks_ndata == 1 */
|
|
||||||
#define KSTAT_TYPE_IO 3 /* I/O statistics */
|
|
||||||
/* ks_ndata == 1 */
|
|
||||||
#define KSTAT_TYPE_TIMER 4 /* event timer */
|
|
||||||
/* ks_ndata >= 1 */
|
|
||||||
|
|
||||||
#define KSTAT_NUM_TYPES 5
|
|
||||||
|
|
||||||
/*
|
|
||||||
* kstat class
|
|
||||||
*
|
|
||||||
* Each kstat can be characterized as belonging to some broad class
|
|
||||||
* of statistics, e.g. disk, tape, net, vm, streams, etc. This field
|
|
||||||
* can be used as a filter to extract related kstats. The following
|
|
||||||
* values are currently in use: disk, tape, net, controller, vm, kvm,
|
|
||||||
* hat, streams, kstat, and misc. (The kstat class encompasses things
|
|
||||||
* like kstat_types.)
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* kstat flags
|
|
||||||
*
|
|
||||||
* Any of the following flags may be passed to kstat_create(). They are
|
|
||||||
* all zero by default.
|
|
||||||
*
|
|
||||||
* KSTAT_FLAG_VIRTUAL:
|
|
||||||
*
|
|
||||||
* Tells kstat_create() not to allocate memory for the
|
|
||||||
* kstat data section; instead, you will set the ks_data
|
|
||||||
* field to point to the data you wish to export. This
|
|
||||||
* provides a convenient way to export existing data
|
|
||||||
* structures.
|
|
||||||
*
|
|
||||||
* KSTAT_FLAG_VAR_SIZE:
|
|
||||||
*
|
|
||||||
* The size of the kstat you are creating will vary over time.
|
|
||||||
* For example, you may want to use the kstat mechanism to
|
|
||||||
* export a linked list. NOTE: The kstat framework does not
|
|
||||||
* manage the data section, so all variable-size kstats must be
|
|
||||||
* virtual kstats. Moreover, variable-size kstats MUST employ
|
|
||||||
* kstat data locking to prevent data-size races with kstat
|
|
||||||
* clients. See the section on "kstat snapshot" for details.
|
|
||||||
*
|
|
||||||
* KSTAT_FLAG_WRITABLE:
|
|
||||||
*
|
|
||||||
* Makes the kstat's data section writable by root.
|
|
||||||
* The ks_snapshot routine (see below) does not need to check for
|
|
||||||
* this; permission checking is handled in the kstat driver.
|
|
||||||
*
|
|
||||||
* KSTAT_FLAG_PERSISTENT:
|
|
||||||
*
|
|
||||||
* Indicates that this kstat is to be persistent over time.
|
|
||||||
* For persistent kstats, kstat_delete() simply marks the
|
|
||||||
* kstat as dormant; a subsequent kstat_create() reactivates
|
|
||||||
* the kstat. This feature is provided so that statistics
|
|
||||||
* are not lost across driver close/open (e.g., raw disk I/O
|
|
||||||
* on a disk with no mounted partitions.)
|
|
||||||
* NOTE: Persistent kstats cannot be virtual, since ks_data
|
|
||||||
* points to garbage as soon as the driver goes away.
|
|
||||||
*
|
|
||||||
* The following flags are maintained by the kstat framework:
|
|
||||||
*
|
|
||||||
* KSTAT_FLAG_DORMANT:
|
|
||||||
*
|
|
||||||
* For persistent kstats, indicates that the kstat is in the
|
|
||||||
* dormant state (e.g., the corresponding device is closed).
|
|
||||||
*
|
|
||||||
* KSTAT_FLAG_INVALID:
|
|
||||||
*
|
|
||||||
* This flag is set when a kstat is in a transitional state,
|
|
||||||
* e.g. between kstat_create() and kstat_install().
|
|
||||||
* kstat clients must not attempt to access the kstat's data
|
|
||||||
* if this flag is set.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define KSTAT_FLAG_VIRTUAL 0x01
|
|
||||||
#define KSTAT_FLAG_VAR_SIZE 0x02
|
|
||||||
#define KSTAT_FLAG_WRITABLE 0x04
|
|
||||||
#define KSTAT_FLAG_PERSISTENT 0x08
|
|
||||||
#define KSTAT_FLAG_DORMANT 0x10
|
|
||||||
#define KSTAT_FLAG_INVALID 0x20
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Dynamic update support
|
|
||||||
*
|
|
||||||
* The kstat mechanism allows for an optional ks_update function to update
|
|
||||||
* kstat data. This is useful for drivers where the underlying device
|
|
||||||
* keeps cheap hardware stats, but extraction is expensive. Instead of
|
|
||||||
* constantly keeping the kstat data section up to date, you can supply a
|
|
||||||
* ks_update function which updates the kstat's data section on demand.
|
|
||||||
* To take advantage of this feature, simply set the ks_update field before
|
|
||||||
* calling kstat_install().
|
|
||||||
*
|
|
||||||
* The ks_update function, if supplied, must have the following structure:
|
|
||||||
*
|
|
||||||
* int
|
|
||||||
* foo_kstat_update(kstat_t *ksp, int rw)
|
|
||||||
* {
|
|
||||||
* if (rw == KSTAT_WRITE) {
|
|
||||||
* ... update the native stats from ksp->ks_data;
|
|
||||||
* return EACCES if you don't support this
|
|
||||||
* } else {
|
|
||||||
* ... update ksp->ks_data from the native stats
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* The ks_update return codes are: 0 for success, EACCES if you don't allow
|
|
||||||
* KSTAT_WRITE, and EIO for any other type of error.
|
|
||||||
*
|
|
||||||
* In general, the ks_update function may need to refer to provider-private
|
|
||||||
* data; for example, it may need a pointer to the provider's raw statistics.
|
|
||||||
* The ks_private field is available for this purpose. Its use is entirely
|
|
||||||
* at the provider's discretion.
|
|
||||||
*
|
|
||||||
* All variable-size kstats MUST supply a ks_update routine, which computes
|
|
||||||
* and sets ks_data_size (and ks_ndata if that is meaningful), since these
|
|
||||||
* are needed to perform kstat snapshots (see below).
|
|
||||||
*
|
|
||||||
* No kstat locking should be done inside the ks_update routine. The caller
|
|
||||||
* will already be holding the kstat's ks_lock (to ensure consistent data).
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define KSTAT_READ 0
|
|
||||||
#define KSTAT_WRITE 1
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Kstat snapshot
|
|
||||||
*
|
|
||||||
* In order to get a consistent view of a kstat's data, clients must obey
|
|
||||||
* the kstat's locking strategy. However, these clients may need to perform
|
|
||||||
* operations on the data which could cause a fault (e.g. copyout()), or
|
|
||||||
* operations which are simply expensive. Doing so could cause deadlock
|
|
||||||
* (e.g. if you're holding a disk's kstat lock which is ultimately required
|
|
||||||
* to resolve a copyout() fault), performance degradation (since the providers'
|
|
||||||
* activity is serialized at the kstat lock), device timing problems, etc.
|
|
||||||
*
|
|
||||||
* To avoid these problems, kstat data is provided via snapshots. Taking
|
|
||||||
* a snapshot is a simple process: allocate a wired-down kernel buffer,
|
|
||||||
* acquire the kstat's data lock, copy the data into the buffer ("take the
|
|
||||||
* snapshot"), and release the lock. This ensures that the kstat's data lock
|
|
||||||
* will be held as briefly as possible, and that no faults will occur while
|
|
||||||
* the lock is held.
|
|
||||||
*
|
|
||||||
* Normally, the snapshot is taken by default_kstat_snapshot(), which
|
|
||||||
* timestamps the data (sets ks_snaptime), copies it, and does a little
|
|
||||||
* massaging to deal with incomplete transactions on i/o kstats. However,
|
|
||||||
* this routine only works for kstats with contiguous data (the typical case).
|
|
||||||
* If you create a kstat whose data is, say, a linked list, you must provide
|
|
||||||
* your own ks_snapshot routine. The routine you supply must have the
|
|
||||||
* following prototype (replace "foo" with something appropriate):
|
|
||||||
*
|
|
||||||
* int foo_kstat_snapshot(kstat_t *ksp, void *buf, int rw);
|
|
||||||
*
|
|
||||||
* The minimal snapshot routine -- one which copies contiguous data that
|
|
||||||
* doesn't need any massaging -- would be this:
|
|
||||||
*
|
|
||||||
* ksp->ks_snaptime = gethrtime();
|
|
||||||
* if (rw == KSTAT_WRITE)
|
|
||||||
* bcopy(buf, ksp->ks_data, ksp->ks_data_size);
|
|
||||||
* else
|
|
||||||
* bcopy(ksp->ks_data, buf, ksp->ks_data_size);
|
|
||||||
* return (0);
|
|
||||||
*
|
|
||||||
* A more illuminating example is taking a snapshot of a linked list:
|
|
||||||
*
|
|
||||||
* ksp->ks_snaptime = gethrtime();
|
|
||||||
* if (rw == KSTAT_WRITE)
|
|
||||||
* return (EACCES); ... See below ...
|
|
||||||
* for (foo = first_foo; foo; foo = foo->next) {
|
|
||||||
* bcopy((char *) foo, (char *) buf, sizeof (struct foo));
|
|
||||||
* buf = ((struct foo *) buf) + 1;
|
|
||||||
* }
|
|
||||||
* return (0);
|
|
||||||
*
|
|
||||||
* In the example above, we have decided that we don't want to allow
|
|
||||||
* KSTAT_WRITE access, so we return EACCES if this is attempted.
|
|
||||||
*
|
|
||||||
* The key points are:
|
|
||||||
*
|
|
||||||
* (1) ks_snaptime must be set (via gethrtime()) to timestamp the data.
|
|
||||||
* (2) Data gets copied from the kstat to the buffer on KSTAT_READ,
|
|
||||||
* and from the buffer to the kstat on KSTAT_WRITE.
|
|
||||||
* (3) ks_snapshot return values are: 0 for success, EACCES if you
|
|
||||||
* don't allow KSTAT_WRITE, and EIO for any other type of error.
|
|
||||||
*
|
|
||||||
* Named kstats (see section on "Named statistics" below) containing long
|
|
||||||
* strings (KSTAT_DATA_STRING) need special handling. The kstat driver
|
|
||||||
* assumes that all strings are copied into the buffer after the array of
|
|
||||||
* named kstats, and the pointers (KSTAT_NAMED_STR_PTR()) are updated to point
|
|
||||||
* into the copy within the buffer. The default snapshot routine does this,
|
|
||||||
* but overriding routines should contain at least the following:
|
|
||||||
*
|
|
||||||
* if (rw == KSTAT_READ) {
|
|
||||||
* kstat_named_t *knp = buf;
|
|
||||||
* char *end = knp + ksp->ks_ndata;
|
|
||||||
* uint_t i;
|
|
||||||
*
|
|
||||||
* ... Do the regular copy ...
|
|
||||||
* bcopy(ksp->ks_data, buf, sizeof (kstat_named_t) * ksp->ks_ndata);
|
|
||||||
*
|
|
||||||
* for (i = 0; i < ksp->ks_ndata; i++, knp++) {
|
|
||||||
* if (knp[i].data_type == KSTAT_DATA_STRING &&
|
|
||||||
* KSTAT_NAMED_STR_PTR(knp) != NULL) {
|
|
||||||
* bcopy(KSTAT_NAMED_STR_PTR(knp), end,
|
|
||||||
* KSTAT_NAMED_STR_BUFLEN(knp));
|
|
||||||
* KSTAT_NAMED_STR_PTR(knp) = end;
|
|
||||||
* end += KSTAT_NAMED_STR_BUFLEN(knp);
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Named statistics.
|
|
||||||
*
|
|
||||||
* List of arbitrary name=value statistics.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct kstat_named {
|
|
||||||
char name[KSTAT_STRLEN]; /* name of counter */
|
|
||||||
uchar_t data_type; /* data type */
|
|
||||||
union {
|
|
||||||
char c[16]; /* enough for 128-bit ints */
|
|
||||||
int32_t i32;
|
|
||||||
uint32_t ui32;
|
|
||||||
struct {
|
|
||||||
union {
|
|
||||||
char *ptr; /* NULL-term string */
|
|
||||||
#if defined(_KERNEL) && defined(_MULTI_DATAMODEL)
|
|
||||||
caddr32_t ptr32;
|
|
||||||
#endif
|
|
||||||
char __pad[8]; /* 64-bit padding */
|
|
||||||
} addr;
|
|
||||||
uint32_t len; /* # bytes for strlen + '\0' */
|
|
||||||
} str;
|
|
||||||
/*
|
|
||||||
* The int64_t and uint64_t types are not valid for a maximally conformant
|
|
||||||
* 32-bit compilation environment (cc -Xc) using compilers prior to the
|
|
||||||
* introduction of C99 conforming compiler (reference ISO/IEC 9899:1990).
|
|
||||||
* In these cases, the visibility of i64 and ui64 is only permitted for
|
|
||||||
* 64-bit compilation environments or 32-bit non-maximally conformant
|
|
||||||
* C89 or C90 ANSI C compilation environments (cc -Xt and cc -Xa). In the
|
|
||||||
* C99 ANSI C compilation environment, the long long type is supported.
|
|
||||||
* The _INT64_TYPE is defined by the implementation (see sys/int_types.h).
|
|
||||||
*/
|
|
||||||
#if defined(_INT64_TYPE)
|
|
||||||
int64_t i64;
|
|
||||||
uint64_t ui64;
|
|
||||||
#endif
|
|
||||||
long l;
|
|
||||||
ulong_t ul;
|
|
||||||
|
|
||||||
/* These structure members are obsolete */
|
|
||||||
|
|
||||||
longlong_t ll;
|
|
||||||
u_longlong_t ull;
|
|
||||||
float f;
|
|
||||||
double d;
|
|
||||||
} value; /* value of counter */
|
|
||||||
} kstat_named_t;
|
|
||||||
|
|
||||||
#define KSTAT_DATA_CHAR 0
|
|
||||||
#define KSTAT_DATA_INT32 1
|
|
||||||
#define KSTAT_DATA_UINT32 2
|
|
||||||
#define KSTAT_DATA_INT64 3
|
|
||||||
#define KSTAT_DATA_UINT64 4
|
|
||||||
|
|
||||||
#if !defined(_LP64)
|
|
||||||
#define KSTAT_DATA_LONG KSTAT_DATA_INT32
|
|
||||||
#define KSTAT_DATA_ULONG KSTAT_DATA_UINT32
|
|
||||||
#else
|
|
||||||
#if !defined(_KERNEL)
|
|
||||||
#define KSTAT_DATA_LONG KSTAT_DATA_INT64
|
|
||||||
#define KSTAT_DATA_ULONG KSTAT_DATA_UINT64
|
|
||||||
#else
|
|
||||||
#define KSTAT_DATA_LONG 7 /* only visible to the kernel */
|
|
||||||
#define KSTAT_DATA_ULONG 8 /* only visible to the kernel */
|
|
||||||
#endif /* !_KERNEL */
|
|
||||||
#endif /* !_LP64 */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Statistics exporting named kstats with long strings (KSTAT_DATA_STRING)
|
|
||||||
* may not make the assumption that ks_data_size is equal to (ks_ndata * sizeof
|
|
||||||
* (kstat_named_t)). ks_data_size in these cases is equal to the sum of the
|
|
||||||
* amount of space required to store the strings (ie, the sum of
|
|
||||||
* KSTAT_NAMED_STR_BUFLEN() for all KSTAT_DATA_STRING statistics) plus the
|
|
||||||
* space required to store the kstat_named_t's.
|
|
||||||
*
|
|
||||||
* The default update routine will update ks_data_size automatically for
|
|
||||||
* variable-length kstats containing long strings (using the default update
|
|
||||||
* routine only makes sense if the string is the only thing that is changing
|
|
||||||
* in size, and ks_ndata is constant). Fixed-length kstats containing long
|
|
||||||
* strings must explicitly change ks_data_size (after creation but before
|
|
||||||
* initialization) to reflect the correct amount of space required for the
|
|
||||||
* long strings and the kstat_named_t's.
|
|
||||||
*/
|
|
||||||
#define KSTAT_DATA_STRING 9
|
|
||||||
|
|
||||||
/* These types are obsolete */
|
|
||||||
|
|
||||||
#define KSTAT_DATA_LONGLONG KSTAT_DATA_INT64
|
|
||||||
#define KSTAT_DATA_ULONGLONG KSTAT_DATA_UINT64
|
|
||||||
#define KSTAT_DATA_FLOAT 5
|
|
||||||
#define KSTAT_DATA_DOUBLE 6
|
|
||||||
|
|
||||||
#define KSTAT_NAMED_PTR(kptr) ((kstat_named_t *)(kptr)->ks_data)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Retrieve the pointer of the string contained in the given named kstat.
|
|
||||||
*/
|
|
||||||
#define KSTAT_NAMED_STR_PTR(knptr) ((knptr)->value.str.addr.ptr)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Retrieve the length of the buffer required to store the string in the given
|
|
||||||
* named kstat.
|
|
||||||
*/
|
|
||||||
#define KSTAT_NAMED_STR_BUFLEN(knptr) ((knptr)->value.str.len)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Interrupt statistics.
|
|
||||||
*
|
|
||||||
* An interrupt is a hard interrupt (sourced from the hardware device
|
|
||||||
* itself), a soft interrupt (induced by the system via the use of
|
|
||||||
* some system interrupt source), a watchdog interrupt (induced by
|
|
||||||
* a periodic timer call), spurious (an interrupt entry point was
|
|
||||||
* entered but there was no interrupt condition to service),
|
|
||||||
* or multiple service (an interrupt condition was detected and
|
|
||||||
* serviced just prior to returning from any of the other types).
|
|
||||||
*
|
|
||||||
* Measurement of the spurious class of interrupts is useful for
|
|
||||||
* autovectored devices in order to pinpoint any interrupt latency
|
|
||||||
* problems in a particular system configuration.
|
|
||||||
*
|
|
||||||
* Devices that have more than one interrupt of the same
|
|
||||||
* type should use multiple structures.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define KSTAT_INTR_HARD 0
|
|
||||||
#define KSTAT_INTR_SOFT 1
|
|
||||||
#define KSTAT_INTR_WATCHDOG 2
|
|
||||||
#define KSTAT_INTR_SPURIOUS 3
|
|
||||||
#define KSTAT_INTR_MULTSVC 4
|
|
||||||
|
|
||||||
#define KSTAT_NUM_INTRS 5
|
|
||||||
|
|
||||||
typedef struct kstat_intr {
|
|
||||||
uint_t intrs[KSTAT_NUM_INTRS]; /* interrupt counters */
|
|
||||||
} kstat_intr_t;
|
|
||||||
|
|
||||||
#define KSTAT_INTR_PTR(kptr) ((kstat_intr_t *)(kptr)->ks_data)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* I/O statistics.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct kstat_io {
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Basic counters.
|
|
||||||
*
|
|
||||||
* The counters should be updated at the end of service
|
|
||||||
* (e.g., just prior to calling biodone()).
|
|
||||||
*/
|
|
||||||
|
|
||||||
u_longlong_t nread; /* number of bytes read */
|
|
||||||
u_longlong_t nwritten; /* number of bytes written */
|
|
||||||
uint_t reads; /* number of read operations */
|
|
||||||
uint_t writes; /* number of write operations */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Accumulated time and queue length statistics.
|
|
||||||
*
|
|
||||||
* Accumulated time statistics are kept as a running sum
|
|
||||||
* of "active" time. Queue length statistics are kept as a
|
|
||||||
* running sum of the product of queue length and elapsed time
|
|
||||||
* at that length -- i.e., a Riemann sum for queue length
|
|
||||||
* integrated against time. (You can also think of the active time
|
|
||||||
* as a Riemann sum, for the boolean function (queue_length > 0)
|
|
||||||
* integrated against time, or you can think of it as the
|
|
||||||
* Lebesgue measure of the set on which queue_length > 0.)
|
|
||||||
*
|
|
||||||
* ^
|
|
||||||
* | _________
|
|
||||||
* 8 | i4 |
|
|
||||||
* | | |
|
|
||||||
* Queue 6 | |
|
|
||||||
* Length | _________ | |
|
|
||||||
* 4 | i2 |_______| |
|
|
||||||
* | | i3 |
|
|
||||||
* 2_______| |
|
|
||||||
* | i1 |
|
|
||||||
* |_______________________________|
|
|
||||||
* Time-> t1 t2 t3 t4
|
|
||||||
*
|
|
||||||
* At each change of state (entry or exit from the queue),
|
|
||||||
* we add the elapsed time (since the previous state change)
|
|
||||||
* to the active time if the queue length was non-zero during
|
|
||||||
* that interval; and we add the product of the elapsed time
|
|
||||||
* times the queue length to the running length*time sum.
|
|
||||||
*
|
|
||||||
* This method is generalizable to measuring residency
|
|
||||||
* in any defined system: instead of queue lengths, think
|
|
||||||
* of "outstanding RPC calls to server X".
|
|
||||||
*
|
|
||||||
* A large number of I/O subsystems have at least two basic
|
|
||||||
* "lists" of transactions they manage: one for transactions
|
|
||||||
* that have been accepted for processing but for which processing
|
|
||||||
* has yet to begin, and one for transactions which are actively
|
|
||||||
* being processed (but not done). For this reason, two cumulative
|
|
||||||
* time statistics are defined here: wait (pre-service) time,
|
|
||||||
* and run (service) time.
|
|
||||||
*
|
|
||||||
* All times are 64-bit nanoseconds (hrtime_t), as returned by
|
|
||||||
* gethrtime().
|
|
||||||
*
|
|
||||||
* The units of cumulative busy time are accumulated nanoseconds.
|
|
||||||
* The units of cumulative length*time products are elapsed time
|
|
||||||
* times queue length.
|
|
||||||
*
|
|
||||||
* Updates to the fields below are performed implicitly by calls to
|
|
||||||
* these five functions:
|
|
||||||
*
|
|
||||||
* kstat_waitq_enter()
|
|
||||||
* kstat_waitq_exit()
|
|
||||||
* kstat_runq_enter()
|
|
||||||
* kstat_runq_exit()
|
|
||||||
*
|
|
||||||
* kstat_waitq_to_runq() (see below)
|
|
||||||
* kstat_runq_back_to_waitq() (see below)
|
|
||||||
*
|
|
||||||
* Since kstat_waitq_exit() is typically followed immediately
|
|
||||||
* by kstat_runq_enter(), there is a single kstat_waitq_to_runq()
|
|
||||||
* function which performs both operations. This is a performance
|
|
||||||
* win since only one timestamp is required.
|
|
||||||
*
|
|
||||||
* In some instances, it may be necessary to move a request from
|
|
||||||
* the run queue back to the wait queue, e.g. for write throttling.
|
|
||||||
* For these situations, call kstat_runq_back_to_waitq().
|
|
||||||
*
|
|
||||||
* These fields should never be updated by any other means.
|
|
||||||
*/
|
|
||||||
|
|
||||||
hrtime_t wtime; /* cumulative wait (pre-service) time */
|
|
||||||
hrtime_t wlentime; /* cumulative wait length*time product */
|
|
||||||
hrtime_t wlastupdate; /* last time wait queue changed */
|
|
||||||
hrtime_t rtime; /* cumulative run (service) time */
|
|
||||||
hrtime_t rlentime; /* cumulative run length*time product */
|
|
||||||
hrtime_t rlastupdate; /* last time run queue changed */
|
|
||||||
|
|
||||||
uint_t wcnt; /* count of elements in wait state */
|
|
||||||
uint_t rcnt; /* count of elements in run state */
|
|
||||||
|
|
||||||
} kstat_io_t;
|
|
||||||
|
|
||||||
#define KSTAT_IO_PTR(kptr) ((kstat_io_t *)(kptr)->ks_data)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Event timer statistics - cumulative elapsed time and number of events.
|
|
||||||
*
|
|
||||||
* Updates to these fields are performed implicitly by calls to
|
|
||||||
* kstat_timer_start() and kstat_timer_stop().
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct kstat_timer {
|
|
||||||
char name[KSTAT_STRLEN]; /* event name */
|
|
||||||
uchar_t resv; /* reserved */
|
|
||||||
u_longlong_t num_events; /* number of events */
|
|
||||||
hrtime_t elapsed_time; /* cumulative elapsed time */
|
|
||||||
hrtime_t min_time; /* shortest event duration */
|
|
||||||
hrtime_t max_time; /* longest event duration */
|
|
||||||
hrtime_t start_time; /* previous event start time */
|
|
||||||
hrtime_t stop_time; /* previous event stop time */
|
|
||||||
} kstat_timer_t;
|
|
||||||
|
|
||||||
#define KSTAT_TIMER_PTR(kptr) ((kstat_timer_t *)(kptr)->ks_data)
|
|
||||||
|
|
||||||
#if defined(_KERNEL)
|
|
||||||
|
|
||||||
#include <sys/t_lock.h>
|
|
||||||
|
|
||||||
extern kid_t kstat_chain_id; /* bumped at each state change */
|
|
||||||
extern void kstat_init(void); /* initialize kstat framework */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Adding and deleting kstats.
|
|
||||||
*
|
|
||||||
* The typical sequence to add a kstat is:
|
|
||||||
*
|
|
||||||
* ksp = kstat_create(module, instance, name, class, type, ndata, flags);
|
|
||||||
* if (ksp) {
|
|
||||||
* ... provider initialization, if necessary
|
|
||||||
* kstat_install(ksp);
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* There are three logically distinct steps here:
|
|
||||||
*
|
|
||||||
* Step 1: System Initialization (kstat_create)
|
|
||||||
*
|
|
||||||
* kstat_create() performs system initialization. kstat_create()
|
|
||||||
* allocates memory for the entire kstat (header plus data), initializes
|
|
||||||
* all header fields, initializes the data section to all zeroes, assigns
|
|
||||||
* a unique KID, and puts the kstat onto the system's kstat chain.
|
|
||||||
* The returned kstat is marked invalid (KSTAT_FLAG_INVALID is set),
|
|
||||||
* because the provider (caller) has not yet had a chance to initialize
|
|
||||||
* the data section.
|
|
||||||
*
|
|
||||||
* By default, kstats are exported to all zones on the system. A kstat may be
|
|
||||||
* created via kstat_create_zone() to specify a zone to which the statistics
|
|
||||||
* should be exported. kstat_zone_add() may be used to specify additional
|
|
||||||
* zones to which the statistics are to be exported.
|
|
||||||
*
|
|
||||||
* Step 2: Provider Initialization
|
|
||||||
*
|
|
||||||
* The provider performs any necessary initialization of the data section,
|
|
||||||
* e.g. setting the name fields in a KSTAT_TYPE_NAMED. Virtual kstats set
|
|
||||||
* the ks_data field at this time. The provider may also set the ks_update,
|
|
||||||
* ks_snapshot, ks_private, and ks_lock fields if necessary.
|
|
||||||
*
|
|
||||||
* Step 3: Installation (kstat_install)
|
|
||||||
*
|
|
||||||
* Once the kstat is completely initialized, kstat_install() clears the
|
|
||||||
* INVALID flag, thus making the kstat accessible to the outside world.
|
|
||||||
* kstat_install() also clears the DORMANT flag for persistent kstats.
|
|
||||||
*
|
|
||||||
* Removing a kstat from the system
|
|
||||||
*
|
|
||||||
* kstat_delete(ksp) removes ksp from the kstat chain and frees all
|
|
||||||
* associated system resources. NOTE: When you call kstat_delete(),
|
|
||||||
* you must NOT be holding that kstat's ks_lock. Otherwise, you may
|
|
||||||
* deadlock with a kstat reader.
|
|
||||||
*
|
|
||||||
* Persistent kstats
|
|
||||||
*
|
|
||||||
* From the provider's point of view, persistence is transparent. The only
|
|
||||||
* difference between ephemeral (normal) kstats and persistent kstats
|
|
||||||
* is that you pass KSTAT_FLAG_PERSISTENT to kstat_create(). Magically,
|
|
||||||
* this has the effect of making your data visible even when you're
|
|
||||||
* not home. Persistence is important to tools like iostat, which want
|
|
||||||
* to get a meaningful picture of disk activity. Without persistence,
|
|
||||||
* raw disk i/o statistics could never accumulate: they would come and
|
|
||||||
* go with each open/close of the raw device.
|
|
||||||
*
|
|
||||||
* The magic of persistence works by slightly altering the behavior of
|
|
||||||
* kstat_create() and kstat_delete(). The first call to kstat_create()
|
|
||||||
* creates a new kstat, as usual. However, kstat_delete() does not
|
|
||||||
* actually delete the kstat: it performs one final update of the data
|
|
||||||
* (i.e., calls the ks_update routine), marks the kstat as dormant, and
|
|
||||||
* sets the ks_lock, ks_update, ks_private, and ks_snapshot fields back
|
|
||||||
* to their default values (since they might otherwise point to garbage,
|
|
||||||
* e.g. if the provider is going away). kstat clients can still access
|
|
||||||
* the dormant kstat just like a live kstat; they just continue to see
|
|
||||||
* the final data values as long as the kstat remains dormant.
|
|
||||||
* All subsequent kstat_create() calls simply find the already-existing,
|
|
||||||
* dormant kstat and return a pointer to it, without altering any fields.
|
|
||||||
* The provider then performs its usual initialization sequence, and
|
|
||||||
* calls kstat_install(). kstat_install() uses the old data values to
|
|
||||||
* initialize the native data (i.e., ks_update is called with KSTAT_WRITE),
|
|
||||||
* thus making it seem like you were never gone.
|
|
||||||
*/
|
|
||||||
|
|
||||||
extern kstat_t *kstat_create(const char *, int, const char *, const char *,
|
|
||||||
uchar_t, uint_t, uchar_t);
|
|
||||||
extern kstat_t *kstat_create_zone(const char *, int, const char *,
|
|
||||||
const char *, uchar_t, uint_t, uchar_t, zoneid_t);
|
|
||||||
extern void kstat_install(kstat_t *);
|
|
||||||
extern void kstat_delete(kstat_t *);
|
|
||||||
extern void kstat_named_setstr(kstat_named_t *knp, const char *src);
|
|
||||||
extern void kstat_set_string(char *, const char *);
|
|
||||||
extern void kstat_delete_byname(const char *, int, const char *);
|
|
||||||
extern void kstat_delete_byname_zone(const char *, int, const char *, zoneid_t);
|
|
||||||
extern void kstat_named_init(kstat_named_t *, const char *, uchar_t);
|
|
||||||
extern void kstat_timer_init(kstat_timer_t *, const char *);
|
|
||||||
extern void kstat_waitq_enter(kstat_io_t *);
|
|
||||||
extern void kstat_waitq_exit(kstat_io_t *);
|
|
||||||
extern void kstat_runq_enter(kstat_io_t *);
|
|
||||||
extern void kstat_runq_exit(kstat_io_t *);
|
|
||||||
extern void kstat_waitq_to_runq(kstat_io_t *);
|
|
||||||
extern void kstat_runq_back_to_waitq(kstat_io_t *);
|
|
||||||
extern void kstat_timer_start(kstat_timer_t *);
|
|
||||||
extern void kstat_timer_stop(kstat_timer_t *);
|
|
||||||
|
|
||||||
extern void kstat_zone_add(kstat_t *, zoneid_t);
|
|
||||||
extern void kstat_zone_remove(kstat_t *, zoneid_t);
|
|
||||||
extern int kstat_zone_find(kstat_t *, zoneid_t);
|
|
||||||
|
|
||||||
extern kstat_t *kstat_hold_bykid(kid_t kid, zoneid_t);
|
|
||||||
extern kstat_t *kstat_hold_byname(const char *, int, const char *, zoneid_t);
|
|
||||||
extern void kstat_rele(kstat_t *);
|
|
||||||
|
|
||||||
#endif /* defined(_KERNEL) */
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _SYS_KSTAT_H */
|
|
|
@ -1,142 +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) 1984, 1986, 1987, 1988, 1989 AT&T
|
|
||||||
* All Rights Reserved
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SYS_MNTENT_H
|
|
||||||
#define _SYS_MNTENT_H
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MNTTAB "/proc/mounts"
|
|
||||||
#define VFSTAB "/etc/vfstab"
|
|
||||||
#define MNTMAXSTR 128
|
|
||||||
|
|
||||||
#define MNTTYPE_ZFS "zfs" /* ZFS file system */
|
|
||||||
#define MNTTYPE_UFS "ufs" /* Unix file system */
|
|
||||||
#define MNTTYPE_SMBFS "smbfs" /* SMBFS file system */
|
|
||||||
#define MNTTYPE_NFS "nfs" /* NFS file system */
|
|
||||||
#define MNTTYPE_NFS3 "nfs3" /* NFS Version 3 file system */
|
|
||||||
#define MNTTYPE_NFS4 "nfs4" /* NFS Version 4 file system */
|
|
||||||
#define MNTTYPE_CACHEFS "cachefs" /* Cache File System */
|
|
||||||
#define MNTTYPE_PCFS "pcfs" /* PC (MSDOS) file system */
|
|
||||||
#define MNTTYPE_PC MNTTYPE_PCFS /* Deprecated name; use MNTTYPE_PCFS */
|
|
||||||
#define MNTTYPE_LOFS "lofs" /* Loop back file system */
|
|
||||||
#define MNTTYPE_LO MNTTYPE_LOFS /* Deprecated name; use MNTTYPE_LOFS */
|
|
||||||
#define MNTTYPE_HSFS "hsfs" /* High Sierra (9660) file system */
|
|
||||||
#define MNTTYPE_SWAP "swap" /* Swap file system */
|
|
||||||
#define MNTTYPE_TMPFS "tmpfs" /* Tmp volatile file system */
|
|
||||||
#define MNTTYPE_AUTOFS "autofs" /* Automounter ``file'' system */
|
|
||||||
#define MNTTYPE_MNTFS "mntfs" /* In-kernel mnttab */
|
|
||||||
#define MNTTYPE_DEV "dev" /* /dev file system */
|
|
||||||
#define MNTTYPE_CTFS "ctfs" /* Contract file system */
|
|
||||||
#define MNTTYPE_OBJFS "objfs" /* Kernel object file system */
|
|
||||||
#define MNTTYPE_SHAREFS "sharefs" /* Kernel sharetab file system */
|
|
||||||
|
|
||||||
|
|
||||||
#define MNTOPT_RO "ro" /* Read only */
|
|
||||||
#define MNTOPT_RW "rw" /* Read/write */
|
|
||||||
#define MNTOPT_RQ "rq" /* Read/write with quotas */
|
|
||||||
#define MNTOPT_QUOTA "quota" /* Check quotas */
|
|
||||||
#define MNTOPT_NOQUOTA "noquota" /* Don't check quotas */
|
|
||||||
#define MNTOPT_ONERROR "onerror" /* action to taken on error */
|
|
||||||
#define MNTOPT_SOFT "soft" /* Soft mount */
|
|
||||||
#define MNTOPT_SEMISOFT "semisoft" /* partial soft, uncommited interface */
|
|
||||||
#define MNTOPT_HARD "hard" /* Hard mount */
|
|
||||||
#define MNTOPT_SUID "suid" /* Both setuid and devices allowed */
|
|
||||||
#define MNTOPT_NOSUID "nosuid" /* Neither setuid nor devices allowed */
|
|
||||||
#define MNTOPT_DEVICES "devices" /* Device-special allowed */
|
|
||||||
#define MNTOPT_NODEVICES "nodevices" /* Device-special disallowed */
|
|
||||||
#define MNTOPT_SETUID "setuid" /* Set uid allowed */
|
|
||||||
#define MNTOPT_NOSETUID "nosetuid" /* Set uid not allowed */
|
|
||||||
#define MNTOPT_GRPID "grpid" /* SysV-compatible gid on create */
|
|
||||||
#define MNTOPT_REMOUNT "remount" /* Change mount options */
|
|
||||||
#define MNTOPT_NOSUB "nosub" /* Disallow mounts on subdirs */
|
|
||||||
#define MNTOPT_MULTI "multi" /* Do multi-component lookup */
|
|
||||||
#define MNTOPT_INTR "intr" /* Allow NFS ops to be interrupted */
|
|
||||||
#define MNTOPT_NOINTR "nointr" /* Don't allow interrupted ops */
|
|
||||||
#define MNTOPT_PORT "port" /* NFS server IP port number */
|
|
||||||
#define MNTOPT_SECURE "secure" /* Secure (AUTH_DES) mounting */
|
|
||||||
#define MNTOPT_RSIZE "rsize" /* Max NFS read size (bytes) */
|
|
||||||
#define MNTOPT_WSIZE "wsize" /* Max NFS write size (bytes) */
|
|
||||||
#define MNTOPT_TIMEO "timeo" /* NFS timeout (1/10 sec) */
|
|
||||||
#define MNTOPT_RETRANS "retrans" /* Max retransmissions (soft mnts) */
|
|
||||||
#define MNTOPT_ACTIMEO "actimeo" /* Attr cache timeout (sec) */
|
|
||||||
#define MNTOPT_ACREGMIN "acregmin" /* Min attr cache timeout (files) */
|
|
||||||
#define MNTOPT_ACREGMAX "acregmax" /* Max attr cache timeout (files) */
|
|
||||||
#define MNTOPT_ACDIRMIN "acdirmin" /* Min attr cache timeout (dirs) */
|
|
||||||
#define MNTOPT_ACDIRMAX "acdirmax" /* Max attr cache timeout (dirs) */
|
|
||||||
#define MNTOPT_NOAC "noac" /* Don't cache attributes at all */
|
|
||||||
#define MNTOPT_NOCTO "nocto" /* No close-to-open consistency */
|
|
||||||
#define MNTOPT_BG "bg" /* Do mount retries in background */
|
|
||||||
#define MNTOPT_FG "fg" /* Do mount retries in foreground */
|
|
||||||
#define MNTOPT_RETRY "retry" /* Number of mount retries */
|
|
||||||
#define MNTOPT_DEV "dev" /* Device id of mounted fs */
|
|
||||||
#define MNTOPT_POSIX "posix" /* Get static pathconf for mount */
|
|
||||||
#define MNTOPT_MAP "map" /* Automount map */
|
|
||||||
#define MNTOPT_DIRECT "direct" /* Automount direct map mount */
|
|
||||||
#define MNTOPT_INDIRECT "indirect" /* Automount indirect map mount */
|
|
||||||
#define MNTOPT_LLOCK "llock" /* Local locking (no lock manager) */
|
|
||||||
#define MNTOPT_IGNORE "ignore" /* Ignore this entry */
|
|
||||||
#define MNTOPT_VERS "vers" /* protocol version number indicator */
|
|
||||||
#define MNTOPT_PROTO "proto" /* protocol network_id indicator */
|
|
||||||
#define MNTOPT_SEC "sec" /* Security flavor indicator */
|
|
||||||
#define MNTOPT_SYNCDIR "syncdir" /* Synchronous local directory ops */
|
|
||||||
#define MNTOPT_NOSETSEC "nosec" /* Do no allow setting sec attrs */
|
|
||||||
#define MNTOPT_NOPRINT "noprint" /* Do not print messages */
|
|
||||||
#define MNTOPT_LARGEFILES "largefiles" /* allow large files */
|
|
||||||
#define MNTOPT_NOLARGEFILES "nolargefiles" /* don't allow large files */
|
|
||||||
#define MNTOPT_FORCEDIRECTIO "forcedirectio" /* Force DirectIO on all files */
|
|
||||||
#define MNTOPT_NOFORCEDIRECTIO "noforcedirectio" /* No Force DirectIO */
|
|
||||||
#define MNTOPT_DISABLEDIRECTIO "disabledirectio" /* Disable DirectIO ioctls */
|
|
||||||
#define MNTOPT_PUBLIC "public" /* Use NFS public file handlee */
|
|
||||||
#define MNTOPT_LOGGING "logging" /* enable logging */
|
|
||||||
#define MNTOPT_NOLOGGING "nologging" /* disable logging */
|
|
||||||
#define MNTOPT_ATIME "atime" /* update atime for files */
|
|
||||||
#define MNTOPT_NOATIME "noatime" /* do not update atime for files */
|
|
||||||
#define MNTOPT_GLOBAL "global" /* Cluster-wide global mount */
|
|
||||||
#define MNTOPT_NOGLOBAL "noglobal" /* Mount local to single node */
|
|
||||||
#define MNTOPT_DFRATIME "dfratime" /* Deferred access time updates */
|
|
||||||
#define MNTOPT_NODFRATIME "nodfratime" /* No Deferred access time updates */
|
|
||||||
#define MNTOPT_NBMAND "nbmand" /* allow non-blocking mandatory locks */
|
|
||||||
#define MNTOPT_NONBMAND "nonbmand" /* deny non-blocking mandatory locks */
|
|
||||||
#define MNTOPT_XATTR "xattr" /* enable extended attributes */
|
|
||||||
#define MNTOPT_NOXATTR "noxattr" /* disable extended attributes */
|
|
||||||
#define MNTOPT_EXEC "exec" /* enable executables */
|
|
||||||
#define MNTOPT_NOEXEC "noexec" /* disable executables */
|
|
||||||
#define MNTOPT_RESTRICT "restrict" /* restricted autofs mount */
|
|
||||||
#define MNTOPT_BROWSE "browse" /* browsable autofs mount */
|
|
||||||
#define MNTOPT_NOBROWSE "nobrowse" /* non-browsable autofs mount */
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _SYS_MNTENT_H */
|
|
|
@ -1,86 +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 (c) 1984, 1986, 1987, 1988, 1989 AT&T*/
|
|
||||||
/* All Rights Reserved */
|
|
||||||
/*
|
|
||||||
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
/* Copyright 2006 Ricardo Correia */
|
|
||||||
|
|
||||||
#ifndef _SYS_MNTTAB_H
|
|
||||||
#define _SYS_MNTTAB_H
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <mntent.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#ifdef MNTTAB
|
|
||||||
#undef MNTTAB
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MNTTAB "/proc/mounts"
|
|
||||||
#define MNT_LINE_MAX 1024
|
|
||||||
|
|
||||||
#define MNT_TOOLONG 1 /* entry exceeds MNT_LINE_MAX */
|
|
||||||
#define MNT_TOOMANY 2 /* too many fields in line */
|
|
||||||
#define MNT_TOOFEW 3 /* too few fields in line */
|
|
||||||
|
|
||||||
struct mnttab {
|
|
||||||
char *mnt_special;
|
|
||||||
char *mnt_mountp;
|
|
||||||
char *mnt_fstype;
|
|
||||||
char *mnt_mntopts;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NOTE: fields in extmnttab should match struct mnttab till new fields
|
|
||||||
* are encountered, this allows hasmntopt to work properly when its arg is
|
|
||||||
* a pointer to an extmnttab struct cast to a mnttab struct pointer.
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct extmnttab {
|
|
||||||
char *mnt_special;
|
|
||||||
char *mnt_mountp;
|
|
||||||
char *mnt_fstype;
|
|
||||||
char *mnt_mntopts;
|
|
||||||
uint_t mnt_major;
|
|
||||||
uint_t mnt_minor;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern int getmntany(FILE *fp, struct mnttab *mp, struct mnttab *mpref);
|
|
||||||
extern int _sol_getmntent(FILE *fp, struct mnttab *mp);
|
|
||||||
extern int getextmntent(FILE *fp, struct extmnttab *mp, int len);
|
|
||||||
|
|
||||||
static inline char *_sol_hasmntopt(struct mnttab *mnt, char *opt)
|
|
||||||
{
|
|
||||||
struct mntent mnt_new;
|
|
||||||
|
|
||||||
mnt_new.mnt_opts = mnt->mnt_mntopts;
|
|
||||||
|
|
||||||
return hasmntopt(&mnt_new, opt);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define hasmntopt _sol_hasmntopt
|
|
||||||
#define getmntent _sol_getmntent
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,2 +0,0 @@
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
|
@ -1,56 +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 (c) 1994 by Sun Microsystems, Inc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* sys/note.h: interface for annotating source with info for tools
|
|
||||||
*
|
|
||||||
* This is the underlying interface; NOTE (/usr/include/note.h) is the
|
|
||||||
* preferred interface, but all exported header files should include this
|
|
||||||
* file directly and use _NOTE so as not to take "NOTE" from the user's
|
|
||||||
* namespace. For consistency, *all* kernel source should use _NOTE.
|
|
||||||
*
|
|
||||||
* By default, annotations expand to nothing. This file implements
|
|
||||||
* that. Tools using annotations will interpose a different version
|
|
||||||
* of this file that will expand annotations as needed.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SYS_NOTE_H
|
|
||||||
#define _SYS_NOTE_H
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _NOTE
|
|
||||||
#define _NOTE(s)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _SYS_NOTE_H */
|
|
|
@ -1,62 +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 2006 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SOL_SYS_PARAM_H
|
|
||||||
#define _SOL_SYS_PARAM_H
|
|
||||||
|
|
||||||
#include_next <sys/param.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* File system parameters and macros.
|
|
||||||
*
|
|
||||||
* The file system is made out of blocks of at most MAXBSIZE units,
|
|
||||||
* with smaller units (fragments) only in the last direct block.
|
|
||||||
* MAXBSIZE primarily determines the size of buffers in the buffer
|
|
||||||
* pool. It may be made larger without any effect on existing
|
|
||||||
* file systems; however making it smaller make make some file
|
|
||||||
* systems unmountable.
|
|
||||||
*
|
|
||||||
* Note that the blocked devices are assumed to have DEV_BSIZE
|
|
||||||
* "sectors" and that fragments must be some multiple of this size.
|
|
||||||
*/
|
|
||||||
#define MAXBSIZE 8192
|
|
||||||
#define DEV_BSIZE 512
|
|
||||||
#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
|
|
||||||
|
|
||||||
#define MAXNAMELEN 256
|
|
||||||
#define MAXOFFSET_T 0x7fffffffffffffffl
|
|
||||||
|
|
||||||
#define UID_NOBODY 60001 /* user ID no body */
|
|
||||||
#define GID_NOBODY UID_NOBODY
|
|
||||||
#define UID_NOACCESS 60002 /* user ID no access */
|
|
||||||
|
|
||||||
#define MAXUID 2147483647 /* max user id */
|
|
||||||
#define MAXPROJID MAXUID /* max project id */
|
|
||||||
|
|
||||||
#define PAGESIZE (sysconf(_SC_PAGESIZE))
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,32 +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 2007 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SOL_SYS_PROCESSOR_H
|
|
||||||
#define _SOL_SYS_PROCESSOR_H
|
|
||||||
|
|
||||||
#define getcpuid() (-1)
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1 +0,0 @@
|
||||||
#include <sys/kmem.h>
|
|
|
@ -1,35 +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 2007 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SOL_SYS_SDT_H
|
|
||||||
#define _SOL_SYS_SDT_H
|
|
||||||
|
|
||||||
#define DTRACE_PROBE1(a,b,c) ((void) 0)
|
|
||||||
#define DTRACE_PROBE2(a,b,c,d,e) ((void) 0)
|
|
||||||
#define DTRACE_PROBE3(a,b,c,d,e,f,g) ((void) 0)
|
|
||||||
#define DTRACE_PROBE4(a,b,c,d,e,f,g,h,i) ((void) 0)
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,60 +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 2006 Ricardo Correia. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SOL_STAT_H
|
|
||||||
#define _SOL_STAT_H
|
|
||||||
|
|
||||||
#include_next <sys/stat.h>
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
/* LINUX */
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <sys/mount.h>
|
|
||||||
|
|
||||||
static inline int zfsfuse_fstat64(int fd, struct stat64 *buf)
|
|
||||||
{
|
|
||||||
if(fstat64(fd, buf) == -1)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if(S_ISBLK(buf->st_mode)) {
|
|
||||||
/* LINUX */
|
|
||||||
uint64_t size;
|
|
||||||
if(real_ioctl(fd, BLKGETSIZE64, &size) != 0) {
|
|
||||||
fprintf(stderr, "failed to read device size: %s\n", strerror(errno));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
buf->st_size = size;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define fstat64(fd, buf) zfsfuse_fstat64(fd, buf)
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,50 +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 2007 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SOL_SUNDDI_H
|
|
||||||
#define _SOL_SUNDDI_H
|
|
||||||
|
|
||||||
#ifdef _KERNEL
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#include <sys/u8_textprep.h>
|
|
||||||
|
|
||||||
static inline int
|
|
||||||
ddi_strtoul(const char *hw_serial, char **nptr, int base, unsigned long *result)
|
|
||||||
{
|
|
||||||
char *end;
|
|
||||||
|
|
||||||
*result = strtoul(hw_serial, &end, base);
|
|
||||||
if (*result == 0)
|
|
||||||
return (errno);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,235 +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 2007 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SYS_SYSEVENT_EVENTDEFS_H
|
|
||||||
#define _SYS_SYSEVENT_EVENTDEFS_H
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* eventdefs.h contains public definitions for sysevent types (classes
|
|
||||||
* and subclasses). All additions/removal/changes are subject
|
|
||||||
* to PSARC approval.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Sysevent Class definitions */
|
|
||||||
#define EC_NONE "EC_none"
|
|
||||||
#define EC_PRIV "EC_priv"
|
|
||||||
#define EC_PLATFORM "EC_platform" /* events private to platform */
|
|
||||||
#define EC_DR "EC_dr" /* Dynamic reconfiguration event class */
|
|
||||||
#define EC_ENV "EC_env" /* Environmental monitor event class */
|
|
||||||
#define EC_DOMAIN "EC_domain" /* Domain event class */
|
|
||||||
#define EC_AP_DRIVER "EC_ap_driver" /* Alternate Pathing event class */
|
|
||||||
#define EC_IPMP "EC_ipmp" /* IP Multipathing event class */
|
|
||||||
#define EC_DEV_ADD "EC_dev_add" /* device add event class */
|
|
||||||
#define EC_DEV_REMOVE "EC_dev_remove" /* device remove event class */
|
|
||||||
#define EC_DEV_BRANCH "EC_dev_branch" /* device tree branch event class */
|
|
||||||
#define EC_FM "EC_fm" /* FMA error report event */
|
|
||||||
#define EC_ZFS "EC_zfs" /* ZFS event */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The following event class is reserved for exclusive use
|
|
||||||
* by Sun Cluster software.
|
|
||||||
*/
|
|
||||||
#define EC_CLUSTER "EC_Cluster"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The following classes are exclusively reserved for use by the
|
|
||||||
* Solaris Volume Manager (SVM)
|
|
||||||
*/
|
|
||||||
#define EC_SVM_CONFIG "EC_SVM_Config"
|
|
||||||
#define EC_SVM_STATE "EC_SVM_State"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* EC_SVM_CONFIG subclass definitions - supporting attributes (name/value pairs)
|
|
||||||
* are found in sys/sysevent/svm.h
|
|
||||||
*/
|
|
||||||
#define ESC_SVM_CREATE "ESC_SVM_Create"
|
|
||||||
#define ESC_SVM_DELETE "ESC_SVM_Delete"
|
|
||||||
#define ESC_SVM_ADD "ESC_SVM_Add"
|
|
||||||
#define ESC_SVM_REMOVE "ESC_SVM_Remove"
|
|
||||||
#define ESC_SVM_REPLACE "ESC_SVM_Replace"
|
|
||||||
#define ESC_SVM_GROW "ESC_SVM_Grow"
|
|
||||||
#define ESC_SVM_RENAME_SRC "ESC_SVM_Rename_Src"
|
|
||||||
#define ESC_SVM_RENAME_DST "ESC_SVM_Rename_Dst"
|
|
||||||
#define ESC_SVM_MEDIATOR_ADD "ESC_SVM_Mediator_Add"
|
|
||||||
#define ESC_SVM_MEDIATOR_DELETE "ESC_SVM_Mediator_Delete"
|
|
||||||
#define ESC_SVM_HOST_ADD "ESC_SVM_Host_Add"
|
|
||||||
#define ESC_SVM_HOST_DELETE "ESC_SVM_Host_Delete"
|
|
||||||
#define ESC_SVM_DRIVE_ADD "ESC_SVM_Drive_Add"
|
|
||||||
#define ESC_SVM_DRIVE_DELETE "ESC_SVM_Drive_Delete"
|
|
||||||
#define ESC_SVM_DETACH "ESC_SVM_Detach"
|
|
||||||
#define ESC_SVM_DETACHING "ESC_SVM_Detaching"
|
|
||||||
#define ESC_SVM_ATTACH "ESC_SVM_Attach"
|
|
||||||
#define ESC_SVM_ATTACHING "ESC_SVM_Attaching"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* EC_SVM_STATE subclass definitions - supporting attributes (name/value pairs)
|
|
||||||
* are found in sys/sysevent/svm.h
|
|
||||||
*/
|
|
||||||
#define ESC_SVM_INIT_START "ESC_SVM_Init_Start"
|
|
||||||
#define ESC_SVM_INIT_FAILED "ESC_SVM_Init_Failed"
|
|
||||||
#define ESC_SVM_INIT_FATAL "ESC_SVM_Init_Fatal"
|
|
||||||
#define ESC_SVM_INIT_SUCCESS "ESC_SVM_Init_Success"
|
|
||||||
#define ESC_SVM_IOERR "ESC_SVM_Ioerr"
|
|
||||||
#define ESC_SVM_ERRED "ESC_SVM_Erred"
|
|
||||||
#define ESC_SVM_LASTERRED "ESC_SVM_Lasterred"
|
|
||||||
#define ESC_SVM_OK "ESC_SVM_Ok"
|
|
||||||
#define ESC_SVM_ENABLE "ESC_SVM_Enable"
|
|
||||||
#define ESC_SVM_RESYNC_START "ESC_SVM_Resync_Start"
|
|
||||||
#define ESC_SVM_RESYNC_FAILED "ESC_SVM_Resync_Failed"
|
|
||||||
#define ESC_SVM_RESYNC_SUCCESS "ESC_SVM_Resync_Success"
|
|
||||||
#define ESC_SVM_RESYNC_DONE "ESC_SVM_Resync_Done"
|
|
||||||
#define ESC_SVM_HOTSPARED "ESC_SVM_Hotspared"
|
|
||||||
#define ESC_SVM_HS_FREED "ESC_SVM_HS_Freed"
|
|
||||||
#define ESC_SVM_HS_CHANGED "ESC_SVM_HS_Changed"
|
|
||||||
#define ESC_SVM_TAKEOVER "ESC_SVM_Takeover"
|
|
||||||
#define ESC_SVM_RELEASE "ESC_SVM_Release"
|
|
||||||
#define ESC_SVM_OPEN_FAIL "ESC_SVM_Open_Fail"
|
|
||||||
#define ESC_SVM_OFFLINE "ESC_SVM_Offline"
|
|
||||||
#define ESC_SVM_ONLINE "ESC_SVM_Online"
|
|
||||||
#define ESC_SVM_CHANGE "ESC_SVM_Change"
|
|
||||||
#define ESC_SVM_EXCHANGE "ESC_SVM_Exchange"
|
|
||||||
#define ESC_SVM_REGEN_START "ESC_SVM_Regen_Start"
|
|
||||||
#define ESC_SVM_REGEN_DONE "ESC_SVM_Regen_Done"
|
|
||||||
#define ESC_SVM_REGEN_FAILED "ESC_SVM_Regen_Failed"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* EC_DR subclass definitions - supporting attributes (name/value pairs)
|
|
||||||
* are found in sys/sysevent/dr.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Attachment point state change */
|
|
||||||
#define ESC_DR_AP_STATE_CHANGE "ESC_dr_ap_state_change"
|
|
||||||
#define ESC_DR_REQ "ESC_dr_req" /* Request DR */
|
|
||||||
#define ESC_DR_TARGET_STATE_CHANGE "ESC_dr_target_state_change"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* EC_ENV subclass definitions - supporting attributes (name/value pairs)
|
|
||||||
* are found in sys/sysevent/env.h
|
|
||||||
*/
|
|
||||||
#define ESC_ENV_TEMP "ESC_env_temp" /* Temperature change event subclass */
|
|
||||||
#define ESC_ENV_FAN "ESC_env_fan" /* Fan status change event subclass */
|
|
||||||
#define ESC_ENV_POWER "ESC_env_power" /* Power supply change event subclass */
|
|
||||||
#define ESC_ENV_LED "ESC_env_led" /* LED change event subclass */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* EC_DOMAIN subclass definitions - supporting attributes (name/value pairs)
|
|
||||||
* are found in sys/sysevent/domain.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Domain state change */
|
|
||||||
#define ESC_DOMAIN_STATE_CHANGE "ESC_domain_state_change"
|
|
||||||
/* Domain loghost name change */
|
|
||||||
#define ESC_DOMAIN_LOGHOST_CHANGE "ESC_domain_loghost_change"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* EC_AP_DRIVER subclass definitions - supporting attributes (name/value pairs)
|
|
||||||
* are found in sys/sysevent/ap_driver.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Alternate Pathing path switch */
|
|
||||||
#define ESC_AP_DRIVER_PATHSWITCH "ESC_ap_driver_pathswitch"
|
|
||||||
/* Alternate Pathing database commit */
|
|
||||||
#define ESC_AP_DRIVER_COMMIT "ESC_ap_driver_commit"
|
|
||||||
/* Alternate Pathing physical path status change */
|
|
||||||
#define ESC_AP_DRIVER_PHYS_PATH_STATUS_CHANGE \
|
|
||||||
"ESC_ap_driver_phys_path_status_change"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* EC_IPMP subclass definitions - supporting attributes (name/value pairs)
|
|
||||||
* are found in sys/sysevent/ipmp.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* IPMP group has changed state */
|
|
||||||
#define ESC_IPMP_GROUP_STATE "ESC_ipmp_group_state"
|
|
||||||
|
|
||||||
/* IPMP group has been created or removed */
|
|
||||||
#define ESC_IPMP_GROUP_CHANGE "ESC_ipmp_group_change"
|
|
||||||
|
|
||||||
/* IPMP group has had an interface added or removed */
|
|
||||||
#define ESC_IPMP_GROUP_MEMBER_CHANGE "ESC_ipmp_group_member_change"
|
|
||||||
|
|
||||||
/* Interface within an IPMP group has changed state or type */
|
|
||||||
#define ESC_IPMP_IF_CHANGE "ESC_ipmp_if_change"
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* EC_DEV_ADD and EC_DEV_REMOVE subclass definitions - supporting attributes
|
|
||||||
* (name/value pairs) are found in sys/sysevent/dev.h
|
|
||||||
*/
|
|
||||||
#define ESC_DISK "disk" /* disk device */
|
|
||||||
#define ESC_NETWORK "network" /* network interface */
|
|
||||||
#define ESC_PRINTER "printer" /* printer device */
|
|
||||||
#define ESC_LOFI "lofi" /* lofi device */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* EC_DEV_BRANCH subclass definitions - supporting attributes (name/value pairs)
|
|
||||||
* are found in sys/sysevent/dev.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* device tree branch added */
|
|
||||||
#define ESC_DEV_BRANCH_ADD "ESC_dev_branch_add"
|
|
||||||
|
|
||||||
/* device tree branch removed */
|
|
||||||
#define ESC_DEV_BRANCH_REMOVE "ESC_dev_branch_remove"
|
|
||||||
|
|
||||||
/* FMA Fault and Error event protocol subclass */
|
|
||||||
#define ESC_FM_ERROR "ESC_FM_error"
|
|
||||||
#define ESC_FM_ERROR_REPLAY "ESC_FM_error_replay"
|
|
||||||
|
|
||||||
/* Service processor subclass definitions */
|
|
||||||
#define ESC_PLATFORM_SP_RESET "ESC_platform_sp_reset"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* EC_ACPIEV subclass definitions
|
|
||||||
*/
|
|
||||||
#define EC_ACPIEV "EC_acpiev"
|
|
||||||
#define ESC_ACPIEV_ADD "ESC_acpiev_add"
|
|
||||||
#define ESC_ACPIEV_REMOVE "ESC_acpiev_remove"
|
|
||||||
#define ESC_ACPIEV_WARN "ESC_acpiev_warn"
|
|
||||||
#define ESC_ACPIEV_LOW "ESC_acpiev_low"
|
|
||||||
#define ESC_ACPIEV_STATE_CHANGE "ESC_acpiev_state_change"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ZFS subclass definitions. supporting attributes (name/value paris) are found
|
|
||||||
* in sys/fs/zfs.h
|
|
||||||
*/
|
|
||||||
#define ESC_ZFS_RESILVER_START "ESC_ZFS_resilver_start"
|
|
||||||
#define ESC_ZFS_RESILVER_FINISH "ESC_ZFS_resilver_finish"
|
|
||||||
#define ESC_ZFS_VDEV_REMOVE "ESC_ZFS_vdev_remove"
|
|
||||||
#define ESC_ZFS_POOL_DESTROY "ESC_ZFS_pool_destroy"
|
|
||||||
#define ESC_ZFS_VDEV_CLEAR "ESC_ZFS_vdev_clear"
|
|
||||||
#define ESC_ZFS_VDEV_CHECK "ESC_ZFS_vdev_check"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _SYS_SYSEVENT_EVENTDEFS_H */
|
|
|
@ -1,95 +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 2007 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SOL_SYS_SYSMACROS_H
|
|
||||||
#define _SOL_SYS_SYSMACROS_H
|
|
||||||
|
|
||||||
#include_next <sys/sysmacros.h>
|
|
||||||
|
|
||||||
#define makedevice(maj,min) makedev(maj,min)
|
|
||||||
|
|
||||||
/* common macros */
|
|
||||||
#ifndef MIN
|
|
||||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
|
||||||
#endif
|
|
||||||
#ifndef MAX
|
|
||||||
#define MAX(a, b) ((a) < (b) ? (b) : (a))
|
|
||||||
#endif
|
|
||||||
#ifndef ABS
|
|
||||||
#define ABS(a) ((a) < 0 ? -(a) : (a))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Compatibility macros/typedefs needed for Solaris -> Linux port
|
|
||||||
*/
|
|
||||||
#define P2ALIGN(x, align) ((x) & -(align))
|
|
||||||
#define P2CROSS(x, y, align) (((x) ^ (y)) > (align) - 1)
|
|
||||||
#define P2ROUNDUP(x, align) (-(-(x) & -(align)))
|
|
||||||
#define P2ROUNDUP_TYPED(x, align, type) \
|
|
||||||
(-(-(type)(x) & -(type)(align)))
|
|
||||||
#define P2PHASE(x, align) ((x) & ((align) - 1))
|
|
||||||
#define P2NPHASE(x, align) (-(x) & ((align) - 1))
|
|
||||||
#define P2NPHASE_TYPED(x, align, type) \
|
|
||||||
(-(type)(x) & ((type)(align) - 1))
|
|
||||||
#define ISP2(x) (((x) & ((x) - 1)) == 0)
|
|
||||||
#define IS_P2ALIGNED(v, a) ((((uintptr_t)(v)) & ((uintptr_t)(a) - 1)) == 0)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Typed version of the P2* macros. These macros should be used to ensure
|
|
||||||
* that the result is correctly calculated based on the data type of (x),
|
|
||||||
* which is passed in as the last argument, regardless of the data
|
|
||||||
* type of the alignment. For example, if (x) is of type uint64_t,
|
|
||||||
* and we want to round it up to a page boundary using "PAGESIZE" as
|
|
||||||
* the alignment, we can do either
|
|
||||||
* P2ROUNDUP(x, (uint64_t)PAGESIZE)
|
|
||||||
* or
|
|
||||||
* P2ROUNDUP_TYPED(x, PAGESIZE, uint64_t)
|
|
||||||
*/
|
|
||||||
#define P2ALIGN_TYPED(x, align, type) \
|
|
||||||
((type)(x) & -(type)(align))
|
|
||||||
#define P2PHASE_TYPED(x, align, type) \
|
|
||||||
((type)(x) & ((type)(align) - 1))
|
|
||||||
#define P2NPHASE_TYPED(x, align, type) \
|
|
||||||
(-(type)(x) & ((type)(align) - 1))
|
|
||||||
#define P2ROUNDUP_TYPED(x, align, type) \
|
|
||||||
(-(-(type)(x) & -(type)(align)))
|
|
||||||
#define P2END_TYPED(x, align, type) \
|
|
||||||
(-(~(type)(x) & -(type)(align)))
|
|
||||||
#define P2PHASEUP_TYPED(x, align, phase, type) \
|
|
||||||
((type)(phase) - (((type)(phase) - (type)(x)) & -(type)(align)))
|
|
||||||
#define P2CROSS_TYPED(x, y, align, type) \
|
|
||||||
(((type)(x) ^ (type)(y)) > (type)(align) - 1)
|
|
||||||
#define P2SAMEHIGHBIT_TYPED(x, y, type) \
|
|
||||||
(((type)(x) ^ (type)(y)) < ((type)(x) & (type)(y)))
|
|
||||||
|
|
||||||
#if defined(_KERNEL) && !defined(_KMEMUSER) && !defined(offsetof)
|
|
||||||
|
|
||||||
/* avoid any possibility of clashing with <stddef.h> version */
|
|
||||||
|
|
||||||
#define offsetof(s, m) ((size_t)(&(((s *)0)->m)))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue