17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*19397407SSherry Moore * Common Development and Distribution License (the "License"). 6*19397407SSherry Moore * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*19397407SSherry Moore * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #include <sys/types.h> 287c478bd9Sstevel@tonic-gate #include <sys/file.h> 297c478bd9Sstevel@tonic-gate #include <sys/errno.h> 307c478bd9Sstevel@tonic-gate #include <sys/open.h> 317c478bd9Sstevel@tonic-gate #include <sys/cred.h> 327c478bd9Sstevel@tonic-gate #include <sys/conf.h> 337c478bd9Sstevel@tonic-gate #include <sys/modctl.h> 347c478bd9Sstevel@tonic-gate #include <sys/stat.h> 357c478bd9Sstevel@tonic-gate #include <sys/ddi.h> 367c478bd9Sstevel@tonic-gate #include <sys/sunddi.h> 377c478bd9Sstevel@tonic-gate #include <sys/policy.h> 387c478bd9Sstevel@tonic-gate #include <sys/pool.h> 397c478bd9Sstevel@tonic-gate #include <sys/pool_impl.h> 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate /* 427c478bd9Sstevel@tonic-gate * The kernel pools subsystem is accessed and manipulated through the pool 437c478bd9Sstevel@tonic-gate * device, which has two minor nodes /dev/pool, and /dev/poolctl. User 447c478bd9Sstevel@tonic-gate * processes can comminicate with pools through ioctls on these devices. 457c478bd9Sstevel@tonic-gate * 467c478bd9Sstevel@tonic-gate * The poolctl device (POOL_CTL_PARENT) can be used to modify and take 477c478bd9Sstevel@tonic-gate * snapshot of the current configuration. Only one process on the system 487c478bd9Sstevel@tonic-gate * can have it open at any given time. This device is also used to enable 497c478bd9Sstevel@tonic-gate * or disable pools. If pools are disabled, the pool driver can be unloaded 507c478bd9Sstevel@tonic-gate * and completely removed from the system. 517c478bd9Sstevel@tonic-gate * 527c478bd9Sstevel@tonic-gate * The pool "info" device (POOL_INFO_PARENT) can only be used to obtain 537c478bd9Sstevel@tonic-gate * snapshots of the current configuration and change/query pool bindings. 547c478bd9Sstevel@tonic-gate * While some reconfiguration transaction via the poolctl device is in 557c478bd9Sstevel@tonic-gate * progress, all processes using this "info" device will be provided with 567c478bd9Sstevel@tonic-gate * the snapshot taken at the beginning of that transaction. 577c478bd9Sstevel@tonic-gate */ 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate #define POOL_CTL_PARENT 0 607c478bd9Sstevel@tonic-gate #define POOL_INFO_PARENT 1 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate static dev_info_t *pool_devi; /* pool device information */ 637c478bd9Sstevel@tonic-gate static int pool_openctl; /* poolctl device is already open */ 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 667c478bd9Sstevel@tonic-gate static int 677c478bd9Sstevel@tonic-gate pool_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result) 687c478bd9Sstevel@tonic-gate { 697c478bd9Sstevel@tonic-gate int error = DDI_FAILURE; 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate switch (infocmd) { 727c478bd9Sstevel@tonic-gate case DDI_INFO_DEVT2DEVINFO: 737c478bd9Sstevel@tonic-gate *result = pool_devi; 747c478bd9Sstevel@tonic-gate error = DDI_SUCCESS; 757c478bd9Sstevel@tonic-gate break; 767c478bd9Sstevel@tonic-gate case DDI_INFO_DEVT2INSTANCE: 777c478bd9Sstevel@tonic-gate /* 787c478bd9Sstevel@tonic-gate * All dev_t's map to the same, single instance. 797c478bd9Sstevel@tonic-gate */ 807c478bd9Sstevel@tonic-gate *result = NULL; 817c478bd9Sstevel@tonic-gate error = DDI_SUCCESS; 827c478bd9Sstevel@tonic-gate break; 837c478bd9Sstevel@tonic-gate default: 847c478bd9Sstevel@tonic-gate break; 857c478bd9Sstevel@tonic-gate } 867c478bd9Sstevel@tonic-gate return (error); 877c478bd9Sstevel@tonic-gate } 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate static int 907c478bd9Sstevel@tonic-gate pool_detach(dev_info_t *devi, ddi_detach_cmd_t cmd) 917c478bd9Sstevel@tonic-gate { 927c478bd9Sstevel@tonic-gate int ret = DDI_SUCCESS; 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate switch (cmd) { 957c478bd9Sstevel@tonic-gate case DDI_DETACH: 967c478bd9Sstevel@tonic-gate pool_lock(); 977c478bd9Sstevel@tonic-gate if (pool_state == POOL_ENABLED) { 987c478bd9Sstevel@tonic-gate ret = DDI_FAILURE; 997c478bd9Sstevel@tonic-gate pool_unlock(); 1007c478bd9Sstevel@tonic-gate break; 1017c478bd9Sstevel@tonic-gate } 1027c478bd9Sstevel@tonic-gate ddi_remove_minor_node(devi, NULL); 1037c478bd9Sstevel@tonic-gate pool_devi = NULL; 1047c478bd9Sstevel@tonic-gate pool_unlock(); 1057c478bd9Sstevel@tonic-gate break; 1067c478bd9Sstevel@tonic-gate default: 1077c478bd9Sstevel@tonic-gate ret = DDI_FAILURE; 1087c478bd9Sstevel@tonic-gate } 1097c478bd9Sstevel@tonic-gate return (ret); 1107c478bd9Sstevel@tonic-gate } 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate static int 1137c478bd9Sstevel@tonic-gate pool_attach(dev_info_t *devi, ddi_attach_cmd_t cmd) 1147c478bd9Sstevel@tonic-gate { 1157c478bd9Sstevel@tonic-gate switch (cmd) { 1167c478bd9Sstevel@tonic-gate case DDI_ATTACH: 1177c478bd9Sstevel@tonic-gate if (pool_devi != NULL) 1187c478bd9Sstevel@tonic-gate return (DDI_FAILURE); 1197c478bd9Sstevel@tonic-gate if (ddi_create_minor_node(devi, "poolctl", S_IFCHR, 1207c478bd9Sstevel@tonic-gate POOL_CTL_PARENT, DDI_PSEUDO, 0) == DDI_FAILURE || 1217c478bd9Sstevel@tonic-gate ddi_create_minor_node(devi, "pool", S_IFCHR, 1227c478bd9Sstevel@tonic-gate POOL_INFO_PARENT, DDI_PSEUDO, 0) == DDI_FAILURE) { 1237c478bd9Sstevel@tonic-gate ddi_remove_minor_node(devi, NULL); 1247c478bd9Sstevel@tonic-gate return (DDI_FAILURE); 1257c478bd9Sstevel@tonic-gate } 1267c478bd9Sstevel@tonic-gate pool_devi = devi; 1277c478bd9Sstevel@tonic-gate ddi_report_dev(devi); 1287c478bd9Sstevel@tonic-gate break; 1297c478bd9Sstevel@tonic-gate case DDI_RESUME: 1307c478bd9Sstevel@tonic-gate break; 1317c478bd9Sstevel@tonic-gate default: 1327c478bd9Sstevel@tonic-gate return (DDI_FAILURE); 1337c478bd9Sstevel@tonic-gate } 1347c478bd9Sstevel@tonic-gate return (DDI_SUCCESS); 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate } 1377c478bd9Sstevel@tonic-gate 1387c478bd9Sstevel@tonic-gate /* 1397c478bd9Sstevel@tonic-gate * There is only one instance of the pool control device, poolctl, 1407c478bd9Sstevel@tonic-gate * and multiple instances of the pool info device, pool. 1417c478bd9Sstevel@tonic-gate */ 1427c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 1437c478bd9Sstevel@tonic-gate static int 1447c478bd9Sstevel@tonic-gate pool_open(dev_t *devp, int flag, int otype, cred_t *credp) 1457c478bd9Sstevel@tonic-gate { 1467c478bd9Sstevel@tonic-gate minor_t minor = getminor(*devp); 1477c478bd9Sstevel@tonic-gate 1487c478bd9Sstevel@tonic-gate if (otype != OTYP_CHR) 1497c478bd9Sstevel@tonic-gate return (EINVAL); 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gate switch (minor) { 1527c478bd9Sstevel@tonic-gate case POOL_CTL_PARENT: 1537c478bd9Sstevel@tonic-gate if (secpolicy_pool(CRED()) != 0) 1547c478bd9Sstevel@tonic-gate return (EPERM); 1557c478bd9Sstevel@tonic-gate if (pool_lock_intr() != 0) 1567c478bd9Sstevel@tonic-gate return (EINTR); 1577c478bd9Sstevel@tonic-gate if (pool_openctl == 1) { 1587c478bd9Sstevel@tonic-gate pool_unlock(); 1597c478bd9Sstevel@tonic-gate return (EBUSY); 1607c478bd9Sstevel@tonic-gate } 1617c478bd9Sstevel@tonic-gate pool_openctl = 1; 1627c478bd9Sstevel@tonic-gate pool_unlock(); 1637c478bd9Sstevel@tonic-gate break; 1647c478bd9Sstevel@tonic-gate case POOL_INFO_PARENT: 1657c478bd9Sstevel@tonic-gate break; 1667c478bd9Sstevel@tonic-gate default: 1677c478bd9Sstevel@tonic-gate return (ENXIO); 1687c478bd9Sstevel@tonic-gate } 1697c478bd9Sstevel@tonic-gate return (0); 1707c478bd9Sstevel@tonic-gate } 1717c478bd9Sstevel@tonic-gate 1727c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 1737c478bd9Sstevel@tonic-gate static int 1747c478bd9Sstevel@tonic-gate pool_close(dev_t dev, int flag, int otype, cred_t *credp) 1757c478bd9Sstevel@tonic-gate { 1767c478bd9Sstevel@tonic-gate if (otype != OTYP_CHR) 1777c478bd9Sstevel@tonic-gate return (EINVAL); 1787c478bd9Sstevel@tonic-gate if (getminor(dev) == 0) { 1797c478bd9Sstevel@tonic-gate /* 1807c478bd9Sstevel@tonic-gate * We could be closing the poolctl device without finishing 1817c478bd9Sstevel@tonic-gate * the commit transaction first, so do that now. 1827c478bd9Sstevel@tonic-gate */ 1837c478bd9Sstevel@tonic-gate pool_lock(); 1847c478bd9Sstevel@tonic-gate (void) pool_commit(0); /* cannot fail since arg is 0 */ 1857c478bd9Sstevel@tonic-gate pool_openctl = 0; 1867c478bd9Sstevel@tonic-gate pool_unlock(); 1877c478bd9Sstevel@tonic-gate } 1887c478bd9Sstevel@tonic-gate return (0); 1897c478bd9Sstevel@tonic-gate } 1907c478bd9Sstevel@tonic-gate 1917c478bd9Sstevel@tonic-gate /* 1927c478bd9Sstevel@tonic-gate * Main pool interface. 1937c478bd9Sstevel@tonic-gate */ 1947c478bd9Sstevel@tonic-gate /* ARGSUSED4 */ 1957c478bd9Sstevel@tonic-gate static int 1967c478bd9Sstevel@tonic-gate pool_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *credp, 1977c478bd9Sstevel@tonic-gate int *rvalp) 1987c478bd9Sstevel@tonic-gate { 1997c478bd9Sstevel@tonic-gate pool_xtransfer_t xtransfer; 2007c478bd9Sstevel@tonic-gate pool_transfer_t transfer; 2017c478bd9Sstevel@tonic-gate pool_destroy_t destroy; 2027c478bd9Sstevel@tonic-gate pool_propget_t propget; 2037c478bd9Sstevel@tonic-gate pool_propput_t propput; 2047c478bd9Sstevel@tonic-gate pool_proprm_t proprm; 2057c478bd9Sstevel@tonic-gate pool_status_t status; 2067c478bd9Sstevel@tonic-gate pool_dissoc_t dissoc; 2077c478bd9Sstevel@tonic-gate pool_create_t create; 2087c478bd9Sstevel@tonic-gate pool_assoc_t assoc; 2097c478bd9Sstevel@tonic-gate pool_bindq_t bindq; 2107c478bd9Sstevel@tonic-gate pool_query_t query; 2117c478bd9Sstevel@tonic-gate pool_bind_t bind; 2127c478bd9Sstevel@tonic-gate #ifdef _MULTI_DATAMODEL 2137c478bd9Sstevel@tonic-gate pool_xtransfer32_t xtransfer32; 2147c478bd9Sstevel@tonic-gate pool_propput32_t propput32; 2157c478bd9Sstevel@tonic-gate pool_propget32_t propget32; 2167c478bd9Sstevel@tonic-gate pool_proprm32_t proprm32; 2177c478bd9Sstevel@tonic-gate pool_query32_t query32; 2187c478bd9Sstevel@tonic-gate #endif /* _MULTI_DATAMODEL */ 2197c478bd9Sstevel@tonic-gate char *kbuf = NULL; 2207c478bd9Sstevel@tonic-gate size_t kbufsz = 0; 2217c478bd9Sstevel@tonic-gate int snapshot = 0; 2227c478bd9Sstevel@tonic-gate char *prop_name; 2237c478bd9Sstevel@tonic-gate size_t size = 0; 2247c478bd9Sstevel@tonic-gate nvlist_t *list; 2257c478bd9Sstevel@tonic-gate nvpair_t *pair; 2267c478bd9Sstevel@tonic-gate char *listbuf; 2277c478bd9Sstevel@tonic-gate minor_t minor; 2287c478bd9Sstevel@tonic-gate uint_t model; 2297c478bd9Sstevel@tonic-gate id_t *id_buf; 2307c478bd9Sstevel@tonic-gate int ret = 0; 2317c478bd9Sstevel@tonic-gate 2327c478bd9Sstevel@tonic-gate model = ddi_model_convert_from(mode & FMODELS); 2337c478bd9Sstevel@tonic-gate minor = getminor(dev); 2347c478bd9Sstevel@tonic-gate 2357c478bd9Sstevel@tonic-gate /* 2367c478bd9Sstevel@tonic-gate * Check basic permissions first. 2377c478bd9Sstevel@tonic-gate */ 2387c478bd9Sstevel@tonic-gate switch (cmd) { 2397c478bd9Sstevel@tonic-gate case POOL_STATUS: 2407c478bd9Sstevel@tonic-gate case POOL_CREATE: 2417c478bd9Sstevel@tonic-gate case POOL_ASSOC: 2427c478bd9Sstevel@tonic-gate case POOL_DISSOC: 2437c478bd9Sstevel@tonic-gate case POOL_DESTROY: 2447c478bd9Sstevel@tonic-gate case POOL_TRANSFER: 2457c478bd9Sstevel@tonic-gate case POOL_XTRANSFER: 2467c478bd9Sstevel@tonic-gate case POOL_PROPPUT: 2477c478bd9Sstevel@tonic-gate case POOL_PROPRM: 2487c478bd9Sstevel@tonic-gate case POOL_COMMIT: 2497c478bd9Sstevel@tonic-gate if (minor != POOL_CTL_PARENT) 2507c478bd9Sstevel@tonic-gate return (EINVAL); 2517c478bd9Sstevel@tonic-gate /*FALLTHROUGH*/ 2527c478bd9Sstevel@tonic-gate case POOL_BIND: 2537c478bd9Sstevel@tonic-gate if (secpolicy_pool(CRED()) != 0) 2547c478bd9Sstevel@tonic-gate return (EPERM); 2557c478bd9Sstevel@tonic-gate break; 2567c478bd9Sstevel@tonic-gate } 2577c478bd9Sstevel@tonic-gate 2587c478bd9Sstevel@tonic-gate switch (cmd) { 2597c478bd9Sstevel@tonic-gate case POOL_STATUS: 2607c478bd9Sstevel@tonic-gate if (ddi_copyin((void *)arg, &status, 2617c478bd9Sstevel@tonic-gate sizeof (pool_status_t), mode) != 0) 2627c478bd9Sstevel@tonic-gate return (EFAULT); 2637c478bd9Sstevel@tonic-gate if (pool_lock_intr() != 0) 2647c478bd9Sstevel@tonic-gate return (EINTR); 2657c478bd9Sstevel@tonic-gate ret = pool_status(status.ps_io_state); 2667c478bd9Sstevel@tonic-gate pool_unlock(); 2677c478bd9Sstevel@tonic-gate break; 2687c478bd9Sstevel@tonic-gate case POOL_STATUSQ: 2697c478bd9Sstevel@tonic-gate /* 2707c478bd9Sstevel@tonic-gate * No need to grab pool_lock() to look at the current state. 2717c478bd9Sstevel@tonic-gate */ 2727c478bd9Sstevel@tonic-gate status.ps_io_state = pool_state; 2737c478bd9Sstevel@tonic-gate if (ddi_copyout(&status, (void *)arg, 2747c478bd9Sstevel@tonic-gate sizeof (pool_status_t), mode) != 0) 2757c478bd9Sstevel@tonic-gate return (EFAULT); 2767c478bd9Sstevel@tonic-gate break; 2777c478bd9Sstevel@tonic-gate case POOL_QUERY: 2787c478bd9Sstevel@tonic-gate switch (model) { 2797c478bd9Sstevel@tonic-gate #ifdef _MULTI_DATAMODEL 2807c478bd9Sstevel@tonic-gate case DDI_MODEL_ILP32: 2817c478bd9Sstevel@tonic-gate if (ddi_copyin((void *)arg, &query32, 2827c478bd9Sstevel@tonic-gate sizeof (pool_query32_t), mode) != 0) 2837c478bd9Sstevel@tonic-gate return (EFAULT); 2847c478bd9Sstevel@tonic-gate query.pq_io_bufsize = query32.pq_io_bufsize; 2857c478bd9Sstevel@tonic-gate query.pq_io_buf = (char *)(uintptr_t)query32.pq_io_buf; 2867c478bd9Sstevel@tonic-gate break; 2877c478bd9Sstevel@tonic-gate #endif /* _MULTI_DATAMODEL */ 2887c478bd9Sstevel@tonic-gate default: 2897c478bd9Sstevel@tonic-gate case DDI_MODEL_NONE: 2907c478bd9Sstevel@tonic-gate if (ddi_copyin((void *)arg, &query, 2917c478bd9Sstevel@tonic-gate sizeof (pool_query_t), mode) != 0) 2927c478bd9Sstevel@tonic-gate return (EFAULT); 2937c478bd9Sstevel@tonic-gate } 2947c478bd9Sstevel@tonic-gate if (pool_lock_intr() != 0) 2957c478bd9Sstevel@tonic-gate return (EINTR); 2967c478bd9Sstevel@tonic-gate if (pool_state == POOL_DISABLED) { 2977c478bd9Sstevel@tonic-gate pool_unlock(); 2987c478bd9Sstevel@tonic-gate return (ENOTACTIVE); 2997c478bd9Sstevel@tonic-gate } 3007c478bd9Sstevel@tonic-gate if (minor != 0 && pool_buf != NULL) { 3017c478bd9Sstevel@tonic-gate /* 3027c478bd9Sstevel@tonic-gate * Return last snapshot if some 3037c478bd9Sstevel@tonic-gate * transaction is still in progress 3047c478bd9Sstevel@tonic-gate */ 3057c478bd9Sstevel@tonic-gate if (kbufsz != 0 && pool_bufsz > kbufsz) { 3067c478bd9Sstevel@tonic-gate pool_unlock(); 3077c478bd9Sstevel@tonic-gate return (ENOMEM); 3087c478bd9Sstevel@tonic-gate } 3097c478bd9Sstevel@tonic-gate kbuf = pool_buf; 3107c478bd9Sstevel@tonic-gate kbufsz = size = pool_bufsz; 3117c478bd9Sstevel@tonic-gate snapshot = 1; 3127c478bd9Sstevel@tonic-gate } else if (query.pq_io_bufsize != 0) { 3137c478bd9Sstevel@tonic-gate kbufsz = query.pq_io_bufsize; 3147c478bd9Sstevel@tonic-gate kbuf = kmem_alloc(kbufsz, KM_NOSLEEP); 3157c478bd9Sstevel@tonic-gate if (kbuf == NULL) { 3167c478bd9Sstevel@tonic-gate pool_unlock(); 3177c478bd9Sstevel@tonic-gate return (ENOMEM); 3187c478bd9Sstevel@tonic-gate } 3197c478bd9Sstevel@tonic-gate ret = pool_pack_conf(kbuf, kbufsz, &size); 3207c478bd9Sstevel@tonic-gate } else { 3217c478bd9Sstevel@tonic-gate ret = pool_pack_conf(NULL, 0, &size); 3227c478bd9Sstevel@tonic-gate } 3237c478bd9Sstevel@tonic-gate if (ret == 0) { 3247c478bd9Sstevel@tonic-gate switch (model) { 3257c478bd9Sstevel@tonic-gate #ifdef _MULTI_DATAMODEL 3267c478bd9Sstevel@tonic-gate case DDI_MODEL_ILP32: 3277c478bd9Sstevel@tonic-gate query32.pq_io_bufsize = size; 3287c478bd9Sstevel@tonic-gate if (ddi_copyout((caddr_t)&query32, (void *)arg, 3297c478bd9Sstevel@tonic-gate sizeof (pool_query32_t), mode) != 0) 3307c478bd9Sstevel@tonic-gate ret = EFAULT; 3317c478bd9Sstevel@tonic-gate break; 3327c478bd9Sstevel@tonic-gate #endif /* _MULTI_DATAMODEL */ 3337c478bd9Sstevel@tonic-gate default: 3347c478bd9Sstevel@tonic-gate case DDI_MODEL_NONE: 3357c478bd9Sstevel@tonic-gate query.pq_io_bufsize = size; 3367c478bd9Sstevel@tonic-gate if (ddi_copyout(&query, (void *)arg, 3377c478bd9Sstevel@tonic-gate sizeof (pool_query_t), mode) != 0) 3387c478bd9Sstevel@tonic-gate ret = EFAULT; 3397c478bd9Sstevel@tonic-gate } 3407c478bd9Sstevel@tonic-gate if (ret == 0 && query.pq_io_buf != NULL && 3417c478bd9Sstevel@tonic-gate ddi_copyout(kbuf, query.pq_io_buf, size, mode) != 0) 3427c478bd9Sstevel@tonic-gate ret = EFAULT; 3437c478bd9Sstevel@tonic-gate } 3447c478bd9Sstevel@tonic-gate pool_unlock(); 3457c478bd9Sstevel@tonic-gate if (snapshot == 0) 3467c478bd9Sstevel@tonic-gate kmem_free(kbuf, kbufsz); 3477c478bd9Sstevel@tonic-gate break; 3487c478bd9Sstevel@tonic-gate case POOL_CREATE: 3497c478bd9Sstevel@tonic-gate if (ddi_copyin((void *)arg, 3507c478bd9Sstevel@tonic-gate &create, sizeof (pool_create_t), mode) != 0) 3517c478bd9Sstevel@tonic-gate return (EFAULT); 3527c478bd9Sstevel@tonic-gate if (pool_lock_intr() != 0) 3537c478bd9Sstevel@tonic-gate return (EINTR); 3547c478bd9Sstevel@tonic-gate ret = pool_create(create.pc_o_type, 3557c478bd9Sstevel@tonic-gate create.pc_o_sub_type, &create.pc_i_id); 3567c478bd9Sstevel@tonic-gate pool_unlock(); 3577c478bd9Sstevel@tonic-gate if (ret == 0 && ddi_copyout(&create, (void *)arg, 3587c478bd9Sstevel@tonic-gate sizeof (pool_create_t), mode) != 0) 3597c478bd9Sstevel@tonic-gate ret = EFAULT; 3607c478bd9Sstevel@tonic-gate break; 3617c478bd9Sstevel@tonic-gate case POOL_ASSOC: 3627c478bd9Sstevel@tonic-gate if (ddi_copyin((void *)arg, &assoc, 3637c478bd9Sstevel@tonic-gate sizeof (pool_assoc_t), mode) != 0) 3647c478bd9Sstevel@tonic-gate return (EFAULT); 3657c478bd9Sstevel@tonic-gate if (pool_lock_intr() != 0) 3667c478bd9Sstevel@tonic-gate return (EINTR); 3677c478bd9Sstevel@tonic-gate ret = pool_assoc(assoc.pa_o_pool_id, 3687c478bd9Sstevel@tonic-gate assoc.pa_o_id_type, assoc.pa_o_res_id); 3697c478bd9Sstevel@tonic-gate pool_unlock(); 3707c478bd9Sstevel@tonic-gate break; 3717c478bd9Sstevel@tonic-gate case POOL_DISSOC: 3727c478bd9Sstevel@tonic-gate if (ddi_copyin((void *)arg, &dissoc, 3737c478bd9Sstevel@tonic-gate sizeof (pool_dissoc_t), mode) != 0) 3747c478bd9Sstevel@tonic-gate return (EFAULT); 3757c478bd9Sstevel@tonic-gate if (pool_lock_intr() != 0) 3767c478bd9Sstevel@tonic-gate return (EINTR); 3777c478bd9Sstevel@tonic-gate ret = pool_dissoc(dissoc.pd_o_pool_id, dissoc.pd_o_id_type); 3787c478bd9Sstevel@tonic-gate pool_unlock(); 3797c478bd9Sstevel@tonic-gate break; 3807c478bd9Sstevel@tonic-gate case POOL_DESTROY: 3817c478bd9Sstevel@tonic-gate if (ddi_copyin((void *)arg, &destroy, 3827c478bd9Sstevel@tonic-gate sizeof (pool_destroy_t), mode) != 0) 3837c478bd9Sstevel@tonic-gate return (EFAULT); 3847c478bd9Sstevel@tonic-gate if (pool_lock_intr() != 0) 3857c478bd9Sstevel@tonic-gate return (EINTR); 3867c478bd9Sstevel@tonic-gate ret = pool_destroy(destroy.pd_o_type, destroy.pd_o_sub_type, 3877c478bd9Sstevel@tonic-gate destroy.pd_o_id); 3887c478bd9Sstevel@tonic-gate pool_unlock(); 3897c478bd9Sstevel@tonic-gate break; 3907c478bd9Sstevel@tonic-gate case POOL_TRANSFER: 3917c478bd9Sstevel@tonic-gate if (ddi_copyin((void *)arg, &transfer, 3927c478bd9Sstevel@tonic-gate sizeof (pool_transfer_t), mode) != 0) 3937c478bd9Sstevel@tonic-gate return (EFAULT); 3947c478bd9Sstevel@tonic-gate if (pool_lock_intr() != 0) 3957c478bd9Sstevel@tonic-gate return (EINTR); 3967c478bd9Sstevel@tonic-gate ret = pool_transfer(transfer.pt_o_id_type, transfer.pt_o_src_id, 3977c478bd9Sstevel@tonic-gate transfer.pt_o_tgt_id, transfer.pt_o_qty); 3987c478bd9Sstevel@tonic-gate pool_unlock(); 3997c478bd9Sstevel@tonic-gate break; 4007c478bd9Sstevel@tonic-gate case POOL_XTRANSFER: 4017c478bd9Sstevel@tonic-gate switch (model) { 4027c478bd9Sstevel@tonic-gate #ifdef _MULTI_DATAMODEL 4037c478bd9Sstevel@tonic-gate case DDI_MODEL_ILP32: 4047c478bd9Sstevel@tonic-gate if (ddi_copyin((void *)arg, &xtransfer32, 4057c478bd9Sstevel@tonic-gate sizeof (pool_xtransfer32_t), mode) != 0) 4067c478bd9Sstevel@tonic-gate return (EFAULT); 4077c478bd9Sstevel@tonic-gate xtransfer.px_o_id_type = xtransfer32.px_o_id_type; 4087c478bd9Sstevel@tonic-gate xtransfer.px_o_src_id = xtransfer32.px_o_src_id; 4097c478bd9Sstevel@tonic-gate xtransfer.px_o_tgt_id = xtransfer32.px_o_tgt_id; 4107c478bd9Sstevel@tonic-gate xtransfer.px_o_complist_size = 4117c478bd9Sstevel@tonic-gate xtransfer32.px_o_complist_size; 4127c478bd9Sstevel@tonic-gate xtransfer.px_o_comp_list = 4137c478bd9Sstevel@tonic-gate (id_t *)(uintptr_t)xtransfer32.px_o_comp_list; 4147c478bd9Sstevel@tonic-gate break; 4157c478bd9Sstevel@tonic-gate #endif /* _MULTI_DATAMODEL */ 4167c478bd9Sstevel@tonic-gate default: 4177c478bd9Sstevel@tonic-gate case DDI_MODEL_NONE: 4187c478bd9Sstevel@tonic-gate if (ddi_copyin((void *)arg, &xtransfer, 4197c478bd9Sstevel@tonic-gate sizeof (pool_xtransfer_t), mode) != 0) 4207c478bd9Sstevel@tonic-gate return (EFAULT); 4217c478bd9Sstevel@tonic-gate } 4227c478bd9Sstevel@tonic-gate /* 4237c478bd9Sstevel@tonic-gate * Copy in IDs to transfer from the userland 4247c478bd9Sstevel@tonic-gate */ 4257c478bd9Sstevel@tonic-gate if (xtransfer.px_o_complist_size > POOL_IDLIST_SIZE) 4267c478bd9Sstevel@tonic-gate return (EINVAL); 4277c478bd9Sstevel@tonic-gate id_buf = kmem_alloc(xtransfer.px_o_complist_size * 4287c478bd9Sstevel@tonic-gate sizeof (id_t), KM_SLEEP); 4297c478bd9Sstevel@tonic-gate if (ddi_copyin((void *)xtransfer.px_o_comp_list, id_buf, 4307c478bd9Sstevel@tonic-gate xtransfer.px_o_complist_size * sizeof (id_t), mode) != 0) { 4317c478bd9Sstevel@tonic-gate kmem_free(id_buf, xtransfer.px_o_complist_size * 4327c478bd9Sstevel@tonic-gate sizeof (id_t)); 4337c478bd9Sstevel@tonic-gate return (EFAULT); 4347c478bd9Sstevel@tonic-gate } 4357c478bd9Sstevel@tonic-gate if (pool_lock_intr() != 0) { 4367c478bd9Sstevel@tonic-gate kmem_free(id_buf, xtransfer.px_o_complist_size * 4377c478bd9Sstevel@tonic-gate sizeof (id_t)); 4387c478bd9Sstevel@tonic-gate return (EINTR); 4397c478bd9Sstevel@tonic-gate } 4407c478bd9Sstevel@tonic-gate ret = pool_xtransfer(xtransfer.px_o_id_type, 4417c478bd9Sstevel@tonic-gate xtransfer.px_o_src_id, xtransfer.px_o_tgt_id, 4427c478bd9Sstevel@tonic-gate xtransfer.px_o_complist_size, id_buf); 4437c478bd9Sstevel@tonic-gate pool_unlock(); 4447c478bd9Sstevel@tonic-gate kmem_free(id_buf, xtransfer.px_o_complist_size * 4457c478bd9Sstevel@tonic-gate sizeof (id_t)); 4467c478bd9Sstevel@tonic-gate break; 4477c478bd9Sstevel@tonic-gate case POOL_BIND: 4487c478bd9Sstevel@tonic-gate if (ddi_copyin((void *)arg, &bind, 4497c478bd9Sstevel@tonic-gate sizeof (pool_bind_t), mode) != 0) 4507c478bd9Sstevel@tonic-gate return (EFAULT); 4517c478bd9Sstevel@tonic-gate if (pool_lock_intr() != 0) 4527c478bd9Sstevel@tonic-gate return (EINTR); 4537c478bd9Sstevel@tonic-gate ret = pool_bind(bind.pb_o_pool_id, bind.pb_o_id_type, 4547c478bd9Sstevel@tonic-gate bind.pb_o_id); 4557c478bd9Sstevel@tonic-gate pool_unlock(); 4567c478bd9Sstevel@tonic-gate break; 4577c478bd9Sstevel@tonic-gate case POOL_BINDQ: 4587c478bd9Sstevel@tonic-gate if (ddi_copyin((void *)arg, &bindq, 4597c478bd9Sstevel@tonic-gate sizeof (pool_bindq_t), mode) != 0) { 4607c478bd9Sstevel@tonic-gate return (EFAULT); 4617c478bd9Sstevel@tonic-gate } 4627c478bd9Sstevel@tonic-gate if (pool_lock_intr() != 0) 4637c478bd9Sstevel@tonic-gate return (EINTR); 4647c478bd9Sstevel@tonic-gate if ((ret = pool_query_binding(bindq.pb_o_id_type, 4657c478bd9Sstevel@tonic-gate bindq.pb_o_id, &bindq.pb_i_id)) == 0 && 4667c478bd9Sstevel@tonic-gate ddi_copyout(&bindq, (void *)arg, 4677c478bd9Sstevel@tonic-gate sizeof (pool_bindq_t), mode) != 0) 4687c478bd9Sstevel@tonic-gate ret = EFAULT; 4697c478bd9Sstevel@tonic-gate pool_unlock(); 4707c478bd9Sstevel@tonic-gate break; 4717c478bd9Sstevel@tonic-gate case POOL_PROPGET: 4727c478bd9Sstevel@tonic-gate switch (model) { 4737c478bd9Sstevel@tonic-gate #ifdef _MULTI_DATAMODEL 4747c478bd9Sstevel@tonic-gate case DDI_MODEL_ILP32: 4757c478bd9Sstevel@tonic-gate if (ddi_copyin((void *)arg, &propget32, 4767c478bd9Sstevel@tonic-gate sizeof (pool_propget32_t), mode) != 0) 4777c478bd9Sstevel@tonic-gate return (EFAULT); 4787c478bd9Sstevel@tonic-gate propget.pp_o_id = propget32.pp_o_id; 4797c478bd9Sstevel@tonic-gate propget.pp_o_id_type = propget32.pp_o_id_type; 4807c478bd9Sstevel@tonic-gate propget.pp_o_id_subtype = propget32.pp_o_id_subtype; 4817c478bd9Sstevel@tonic-gate propget.pp_o_prop_name = 4827c478bd9Sstevel@tonic-gate (char *)(uintptr_t)propget32.pp_o_prop_name; 4837c478bd9Sstevel@tonic-gate propget.pp_o_prop_name_size = 4847c478bd9Sstevel@tonic-gate propget32.pp_o_prop_name_size; 4857c478bd9Sstevel@tonic-gate propget.pp_i_buf = 4867c478bd9Sstevel@tonic-gate (char *)(uintptr_t)propget32.pp_i_buf; 4877c478bd9Sstevel@tonic-gate propget.pp_i_bufsize = propget32.pp_i_bufsize; 4887c478bd9Sstevel@tonic-gate break; 4897c478bd9Sstevel@tonic-gate #endif /* _MULTI_DATAMODEL */ 4907c478bd9Sstevel@tonic-gate default: 4917c478bd9Sstevel@tonic-gate case DDI_MODEL_NONE: 4927c478bd9Sstevel@tonic-gate if (ddi_copyin((void *)arg, &propget, 4937c478bd9Sstevel@tonic-gate sizeof (pool_propget_t), mode) != 0) 4947c478bd9Sstevel@tonic-gate return (EFAULT); 4957c478bd9Sstevel@tonic-gate } 4967c478bd9Sstevel@tonic-gate if (propget.pp_o_prop_name_size + 1 > POOL_PROPNAME_SIZE) 4977c478bd9Sstevel@tonic-gate return (EINVAL); 4987c478bd9Sstevel@tonic-gate prop_name = kmem_alloc(propget.pp_o_prop_name_size + 1, 4997c478bd9Sstevel@tonic-gate KM_SLEEP); 5007c478bd9Sstevel@tonic-gate if (ddi_copyin(propget.pp_o_prop_name, prop_name, 5017c478bd9Sstevel@tonic-gate propget.pp_o_prop_name_size + 1, mode) != 0) { 5027c478bd9Sstevel@tonic-gate kmem_free(prop_name, propget.pp_o_prop_name_size + 1); 5037c478bd9Sstevel@tonic-gate return (EFAULT); 5047c478bd9Sstevel@tonic-gate } 5057c478bd9Sstevel@tonic-gate list = NULL; 5067c478bd9Sstevel@tonic-gate if (pool_lock_intr() != 0) { 5077c478bd9Sstevel@tonic-gate kmem_free(prop_name, propget.pp_o_prop_name_size + 1); 5087c478bd9Sstevel@tonic-gate return (EINTR); 5097c478bd9Sstevel@tonic-gate } 5107c478bd9Sstevel@tonic-gate ret = pool_propget(prop_name, propget.pp_o_id_type, 5117c478bd9Sstevel@tonic-gate propget.pp_o_id_subtype, propget.pp_o_id, &list); 5127c478bd9Sstevel@tonic-gate pool_unlock(); 5137c478bd9Sstevel@tonic-gate kmem_free(prop_name, propget.pp_o_prop_name_size + 1); 5147c478bd9Sstevel@tonic-gate if (ret != 0) 5157c478bd9Sstevel@tonic-gate return (ret); 5167c478bd9Sstevel@tonic-gate ret = nvlist_pack(list, &kbuf, &kbufsz, NV_ENCODE_NATIVE, 0); 5177c478bd9Sstevel@tonic-gate if (ret != 0) { 5187c478bd9Sstevel@tonic-gate nvlist_free(list); 5197c478bd9Sstevel@tonic-gate return (ret); 5207c478bd9Sstevel@tonic-gate } 5217c478bd9Sstevel@tonic-gate switch (model) { 5227c478bd9Sstevel@tonic-gate #ifdef _MULTI_DATAMODEL 5237c478bd9Sstevel@tonic-gate case DDI_MODEL_ILP32: 5247c478bd9Sstevel@tonic-gate propget32.pp_i_bufsize = kbufsz; 5257c478bd9Sstevel@tonic-gate if (ddi_copyout((caddr_t)&propget32, (void *)arg, 5267c478bd9Sstevel@tonic-gate sizeof (pool_propget32_t), mode) != 0) 5277c478bd9Sstevel@tonic-gate ret = EFAULT; 5287c478bd9Sstevel@tonic-gate break; 5297c478bd9Sstevel@tonic-gate #endif /* _MULTI_DATAMODEL */ 5307c478bd9Sstevel@tonic-gate default: 5317c478bd9Sstevel@tonic-gate case DDI_MODEL_NONE: 5327c478bd9Sstevel@tonic-gate if (ddi_copyout(&propget, (void *)arg, 5337c478bd9Sstevel@tonic-gate sizeof (pool_propget_t), mode) != 0) 5347c478bd9Sstevel@tonic-gate ret = EFAULT; 5357c478bd9Sstevel@tonic-gate } 5367c478bd9Sstevel@tonic-gate if (ret == 0) { 5377c478bd9Sstevel@tonic-gate if (propget.pp_i_buf == NULL) { 5387c478bd9Sstevel@tonic-gate ret = 0; 5397c478bd9Sstevel@tonic-gate } else if (propget.pp_i_bufsize >= kbufsz) { 5407c478bd9Sstevel@tonic-gate if (ddi_copyout(kbuf, propget.pp_i_buf, 5417c478bd9Sstevel@tonic-gate kbufsz, mode) != 0) 5427c478bd9Sstevel@tonic-gate ret = EFAULT; 5437c478bd9Sstevel@tonic-gate } else { 5447c478bd9Sstevel@tonic-gate ret = ENOMEM; 5457c478bd9Sstevel@tonic-gate } 5467c478bd9Sstevel@tonic-gate } 5477c478bd9Sstevel@tonic-gate kmem_free(kbuf, kbufsz); 5487c478bd9Sstevel@tonic-gate nvlist_free(list); 5497c478bd9Sstevel@tonic-gate break; 5507c478bd9Sstevel@tonic-gate case POOL_PROPPUT: 5517c478bd9Sstevel@tonic-gate switch (model) { 5527c478bd9Sstevel@tonic-gate #ifdef _MULTI_DATAMODEL 5537c478bd9Sstevel@tonic-gate case DDI_MODEL_ILP32: 5547c478bd9Sstevel@tonic-gate if (ddi_copyin((void *)arg, &propput32, 5557c478bd9Sstevel@tonic-gate sizeof (pool_propput32_t), mode) != 0) 5567c478bd9Sstevel@tonic-gate return (EFAULT); 5577c478bd9Sstevel@tonic-gate propput.pp_o_id_type = propput32.pp_o_id_type; 5587c478bd9Sstevel@tonic-gate propput.pp_o_id_sub_type = propput32.pp_o_id_sub_type; 5597c478bd9Sstevel@tonic-gate propput.pp_o_id = propput32.pp_o_id; 5607c478bd9Sstevel@tonic-gate propput.pp_o_bufsize = propput32.pp_o_bufsize; 5617c478bd9Sstevel@tonic-gate propput.pp_o_buf = 5627c478bd9Sstevel@tonic-gate (char *)(uintptr_t)propput32.pp_o_buf; 5637c478bd9Sstevel@tonic-gate break; 5647c478bd9Sstevel@tonic-gate #endif /* _MULTI_DATAMODEL */ 5657c478bd9Sstevel@tonic-gate default: 5667c478bd9Sstevel@tonic-gate case DDI_MODEL_NONE: 5677c478bd9Sstevel@tonic-gate if (ddi_copyin((void *)arg, &propput, 5687c478bd9Sstevel@tonic-gate sizeof (pool_propput_t), mode) != 0) 5697c478bd9Sstevel@tonic-gate return (EFAULT); 5707c478bd9Sstevel@tonic-gate } 5717c478bd9Sstevel@tonic-gate if (propput.pp_o_bufsize > POOL_PROPBUF_SIZE) 5727c478bd9Sstevel@tonic-gate return (EINVAL); 5737c478bd9Sstevel@tonic-gate listbuf = kmem_alloc(propput.pp_o_bufsize, KM_SLEEP); 5747c478bd9Sstevel@tonic-gate if (ddi_copyin(propput.pp_o_buf, listbuf, 5757c478bd9Sstevel@tonic-gate propput.pp_o_bufsize, mode) != 0) { 5767c478bd9Sstevel@tonic-gate kmem_free(listbuf, propput.pp_o_bufsize); 5777c478bd9Sstevel@tonic-gate return (EFAULT); 5787c478bd9Sstevel@tonic-gate } 5797c478bd9Sstevel@tonic-gate if (nvlist_unpack(listbuf, propput.pp_o_bufsize, 5807c478bd9Sstevel@tonic-gate &list, KM_SLEEP) != 0) { 5817c478bd9Sstevel@tonic-gate kmem_free(listbuf, propput.pp_o_bufsize); 5827c478bd9Sstevel@tonic-gate return (EFAULT); 5837c478bd9Sstevel@tonic-gate } 5847c478bd9Sstevel@tonic-gate if (pool_lock_intr() != 0) { 5857c478bd9Sstevel@tonic-gate nvlist_free(list); 5867c478bd9Sstevel@tonic-gate kmem_free(listbuf, propput.pp_o_bufsize); 5877c478bd9Sstevel@tonic-gate return (EINTR); 5887c478bd9Sstevel@tonic-gate } 5897c478bd9Sstevel@tonic-gate /* 5907c478bd9Sstevel@tonic-gate * Extract the nvpair from the list. The list may 5917c478bd9Sstevel@tonic-gate * contain multiple properties. 5927c478bd9Sstevel@tonic-gate */ 5937c478bd9Sstevel@tonic-gate for (pair = nvlist_next_nvpair(list, NULL); pair != NULL; 5947c478bd9Sstevel@tonic-gate pair = nvlist_next_nvpair(list, pair)) { 5957c478bd9Sstevel@tonic-gate if ((ret = pool_propput(propput.pp_o_id_type, 5967c478bd9Sstevel@tonic-gate propput.pp_o_id_sub_type, 5977c478bd9Sstevel@tonic-gate propput.pp_o_id, pair)) != 0) 5987c478bd9Sstevel@tonic-gate break; 5997c478bd9Sstevel@tonic-gate } 6007c478bd9Sstevel@tonic-gate pool_unlock(); 6017c478bd9Sstevel@tonic-gate nvlist_free(list); 6027c478bd9Sstevel@tonic-gate kmem_free(listbuf, propput.pp_o_bufsize); 6037c478bd9Sstevel@tonic-gate break; 6047c478bd9Sstevel@tonic-gate case POOL_PROPRM: 6057c478bd9Sstevel@tonic-gate switch (model) { 6067c478bd9Sstevel@tonic-gate #ifdef _MULTI_DATAMODEL 6077c478bd9Sstevel@tonic-gate case DDI_MODEL_ILP32: 6087c478bd9Sstevel@tonic-gate if (ddi_copyin((void *)arg, &proprm32, 6097c478bd9Sstevel@tonic-gate sizeof (pool_proprm32_t), mode) != 0) 6107c478bd9Sstevel@tonic-gate return (EFAULT); 6117c478bd9Sstevel@tonic-gate proprm.pp_o_id_type = proprm32.pp_o_id_type; 6127c478bd9Sstevel@tonic-gate proprm.pp_o_id_sub_type = proprm32.pp_o_id_sub_type; 6137c478bd9Sstevel@tonic-gate proprm.pp_o_id = proprm32.pp_o_id; 6147c478bd9Sstevel@tonic-gate proprm.pp_o_prop_name_size = 6157c478bd9Sstevel@tonic-gate proprm32.pp_o_prop_name_size; 6167c478bd9Sstevel@tonic-gate proprm.pp_o_prop_name = 6177c478bd9Sstevel@tonic-gate (void *)(uintptr_t)proprm32.pp_o_prop_name; 6187c478bd9Sstevel@tonic-gate break; 6197c478bd9Sstevel@tonic-gate #endif /* _MULTI_DATAMODEL */ 6207c478bd9Sstevel@tonic-gate default: 6217c478bd9Sstevel@tonic-gate case DDI_MODEL_NONE: 6227c478bd9Sstevel@tonic-gate if (ddi_copyin((void *)arg, &proprm, 6237c478bd9Sstevel@tonic-gate sizeof (pool_proprm_t), mode) != 0) 6247c478bd9Sstevel@tonic-gate return (EFAULT); 6257c478bd9Sstevel@tonic-gate } 6267c478bd9Sstevel@tonic-gate if (proprm.pp_o_prop_name_size + 1 > POOL_PROPNAME_SIZE) 6277c478bd9Sstevel@tonic-gate return (EINVAL); 6287c478bd9Sstevel@tonic-gate prop_name = kmem_alloc(proprm.pp_o_prop_name_size + 1, 6297c478bd9Sstevel@tonic-gate KM_SLEEP); 6307c478bd9Sstevel@tonic-gate if (ddi_copyin(proprm.pp_o_prop_name, prop_name, 6317c478bd9Sstevel@tonic-gate proprm.pp_o_prop_name_size + 1, mode) != 0) { 6327c478bd9Sstevel@tonic-gate kmem_free(prop_name, proprm.pp_o_prop_name_size + 1); 6337c478bd9Sstevel@tonic-gate return (EFAULT); 6347c478bd9Sstevel@tonic-gate } 6357c478bd9Sstevel@tonic-gate if (pool_lock_intr() != 0) { 6367c478bd9Sstevel@tonic-gate kmem_free(prop_name, proprm.pp_o_prop_name_size + 1); 6377c478bd9Sstevel@tonic-gate return (EINTR); 6387c478bd9Sstevel@tonic-gate } 6397c478bd9Sstevel@tonic-gate ret = pool_proprm(proprm.pp_o_id_type, 6407c478bd9Sstevel@tonic-gate proprm.pp_o_id_sub_type, proprm.pp_o_id, prop_name); 6417c478bd9Sstevel@tonic-gate pool_unlock(); 6427c478bd9Sstevel@tonic-gate kmem_free(prop_name, proprm.pp_o_prop_name_size + 1); 6437c478bd9Sstevel@tonic-gate break; 6447c478bd9Sstevel@tonic-gate case POOL_COMMIT: 6457c478bd9Sstevel@tonic-gate if (pool_lock_intr() != 0) 6467c478bd9Sstevel@tonic-gate return (EINTR); 6477c478bd9Sstevel@tonic-gate ret = pool_commit((int)arg); 6487c478bd9Sstevel@tonic-gate pool_unlock(); 6497c478bd9Sstevel@tonic-gate break; 6507c478bd9Sstevel@tonic-gate default: 6517c478bd9Sstevel@tonic-gate return (EINVAL); 6527c478bd9Sstevel@tonic-gate } 6537c478bd9Sstevel@tonic-gate return (ret); 6547c478bd9Sstevel@tonic-gate } 6557c478bd9Sstevel@tonic-gate 6567c478bd9Sstevel@tonic-gate static struct cb_ops pool_cb_ops = { 6577c478bd9Sstevel@tonic-gate pool_open, /* open */ 6587c478bd9Sstevel@tonic-gate pool_close, /* close */ 6597c478bd9Sstevel@tonic-gate nodev, /* strategy */ 6607c478bd9Sstevel@tonic-gate nodev, /* print */ 6617c478bd9Sstevel@tonic-gate nodev, /* dump */ 6627c478bd9Sstevel@tonic-gate nodev, /* read */ 6637c478bd9Sstevel@tonic-gate nodev, /* write */ 6647c478bd9Sstevel@tonic-gate pool_ioctl, /* ioctl */ 6657c478bd9Sstevel@tonic-gate nodev, /* devmap */ 6667c478bd9Sstevel@tonic-gate nodev, /* mmap */ 6677c478bd9Sstevel@tonic-gate nodev, /* segmap */ 6687c478bd9Sstevel@tonic-gate nochpoll, /* poll */ 6697c478bd9Sstevel@tonic-gate nodev, /* cb_prop_op */ 6707c478bd9Sstevel@tonic-gate (struct streamtab *)0, /* streamtab */ 6717c478bd9Sstevel@tonic-gate D_NEW | D_MP /* driver compatibility flags */ 6727c478bd9Sstevel@tonic-gate }; 6737c478bd9Sstevel@tonic-gate 6747c478bd9Sstevel@tonic-gate static struct dev_ops pool_ops = { 6757c478bd9Sstevel@tonic-gate DEVO_REV, /* devo_rev */ 6767c478bd9Sstevel@tonic-gate 0, /* refcnt */ 6777c478bd9Sstevel@tonic-gate pool_info, /* info */ 6787c478bd9Sstevel@tonic-gate nulldev, /* identify */ 6797c478bd9Sstevel@tonic-gate nulldev, /* probe */ 6807c478bd9Sstevel@tonic-gate pool_attach, /* attach */ 6817c478bd9Sstevel@tonic-gate pool_detach, /* detach */ 6827c478bd9Sstevel@tonic-gate nodev, /* reset */ 6837c478bd9Sstevel@tonic-gate &pool_cb_ops, /* cb_ops */ 6847c478bd9Sstevel@tonic-gate (struct bus_ops *)NULL, /* bus_ops */ 685*19397407SSherry Moore nulldev, /* power */ 686*19397407SSherry Moore ddi_quiesce_not_needed, /* quiesce */ 6877c478bd9Sstevel@tonic-gate }; 6887c478bd9Sstevel@tonic-gate 6897c478bd9Sstevel@tonic-gate /* 6907c478bd9Sstevel@tonic-gate * Module linkage information for the kernel 6917c478bd9Sstevel@tonic-gate */ 6927c478bd9Sstevel@tonic-gate static struct modldrv modldrv = { 6937c478bd9Sstevel@tonic-gate &mod_driverops, /* this one is a pseudo driver */ 694*19397407SSherry Moore "pool driver", 6957c478bd9Sstevel@tonic-gate &pool_ops 6967c478bd9Sstevel@tonic-gate }; 6977c478bd9Sstevel@tonic-gate 6987c478bd9Sstevel@tonic-gate static struct modlinkage modlinkage = { 6997c478bd9Sstevel@tonic-gate MODREV_1, 7007c478bd9Sstevel@tonic-gate &modldrv, 7017c478bd9Sstevel@tonic-gate NULL 7027c478bd9Sstevel@tonic-gate }; 7037c478bd9Sstevel@tonic-gate 7047c478bd9Sstevel@tonic-gate int 7057c478bd9Sstevel@tonic-gate _init(void) 7067c478bd9Sstevel@tonic-gate { 7077c478bd9Sstevel@tonic-gate return (mod_install(&modlinkage)); 7087c478bd9Sstevel@tonic-gate } 7097c478bd9Sstevel@tonic-gate 7107c478bd9Sstevel@tonic-gate int 7117c478bd9Sstevel@tonic-gate _fini(void) 7127c478bd9Sstevel@tonic-gate { 7137c478bd9Sstevel@tonic-gate return (mod_remove(&modlinkage)); 7147c478bd9Sstevel@tonic-gate } 7157c478bd9Sstevel@tonic-gate 7167c478bd9Sstevel@tonic-gate int 7177c478bd9Sstevel@tonic-gate _info(struct modinfo *modinfop) 7187c478bd9Sstevel@tonic-gate { 7197c478bd9Sstevel@tonic-gate return (mod_info(&modlinkage, modinfop)); 7207c478bd9Sstevel@tonic-gate } 721