Date: Sat, 18 Nov 2000 13:54:56 +0000 (GMT) From: George Reid <greid@ukug.uk.freebsd.org> To: David Malone <dwmalone@maths.tcd.ie> Cc: Steve Bano <esteban0@excite.com>, freebsd-bugs@freebsd.org Subject: Re: Shell or FreeBSD bug? Message-ID: <Pine.BSF.4.21.0011181351590.20548-100000@sobek.nevernet.net> In-Reply-To: <20001118091212.A2414@walton.maths.tcd.ie>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0011181351590.20548-100000>
