From owner-freebsd-bugs Wed Nov 28 5:50:18 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 2134637B41C for ; Wed, 28 Nov 2001 05:50:01 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id fASDo1C20693; Wed, 28 Nov 2001 05:50:01 -0800 (PST) (envelope-from gnats) Received: from westhost36.westhost.net (westhost36.westhost.net [216.71.84.209]) by hub.freebsd.org (Postfix) with ESMTP id C7D1737B417 for ; Wed, 28 Nov 2001 05:41:00 -0800 (PST) Received: (from haikugeek@localhost) by westhost36.westhost.net (8.11.6/8.11.6) id fASDeBg14536 for FreeBSD-gnats-submit@freebsd.org; Wed, 28 Nov 2001 07:40:11 -0600 Message-Id: <200111281340.fASDeBg14536@westhost36.westhost.net> Date: Wed, 28 Nov 2001 07:40:11 -0600 From: haikugeek@westhost36.westhost.net To: FreeBSD-gnats-submit@freebsd.org Subject: kern/32350: libstand's write always returns 0 unless error. Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 32350 >Category: kern >Synopsis: libstand's write always returns 0 unless error. >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Nov 28 05:50:01 PST 2001 >Closed-Date: >Last-Modified: >Originator: Jonathan Mini >Release: FreeBSD 5.0-CURRENT i386 >Organization: >Environment: System: FreeBSD groove.haikugeek.com FreeBSD 5.0-CURRENT #1: Sun Nov 18 02:30:58 GMT 2001 mini@:/usr/obj/usr/home/mini/work/src/sys/GENERIC i386 >Description: Libstand's implementation of write() returns 0 on success, instead of the number of bytes written. >How-To-Repeat: Well, it's a little hard to reproduce unless you have my changes to allow ufs writes in libstand, as none of the filesystems accept write requests and no console access is done via the write() interface. However, if you apply this patch: http://www.haikugeek.com/freebsd/5.0-boot-libstand.diff .. which adds limited write support to the ufs code, and then open a file and write to it, you will see that write will return 0 instead of the number of bytes written, e.g.: int fd,res; fd = open("/etc/motd",O_WRONLY); res = write(fd,"foo!",4); printf("write: %d bytes written.\n",res); will print: write: 0 bytes written. >Fix: Apply this patch: Index: lib/libstand/write.c =================================================================== RCS file: /usr/FreeBSD/src/lib/libstand/write.c,v retrieving revision 1.2 diff -c -r1.2 write.c *** lib/libstand/write.c 2001/09/30 22:28:01 1.2 --- lib/libstand/write.c 2001/11/15 18:04:19 *************** *** 95,99 **** resid = bcount; if ((errno = (f->f_ops->fo_write)(f, dest, bcount, &resid))) return (-1); ! return (0); } --- 97,101 ---- resid = bcount; if ((errno = (f->f_ops->fo_write)(f, dest, bcount, &resid))) return (-1); ! return (bcount - resid); } >Release-Note: >Audit-Trail: >Unformatted: To: FreeBSD-gnats-submit@freebsd.org From: Jonathan Mini Reply-To: Jonathan Mini Cc: X-send-pr-version: 3.113 X-GNATS-Notify: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message