From owner-freebsd-bugbusters@FreeBSD.ORG Sat Apr 28 19:45:06 2007 Return-Path: X-Original-To: bugbusters@freebsd.org Delivered-To: freebsd-bugbusters@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9CDB216A400 for ; Sat, 28 Apr 2007 19:45:06 +0000 (UTC) (envelope-from jschauma@netmeister.org) Received: from netmeister.org (netmeister.org [64.81.58.47]) by mx1.freebsd.org (Postfix) with ESMTP id 5E04D13C44B for ; Sat, 28 Apr 2007 19:45:01 +0000 (UTC) (envelope-from jschauma@netmeister.org) Received: by netmeister.org (Postfix, from userid 1000) id E25C882207; Sat, 28 Apr 2007 12:15:25 -0700 (PDT) Date: Sat, 28 Apr 2007 12:15:25 -0700 From: Jan Schaumann To: bugbusters@freebsd.org Message-ID: <20070428191525.GB25064@netmeister.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="UugvWAfsgieZRqgk" Content-Disposition: inline User-Agent: Mutt/1.5.13 (2006-08-11) Cc: Subject: touch(1)ing a directory and failing yields return code 0 X-BeenThere: freebsd-bugbusters@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Coordination of the Problem Report handling effort." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Apr 2007 19:45:06 -0000 --UugvWAfsgieZRqgk Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable When using touch(1) on a directory that I can't update the timestamp on (say, if the filesystem is mounted read-only), it will return 0 as the return value, even though it failed. The reason this happens is in touch.c#225: /* Try reading/writing. */ if (!S_ISLNK(sb.st_mode) && !S_ISDIR(sb.st_mode) && rw(*argv, &sb, fflag)) rval =3D 1; else warn("%s", *argv); At this point, it tries to update the timestamp using utimes(2), which failed, so it would continue to try to update it by reading and writing the file. However, since the file in question is a directory, it doesn't try this and simply warns instead of setting the return value to 1. $ mkdir foo $ touch foo/bar $ mount -u -o ro / $ touch foo/bar touch: foo/bar: Read-only file system $ echo $? 1 $ touch foo touch: foo: Read-only file system $ echo $? 0 $ See NetBSD's touch(1): /* Try reading/writing. */ if (!S_ISLNK(sb.st_mode) && rw(*argv, &sb, fflag)) rval =3D 1; This still is slightly suboptimal, since the error message will be $ touch foo touch: foo: Is a directory $ echo $? 1 $=20 But that's better than returning 0. --=20 Probability factor of one to one. We have normality. I repeat, we have=20 normality. Anything you still can't cope with is therefore your own lookout. --UugvWAfsgieZRqgk Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (NetBSD) iD8DBQFGM51NfFtkr68iakwRAv12AKDx50xVD9WjKzuBYs1ZrOKT54urNwCdFQnP 2+ZB1wezbGtRAOQAgIAWPdw= =KYYY -----END PGP SIGNATURE----- --UugvWAfsgieZRqgk--