Subject: Re: /dev/std{in, out, err}
To: None <jim@reptiles.org>
From: Brad Spencer <brad@anduin.eldar.org>
List: port-sun3
Date: 11/30/1995 06:50:22
>> > From: jim@reptiles.org (Jim Mercer)
>> > Date: Tue, 28 Nov 1995 21:23:34 -0500 (EST)
>> 
>> > ok, so i'm building Cnews CR.G on NetBSD-1.1/sun3.
>> > 
>> > well, during the regression tests it uses /usr/bin/compress to do
>> > some stuff.
>> > 
>> > /usr/bin/compress is complaining that /dev/stdin doesn't exist.
>> [...]
>> > ah, so, what, or should, i set /dev/std{in,out,err} to?
>> 
>> You need to add this line to /etc/fstab:
>> fdesc   /dev    fdesc   rw,union
>
>i did a reboot -a, rm /dev/std* and restarted with the above fstab entry.
>
>now i get:
>tuatara# compress < gated_dump > gated.dump.Z
>overwrite /dev/stdout? tuatara# 
>
>hmmm.
>
>it was working when i did the mknod stuff.
>

[snip]

Sigh.... I reported this quite a long time ago [PR bin/774].  I think
part of the problem is that the fdesc filesystem makes /dev/stdin and
friends symbolic links to /dev/fd/_number_.  Following is a very old,
and perhaps non-working, patch to compress to get it to work again.  I
discovered this in the first place, when I built X11R6.  It failed to
build the fonts.  As an alternative one can replace the above line
with:

		compress < gated_dump | cat > gated.dump.Z




*** compress.c.ORIG	Sun Dec 25 06:26:26 1994
--- compress.c	Wed Feb  1 10:16:32 1995
***************
*** 201,207 ****
  	exists = !stat(out, &sb);
  	if (!force && exists && S_ISREG(sb.st_mode) && !permission(out))
  		return;
! 	isreg = oreg = !exists || S_ISREG(sb.st_mode);
  
  	ifp = ofp = NULL;
  	if ((ifp = fopen(in, "r")) == NULL) {
--- 201,207 ----
  	exists = !stat(out, &sb);
  	if (!force && exists && S_ISREG(sb.st_mode) && !permission(out))
  		return;
! 	isreg = oreg = !exists || S_ISREG(sb.st_mode) && (strcasecmp(out,"/dev/stdout") != 0);
  
  	ifp = ofp = NULL;
  	if ((ifp = fopen(in, "r")) == NULL) {
***************
*** 212,218 ****
  		cwarn("%s", in);
  		goto err;
  	}
! 	if (!S_ISREG(isb.st_mode))
  		isreg = 0;
  
  	if ((ofp = zopen(out, "w", bits)) == NULL) {
--- 212,218 ----
  		cwarn("%s", in);
  		goto err;
  	}
! 	if ((!S_ISREG(isb.st_mode)) || (strcasecmp(in,"/dev/stdin") == 0))
  		isreg = 0;
  
  	if ((ofp = zopen(out, "w", bits)) == NULL) {
***************
*** 291,297 ****
  	exists = !stat(out, &sb);
  	if (!force && exists && S_ISREG(sb.st_mode) && !permission(out))
  		return;
! 	isreg = oreg = !exists || S_ISREG(sb.st_mode);
  
  	ifp = ofp = NULL;
  	if ((ofp = fopen(out, "w")) == NULL) {
--- 291,297 ----
  	exists = !stat(out, &sb);
  	if (!force && exists && S_ISREG(sb.st_mode) && !permission(out))
  		return;
! 	isreg = oreg = !exists || S_ISREG(sb.st_mode) && (strcasecmp(out,"/dev/stdout") != 0);
  
  	ifp = ofp = NULL;
  	if ((ofp = fopen(out, "w")) == NULL) {
***************
*** 307,313 ****
  		cwarn("%s", in);
  		goto err;
  	}
! 	if (!S_ISREG(sb.st_mode))
  		isreg = 0;
  
  	while ((nr = fread(buf, 1, sizeof(buf), ifp)) != 0)
--- 307,313 ----
  		cwarn("%s", in);
  		goto err;
  	}
! 	if ((!S_ISREG(sb.st_mode)) || (strcasecmp(in,"/dev/stdin") == 0))
  		isreg = 0;
  
  	while ((nr = fread(buf, 1, sizeof(buf), ifp)) != 0)
***************
*** 384,389 ****
--- 384,391 ----
  
  	if (!isatty(fileno(stderr)))
  		return (0);
+ 	if (!isatty(fileno(stdin)))
+ 		return (1);
  	(void)fprintf(stderr, "overwrite %s? ", fname);
  	first = ch = getchar();
  	while (ch != '\n' && ch != EOF)



Brad Spencer - brad@anduin.eldar.org   http://anduin.eldar.org