From owner-freebsd-bugs Sat Nov 18 5:54:27 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from mta01-svc.ntlworld.com (mta01-svc.ntlworld.com [62.253.162.41]) by hub.freebsd.org (Postfix) with ESMTP id 2CABA37B479 for ; Sat, 18 Nov 2000 05:54:25 -0800 (PST) Received: from m276-mp1-cvx1c.gui.ntl.com ([62.252.13.20]) by mta01-svc.ntlworld.com (InterMail vM.4.01.02.27 201-229-119-110) with ESMTP id <20001118135422.EUOK277.mta01-svc.ntlworld.com@m276-mp1-cvx1c.gui.ntl.com>; Sat, 18 Nov 2000 13:54:22 +0000 Date: Sat, 18 Nov 2000 13:54:56 +0000 (GMT) From: George Reid X-Sender: geeorgy@sobek.nevernet.net To: David Malone Cc: Steve Bano , freebsd-bugs@freebsd.org Subject: Re: Shell or FreeBSD bug? In-Reply-To: <20001118091212.A2414@walton.maths.tcd.ie> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org On Sat, 18 Nov 2000, David Malone wrote: > This looks like the output of "cat /". Could you have accidently typed > something that would have had this effect? > > David. I'm not sure of the logic of being able to cat directories directly - doing so will list filenames (among the garbage) which don't reside in the directory cat'ted, but rather in it's subdirectories. Patch follows. Am I on crack, and is there a useful reason for catting a directory? (begin patch) --- cat.c.orig Sat Nov 18 13:38:47 2000 +++ cat.c Sat Nov 18 13:51:11 2000 @@ -241,13 +241,18 @@ ssize_t nr, nw; static size_t bsize; static char *buf; - struct stat sbuf; + struct stat sbuf[2]; wfd = fileno(stdout); + + fstat(rfd, &sbuf[1]); + if(sbuf[1].st_mode & S_IFDIR) + errx(1, "%s: is a directory", filename); + if (buf == NULL) { - if (fstat(wfd, &sbuf)) + if (fstat(wfd, &sbuf[0])) err(1, "%s", filename); - bsize = MAX(sbuf.st_blksize, 1024); + bsize = MAX(sbuf[0].st_blksize, 1024); if ((buf = malloc(bsize)) == NULL) err(1, "buffer"); } (end patch) "And then it comes to be that the soothing light at the end of your tunnel was just a freight train, comin' your way." George Reid * greid@ukug.uk.freebsd.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message