1*b819cea2SGordon Ross /* 2*b819cea2SGordon Ross * CDDL HEADER START 3*b819cea2SGordon Ross * 4*b819cea2SGordon Ross * The contents of this file are subject to the terms of the 5*b819cea2SGordon Ross * Common Development and Distribution License (the "License"). 6*b819cea2SGordon Ross * You may not use this file except in compliance with the License. 7*b819cea2SGordon Ross * 8*b819cea2SGordon Ross * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*b819cea2SGordon Ross * or http://www.opensolaris.org/os/licensing. 10*b819cea2SGordon Ross * See the License for the specific language governing permissions 11*b819cea2SGordon Ross * and limitations under the License. 12*b819cea2SGordon Ross * 13*b819cea2SGordon Ross * When distributing Covered Code, include this CDDL HEADER in each 14*b819cea2SGordon Ross * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*b819cea2SGordon Ross * If applicable, add the following below this CDDL HEADER, with the 16*b819cea2SGordon Ross * fields enclosed by brackets "[]" replaced with your own identifying 17*b819cea2SGordon Ross * information: Portions Copyright [yyyy] [name of copyright owner] 18*b819cea2SGordon Ross * 19*b819cea2SGordon Ross * CDDL HEADER END 20*b819cea2SGordon Ross */ 21*b819cea2SGordon Ross /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 22*b819cea2SGordon Ross /* All Rights Reserved */ 23*b819cea2SGordon Ross 24*b819cea2SGordon Ross 25*b819cea2SGordon Ross /* 26*b819cea2SGordon Ross * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. 27*b819cea2SGordon Ross * Copyright 2013 Nexenta Systems, Inc. All rights reserved. 28*b819cea2SGordon Ross */ 29*b819cea2SGordon Ross 30*b819cea2SGordon Ross #include <sys/types.h> 31*b819cea2SGordon Ross #include <sys/param.h> 32*b819cea2SGordon Ross #include <sys/errno.h> 33*b819cea2SGordon Ross #include <sys/vnode.h> 34*b819cea2SGordon Ross #include <sys/nvpair.h> 35*b819cea2SGordon Ross #include <sys/uio.h> 36*b819cea2SGordon Ross #include <sys/kmem.h> 37*b819cea2SGordon Ross #include <fs/fs_subr.h> 38*b819cea2SGordon Ross #include <fs/fs_reparse.h> 39*b819cea2SGordon Ross 40*b819cea2SGordon Ross 41*b819cea2SGordon Ross /* 42*b819cea2SGordon Ross * support functions for reparse point 43*b819cea2SGordon Ross * copied from uts/common/fs/fs_subr.c 44*b819cea2SGordon Ross */ 45*b819cea2SGordon Ross 46*b819cea2SGordon Ross /* 47*b819cea2SGordon Ross * reparse_vnode_parse 48*b819cea2SGordon Ross * 49*b819cea2SGordon Ross * Read the symlink data of a reparse point specified by the vnode 50*b819cea2SGordon Ross * and return the reparse data as name-value pair in the nvlist. 51*b819cea2SGordon Ross */ 52*b819cea2SGordon Ross int 53*b819cea2SGordon Ross reparse_vnode_parse(vnode_t *vp, nvlist_t *nvl) 54*b819cea2SGordon Ross { 55*b819cea2SGordon Ross int err; 56*b819cea2SGordon Ross char *lkdata; 57*b819cea2SGordon Ross struct uio uio; 58*b819cea2SGordon Ross struct iovec iov; 59*b819cea2SGordon Ross 60*b819cea2SGordon Ross if (vp == NULL || nvl == NULL) 61*b819cea2SGordon Ross return (EINVAL); 62*b819cea2SGordon Ross 63*b819cea2SGordon Ross lkdata = kmem_alloc(MAXREPARSELEN, KM_SLEEP); 64*b819cea2SGordon Ross 65*b819cea2SGordon Ross /* 66*b819cea2SGordon Ross * Set up io vector to read sym link data 67*b819cea2SGordon Ross */ 68*b819cea2SGordon Ross iov.iov_base = lkdata; 69*b819cea2SGordon Ross iov.iov_len = MAXREPARSELEN; 70*b819cea2SGordon Ross uio.uio_iov = &iov; 71*b819cea2SGordon Ross uio.uio_iovcnt = 1; 72*b819cea2SGordon Ross uio.uio_segflg = UIO_SYSSPACE; 73*b819cea2SGordon Ross uio.uio_extflg = UIO_COPY_CACHED; 74*b819cea2SGordon Ross uio.uio_loffset = (offset_t)0; 75*b819cea2SGordon Ross uio.uio_resid = MAXREPARSELEN; 76*b819cea2SGordon Ross 77*b819cea2SGordon Ross if ((err = VOP_READLINK(vp, &uio, zone_kcred(), NULL)) == 0) { 78*b819cea2SGordon Ross *(lkdata + MAXREPARSELEN - uio.uio_resid) = '\0'; 79*b819cea2SGordon Ross err = reparse_parse(lkdata, nvl); 80*b819cea2SGordon Ross } 81*b819cea2SGordon Ross kmem_free(lkdata, MAXREPARSELEN); /* done with lkdata */ 82*b819cea2SGordon Ross 83*b819cea2SGordon Ross return (err); 84*b819cea2SGordon Ross } 85