components/openssh/dtrace_sftp/sftp64.d
author John Beck <John.Beck@Oracle.COM>
Tue, 20 Oct 2015 18:38:49 -0700
changeset 4985 eed3576cafd0
parent 3820 1063fcafa7a5
permissions -rw-r--r--
21136303 Python 2.6 EOF (remove duplicate pkg history entry)

/*
 * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
 */

#pragma D depends_on library net.d
#pragma D depends_on library io.d
#pragma D depends_on module lofs

typedef struct sftpinfo {
	string sfi_user;		/* user name */
	string sfi_operation;		/* SFTP Operation */
	ssize_t sfi_nbytes;		/* bytes transferred, if any */
	string sfi_pathname;		/* pathname of transfer */
	string sfi_fsresource;		/* Dataset(ZFS) or resource name */
} sftpinfo_t;

/*
 * This structure must match the definition of same in sftp_provider_impl.h.
 */
typedef struct sftpproto {
	int64_t sftp_nbytes;		/* bytes written or read */
	uint64_t sftp_user;		/* user name */
	uint64_t sftp_operation;	/* SFTP operation */
	uint64_t sftp_raddr;		/* remote address */
	uint64_t sftp_pathname;		/* path with file name */
	int32_t sftp_fd;		/* fd for transfer, if any */
} sftpproto_t;

#pragma D binding "1.6.1" translator
translator conninfo_t <sftpproto_t *s> {
	ci_protocol = "tcp";
	ci_remote = copyinstr((uintptr_t)
	    *(uint64_t *)copyin((uintptr_t)&s->sftp_raddr, sizeof (uint64_t)));
	ci_local = "<unknown>";
};

#pragma D binding "1.6.1" translator
translator sftpinfo_t <sftpproto_t *s> {
	sfi_user = copyinstr((uintptr_t)
	    *(uint64_t *)copyin((uintptr_t)&s->sftp_user, sizeof (uint64_t)));
	sfi_operation = copyinstr((uintptr_t)
	    *(uint64_t *)copyin((uintptr_t)&s->sftp_operation,
	    sizeof (uint64_t)));
	sfi_nbytes =
	    *(uint64_t *)copyin((uintptr_t)&s->sftp_nbytes, sizeof (uint64_t));
	sfi_fsresource = stringof(fds[*(int32_t *)copyin((uintptr_t)&s->sftp_fd,
	    sizeof (int32_t))].fi_fs) == "lofs" ? stringof(((struct loinfo *)
	    curthread->t_procp->p_user.u_finfo.fi_list[*(int32_t *)copyin(
	    (uintptr_t)&s->sftp_fd, sizeof (int32_t))].uf_file->f_vnode->
	    v_vfsp->vfs_data)->li_realvfs->vfs_resource->rs_string) :
	    stringof(curthread->t_procp->p_user.u_finfo.fi_list[
	    *(int32_t *)copyin((uintptr_t)&s->sftp_fd, sizeof (int32_t))].
	    uf_file->f_vnode->v_vfsp->vfs_resource->rs_string);
	sfi_pathname = copyinstr((uintptr_t)*(uint64_t *)copyin(
	    (uintptr_t)&s->sftp_pathname, sizeof (uint64_t)));
};