4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
24 */
25
26 #include <sys/types.h>
27 #include <sys/t_lock.h>
28 #include <sys/param.h>
29 #include <sys/systm.h>
30 #include <sys/buf.h>
31 #include <sys/conf.h>
32 #include <sys/cred.h>
33 #include <sys/kmem.h>
34 #include <sys/sysmacros.h>
35 #include <sys/vfs.h>
36 #include <sys/vfs_opreg.h>
37 #include <sys/vnode.h>
38 #include <sys/debug.h>
39 #include <sys/errno.h>
40 #include <sys/time.h>
41 #include <sys/file.h>
42 #include <sys/open.h>
43 #include <sys/user.h>
419 ptr1 = (uintptr_t)mp->b_rptr + offset;
420 ptr2 = (uintptr_t)ptr1 + length;
421 if (ptr1 < (uintptr_t)mp->b_rptr || ptr2 > (uintptr_t)mp->b_wptr) {
422 eprintline(0);
423 return (NULL);
424 }
425 if ((ptr1 & (align_size - 1)) != 0) {
426 eprintline(0);
427 return (NULL);
428 }
429 return ((void *)ptr1);
430 }
431
432 /*
433 * Return the AF_UNIX underlying filesystem vnode matching a given name.
434 * Makes sure the sending and the destination sonodes are compatible.
435 * The vnode is returned held.
436 *
437 * The underlying filesystem VSOCK vnode has a v_stream pointer that
438 * references the actual stream head (hence indirectly the actual sonode).
439 */
440 static int
441 so_ux_lookup(struct sonode *so, struct sockaddr_un *soun, int checkaccess,
442 vnode_t **vpp)
443 {
444 vnode_t *vp; /* Underlying filesystem vnode */
445 vnode_t *rvp; /* real vnode */
446 vnode_t *svp; /* sockfs vnode */
447 struct sonode *so2;
448 int error;
449
450 dprintso(so, 1, ("so_ux_lookup(%p) name <%s>\n", (void *)so,
451 soun->sun_path));
452
453 error = lookupname(soun->sun_path, UIO_SYSSPACE, FOLLOW, NULLVPP, &vp);
454 if (error) {
455 eprintsoline(so, error);
456 return (error);
457 }
458
459 /*
460 * Traverse lofs mounts get the real vnode
1862 mutex_exit(&so->so_lock);
1863
1864 (void) sprintf(pksi->ks_straddr[0], "%p", (void *)so);
1865 (void) sprintf(pksi->ks_straddr[1], "%p",
1866 (void *)sti->sti_ux_laddr.soua_vp);
1867 (void) sprintf(pksi->ks_straddr[2], "%p",
1868 (void *)sti->sti_ux_faddr.soua_vp);
1869
1870 ns++;
1871 pksi++;
1872 }
1873
1874 ksp->ks_ndata = ns;
1875 return (0);
1876 }
1877
1878 ssize_t
1879 soreadfile(file_t *fp, uchar_t *buf, u_offset_t fileoff, int *err, size_t size)
1880 {
1881 struct uio auio;
1882 struct iovec aiov[MSG_MAXIOVLEN];
1883 register vnode_t *vp;
1884 int ioflag, rwflag;
1885 ssize_t cnt;
1886 int error = 0;
1887 int iovcnt = 0;
1888 short fflag;
1889
1890 vp = fp->f_vnode;
1891 fflag = fp->f_flag;
1892
1893 rwflag = 0;
1894 aiov[0].iov_base = (caddr_t)buf;
1895 aiov[0].iov_len = size;
1896 iovcnt = 1;
1897 cnt = (ssize_t)size;
1898 (void) VOP_RWLOCK(vp, rwflag, NULL);
1899
1900 auio.uio_loffset = fileoff;
1901 auio.uio_iov = aiov;
1902 auio.uio_iovcnt = iovcnt;
|
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2015, Joyent, Inc. All rights reserved.
25 */
26
27 #include <sys/types.h>
28 #include <sys/t_lock.h>
29 #include <sys/param.h>
30 #include <sys/systm.h>
31 #include <sys/buf.h>
32 #include <sys/conf.h>
33 #include <sys/cred.h>
34 #include <sys/kmem.h>
35 #include <sys/sysmacros.h>
36 #include <sys/vfs.h>
37 #include <sys/vfs_opreg.h>
38 #include <sys/vnode.h>
39 #include <sys/debug.h>
40 #include <sys/errno.h>
41 #include <sys/time.h>
42 #include <sys/file.h>
43 #include <sys/open.h>
44 #include <sys/user.h>
420 ptr1 = (uintptr_t)mp->b_rptr + offset;
421 ptr2 = (uintptr_t)ptr1 + length;
422 if (ptr1 < (uintptr_t)mp->b_rptr || ptr2 > (uintptr_t)mp->b_wptr) {
423 eprintline(0);
424 return (NULL);
425 }
426 if ((ptr1 & (align_size - 1)) != 0) {
427 eprintline(0);
428 return (NULL);
429 }
430 return ((void *)ptr1);
431 }
432
433 /*
434 * Return the AF_UNIX underlying filesystem vnode matching a given name.
435 * Makes sure the sending and the destination sonodes are compatible.
436 * The vnode is returned held.
437 *
438 * The underlying filesystem VSOCK vnode has a v_stream pointer that
439 * references the actual stream head (hence indirectly the actual sonode).
440 *
441 * This function is non-static so it can be used by brand emulation.
442 */
443 int
444 so_ux_lookup(struct sonode *so, struct sockaddr_un *soun, int checkaccess,
445 vnode_t **vpp)
446 {
447 vnode_t *vp; /* Underlying filesystem vnode */
448 vnode_t *rvp; /* real vnode */
449 vnode_t *svp; /* sockfs vnode */
450 struct sonode *so2;
451 int error;
452
453 dprintso(so, 1, ("so_ux_lookup(%p) name <%s>\n", (void *)so,
454 soun->sun_path));
455
456 error = lookupname(soun->sun_path, UIO_SYSSPACE, FOLLOW, NULLVPP, &vp);
457 if (error) {
458 eprintsoline(so, error);
459 return (error);
460 }
461
462 /*
463 * Traverse lofs mounts get the real vnode
1865 mutex_exit(&so->so_lock);
1866
1867 (void) sprintf(pksi->ks_straddr[0], "%p", (void *)so);
1868 (void) sprintf(pksi->ks_straddr[1], "%p",
1869 (void *)sti->sti_ux_laddr.soua_vp);
1870 (void) sprintf(pksi->ks_straddr[2], "%p",
1871 (void *)sti->sti_ux_faddr.soua_vp);
1872
1873 ns++;
1874 pksi++;
1875 }
1876
1877 ksp->ks_ndata = ns;
1878 return (0);
1879 }
1880
1881 ssize_t
1882 soreadfile(file_t *fp, uchar_t *buf, u_offset_t fileoff, int *err, size_t size)
1883 {
1884 struct uio auio;
1885 struct iovec aiov[1];
1886 register vnode_t *vp;
1887 int ioflag, rwflag;
1888 ssize_t cnt;
1889 int error = 0;
1890 int iovcnt = 0;
1891 short fflag;
1892
1893 vp = fp->f_vnode;
1894 fflag = fp->f_flag;
1895
1896 rwflag = 0;
1897 aiov[0].iov_base = (caddr_t)buf;
1898 aiov[0].iov_len = size;
1899 iovcnt = 1;
1900 cnt = (ssize_t)size;
1901 (void) VOP_RWLOCK(vp, rwflag, NULL);
1902
1903 auio.uio_loffset = fileoff;
1904 auio.uio_iov = aiov;
1905 auio.uio_iovcnt = iovcnt;
|