From owner-freebsd-hackers Mon Apr 12 7: 4:36 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from ns.oeno.com (ns.oeno.com [194.100.99.145]) by hub.freebsd.org (Postfix) with SMTP id 93C7B14E95 for ; Mon, 12 Apr 1999 07:04:28 -0700 (PDT) (envelope-from will@ns.oeno.com) Received: (qmail 2207 invoked by uid 1001); 12 Apr 1999 14:02:06 -0000 To: dillon@apollo.backplane.com (Matthew Dillon) Cc: hackers@freebsd.org Subject: Re: read() and pread() syscalls References: <199904120126.SAA11924@apollo.backplane.com> From: Ville-Pertti Keinonen Date: 12 Apr 1999 17:01:50 +0300 In-Reply-To: dillon@apollo.backplane.com's message of "12 Apr 1999 04:27:16 +0300" Message-ID: <86hfqmgcoh.fsf@not.demophon.com> Lines: 20 X-Mailer: Gnus v5.5/XEmacs 20.4 - "Emerald" Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG dillon@apollo.backplane.com (Matthew Dillon) writes: > :> But, see above about it not being possible to emulate read() with pread() > :> in userspace. > : > :You mean, without lseek(2) =) > > pread/pwrite + lseek is not atomic, so exact emulation is not > possible. This may come as a shock to you, but read(2)/write(2) aren't atomic in updating the file pointer, either. Actually, read(2) is equivalent to lseek(2)+pread(2)+lseek(2), with the last lseek(2) being SEEK_CUR by the read count returned by pread(2). The difference is that read(2) can only be pre-empted if it blocks doing I/O (which is not unusual). Of course emulating read(2) would be ugly and slow. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message