summaryrefslogtreecommitdiff
path: root/usr/src/lib/libnsctl/common
diff options
context:
space:
mode:
authorYuri Pankov <yuri.pankov@nexenta.com>2018-08-07 16:46:21 -0700
committerJoshua M. Clulow <josh@sysmgr.org>2018-08-07 16:46:22 -0700
commitcb41b9c565d4eec9e1f06e24d429696f59f2f07d (patch)
treeee8675f196c2ea84b5ac5c6f0dff8c9e5305f0ee /usr/src/lib/libnsctl/common
parent0e986b9d87352cd82909c748e7f684afe0ed579f (diff)
downloadillumos-joyent-cb41b9c565d4eec9e1f06e24d429696f59f2f07d.tar.gz
9674 Let's scrap AVS/sdbc
Reviewed by: Dan McDonald <danmcd@joyent.com> Reviewed by: Peter Tribble <peter.tribble@gmail.com> Approved by: Joshua M. Clulow <josh@sysmgr.org>
Diffstat (limited to 'usr/src/lib/libnsctl/common')
-rw-r--r--usr/src/lib/libnsctl/common/cache.c425
-rw-r--r--usr/src/lib/libnsctl/common/hash.c166
-rw-r--r--usr/src/lib/libnsctl/common/libnsctl.h62
-rw-r--r--usr/src/lib/libnsctl/common/llib-lnsctl52
-rw-r--r--usr/src/lib/libnsctl/common/machdep.c314
-rw-r--r--usr/src/lib/libnsctl/common/mapfile-vers70
-rw-r--r--usr/src/lib/libnsctl/common/nsc_hash.h49
7 files changed, 0 insertions, 1138 deletions
diff --git a/usr/src/lib/libnsctl/common/cache.c b/usr/src/lib/libnsctl/common/cache.c
deleted file mode 100644
index e4bbc21f25..0000000000
--- a/usr/src/lib/libnsctl/common/cache.c
+++ /dev/null
@@ -1,425 +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 <sys/types.h>
-#include <sys/fcntl.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <strings.h>
-#include <unistd.h>
-#include <stdio.h>
-
-#include "libnsctl.h"
-#include <nsctl.h>
-
-
-static int _nsc_open_path(nsc_fd_t *);
-static int _nsc_open_check(nsc_fd_t *);
-
-
-/*
- * Turn off ckdchk checking of nsc_open()'d volumes since we have no CKD
- * formatted volumes right now. If/when we come back with CKD volumes,
- * we could do this more sanely by completing the implementation of the
- * CKD module, and having nsc_open() prevent any non-NSC_CKD_DISK open
- * of a CKD volume.
- * -- Simon, Thu Feb 18 10:49:46 GMT 1999
- */
-static int ckdchk = 0;
-
-
-nsc_fd_t *
-nsc_open(path, flag, mode)
-char *path;
-int flag, mode;
-{
- nsc_fd_t *fd;
-
- if (strlen(path) >= NSC_MAXPATH) {
- errno = ENAMETOOLONG;
- return (0);
- }
-
- if (!(fd = (nsc_fd_t *)calloc(1, sizeof (nsc_fd_t))))
- return (0);
-
- if ((mode & O_ACCMODE) == O_WRONLY) {
- mode &= ~O_ACCMODE;
- mode |= O_RDWR;
- }
-
- fd->sf_flag = flag;
- fd->sf_fmode = mode;
-
- strcpy(fd->sf_path, path);
-
- if (!_nsc_open_path(fd)) {
- free(fd);
- return (0);
- }
-
- if (ckdchk && !_nsc_open_check(fd)) {
- (void) nsc_close(fd);
- return (0);
- }
-
- return (fd);
-}
-
-
-nsc_fd_t *
-nsc_fdopen(id, path, mode)
-int id, mode;
-char *path;
-{
- struct flock lk;
- nsc_fd_t *fd;
- int i;
-
- if (strlen(path) >= NSC_MAXPATH) {
- errno = ENAMETOOLONG;
- return (0);
- }
-
- if (!(fd = (nsc_fd_t *)calloc(1, sizeof (nsc_fd_t))))
- return (0);
-
- lk.l_type = F_WRLCK;
- lk.l_whence = SEEK_SET;
- lk.l_start = 0;
- lk.l_len = 0;
-
- if (fcntl(id, F_SETLKW, &lk) < 0)
- return (0);
-
- i = fcntl(id, F_GETFL);
-
- if ((mode & O_ACCMODE) != O_RDONLY) {
- if ((i & O_ACCMODE) == O_RDONLY) {
- errno = EBADF;
- return (0);
- }
- }
-
- if ((mode & O_ACCMODE) != O_WRONLY) {
- if ((i & O_ACCMODE) == O_WRONLY) {
- errno = EBADF;
- return (0);
- }
- }
-
- mode = (i & O_ACCMODE) | (mode & ~O_ACCMODE);
-
- if (fcntl(id, F_SETFL, mode) < 0)
- return (0);
-
- if (lseek(id, 0, SEEK_SET) < 0)
- return (0);
-
- fd->sf_fd = id;
- fd->sf_fmode = mode;
-
- strcpy(fd->sf_path, path);
-
- return (fd);
-}
-
-
-static int
-_nsc_open_path(fd)
-nsc_fd_t *fd;
-{
- struct nscioc_open op;
-
- memset(&op, 0, sizeof (op));
-
- op.flag = fd->sf_flag;
- op.mode = fd->sf_fmode;
- strcpy(op.path, fd->sf_path);
-
- if ((fd->sf_fd = open(_NSC_DEV_PATH, fd->sf_fmode)) < 0)
- return (0);
-
- if (ioctl(fd->sf_fd, NSCIOC_OPEN, &op) == 0)
- return (1);
-
- close(fd->sf_fd);
- return (0);
-}
-
-
-static int
-_nsc_open_check(fd)
-nsc_fd_t *fd;
-{
- struct flock lk;
- char s[30];
- pid_t pid;
- int i;
-
- if ((fd->sf_fmode & O_ACCMODE) == O_RDONLY)
- return (1);
-
- if (access(_NSC_CKDCHK_PATH, X_OK) != 0)
- return (0);
-
- lk.l_type = F_WRLCK;
- lk.l_whence = SEEK_SET;
- lk.l_start = 0;
- lk.l_len = 0;
-
- if (fcntl(fd->sf_fd, F_SETLKW, &lk) < 0)
- return (0);
-
- if ((pid = fork()) == 0) {
- for (i = 1; i <= NSIG; i++)
- signal(i, SIG_IGN);
-
- for (i = fd->sf_fd; i <= 2 && (i = dup(i)) != -1; )
- fd->sf_fd = i;
-
- for (i = sysconf(_SC_OPEN_MAX); i >= 0; i--)
- if (i != fd->sf_fd)
- close(i);
-
- fcntl(fd->sf_fd, F_SETFD, 0);
-
- (void) open("/dev/null", 0);
- (void) open(_NSC_CKDCHK_LOG, O_WRONLY|O_CREAT|O_APPEND, 0666);
- (void) open(_NSC_CKDCHK_LOG, O_WRONLY|O_CREAT|O_APPEND, 0666);
-
- (void) sprintf(s, "%d", fd->sf_fd);
-
- (void) execl(_NSC_CKDCHK_PATH, "ckdchk", "-u", "-F",
- s, fd->sf_path, 0);
-
- exit(1);
- }
-
- return (pid != -1);
-}
-
-
-int
-nsc_close(fd)
-nsc_fd_t *fd;
-{
- int rc;
-
- if (!fd)
- return (0);
-
- rc = close(fd->sf_fd);
- free(fd);
-
- return (rc);
-}
-
-
-int
-nsc_reserve(fd)
-nsc_fd_t *fd;
-{
- return ((fd) ? ioctl(fd->sf_fd, NSCIOC_RESERVE, 0) : 0);
-}
-
-
-int
-nsc_release(fd)
-nsc_fd_t *fd;
-{
- if (!fd)
- return (0);
-
- if (ckdchk && (fd->sf_fmode & O_ACCMODE) != O_RDONLY) {
- errno = EINVAL;
- return (-1);
- }
-
- return (ioctl(fd->sf_fd, NSCIOC_RELEASE, 0));
-}
-
-
-int
-nsc_partsize(nsc_fd_t *fd, nsc_size_t *rvp)
-{
- struct nscioc_partsize partsize;
- int rc;
-
- if (!fd)
- return (0);
-
- rc = ioctl(fd->sf_fd, NSCIOC_PARTSIZE, &partsize);
- if (rc != 0) {
- return (rc);
- }
-
- *rvp = (nsc_size_t)partsize.partsize;
- return (0);
-}
-
-
-int
-nsc_fileno(fd)
-nsc_fd_t *fd;
-{
- return ((fd) ? fd->sf_fd : -1);
-}
-
-
-void
-_nsc_nocheck()
-{
- ckdchk = 0;
-}
-
-
-static int
-_nsc_do_ioctl(cmd, arg)
-int cmd;
-void *arg;
-{
- int fd, rc, save_errno;
-
- fd = open(_NSC_DEV_PATH, O_RDONLY);
- if (fd < 0)
- return (-1);
-
- rc = save_errno = 0;
- rc = ioctl(fd, cmd, arg);
- if (rc < 0)
- save_errno = errno;
-
- close(fd);
-
- errno = save_errno;
- return (rc);
-}
-
-
-/*
- * int
- * nsc_freeze(char *path)
- * Freeze a pathname
- *
- * Calling/Exit State:
- * Returns 0 for success, or -1 and sets errno.
- *
- * Description:
- * This is the user level interface to the nsctl freeze operation.
- * See uts/common/ns/nsctl/nsc_freeze.c for more information.
- */
-int
-nsc_freeze(path)
-char *path;
-{
- if (strlen(path) >= NSC_MAXPATH) {
- errno = ENAMETOOLONG;
- return (-1);
- }
-
- return (_nsc_do_ioctl(NSCIOC_FREEZE, path));
-}
-
-/*
- * int
- * nsc_unfreeze(char *path)
- * Unfreeze a pathname
- *
- * Calling/Exit State:
- * Returns 0 for success, or -1 and sets errno.
- *
- * Description:
- * This is the user level interface to the nsctl unfreeze operation.
- * See uts/common/ns/nsctl/nsc_freeze.c for more information.
- */
-int
-nsc_unfreeze(path)
-char *path;
-{
- if (strlen(path) >= NSC_MAXPATH) {
- errno = ENAMETOOLONG;
- return (-1);
- }
-
- return (_nsc_do_ioctl(NSCIOC_UNFREEZE, path));
-}
-
-
-/*
- * int
- * nsc_isfrozen(char *path)
- * Test if a pathname is frozen
- *
- * Calling/Exit State:
- * Returns:
- * 0 path is frozen
- * 1 path is not frozen
- * -1 error (errno will be set)
- *
- * Description
- * This is the user level interface to to the nsctl isfrozen operation.
- * See uts/common/ns/nsctl/nsc_freeze.c for more information.
- */
-int
-nsc_isfrozen(path)
-char *path;
-{
- if (strlen(path) >= NSC_MAXPATH) {
- errno = ENAMETOOLONG;
- return (-1);
- }
-
- return (_nsc_do_ioctl(NSCIOC_ISFROZEN, path));
-}
-
-int
-nsc_gmem_sizes(int *size)
-{
- return (_nsc_do_ioctl(NSCIOC_GLOBAL_SIZES, size));
-}
-
-int
-nsc_gmem_data(char *addr)
-{
- return (_nsc_do_ioctl(NSCIOC_GLOBAL_DATA, addr));
-}
-
-/*
- * int
- * nsc_nvclean()
- * mark nvmem clean, to prevent a warmstart of the cache on reboot
- */
-int
-nsc_nvclean(int force)
-{
- int cmd;
-
- cmd = force ? NSCIOC_NVMEM_CLEANF : NSCIOC_NVMEM_CLEAN;
-
- return (_nsc_do_ioctl(cmd, (void *)0));
-}
diff --git a/usr/src/lib/libnsctl/common/hash.c b/usr/src/lib/libnsctl/common/hash.c
deleted file mode 100644
index 1cc7e8f257..0000000000
--- a/usr/src/lib/libnsctl/common/hash.c
+++ /dev/null
@@ -1,166 +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 <string.h>
-#include <stdlib.h>
-#include <sys/nsctl/nsc_hash.h>
-
-#define HASH_PRIME 2039
-
-static int calc_hash(const char *);
-
-hash_node_t **
-nsc_create_hash()
-{
- hash_node_t **hash;
-
- hash = (hash_node_t **)calloc(HASH_PRIME, sizeof (hash_node_t *));
- return (hash);
-}
-
-int
-nsc_insert_node(hash_node_t **hash, void *data, const char *key)
-{
- int index;
- hash_node_t *node;
-
- node = (hash_node_t *)malloc(sizeof (hash_node_t));
- if (!node) {
- return (-1);
- }
- node->key = strdup(key);
- node->data = data;
-
- /*
- * possible enhancement would be to search
- * in this index for a duplicate
- */
- index = calc_hash(key);
- node->next = hash[ index ];
- hash[ index ] = node;
-
- return (0);
-}
-
-/*
- * lookup
- *
- * Description:
- * Searches the hash to find a node.
- *
- * Return values:
- * 0 if not found.
- * pointer to node if found.
- */
-void *
-nsc_lookup(hash_node_t **hash, const char *key)
-{
- int index;
- hash_node_t *node;
-
- index = calc_hash(key);
- node = hash[ index ];
- while (node) {
- if (strcmp(node->key, key) == 0)
- return (node->data);
- node = node->next;
- }
- return (0);
-}
-
-void *
-nsc_remove_node(hash_node_t **hash, char *key)
-{
- int index;
- hash_node_t *node, *prev;
- void *retval;
-
- index = calc_hash(key);
- if (!hash[ index ]) {
- return (0);
- }
-
- if (strcmp(hash[ index ]->key, key) == 0) {
- node = hash[ index ];
- retval = node->data;
- hash[ index ] = hash[ index ]->next;
- free(node->key);
- free(node);
- return (retval);
- }
- prev = hash[ index ];
- node = prev->next;
- while (node && (strcmp(node->key, key) != 0)) {
- prev = node;
- node = node->next;
- }
-
- /* did we find it? */
- if (node) {
- prev->next = node->next;
- retval = node->data;
- free(node->key);
- free(node);
- return (retval);
- }
- return (0);
-}
-
-void
-nsc_remove_all(hash_node_t **hash, void (*callback)(void *))
-{
- int i;
- hash_node_t *p, *next;
-
- for (i = 0; i < HASH_PRIME; i++) {
- p = hash[ i ];
- while (p) {
- next = p->next;
- if (callback) {
- callback(p->data);
- }
- free(p->key);
- free(p);
- p = next;
- }
- }
- free(hash);
-}
-
-/* ---------------------------------------------------------------------- */
-
-/*
- * Basic rotating hash, as per Knuth.
- */
-static int
-calc_hash(const char *key)
-{
- unsigned int hash, i;
- int len = strlen(key);
- for (hash = len, i = 0; i < len; i++) {
- hash = (hash << 5) ^ (hash >> 27) ^ key[ i ];
- }
- return (hash % HASH_PRIME);
-}
diff --git a/usr/src/lib/libnsctl/common/libnsctl.h b/usr/src/lib/libnsctl/common/libnsctl.h
deleted file mode 100644
index abd165ce42..0000000000
--- a/usr/src/lib/libnsctl/common/libnsctl.h
+++ /dev/null
@@ -1,62 +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 _LIBNSCTL_H
-#define _LIBNSCTL_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <sys/nsctl/nsctl.h>
-#include <sys/nsctl/nsc_ioctl.h>
-
-
-/*
- * Standard Definitions.
- */
-
-#ifdef sun
-#define _NSC_DEV_PATH "/dev/nsctl"
-#else
-#define _NSC_DEV_PATH "/dev/sd"
-#endif
-#define _NSC_CKDCHK_PATH "/usr/install/simckd/bin/ckdchk"
-#define _NSC_CKDCHK_LOG "/rsvd/dumps/ckdchk.log"
-
-
-typedef struct nsc_fd_s {
- int sf_fd; /* SD device */
- int sf_flag; /* Open flags */
- int sf_fmode; /* File modes */
- char sf_path[NSC_MAXPATH]; /* Pathname */
-} nsc_fd_t;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _LIBNSCTL_H */
diff --git a/usr/src/lib/libnsctl/common/llib-lnsctl b/usr/src/lib/libnsctl/common/llib-lnsctl
deleted file mode 100644
index 7defea0425..0000000000
--- a/usr/src/lib/libnsctl/common/llib-lnsctl
+++ /dev/null
@@ -1,52 +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
- */
-/* LINTLIBRARY */
-/* PROTOLIB1 */
-
-/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#include <sys/types.h>
-#include <nsctl.h>
-#include <sys/nsctl/nsc_hash.h>
-
-void _nsc_nocheck(void);
-nsc_fd_t *nsc_open(char *path, int flag, int mode);
-nsc_fd_t *nsc_fdopen(int id, char *path, int mode);
-int nsc_close(nsc_fd_t *fd);
-int nsc_fileno(nsc_fd_t *fd);
-int nsc_reserve(nsc_fd_t *fd);
-int nsc_release(nsc_fd_t *fd);
-int nsc_partsize(nsc_fd_t *fd, nsc_size_t *size);
-int nsc_freeze(char *path);
-int nsc_unfreeze(char *path);
-int nsc_isfrozen(char *path);
-int nsc_getsystemid(int *id);
-int nsc_name_to_id(char *name, int *id);
-int nsc_id_to_name(char **name, int id);
-int nsc_check_release(const char *build_rel, nsc_release_t *map, char **reqd);
-hash_node_t **nsc_create_hash();
-int nsc_insert_node(hash_node_t **, void *, const char *);
-void *nsc_lookup(hash_node_t **, const char *);
-void *nsc_remove_node(hash_node_t **, char *);
-void nsc_remove_all(hash_node_t **, void (*)(void *));
diff --git a/usr/src/lib/libnsctl/common/machdep.c b/usr/src/lib/libnsctl/common/machdep.c
deleted file mode 100644
index d577995ad1..0000000000
--- a/usr/src/lib/libnsctl/common/machdep.c
+++ /dev/null
@@ -1,314 +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 <sys/types.h>
-#include <sys/utsname.h>
-#include <fcntl.h>
-#include <sys/param.h>
-#include <unistd.h>
-#include <stdarg.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "libnsctl.h"
-#include <nsctl.h>
-#include <sys/ncall/ncall.h>
-
-
-
-/*
- * Internal routine to fetch all the current nodes that are
- * considered 'up'.
- * Returns the number of ncall_info structures that are valid
- * returned via the nodelist pointer, or -1 on an error.
- * If the call succeeds, then the memory returned via the
- * nodelist pointer needs to be freed by the caller.
- */
-
-static int
-nsc_getcurrentnodes(ncall_node_t **nodelist)
-{
- ncall_node_t *mynodelist;
- int size;
- int fd;
- int rc = -1;
- int save_errno = 0;
- int ioctlcmd;
-
- if (nodelist == NULL) {
- errno = EINVAL;
- return (-1);
- }
- *nodelist = NULL;
- if ((fd = open("/dev/ncall", O_RDONLY)) < 0) {
- return (-1);
- }
- if ((size = ioctl(fd, NC_IOC_GETNETNODES, NULL)) < 1) {
- size = 1;
- ioctlcmd = NC_IOC_GETNODE;
- } else {
- ioctlcmd = NC_IOC_GETNETNODES;
- }
-
- mynodelist = malloc(size * sizeof (*mynodelist));
- if (mynodelist == NULL) {
- save_errno = ENOMEM;
- } else {
- rc = ioctl(fd, ioctlcmd, mynodelist);
- if (rc < 0) {
- save_errno = errno;
- free(mynodelist);
- } else {
- /* fixup return value for single node ioctl */
- if (ioctlcmd == NC_IOC_GETNODE)
- rc = 1;
- *nodelist = mynodelist;
- }
- }
- close(fd);
- errno = save_errno;
- return (rc);
-}
-
-
-/*
- * return the system id (the current value in the kernel
- * currently running).
- *
- * on error return -1 and set errno.
- */
-int
-nsc_getsystemid(int *id)
-{
- ncall_node_t node;
- int rval = 0;
- int save_errno = 0;
- int fd;
-
- *id = 0;
-
- fd = open("/dev/ncall", O_RDONLY);
- if (fd < 0)
- return (-1);
-
- memset(&node, 0, sizeof (node));
-
- rval = ioctl(fd, NC_IOC_GETNODE, &node);
- if (rval < 0)
- save_errno = errno;
- else {
- *id = node.nc_nodeid;
- /*
- * Return 0, not the mirror node id as returned
- * from the ioctl.
- */
- rval = 0;
- }
-
- close(fd);
-
- errno = save_errno;
- return (rval);
-}
-
-
-/*
- * Runtime Solaris release checking.
- *
- * Compare the build release to the runtime release to check for an
- * acceptable match.
- *
- * Arguments:
- * build_ver - the string Solaris build release (e.g. "5.8")
- * map - optional array of nsc_release_t defining
- * acceptable build release / runtime release
- * matches. If supplied, must end will a NULL
- * array element. See src/head/nsctl.h for info.
- * reqd - used to return the required OS versions if the
- * return value is not -1. The returned string
- * is readonly.
- *
- * Returns:
- * TRUE - acceptable match
- * FALSE - no match (component should not continue to run)
- * -1 - error (errno is set)
- */
-
-int
-nsc_check_release(const char *build_rel, nsc_release_t *map, char **reqd)
-{
- struct utsname uts;
- nsc_release_t *mp;
- const char *sep = ", ";
- char *cp, *tofree, *last;
- int rc;
-
- if (reqd)
- *reqd = NULL;
-
- if (build_rel == NULL || *build_rel == '\0') {
- errno = EINVAL;
- return (-1);
- }
-
- /* assume that build_rel is the required release for now */
- if (reqd)
- *reqd = (char *)build_rel;
-
- if (uname(&uts) < 0)
- return (-1);
-
- /* build release == runtime release is always acceptable */
- if (strcmp(build_rel, uts.release) == 0)
- return (TRUE);
-
- if (map == NULL)
- return (FALSE);
-
- rc = FALSE;
- tofree = NULL;
-
- for (mp = map; mp->build != NULL && mp->runtime != NULL; mp++) {
- if (strcmp(mp->build, build_rel) == 0) {
- /*
- * found an entry for this build release
- * - search for a match in the runtime releases
- */
-
- /* reset reqd to this entry */
- if (reqd)
- *reqd = (char *)mp->runtime;
-
- /*
- * operate on a copy of the string since strtok
- * is destructive.
- */
- tofree = cp = strdup(mp->runtime);
- if (cp == NULL) {
- errno = ENOMEM;
- rc = -1;
- break;
- }
-
- cp = strtok_r(cp, sep, &last);
- while (cp != NULL) {
- if (strcmp(cp, uts.release) == 0) {
- rc = TRUE;
- break;
- }
-
- cp = strtok_r(NULL, sep, &last);
- }
-
- break;
- }
- }
-
- if (tofree)
- free(tofree);
-
- return (rc);
-}
-
-
-/*
- * return the system id corresponding to name
- *
- * on error return -1 and set errno.
- */
-int
-nsc_name_to_id(char *name, int *id)
-{
- ncall_node_t *nodes;
- int rval = 0;
- int nodecnt;
- int slot;
-
- *id = 0;
-
- nodecnt = nsc_getcurrentnodes(&nodes);
- if (nodecnt < 0) {
- rval = -1;
- } else {
- for (slot = 0; slot < nodecnt; slot++) {
- if (strcmp(name, nodes[slot].nc_nodename) == 0) {
- *id = nodes[slot].nc_nodeid;
- break;
- }
- }
- if (slot >= nodecnt) {
- errno = ENOENT;
- rval = -1;
- }
- free(nodes);
- }
- return (rval);
-}
-
-/*
- * return the node name corresponding to system id
- *
- * on error return -1 and set errno.
- * The returned string has been strdup() and needs
- * to be freed by the caller.
- */
-int
-nsc_id_to_name(char **name, int id)
-{
- ncall_node_t *nodes;
- int rval = 0;
- int nodecnt;
- int slot;
- char *foundname;
-
- *name = 0;
- foundname = NULL;
-
- nodecnt = nsc_getcurrentnodes(&nodes);
- if (nodecnt < 0) {
- rval = -1;
- } else {
- for (slot = 0; slot < nodecnt; slot++) {
- if (nodes[slot].nc_nodeid == id) {
- foundname = strdup(nodes[slot].nc_nodename);
- if (foundname) {
- *name = foundname;
- } else {
- errno = ENOMEM;
- rval = -1;
- }
- break;
- }
- }
- if (slot >= nodecnt) {
- errno = ENOENT;
- rval = -1;
- }
- free(nodes);
- }
- return (rval);
-}
diff --git a/usr/src/lib/libnsctl/common/mapfile-vers b/usr/src/lib/libnsctl/common/mapfile-vers
deleted file mode 100644
index eb399179e2..0000000000
--- a/usr/src/lib/libnsctl/common/mapfile-vers
+++ /dev/null
@@ -1,70 +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 (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
-#
-
-#
-# MAPFILE HEADER START
-#
-# WARNING: STOP NOW. DO NOT MODIFY THIS FILE.
-# Object versioning must comply with the rules detailed in
-#
-# usr/src/lib/README.mapfiles
-#
-# You should not be making modifications here until you've read the most current
-# copy of that file. If you need help, contact a gatekeeper for guidance.
-#
-# MAPFILE HEADER END
-#
-
-$mapfile_version 2
-
-#
-# Generic interface definition for usr/src/lib/libnsctl.
-#
-
-SYMBOL_VERSION SUNWprivate_1.1 {
- global:
- _nsc_nocheck;
- nsc_check_release;
- nsc_close;
- nsc_fdopen;
- nsc_fileno;
- nsc_freeze;
- nsc_getsystemid;
- nsc_gmem_data;
- nsc_gmem_sizes;
- nsc_id_to_name;
- nsc_isfrozen;
- nsc_name_to_id;
- nsc_nvclean;
- nsc_open;
- nsc_partsize;
- nsc_release;
- nsc_reserve;
- nsc_unfreeze;
- nsc_create_hash;
- nsc_insert_node;
- nsc_lookup;
- nsc_remove_node;
- nsc_remove_all;
- local:
- *;
-};
diff --git a/usr/src/lib/libnsctl/common/nsc_hash.h b/usr/src/lib/libnsctl/common/nsc_hash.h
deleted file mode 100644
index 80cf846861..0000000000
--- a/usr/src/lib/libnsctl/common/nsc_hash.h
+++ /dev/null
@@ -1,49 +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 _NSC_HASH_H
-#define _NSC_HASH_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct hash_node_s {
- struct hash_node_s *next;
- char *key;
- void *data;
-} hash_node_t;
-
-hash_node_t **nsc_create_hash();
-int nsc_insert_node(hash_node_t **, void *, const char *);
-void *nsc_lookup(hash_node_t **, const char *);
-void *nsc_remove_node(hash_node_t **, char *);
-void nsc_remove_all(hash_node_t **, void (*)(void *));
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _NSC_HASH_H */