1*8329232eSGordon Ross /*
2*8329232eSGordon Ross  * CDDL HEADER START
3*8329232eSGordon Ross  *
4*8329232eSGordon Ross  * The contents of this file are subject to the terms of the
5*8329232eSGordon Ross  * Common Development and Distribution License (the "License").
6*8329232eSGordon Ross  * You may not use this file except in compliance with the License.
7*8329232eSGordon Ross  *
8*8329232eSGordon Ross  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*8329232eSGordon Ross  * or http://www.opensolaris.org/os/licensing.
10*8329232eSGordon Ross  * See the License for the specific language governing permissions
11*8329232eSGordon Ross  * and limitations under the License.
12*8329232eSGordon Ross  *
13*8329232eSGordon Ross  * When distributing Covered Code, include this CDDL HEADER in each
14*8329232eSGordon Ross  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*8329232eSGordon Ross  * If applicable, add the following below this CDDL HEADER, with the
16*8329232eSGordon Ross  * fields enclosed by brackets "[]" replaced with your own identifying
17*8329232eSGordon Ross  * information: Portions Copyright [yyyy] [name of copyright owner]
18*8329232eSGordon Ross  *
19*8329232eSGordon Ross  * CDDL HEADER END
20*8329232eSGordon Ross  */
21*8329232eSGordon Ross 
22*8329232eSGordon Ross /*
23*8329232eSGordon Ross  * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
24*8329232eSGordon Ross  * Copyright 2017 Nexenta Systems, Inc.  All rights reserved.
25*8329232eSGordon Ross  */
26*8329232eSGordon Ross 
27*8329232eSGordon Ross /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
28*8329232eSGordon Ross /*	  All Rights Reserved	*/
29*8329232eSGordon Ross 
30*8329232eSGordon Ross /*
31*8329232eSGordon Ross  * Portions of this source code were derived from Berkeley 4.3 BSD
32*8329232eSGordon Ross  * under license from the Regents of the University of California.
33*8329232eSGordon Ross  */
34*8329232eSGordon Ross 
35*8329232eSGordon Ross /*
36*8329232eSGordon Ross  * Get file attribute information through a file name or a file descriptor.
37*8329232eSGordon Ross  */
38*8329232eSGordon Ross 
39*8329232eSGordon Ross #include <sys/param.h>
40*8329232eSGordon Ross #include <sys/isa_defs.h>
41*8329232eSGordon Ross #include <sys/types.h>
42*8329232eSGordon Ross #include <sys/sysmacros.h>
43*8329232eSGordon Ross #include <sys/cred.h>
44*8329232eSGordon Ross #include <sys/systm.h>
45*8329232eSGordon Ross #include <sys/errno.h>
46*8329232eSGordon Ross #include <sys/fcntl.h>
47*8329232eSGordon Ross #include <sys/pathname.h>
48*8329232eSGordon Ross #include <sys/stat.h>
49*8329232eSGordon Ross #include <sys/vfs.h>
50*8329232eSGordon Ross #include <sys/vnode.h>
51*8329232eSGordon Ross #include <sys/mode.h>
52*8329232eSGordon Ross #include <sys/file.h>
53*8329232eSGordon Ross #include <sys/proc.h>
54*8329232eSGordon Ross #include <sys/uio.h>
55*8329232eSGordon Ross #include <sys/debug.h>
56*8329232eSGordon Ross #include <sys/cmn_err.h>
57*8329232eSGordon Ross #include <fs/fs_subr.h>
58*8329232eSGordon Ross 
59*8329232eSGordon Ross #include <libfksmbfs.h>
60*8329232eSGordon Ross 
61*8329232eSGordon Ross int
fake_stat(vnode_t * vp,struct stat64 * ubp,int flag)62*8329232eSGordon Ross fake_stat(vnode_t *vp, struct stat64 *ubp, int flag)
63*8329232eSGordon Ross {
64*8329232eSGordon Ross 	cred_t *cr = CRED();
65*8329232eSGordon Ross 	struct vfssw *vswp;
66*8329232eSGordon Ross 	struct stat64 lsb;
67*8329232eSGordon Ross 	vattr_t vattr;
68*8329232eSGordon Ross 	int error;
69*8329232eSGordon Ross 
70*8329232eSGordon Ross 	vattr.va_mask = AT_STAT | AT_NBLOCKS | AT_BLKSIZE | AT_SIZE;
71*8329232eSGordon Ross 	if (error = VOP_GETATTR(vp, &vattr, flag, cr, NULL))
72*8329232eSGordon Ross 		return (error);
73*8329232eSGordon Ross 
74*8329232eSGordon Ross 	bzero(&lsb, sizeof (lsb));
75*8329232eSGordon Ross 	lsb.st_dev = vattr.va_fsid;
76*8329232eSGordon Ross 	lsb.st_ino = vattr.va_nodeid;
77*8329232eSGordon Ross 	lsb.st_mode = VTTOIF(vattr.va_type) | vattr.va_mode;
78*8329232eSGordon Ross 	lsb.st_nlink = vattr.va_nlink;
79*8329232eSGordon Ross 	lsb.st_uid = vattr.va_uid;
80*8329232eSGordon Ross 	lsb.st_gid = vattr.va_gid;
81*8329232eSGordon Ross 	lsb.st_rdev = vattr.va_rdev;
82*8329232eSGordon Ross 	lsb.st_size = vattr.va_size;
83*8329232eSGordon Ross 	lsb.st_atim = vattr.va_atime;
84*8329232eSGordon Ross 	lsb.st_mtim = vattr.va_mtime;
85*8329232eSGordon Ross 	lsb.st_ctim = vattr.va_ctime;
86*8329232eSGordon Ross 	lsb.st_blksize = vattr.va_blksize;
87*8329232eSGordon Ross 	lsb.st_blocks = vattr.va_nblocks;
88*8329232eSGordon Ross 	if (vp->v_vfsp != NULL) {
89*8329232eSGordon Ross 		vswp = &vfssw[vp->v_vfsp->vfs_fstype];
90*8329232eSGordon Ross 		if (vswp->vsw_name && *vswp->vsw_name)
91*8329232eSGordon Ross 			(void) strcpy(lsb.st_fstype, vswp->vsw_name);
92*8329232eSGordon Ross 	}
93*8329232eSGordon Ross 	if (copyout(&lsb, ubp, sizeof (lsb)))
94*8329232eSGordon Ross 		return (EFAULT);
95*8329232eSGordon Ross 	return (0);
96*8329232eSGordon Ross }
97