From owner-freebsd-hackers Wed Nov 29 13:11:21 1995 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id NAA20725 for hackers-outgoing; Wed, 29 Nov 1995 13:11:21 -0800 Received: from phaeton.artisoft.com (phaeton.Artisoft.COM [198.17.250.211]) by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id NAA20715 for ; Wed, 29 Nov 1995 13:11:13 -0800 Received: (from terry@localhost) by phaeton.artisoft.com (8.6.11/8.6.9) id OAA28617; Wed, 29 Nov 1995 14:05:44 -0700 From: Terry Lambert Message-Id: <199511292105.OAA28617@phaeton.artisoft.com> Subject: Re: uio question... To: msmith@atrad.adelaide.edu.au (Michael Smith) Date: Wed, 29 Nov 1995 14:05:44 -0700 (MST) Cc: hackers@freebsd.org In-Reply-To: <199511290134.BAA09808@genesis.atrad.adelaide.edu.au> from "Michael Smith" at Nov 29, 95 01:34:51 am X-Mailer: ELM [version 2.4 PL24] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Length: 1203 Sender: owner-hackers@freebsd.org Precedence: bulk > Okay, my entry for the lame-device-driver-question of the month 8) > > Given a device read function passed a uio struct, what's the correct way > to determine the total size of the read request? > > I have two possibles here : walk the array of iovec structures, or > contemplate the uio_resid field, which appears to be used by a number of > other drivers... > > Experience? The "resid" is used to determine residual read remaining. Typically, a uio struct will have an iovec count of one, or the alternate iovec's will be non-contiguous. In either case , for a non-one iovec count in the uio, you *must* walk the iovec list to return any information. The question is whether your driver does scatter/gather itself, or whether it will be handling I/O one iovec at a time. You should look at the tty, generic (controller independent) scsi code, one of the SCSI controller dependendt code pieces (the 1540/1740? I recommend against the NCR/AHA2xxx code because of the additional complexity) and the readv/writev system call code in /usr/src/sys/kern. Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers.