9512fe850e98fdd448c638ca63fdd92a8a510255ahl/*
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * CDDL HEADER START
9512fe850e98fdd448c638ca63fdd92a8a510255ahl *
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * The contents of this file are subject to the terms of the
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * Common Development and Distribution License (the "License").
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * You may not use this file except in compliance with the License.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl *
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * or http://www.opensolaris.org/os/licensing.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * See the License for the specific language governing permissions
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * and limitations under the License.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl *
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * When distributing Covered Code, include this CDDL HEADER in each
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * If applicable, add the following below this CDDL HEADER, with the
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * fields enclosed by brackets "[]" replaced with your own identifying
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * information: Portions Copyright [yyyy] [name of copyright owner]
9512fe850e98fdd448c638ca63fdd92a8a510255ahl *
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * CDDL HEADER END
9512fe850e98fdd448c638ca63fdd92a8a510255ahl */
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl/*
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * Use is subject to license terms.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl */
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl#pragma ident "%Z%%M% %I% %E% SMI"
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl/*
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * ASSERTION:
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * Verify doc example 7-1
9512fe850e98fdd448c638ca63fdd92a8a510255ahl *
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * SECTION:
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * DocExamples/rwinfo
9512fe850e98fdd448c638ca63fdd92a8a510255ahl */
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl#pragma D option quiet
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahlstruct callinfo {
9512fe850e98fdd448c638ca63fdd92a8a510255ahl uint64_t ts;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl uint64_t elapsed;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl uint64_t calls;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl size_t maxbytes;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl};
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahlstruct callinfo i[string];
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahlsyscall::read:entry,
9512fe850e98fdd448c638ca63fdd92a8a510255ahlsyscall::write:entry
9512fe850e98fdd448c638ca63fdd92a8a510255ahl/pid == 100551/
9512fe850e98fdd448c638ca63fdd92a8a510255ahl{
9512fe850e98fdd448c638ca63fdd92a8a510255ahl i[probefunc].ts = timestamp;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl i[probefunc].calls++;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl i[probefunc].maxbytes = arg2 > i[probefunc].maxbytes ?
9512fe850e98fdd448c638ca63fdd92a8a510255ahl arg2 : i[probefunc].maxbytes;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl}
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahlsyscall::read:return,
9512fe850e98fdd448c638ca63fdd92a8a510255ahlsyscall::write:return
9512fe850e98fdd448c638ca63fdd92a8a510255ahl/i[probefunc].ts != 0 && pid == 100551/
9512fe850e98fdd448c638ca63fdd92a8a510255ahl{
9512fe850e98fdd448c638ca63fdd92a8a510255ahl i[probefunc].elapsed += timestamp - i[probefunc].ts;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl}
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahlEND
9512fe850e98fdd448c638ca63fdd92a8a510255ahl{
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf(" calls max bytes elapsed nsecs\n");
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf("----- ----- --------- -------------\n");
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf(" read %5d %9d %d\n", i["read"].calls,
9512fe850e98fdd448c638ca63fdd92a8a510255ahl i["read"].maxbytes, i["read"].elapsed);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf(" write %5d %9d %d\n", i["write"].calls,
9512fe850e98fdd448c638ca63fdd92a8a510255ahl i["write"].maxbytes, i["write"].elapsed);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl}