1*fcf3ce44SJohn Forte /* 2*fcf3ce44SJohn Forte * CDDL HEADER START 3*fcf3ce44SJohn Forte * 4*fcf3ce44SJohn Forte * The contents of this file are subject to the terms of the 5*fcf3ce44SJohn Forte * Common Development and Distribution License (the "License"). 6*fcf3ce44SJohn Forte * You may not use this file except in compliance with the License. 7*fcf3ce44SJohn Forte * 8*fcf3ce44SJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*fcf3ce44SJohn Forte * or http://www.opensolaris.org/os/licensing. 10*fcf3ce44SJohn Forte * See the License for the specific language governing permissions 11*fcf3ce44SJohn Forte * and limitations under the License. 12*fcf3ce44SJohn Forte * 13*fcf3ce44SJohn Forte * When distributing Covered Code, include this CDDL HEADER in each 14*fcf3ce44SJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*fcf3ce44SJohn Forte * If applicable, add the following below this CDDL HEADER, with the 16*fcf3ce44SJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying 17*fcf3ce44SJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner] 18*fcf3ce44SJohn Forte * 19*fcf3ce44SJohn Forte * CDDL HEADER END 20*fcf3ce44SJohn Forte */ 21*fcf3ce44SJohn Forte /* 22*fcf3ce44SJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23*fcf3ce44SJohn Forte * Use is subject to license terms. 24*fcf3ce44SJohn Forte */ 25*fcf3ce44SJohn Forte 26*fcf3ce44SJohn Forte #include <sys/types.h> 27*fcf3ce44SJohn Forte #include <sys/fcntl.h> 28*fcf3ce44SJohn Forte #include <errno.h> 29*fcf3ce44SJohn Forte #include <fcntl.h> 30*fcf3ce44SJohn Forte #include <stdlib.h> 31*fcf3ce44SJohn Forte #include <signal.h> 32*fcf3ce44SJohn Forte #include <strings.h> 33*fcf3ce44SJohn Forte #include <unistd.h> 34*fcf3ce44SJohn Forte #include <stdio.h> 35*fcf3ce44SJohn Forte 36*fcf3ce44SJohn Forte #include "libnsctl.h" 37*fcf3ce44SJohn Forte #include <nsctl.h> 38*fcf3ce44SJohn Forte 39*fcf3ce44SJohn Forte 40*fcf3ce44SJohn Forte static int _nsc_open_path(nsc_fd_t *); 41*fcf3ce44SJohn Forte static int _nsc_open_check(nsc_fd_t *); 42*fcf3ce44SJohn Forte 43*fcf3ce44SJohn Forte 44*fcf3ce44SJohn Forte /* 45*fcf3ce44SJohn Forte * Turn off ckdchk checking of nsc_open()'d volumes since we have no CKD 46*fcf3ce44SJohn Forte * formatted volumes right now. If/when we come back with CKD volumes, 47*fcf3ce44SJohn Forte * we could do this more sanely by completing the implementation of the 48*fcf3ce44SJohn Forte * CKD module, and having nsc_open() prevent any non-NSC_CKD_DISK open 49*fcf3ce44SJohn Forte * of a CKD volume. 50*fcf3ce44SJohn Forte * -- Simon, Thu Feb 18 10:49:46 GMT 1999 51*fcf3ce44SJohn Forte */ 52*fcf3ce44SJohn Forte static int ckdchk = 0; 53*fcf3ce44SJohn Forte 54*fcf3ce44SJohn Forte 55*fcf3ce44SJohn Forte nsc_fd_t * 56*fcf3ce44SJohn Forte nsc_open(path, flag, mode) 57*fcf3ce44SJohn Forte char *path; 58*fcf3ce44SJohn Forte int flag, mode; 59*fcf3ce44SJohn Forte { 60*fcf3ce44SJohn Forte nsc_fd_t *fd; 61*fcf3ce44SJohn Forte 62*fcf3ce44SJohn Forte if (strlen(path) >= NSC_MAXPATH) { 63*fcf3ce44SJohn Forte errno = ENAMETOOLONG; 64*fcf3ce44SJohn Forte return (0); 65*fcf3ce44SJohn Forte } 66*fcf3ce44SJohn Forte 67*fcf3ce44SJohn Forte if (!(fd = (nsc_fd_t *)calloc(1, sizeof (nsc_fd_t)))) 68*fcf3ce44SJohn Forte return (0); 69*fcf3ce44SJohn Forte 70*fcf3ce44SJohn Forte if ((mode & O_ACCMODE) == O_WRONLY) { 71*fcf3ce44SJohn Forte mode &= ~O_ACCMODE; 72*fcf3ce44SJohn Forte mode |= O_RDWR; 73*fcf3ce44SJohn Forte } 74*fcf3ce44SJohn Forte 75*fcf3ce44SJohn Forte fd->sf_flag = flag; 76*fcf3ce44SJohn Forte fd->sf_fmode = mode; 77*fcf3ce44SJohn Forte 78*fcf3ce44SJohn Forte strcpy(fd->sf_path, path); 79*fcf3ce44SJohn Forte 80*fcf3ce44SJohn Forte if (!_nsc_open_path(fd)) { 81*fcf3ce44SJohn Forte free(fd); 82*fcf3ce44SJohn Forte return (0); 83*fcf3ce44SJohn Forte } 84*fcf3ce44SJohn Forte 85*fcf3ce44SJohn Forte if (ckdchk && !_nsc_open_check(fd)) { 86*fcf3ce44SJohn Forte (void) nsc_close(fd); 87*fcf3ce44SJohn Forte return (0); 88*fcf3ce44SJohn Forte } 89*fcf3ce44SJohn Forte 90*fcf3ce44SJohn Forte return (fd); 91*fcf3ce44SJohn Forte } 92*fcf3ce44SJohn Forte 93*fcf3ce44SJohn Forte 94*fcf3ce44SJohn Forte nsc_fd_t * 95*fcf3ce44SJohn Forte nsc_fdopen(id, path, mode) 96*fcf3ce44SJohn Forte int id, mode; 97*fcf3ce44SJohn Forte char *path; 98*fcf3ce44SJohn Forte { 99*fcf3ce44SJohn Forte struct flock lk; 100*fcf3ce44SJohn Forte nsc_fd_t *fd; 101*fcf3ce44SJohn Forte int i; 102*fcf3ce44SJohn Forte 103*fcf3ce44SJohn Forte if (strlen(path) >= NSC_MAXPATH) { 104*fcf3ce44SJohn Forte errno = ENAMETOOLONG; 105*fcf3ce44SJohn Forte return (0); 106*fcf3ce44SJohn Forte } 107*fcf3ce44SJohn Forte 108*fcf3ce44SJohn Forte if (!(fd = (nsc_fd_t *)calloc(1, sizeof (nsc_fd_t)))) 109*fcf3ce44SJohn Forte return (0); 110*fcf3ce44SJohn Forte 111*fcf3ce44SJohn Forte lk.l_type = F_WRLCK; 112*fcf3ce44SJohn Forte lk.l_whence = SEEK_SET; 113*fcf3ce44SJohn Forte lk.l_start = 0; 114*fcf3ce44SJohn Forte lk.l_len = 0; 115*fcf3ce44SJohn Forte 116*fcf3ce44SJohn Forte if (fcntl(id, F_SETLKW, &lk) < 0) 117*fcf3ce44SJohn Forte return (0); 118*fcf3ce44SJohn Forte 119*fcf3ce44SJohn Forte i = fcntl(id, F_GETFL); 120*fcf3ce44SJohn Forte 121*fcf3ce44SJohn Forte if ((mode & O_ACCMODE) != O_RDONLY) { 122*fcf3ce44SJohn Forte if ((i & O_ACCMODE) == O_RDONLY) { 123*fcf3ce44SJohn Forte errno = EBADF; 124*fcf3ce44SJohn Forte return (0); 125*fcf3ce44SJohn Forte } 126*fcf3ce44SJohn Forte } 127*fcf3ce44SJohn Forte 128*fcf3ce44SJohn Forte if ((mode & O_ACCMODE) != O_WRONLY) { 129*fcf3ce44SJohn Forte if ((i & O_ACCMODE) == O_WRONLY) { 130*fcf3ce44SJohn Forte errno = EBADF; 131*fcf3ce44SJohn Forte return (0); 132*fcf3ce44SJohn Forte } 133*fcf3ce44SJohn Forte } 134*fcf3ce44SJohn Forte 135*fcf3ce44SJohn Forte mode = (i & O_ACCMODE) | (mode & ~O_ACCMODE); 136*fcf3ce44SJohn Forte 137*fcf3ce44SJohn Forte if (fcntl(id, F_SETFL, mode) < 0) 138*fcf3ce44SJohn Forte return (0); 139*fcf3ce44SJohn Forte 140*fcf3ce44SJohn Forte if (lseek(id, 0, SEEK_SET) < 0) 141*fcf3ce44SJohn Forte return (0); 142*fcf3ce44SJohn Forte 143*fcf3ce44SJohn Forte fd->sf_fd = id; 144*fcf3ce44SJohn Forte fd->sf_fmode = mode; 145*fcf3ce44SJohn Forte 146*fcf3ce44SJohn Forte strcpy(fd->sf_path, path); 147*fcf3ce44SJohn Forte 148*fcf3ce44SJohn Forte return (fd); 149*fcf3ce44SJohn Forte } 150*fcf3ce44SJohn Forte 151*fcf3ce44SJohn Forte 152*fcf3ce44SJohn Forte static int 153*fcf3ce44SJohn Forte _nsc_open_path(fd) 154*fcf3ce44SJohn Forte nsc_fd_t *fd; 155*fcf3ce44SJohn Forte { 156*fcf3ce44SJohn Forte struct nscioc_open op; 157*fcf3ce44SJohn Forte 158*fcf3ce44SJohn Forte memset(&op, 0, sizeof (op)); 159*fcf3ce44SJohn Forte 160*fcf3ce44SJohn Forte op.flag = fd->sf_flag; 161*fcf3ce44SJohn Forte op.mode = fd->sf_fmode; 162*fcf3ce44SJohn Forte strcpy(op.path, fd->sf_path); 163*fcf3ce44SJohn Forte 164*fcf3ce44SJohn Forte if ((fd->sf_fd = open(_NSC_DEV_PATH, fd->sf_fmode)) < 0) 165*fcf3ce44SJohn Forte return (0); 166*fcf3ce44SJohn Forte 167*fcf3ce44SJohn Forte if (ioctl(fd->sf_fd, NSCIOC_OPEN, &op) == 0) 168*fcf3ce44SJohn Forte return (1); 169*fcf3ce44SJohn Forte 170*fcf3ce44SJohn Forte close(fd->sf_fd); 171*fcf3ce44SJohn Forte return (0); 172*fcf3ce44SJohn Forte } 173*fcf3ce44SJohn Forte 174*fcf3ce44SJohn Forte 175*fcf3ce44SJohn Forte static int 176*fcf3ce44SJohn Forte _nsc_open_check(fd) 177*fcf3ce44SJohn Forte nsc_fd_t *fd; 178*fcf3ce44SJohn Forte { 179*fcf3ce44SJohn Forte struct flock lk; 180*fcf3ce44SJohn Forte char s[30]; 181*fcf3ce44SJohn Forte pid_t pid; 182*fcf3ce44SJohn Forte int i; 183*fcf3ce44SJohn Forte 184*fcf3ce44SJohn Forte if ((fd->sf_fmode & O_ACCMODE) == O_RDONLY) 185*fcf3ce44SJohn Forte return (1); 186*fcf3ce44SJohn Forte 187*fcf3ce44SJohn Forte if (access(_NSC_CKDCHK_PATH, X_OK) != 0) 188*fcf3ce44SJohn Forte return (0); 189*fcf3ce44SJohn Forte 190*fcf3ce44SJohn Forte lk.l_type = F_WRLCK; 191*fcf3ce44SJohn Forte lk.l_whence = SEEK_SET; 192*fcf3ce44SJohn Forte lk.l_start = 0; 193*fcf3ce44SJohn Forte lk.l_len = 0; 194*fcf3ce44SJohn Forte 195*fcf3ce44SJohn Forte if (fcntl(fd->sf_fd, F_SETLKW, &lk) < 0) 196*fcf3ce44SJohn Forte return (0); 197*fcf3ce44SJohn Forte 198*fcf3ce44SJohn Forte if ((pid = fork()) == 0) { 199*fcf3ce44SJohn Forte for (i = 1; i <= NSIG; i++) 200*fcf3ce44SJohn Forte signal(i, SIG_IGN); 201*fcf3ce44SJohn Forte 202*fcf3ce44SJohn Forte for (i = fd->sf_fd; i <= 2 && (i = dup(i)) != -1; ) 203*fcf3ce44SJohn Forte fd->sf_fd = i; 204*fcf3ce44SJohn Forte 205*fcf3ce44SJohn Forte for (i = sysconf(_SC_OPEN_MAX); i >= 0; i--) 206*fcf3ce44SJohn Forte if (i != fd->sf_fd) 207*fcf3ce44SJohn Forte close(i); 208*fcf3ce44SJohn Forte 209*fcf3ce44SJohn Forte fcntl(fd->sf_fd, F_SETFD, 0); 210*fcf3ce44SJohn Forte 211*fcf3ce44SJohn Forte (void) open("/dev/null", 0); 212*fcf3ce44SJohn Forte (void) open(_NSC_CKDCHK_LOG, O_WRONLY|O_CREAT|O_APPEND, 0666); 213*fcf3ce44SJohn Forte (void) open(_NSC_CKDCHK_LOG, O_WRONLY|O_CREAT|O_APPEND, 0666); 214*fcf3ce44SJohn Forte 215*fcf3ce44SJohn Forte (void) sprintf(s, "%d", fd->sf_fd); 216*fcf3ce44SJohn Forte 217*fcf3ce44SJohn Forte (void) execl(_NSC_CKDCHK_PATH, "ckdchk", "-u", "-F", 218*fcf3ce44SJohn Forte s, fd->sf_path, 0); 219*fcf3ce44SJohn Forte 220*fcf3ce44SJohn Forte exit(1); 221*fcf3ce44SJohn Forte } 222*fcf3ce44SJohn Forte 223*fcf3ce44SJohn Forte return (pid != -1); 224*fcf3ce44SJohn Forte } 225*fcf3ce44SJohn Forte 226*fcf3ce44SJohn Forte 227*fcf3ce44SJohn Forte int 228*fcf3ce44SJohn Forte nsc_close(fd) 229*fcf3ce44SJohn Forte nsc_fd_t *fd; 230*fcf3ce44SJohn Forte { 231*fcf3ce44SJohn Forte int rc; 232*fcf3ce44SJohn Forte 233*fcf3ce44SJohn Forte if (!fd) 234*fcf3ce44SJohn Forte return (0); 235*fcf3ce44SJohn Forte 236*fcf3ce44SJohn Forte rc = close(fd->sf_fd); 237*fcf3ce44SJohn Forte free(fd); 238*fcf3ce44SJohn Forte 239*fcf3ce44SJohn Forte return (rc); 240*fcf3ce44SJohn Forte } 241*fcf3ce44SJohn Forte 242*fcf3ce44SJohn Forte 243*fcf3ce44SJohn Forte int 244*fcf3ce44SJohn Forte nsc_reserve(fd) 245*fcf3ce44SJohn Forte nsc_fd_t *fd; 246*fcf3ce44SJohn Forte { 247*fcf3ce44SJohn Forte return ((fd) ? ioctl(fd->sf_fd, NSCIOC_RESERVE, 0) : 0); 248*fcf3ce44SJohn Forte } 249*fcf3ce44SJohn Forte 250*fcf3ce44SJohn Forte 251*fcf3ce44SJohn Forte int 252*fcf3ce44SJohn Forte nsc_release(fd) 253*fcf3ce44SJohn Forte nsc_fd_t *fd; 254*fcf3ce44SJohn Forte { 255*fcf3ce44SJohn Forte if (!fd) 256*fcf3ce44SJohn Forte return (0); 257*fcf3ce44SJohn Forte 258*fcf3ce44SJohn Forte if (ckdchk && (fd->sf_fmode & O_ACCMODE) != O_RDONLY) { 259*fcf3ce44SJohn Forte errno = EINVAL; 260*fcf3ce44SJohn Forte return (-1); 261*fcf3ce44SJohn Forte } 262*fcf3ce44SJohn Forte 263*fcf3ce44SJohn Forte return (ioctl(fd->sf_fd, NSCIOC_RELEASE, 0)); 264*fcf3ce44SJohn Forte } 265*fcf3ce44SJohn Forte 266*fcf3ce44SJohn Forte 267*fcf3ce44SJohn Forte int 268*fcf3ce44SJohn Forte nsc_partsize(nsc_fd_t *fd, nsc_size_t *rvp) 269*fcf3ce44SJohn Forte { 270*fcf3ce44SJohn Forte struct nscioc_partsize partsize; 271*fcf3ce44SJohn Forte int rc; 272*fcf3ce44SJohn Forte 273*fcf3ce44SJohn Forte if (!fd) 274*fcf3ce44SJohn Forte return (0); 275*fcf3ce44SJohn Forte 276*fcf3ce44SJohn Forte rc = ioctl(fd->sf_fd, NSCIOC_PARTSIZE, &partsize); 277*fcf3ce44SJohn Forte if (rc != 0) { 278*fcf3ce44SJohn Forte return (rc); 279*fcf3ce44SJohn Forte } 280*fcf3ce44SJohn Forte 281*fcf3ce44SJohn Forte *rvp = (nsc_size_t)partsize.partsize; 282*fcf3ce44SJohn Forte return (0); 283*fcf3ce44SJohn Forte } 284*fcf3ce44SJohn Forte 285*fcf3ce44SJohn Forte 286*fcf3ce44SJohn Forte int 287*fcf3ce44SJohn Forte nsc_fileno(fd) 288*fcf3ce44SJohn Forte nsc_fd_t *fd; 289*fcf3ce44SJohn Forte { 290*fcf3ce44SJohn Forte return ((fd) ? fd->sf_fd : -1); 291*fcf3ce44SJohn Forte } 292*fcf3ce44SJohn Forte 293*fcf3ce44SJohn Forte 294*fcf3ce44SJohn Forte void 295*fcf3ce44SJohn Forte _nsc_nocheck() 296*fcf3ce44SJohn Forte { 297*fcf3ce44SJohn Forte ckdchk = 0; 298*fcf3ce44SJohn Forte } 299*fcf3ce44SJohn Forte 300*fcf3ce44SJohn Forte 301*fcf3ce44SJohn Forte static int 302*fcf3ce44SJohn Forte _nsc_do_ioctl(cmd, arg) 303*fcf3ce44SJohn Forte int cmd; 304*fcf3ce44SJohn Forte void *arg; 305*fcf3ce44SJohn Forte { 306*fcf3ce44SJohn Forte int fd, rc, save_errno; 307*fcf3ce44SJohn Forte 308*fcf3ce44SJohn Forte fd = open(_NSC_DEV_PATH, O_RDONLY); 309*fcf3ce44SJohn Forte if (fd < 0) 310*fcf3ce44SJohn Forte return (-1); 311*fcf3ce44SJohn Forte 312*fcf3ce44SJohn Forte rc = save_errno = 0; 313*fcf3ce44SJohn Forte rc = ioctl(fd, cmd, arg); 314*fcf3ce44SJohn Forte if (rc < 0) 315*fcf3ce44SJohn Forte save_errno = errno; 316*fcf3ce44SJohn Forte 317*fcf3ce44SJohn Forte close(fd); 318*fcf3ce44SJohn Forte 319*fcf3ce44SJohn Forte errno = save_errno; 320*fcf3ce44SJohn Forte return (rc); 321*fcf3ce44SJohn Forte } 322*fcf3ce44SJohn Forte 323*fcf3ce44SJohn Forte 324*fcf3ce44SJohn Forte /* 325*fcf3ce44SJohn Forte * int 326*fcf3ce44SJohn Forte * nsc_freeze(char *path) 327*fcf3ce44SJohn Forte * Freeze a pathname 328*fcf3ce44SJohn Forte * 329*fcf3ce44SJohn Forte * Calling/Exit State: 330*fcf3ce44SJohn Forte * Returns 0 for success, or -1 and sets errno. 331*fcf3ce44SJohn Forte * 332*fcf3ce44SJohn Forte * Description: 333*fcf3ce44SJohn Forte * This is the user level interface to the nsctl freeze operation. 334*fcf3ce44SJohn Forte * See uts/common/ns/nsctl/nsc_freeze.c for more information. 335*fcf3ce44SJohn Forte */ 336*fcf3ce44SJohn Forte int 337*fcf3ce44SJohn Forte nsc_freeze(path) 338*fcf3ce44SJohn Forte char *path; 339*fcf3ce44SJohn Forte { 340*fcf3ce44SJohn Forte if (strlen(path) >= NSC_MAXPATH) { 341*fcf3ce44SJohn Forte errno = ENAMETOOLONG; 342*fcf3ce44SJohn Forte return (-1); 343*fcf3ce44SJohn Forte } 344*fcf3ce44SJohn Forte 345*fcf3ce44SJohn Forte return (_nsc_do_ioctl(NSCIOC_FREEZE, path)); 346*fcf3ce44SJohn Forte } 347*fcf3ce44SJohn Forte 348*fcf3ce44SJohn Forte /* 349*fcf3ce44SJohn Forte * int 350*fcf3ce44SJohn Forte * nsc_unfreeze(char *path) 351*fcf3ce44SJohn Forte * Unfreeze a pathname 352*fcf3ce44SJohn Forte * 353*fcf3ce44SJohn Forte * Calling/Exit State: 354*fcf3ce44SJohn Forte * Returns 0 for success, or -1 and sets errno. 355*fcf3ce44SJohn Forte * 356*fcf3ce44SJohn Forte * Description: 357*fcf3ce44SJohn Forte * This is the user level interface to the nsctl unfreeze operation. 358*fcf3ce44SJohn Forte * See uts/common/ns/nsctl/nsc_freeze.c for more information. 359*fcf3ce44SJohn Forte */ 360*fcf3ce44SJohn Forte int 361*fcf3ce44SJohn Forte nsc_unfreeze(path) 362*fcf3ce44SJohn Forte char *path; 363*fcf3ce44SJohn Forte { 364*fcf3ce44SJohn Forte if (strlen(path) >= NSC_MAXPATH) { 365*fcf3ce44SJohn Forte errno = ENAMETOOLONG; 366*fcf3ce44SJohn Forte return (-1); 367*fcf3ce44SJohn Forte } 368*fcf3ce44SJohn Forte 369*fcf3ce44SJohn Forte return (_nsc_do_ioctl(NSCIOC_UNFREEZE, path)); 370*fcf3ce44SJohn Forte } 371*fcf3ce44SJohn Forte 372*fcf3ce44SJohn Forte 373*fcf3ce44SJohn Forte /* 374*fcf3ce44SJohn Forte * int 375*fcf3ce44SJohn Forte * nsc_isfrozen(char *path) 376*fcf3ce44SJohn Forte * Test if a pathname is frozen 377*fcf3ce44SJohn Forte * 378*fcf3ce44SJohn Forte * Calling/Exit State: 379*fcf3ce44SJohn Forte * Returns: 380*fcf3ce44SJohn Forte * 0 path is frozen 381*fcf3ce44SJohn Forte * 1 path is not frozen 382*fcf3ce44SJohn Forte * -1 error (errno will be set) 383*fcf3ce44SJohn Forte * 384*fcf3ce44SJohn Forte * Description 385*fcf3ce44SJohn Forte * This is the user level interface to to the nsctl isfrozen operation. 386*fcf3ce44SJohn Forte * See uts/common/ns/nsctl/nsc_freeze.c for more information. 387*fcf3ce44SJohn Forte */ 388*fcf3ce44SJohn Forte int 389*fcf3ce44SJohn Forte nsc_isfrozen(path) 390*fcf3ce44SJohn Forte char *path; 391*fcf3ce44SJohn Forte { 392*fcf3ce44SJohn Forte if (strlen(path) >= NSC_MAXPATH) { 393*fcf3ce44SJohn Forte errno = ENAMETOOLONG; 394*fcf3ce44SJohn Forte return (-1); 395*fcf3ce44SJohn Forte } 396*fcf3ce44SJohn Forte 397*fcf3ce44SJohn Forte return (_nsc_do_ioctl(NSCIOC_ISFROZEN, path)); 398*fcf3ce44SJohn Forte } 399*fcf3ce44SJohn Forte 400*fcf3ce44SJohn Forte int 401*fcf3ce44SJohn Forte nsc_gmem_sizes(int *size) 402*fcf3ce44SJohn Forte { 403*fcf3ce44SJohn Forte return (_nsc_do_ioctl(NSCIOC_GLOBAL_SIZES, size)); 404*fcf3ce44SJohn Forte } 405*fcf3ce44SJohn Forte 406*fcf3ce44SJohn Forte int 407*fcf3ce44SJohn Forte nsc_gmem_data(char *addr) 408*fcf3ce44SJohn Forte { 409*fcf3ce44SJohn Forte return (_nsc_do_ioctl(NSCIOC_GLOBAL_DATA, addr)); 410*fcf3ce44SJohn Forte } 411*fcf3ce44SJohn Forte 412*fcf3ce44SJohn Forte /* 413*fcf3ce44SJohn Forte * int 414*fcf3ce44SJohn Forte * nsc_nvclean() 415*fcf3ce44SJohn Forte * mark nvmem clean, to prevent a warmstart of the cache on reboot 416*fcf3ce44SJohn Forte */ 417*fcf3ce44SJohn Forte int 418*fcf3ce44SJohn Forte nsc_nvclean(int force) 419*fcf3ce44SJohn Forte { 420*fcf3ce44SJohn Forte int cmd; 421*fcf3ce44SJohn Forte 422*fcf3ce44SJohn Forte cmd = force ? NSCIOC_NVMEM_CLEANF : NSCIOC_NVMEM_CLEAN; 423*fcf3ce44SJohn Forte 424*fcf3ce44SJohn Forte return (_nsc_do_ioctl(cmd, (void *)0)); 425*fcf3ce44SJohn Forte } 426