2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A#pragma D depends_on module unix
2N/A#pragma D depends_on provider io
2N/A
2N/Ainline int B_BUSY = @B_BUSY@;
2N/A#pragma D binding "1.0" B_BUSY
2N/Ainline int B_DONE = @B_DONE@;
2N/A#pragma D binding "1.0" B_DONE
2N/Ainline int B_ERROR = @B_ERROR@;
2N/A#pragma D binding "1.0" B_ERROR
2N/Ainline int B_PAGEIO = @B_PAGEIO@;
2N/A#pragma D binding "1.0" B_PAGEIO
2N/Ainline int B_PHYS = @B_PHYS@;
2N/A#pragma D binding "1.0" B_PHYS
2N/Ainline int B_READ = @B_READ@;
2N/A#pragma D binding "1.0" B_READ
2N/Ainline int B_WRITE = @B_WRITE@;
2N/A#pragma D binding "1.0" B_WRITE
2N/Ainline int B_ASYNC = @B_ASYNC@;
2N/A#pragma D binding "1.0" B_ASYNC
2N/A
2N/Atypedef struct bufinfo {
2N/A int b_flags; /* buffer status */
2N/A size_t b_bcount; /* number of bytes */
2N/A caddr_t b_addr; /* buffer address */
2N/A uint64_t b_lblkno; /* block # on device */
2N/A uint64_t b_blkno; /* expanded block # on device */
2N/A size_t b_resid; /* # of bytes not transferred */
2N/A size_t b_bufsize; /* size of allocated buffer */
2N/A caddr_t b_iodone; /* I/O completion routine */
2N/A int b_error; /* expanded error field */
2N/A dev_t b_edev; /* extended device */
2N/A} bufinfo_t;
2N/A
2N/A#pragma D binding "1.0" translator
2N/Atranslator bufinfo_t < struct buf *B > {
2N/A b_flags = B->b_flags;
2N/A b_addr = B->b_un.b_addr;
2N/A b_bcount = B->b_bcount;
2N/A b_lblkno = B->_b_blkno._f;
2N/A b_blkno = sizeof (long) == 8 ? B->_b_blkno._f : B->_b_blkno._p._l;
2N/A b_resid = B->b_resid;
2N/A b_bufsize = B->b_bufsize;
2N/A b_iodone = (caddr_t)B->b_iodone;
2N/A b_error = B->b_error;
2N/A b_edev = B->b_edev;
2N/A};
2N/A
2N/Atypedef struct devinfo {
2N/A int dev_major; /* major number */
2N/A int dev_minor; /* minor number */
2N/A int dev_instance; /* instance number */
2N/A string dev_name; /* name of device */
2N/A string dev_statname; /* name of device + instance/minor */
2N/A string dev_pathname; /* pathname of device */
2N/A} devinfo_t;
2N/A
2N/A#pragma D binding "1.0" translator
2N/Atranslator devinfo_t < struct buf *B > {
2N/A dev_major = B->b_dip != NULL ? getmajor(B->b_edev) :
2N/A getmajor(B->b_file->v_vfsp->vfs_dev);
2N/A dev_minor = B->b_dip != NULL ? getminor(B->b_edev) :
2N/A getminor(B->b_file->v_vfsp->vfs_dev);
2N/A dev_instance = B->b_dip == NULL ?
2N/A getminor(B->b_file->v_vfsp->vfs_dev) :
2N/A ((struct dev_info *)B->b_dip)->devi_instance;
2N/A dev_name = B->b_dip == NULL ? "nfs" :
2N/A stringof(`devnamesp[getmajor(B->b_edev)].dn_name);
2N/A dev_statname = strjoin(B->b_dip == NULL ? "nfs" :
2N/A stringof(`devnamesp[getmajor(B->b_edev)].dn_name),
2N/A lltostr(B->b_dip == NULL ? getminor(B->b_file->v_vfsp->vfs_dev) :
2N/A ((struct dev_info *)B->b_dip)->devi_instance == 0 &&
2N/A ((struct dev_info *)B->b_dip)->devi_parent != NULL &&
2N/A ((struct dev_info *)B->b_dip)->devi_parent->devi_node_name ==
2N/A "pseudo" ? getminor(B->b_edev) :
2N/A ((struct dev_info *)B->b_dip)->devi_instance));
2N/A dev_pathname = B->b_dip == NULL ? "<nfs>" :
2N/A ddi_pathname(B->b_dip, getminor(B->b_edev));
2N/A};
2N/A
2N/Atypedef struct fileinfo {
2N/A string fi_name; /* name (basename of fi_pathname) */
2N/A string fi_dirname; /* directory (dirname of fi_pathname) */
2N/A string fi_pathname; /* full pathname */
2N/A offset_t fi_offset; /* offset within file */
2N/A string fi_fs; /* filesystem */
2N/A string fi_mount; /* mount point of file system */
2N/A int fi_oflags; /* open(2) flags for file descriptor */
2N/A} fileinfo_t;
2N/A
2N/A#pragma D binding "1.0" translator
2N/Atranslator fileinfo_t < struct buf *B > {
2N/A fi_name = B->b_file == NULL ? "<none>" :
2N/A B->b_file->v_path == NULL ? "<unknown>" :
2N/A basename(cleanpath(B->b_file->v_path));
2N/A fi_dirname = B->b_file == NULL ? "<none>" :
2N/A B->b_file->v_path == NULL ? "<unknown>" :
2N/A dirname(cleanpath(B->b_file->v_path));
2N/A fi_pathname = B->b_file == NULL ? "<none>" :
2N/A B->b_file->v_path == NULL ? "<unknown>" :
2N/A cleanpath(B->b_file->v_path);
2N/A fi_offset = B->b_offset;
2N/A fi_fs = B->b_file == NULL ? "<none>" :
2N/A stringof(B->b_file->v_op->vnop_name);
2N/A fi_mount = B->b_file == NULL ? "<none>" :
2N/A B->b_file->v_vfsp->vfs_vnodecovered == NULL ? "/" :
2N/A B->b_file->v_vfsp->vfs_vnodecovered->v_path == NULL ? "<unknown>" :
2N/A cleanpath(B->b_file->v_vfsp->vfs_vnodecovered->v_path);
2N/A fi_oflags = 0;
2N/A};
2N/A
2N/A/*
2N/A * The following inline constants can be used to examine fi_oflags when using
2N/A * the fds[] array or a translated fileinfo_t. Note that the various open
2N/A * flags behave as a bit-field *except* for O_RDONLY, O_WRONLY, and O_RDWR.
2N/A * To test the open mode, you write code similar to that used with the fcntl(2)
2N/A * F_GET[X]FL command, such as: if ((fi_oflags & O_ACCMODE) == O_WRONLY).
2N/A */
2N/Ainline int O_ACCMODE = @O_ACCMODE@;
2N/A#pragma D binding "1.1" O_ACCMODE
2N/A
2N/Ainline int O_RDONLY = @O_RDONLY@;
2N/A#pragma D binding "1.1" O_RDONLY
2N/Ainline int O_WRONLY = @O_WRONLY@;
2N/A#pragma D binding "1.1" O_WRONLY
2N/Ainline int O_RDWR = @O_RDWR@;
2N/A#pragma D binding "1.1" O_RDWR
2N/A
2N/Ainline int O_APPEND = @O_APPEND@;
2N/A#pragma D binding "1.1" O_APPEND
2N/Ainline int O_CREAT = @O_CREAT@;
2N/A#pragma D binding "1.1" O_CREAT
2N/Ainline int O_DSYNC = @O_DSYNC@;
2N/A#pragma D binding "1.1" O_DSYNC
2N/Ainline int O_EXCL = @O_EXCL@;
2N/A#pragma D binding "1.1" O_EXCL
2N/Ainline int O_LARGEFILE = @O_LARGEFILE@;
2N/A#pragma D binding "1.1" O_LARGEFILE
2N/Ainline int O_NOCTTY = @O_NOCTTY@;
2N/A#pragma D binding "1.1" O_NOCTTY
2N/Ainline int O_NONBLOCK = @O_NONBLOCK@;
2N/A#pragma D binding "1.1" O_NONBLOCK
2N/Ainline int O_NDELAY = @O_NDELAY@;
2N/A#pragma D binding "1.1" O_NDELAY
2N/Ainline int O_RSYNC = @O_RSYNC@;
2N/A#pragma D binding "1.1" O_RSYNC
2N/Ainline int O_SYNC = @O_SYNC@;
2N/A#pragma D binding "1.1" O_SYNC
2N/Ainline int O_TRUNC = @O_TRUNC@;
2N/A#pragma D binding "1.1" O_TRUNC
2N/Ainline int O_XATTR = @O_XATTR@;
2N/A#pragma D binding "1.1" O_XATTR
2N/A
2N/A#pragma D binding "1.1" translator
2N/Atranslator fileinfo_t < struct file *F > {
2N/A fi_name = F == NULL ? "<none>" :
2N/A F->f_vnode->v_path == NULL ? "<unknown>" :
2N/A basename(cleanpath(F->f_vnode->v_path));
2N/A fi_dirname = F == NULL ? "<none>" :
2N/A F->f_vnode->v_path == NULL ? "<unknown>" :
2N/A dirname(cleanpath(F->f_vnode->v_path));
2N/A fi_pathname = F == NULL ? "<none>" :
2N/A F->f_vnode->v_path == NULL ? "<unknown>" :
2N/A cleanpath(F->f_vnode->v_path);
2N/A fi_offset = F == NULL ? 0 : F->f_offset;
2N/A fi_fs = F == NULL ? "<none>" : stringof(F->f_vnode->v_op->vnop_name);
2N/A fi_mount = F == NULL ? "<none>" :
2N/A F->f_vnode->v_vfsp->vfs_vnodecovered == NULL ? "/" :
2N/A F->f_vnode->v_vfsp->vfs_vnodecovered->v_path == NULL ? "<unknown>" :
2N/A cleanpath(F->f_vnode->v_vfsp->vfs_vnodecovered->v_path);
2N/A fi_oflags = F == NULL ? 0 : F->f_flag + (int)@FOPEN@;
2N/A};
2N/A
2N/Ainline fileinfo_t fds[int fd] = xlate <fileinfo_t> (
2N/A fd >= 0 && fd < curthread->t_procp->p_user.u_finfo.fi_nfiles ?
2N/A curthread->t_procp->p_user.u_finfo.fi_list[fd].uf_file : NULL);
2N/A
2N/A#pragma D attributes Stable/Stable/Common fds
2N/A#pragma D binding "1.1" fds
2N/A
2N/A#pragma D binding "1.2" translator
2N/Atranslator fileinfo_t < struct vnode *V > {
2N/A fi_name = V->v_path == NULL ? "<unknown>" :
2N/A basename(cleanpath(V->v_path));
2N/A fi_dirname = V->v_path == NULL ? "<unknown>" :
2N/A dirname(cleanpath(V->v_path));
2N/A fi_pathname = V->v_path == NULL ? "<unknown>" : cleanpath(V->v_path);
2N/A fi_fs = stringof(V->v_op->vnop_name);
2N/A fi_mount = V->v_vfsp->vfs_vnodecovered == NULL ? "/" :
2N/A V->v_vfsp->vfs_vnodecovered->v_path == NULL ? "<unknown>" :
2N/A cleanpath(V->v_vfsp->vfs_vnodecovered->v_path);
2N/A};