[comp.os.minix] V1.3b bug report

brucee@runx.ips.oz (Bruce Evans) (07/31/88)

No serious ones here, but there sure are a lot. The context diffs pad it
out a bit much.

ctime:
	The bias -1 is still subtracted for yearday, after the recent fix
	to make Jan 1 yearday 0 instead of 1.

	It's still isn't quite right. My V7 manual says Sunday is week
	day 0, and Jan is month 0, while the program (or at least the
	comments) have them as 1. This is getting out of hand again.
	Real Programmers must be too busy to tell the time :-).

date:
	Still fails on Dec 31 1988.

df:
	Has non-portable test for EOF after value returned by getchar() is
	truncated YET AGAIN to a char.

	Stdio is used, but not opened. Rather fd = 0 is closed and reopened
	in the expectation that stdio will cope. This is particularly silly
	because the rest of the program goes to great lengths to avoid using
	stdio (especially printf).

dosdir dosread/doswrite on hard disks:
	Doesn't work on disks over 32K blocks because of poor choice
	of types. Most of the shorts in the program should be unsigneds.
	Perhaps only total_clusters really needs to be changed. The other
	unsigneds in the diff are because of ambiguity in the way an
	unsigned char is extended to an int or unsigned. It should
	probably become an unsigned, but Turbo C at least makes it an
	int, so shifting left by 8 can make it negative!

	I changed the open mode to readonly for dosdir/dosread for
	safety. I didn't trust the program as doswrite on the hard disk.

	I would like to see the debugging reports in the program made
	selectable at runtime, or at least controlled by "#ifdef DEBUG"
	rather than comments.	

floppy driver (non-bug):
	The delay loop in V1.3b works on my 386 system. (I originally
	posted a fix with a much longer delay). We should document
	the black magic delays in the drivers and use a subroutine
	to produce them. The subroutine could be calibrated at system
	startup for accuracy of 10 microseconds even on a PC.

init:
	lseek() is not declared long, but its value is assigned. The
	assigned value is not used.

	I suggest opening the ttys in mode 2 so stdin can be written
	to and stdout and stderr can be read from, as in other ix's
	and assumed in the original patch and compress. This is in the
	diff and has been OK here for months.

login:
	Is now more greedy and gave strange results with chmem =2000.
	I made it 4000. Would someone please post a good list of
	sizes for chmem. I leave almost everything with 64K.

	Writes wtmp too late, after setting uid and losing privilege.

mount:
	Refers to mtab by "/etc/mtab" and alias (char *) mounttable.

	Creation of the initial mtab entry in /etc/rc is annoying
	(not everyone has root on the RAM disk). The mount posted some
	time ago determined root automatically.

mv:
	Doesn't preserve links across file systems, i.e., if 2 linked
	files on one file system are both mv'ed to another, the link
	is lost.

printer driver:
	STILL has lock() but no restore().
	I put an unlock (now restore(old_state)) at the end of the locked
	loop, just before the reply message. This locked loop may cause
	hundreds of tty interrupts to be lost and should be eliminated. 

	I don't like polling the printer just in case it might be
	buffered (mine's not :-). Wouldn't a buffered printer be ready
	again fast enough so no delays are necessary?

sh:
	A stack size of 8000 doesn't seem to be enough. One of my shell
	programs consistently ran out of string space with this, with
	a fairly large environment of 300 bytes of short strings. I used
	the following test program to determine the minimum workable size
	of 13000. Call it shtest.
 
for ARG
do
	case $ARG in
	*)	STR="$STR $ARG"
	esac
done

	This is best run in a large directory such as commands, with
	"sh -x shtest *" to obtain lots of arguments without typing. It
	just concatenates the args. The case statement wrapping
	STR="$STR $ARG" shouldn't be necessary, but for some reason
	(a local bug?) it hangs a short way through the list without it.
	The string built just fits in the shell's line length limit of
	1K. With 8K of stack, the program starts but runs out of string
	space. A full 5K more was necessary for completion. The shell's
	string handling must be poor.

shar:
	After the cleanup, the variables ind and output[] are redundant.
	I preferred the original approach with no stdio. Now input is done
	directly, output through stdio.

term:
	The first 2 chars of the triple-escape exit sequence get written
	to the external device. Something less common than escape should
	be used, maybe a char with the high bit set.

	If the write to the external device is suspended for any reason,
	the escape test is not reachable and there is no legitimate way out.
	My fs does this when the device buffers fill up, and this happens
	(and _should_ happen) sooner or later if the external device is not
	connected or not ready.

tty:
	The new position for rs232 flush_flag test in the clock interrupt
	handler is not safe. If processes are not exhausting their quantum,
	the test will never be executed. 

xt_wini.c:
	Seems to be missing from the diffs and sums posted.

Old bugs in ast/nm/strip
------------------------

nm:
	Treats C_EXT as a bit mask instead of a number, so statics are
	interpreted as externals. This bug is masked by "ast" not setting
	C_STAT for statics and "nm" treating C_NULL as static when it
	should probably be undefined.

	Prints negatives with poor format (-1 as ffffffff instead of 4
	chars wide).

strip:
	Fails when text+bss >= 32K.


Note: some cdifs, some diffs to save space.

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  ctime.c.cdif df.c.cdif dosread.c.diff init.c.diff
#   login.c.cdif nm.c.cdif strip.c.cdif
# Wrapped by src@besplex on Mon Aug  1 00:41:37 1988
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'ctime.c.cdif' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'ctime.c.cdif'\"
else
echo shar: Extracting \"'ctime.c.cdif'\" \(691 characters\)
sed "s/^X//" >'ctime.c.cdif' <<'END_OF_FILE'
X*** ../ctime.c	Sat Jul 30 15:20:19 1988
X--- ctime.c	Mon Aug  1 00:10:55 1988
X***************
X*** 57,63 ****
X  
X  	/* t is now the offset into the current year, in seconds. */
X  	tm.tm_yday = (t/DAY);	/* day # of the year, Jan 1 = 0 */
X! 	tm.tm_wday = ((newyear[tm.tm_year - 1970] + tm.tm_yday - 1) % 7) + 1;
X  
X  	days_per_month[1] = 28;
X  	if ((tm.tm_year % 4) == 0)	/* check for leap year */
X--- 57,63 ----
X  
X  	/* t is now the offset into the current year, in seconds. */
X  	tm.tm_yday = (t/DAY);	/* day # of the year, Jan 1 = 0 */
X! 	tm.tm_wday = ((newyear[tm.tm_year - 1970] + tm.tm_yday) % 7) + 1;
X  
X  	days_per_month[1] = 28;
X  	if ((tm.tm_year % 4) == 0)	/* check for leap year */
END_OF_FILE
if test 691 -ne `wc -c <'ctime.c.cdif'`; then
    echo shar: \"'ctime.c.cdif'\" unpacked with wrong size!
fi
# end of 'ctime.c.cdif'
fi
if test -f 'df.c.cdif' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'df.c.cdif'\"
else
echo shar: Extracting \"'df.c.cdif'\" \(274 characters\)
sed "s/^X//" >'df.c.cdif' <<'END_OF_FILE'
X*** ../df.c	Sat Jun 18 21:33:52 1988
X--- df.c	Sun Jul 31 02:13:47 1988
X***************
X*** 177,183 ****
X  getname(p)
X  char *p;
X  {
X!   char c;
X  
X    while (1) {
X  	c = getchar();
X--- 177,183 ----
X  getname(p)
X  char *p;
X  {
X!   int c;
X  
X    while (1) {
X  	c = getchar();
END_OF_FILE
if test 274 -ne `wc -c <'df.c.cdif'`; then
    echo shar: \"'df.c.cdif'\" unpacked with wrong size!
fi
# end of 'df.c.cdif'
fi
if test -f 'dosread.c.diff' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'dosread.c.diff'\"
else
echo shar: Extracting \"'dosread.c.diff'\" \(2633 characters\)
sed "s/^X//" >'dosread.c.diff' <<'END_OF_FILE'
X117c117,118
X< short total_clusters, cluster_size, fat_size, root_entries, sub_entries;
X---
X> unsigned short total_clusters;
X> short cluster_size, fat_size, root_entries, sub_entries;
X196c197
X< 	if ((disk = open(device, 2)) < 0) {
X---
X> 	if ((disk = open(device, dos_write ? 2 : 0)) < 0) {
X394c395
X< 		(boot.bytes_sector[1] << 8 & HMASK) + (boot.bytes_sector[0] & LMASK)); 
X---
X> 		((unsigned) boot.bytes_sector[1] << 8 & HMASK) + (boot.bytes_sector[0] & LMASK)); 
X397c398
X< 		(boot.res_sectors[1] << 8 & HMASK) + (boot.res_sectors[0] & LMASK));
X---
X> 		((unsigned) boot.res_sectors[1] << 8 & HMASK) + (boot.res_sectors[0] & LMASK));
X400c401
X< 		(boot.root_entries[1] << 8 & HMASK) + (boot.root_entries[0] & LMASK));
X---
X> 		((unsigned) boot.root_entries[1] << 8 & HMASK) + (boot.root_entries[0] & LMASK));
X402c403
X< 		(long) (boot.logical_sectors[1] << 8 & HMASK) + (boot.logical_sectors[0] & LMASK));
X---
X> 		(long) ((unsigned) boot.logical_sectors[1] << 8 & HMASK) + (boot.logical_sectors[0] & LMASK));
X405c406
X< 		(boot.fat_sectors[1] << 8 & HMASK) + (boot.fat_sectors[0] & LMASK));
X---
X> 		((unsigned) boot.fat_sectors[1] << 8 & HMASK) + (boot.fat_sectors[0] & LMASK));
X407c408
X< 		(boot.track_sectors[1] << 8 & HMASK) + (boot.track_sectors[0] & LMASK));
X---
X> 		((unsigned) boot.track_sectors[1] << 8 & HMASK) + (boot.track_sectors[0] & LMASK));
X409c410
X< 		(boot.num_heads[1] << 8 & HMASK) + (boot.num_heads[0] & LMASK));
X---
X> 		((unsigned) boot.num_heads[1] << 8 & HMASK) + (boot.num_heads[0] & LMASK));
X411c412
X< 		(boot.hidden_sectors[1]  << 8 & HMASK) + (boot.hidden_sectors[0] & LMASK));
X---
X> 		((unsigned) boot.hidden_sectors[1]  << 8 & HMASK) + (boot.hidden_sectors[0] & LMASK));
X422c423
X< 	block_size = (boot.bytes_sector[1] << 8 & HMASK) +
X---
X> 	block_size = ((unsigned) boot.bytes_sector[1] << 8 & HMASK) +
X429c430
X< 	reserved =  ((boot.res_sectors[1] << 8 & HMASK) +
X---
X> 	reserved =  (((unsigned) boot.res_sectors[1] << 8 & HMASK) +
X432c433
X< 	root_entries = (boot.root_entries[1] << 8 & HMASK) +
X---
X> 	root_entries = ((unsigned) boot.root_entries[1] << 8 & HMASK) +
X434c435
X< 	fat_size = (boot.fat_sectors[1] << 8 & HMASK) +
X---
X> 	fat_size = ((unsigned) boot.fat_sectors[1] << 8 & HMASK) +
X437c438
X< 	total_clusters = (int) ((long) ((boot.logical_sectors[1] << 8 & HMASK) +
X---
X> 	total_clusters = (unsigned) (((long) (((unsigned) boot.logical_sectors[1] << 8 & HMASK) +
X440c441
X< 		  (fat_size * 2) - reserved) / boot.cluster_size;
X---
X> 		  (fat_size * 2) - reserved) / boot.cluster_size);
X452c453
X< 	printf("total_clusters = %d\n", total_clusters);
X---
X> 	printf("total_clusters = %u\n", total_clusters);
END_OF_FILE
if test 2633 -ne `wc -c <'dosread.c.diff'`; then
    echo shar: \"'dosread.c.diff'\" unpacked with wrong size!
fi
# end of 'dosread.c.diff'
fi
if test -f 'init.c.diff' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'init.c.diff'\"
else
echo shar: Extracting \"'init.c.diff'\" \(655 characters\)
sed "s/^X//" >'init.c.diff' <<'END_OF_FILE'
X87,88c87,88
X< 	open("/dev/tty0", 1);	/* std output */
X< 	open("/dev/tty0", 1);	/* std error */
X---
X> 	open("/dev/tty0", 2);	/* std output */
X> 	open("/dev/tty0", 2);	/* std error */
X157,159c157,159
X< 	if (open(name, 0) != 0) exit(-3);	/* standard input */
X< 	if (open(name, 1) != 1) exit(-3);	/* standard output */
X< 	if (open(name, 1) != 2) exit(-3);	/* standard error */
X---
X> 	if (open(name, 2) != 0) exit(-3);	/* standard input */
X> 	if (open(name, 2) != 1) exit(-3);	/* standard output */
X> 	if (open(name, 2) != 2) exit(-3);	/* standard error */
X190c190
X<   i =lseek(fd, 0L, 2);		/* append to file */
X---
X>   lseek(fd, 0L, 2);		/* append to file */
END_OF_FILE
if test 655 -ne `wc -c <'init.c.diff'`; then
    echo shar: \"'init.c.diff'\" unpacked with wrong size!
fi
# end of 'init.c.diff'
fi
if test -f 'login.c.cdif' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'login.c.cdif'\"
else
echo shar: Extracting \"'login.c.cdif'\" \(608 characters\)
sed "s/^X//" >'login.c.cdif' <<'END_OF_FILE'
X*** ../login.c	Sun Jul 31 00:28:37 1988
X--- login.c	Tue Jul 19 22:40:56 1988
X***************
X*** 65,73 ****
X  			}
X  		}
X  
X- 		/* Creat wmtp entry. */
X- 		wtmp(ttyname, pwd->pw_name);
X- 
X  		/* Successful login.   Set up environment. */
X  		setgid (pwd->pw_gid);
X  		setuid (pwd->pw_uid);
X--- 65,70 ----
X***************
X*** 79,84 ****
X--- 76,84 ----
X  
X  		/* Reset signals to default values. */
X  		for(n = 1; n <= NR_SIGS; ++n) signal(n, SIG_DFL);
X+ 
X+ 		/* Creat wmtp entry. */
X+ 		wtmp(ttyname, pwd->pw_name);
X  
X  		/* If shell has been specified, exec it, else use /bin/sh. */
X  		if (pwd->pw_shell) 
END_OF_FILE
if test 608 -ne `wc -c <'login.c.cdif'`; then
    echo shar: \"'login.c.cdif'\" unpacked with wrong size!
fi
# end of 'login.c.cdif'
fi
if test -f 'nm.c.cdif' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'nm.c.cdif'\"
else
echo shar: Extracting \"'nm.c.cdif'\" \(2075 characters\)
sed "s/^X//" >'nm.c.cdif' <<'END_OF_FILE'
X*** ../nm.c	Sun Mar 20 13:12:06 1988
X--- nm.c	Sat Jul 16 14:09:20 1988
X***************
X*** 68,74 ****
X  				break;
X  			default:
X  				fprintf(stderr, "illegal flag: -%c\n", **argv);
X! 				Exit(-1);
X  			}
X  			*argv += 1;
X  		}
X--- 68,74 ----
X  				break;
X  			default:
X  				fprintf(stderr, "illegal flag: -%c\n", **argv);
X! 				exit(-1);
X  			}
X  			*argv += 1;
X  		}
X***************
X*** 80,95 ****
X  		nm(*argv);
X  		argv++;
X  	}
X! 	Exit(0);
X  }
X  
X- Exit(val)
X- int val;
X- {
X- 	_cleanup();
X- 	exit(val);
X- }
X- 
X  nm_sort(stbl1, stbl2)
X  struct nlist *stbl1, *stbl2;
X  {
X--- 80,88 ----
X  		nm(*argv);
X  		argv++;
X  	}
X! 	exit(0);
X  }
X  
X  nm_sort(stbl1, stbl2)
X  struct nlist *stbl1, *stbl2;
X  {
X***************
X*** 175,181 ****
X  	name[8] = '\0';
X  	if (!o_flag) printf("%s:\n", file);
X  	for (last = &stbl[stbl_elems]; stbl != last; stbl++) {
X! 		if (g_flag && !(stbl->n_sclass & C_EXT)) continue;
X  		if (u_flag && stbl->n_sclass & N_SECT != N_UNDF) continue;
X  
X  		n_sclass = stbl->n_sclass & N_SECT;
X--- 168,174 ----
X  	name[8] = '\0';
X  	if (!o_flag) printf("%s:\n", file);
X  	for (last = &stbl[stbl_elems]; stbl != last; stbl++) {
X! 		if (g_flag && (stbl->n_sclass & N_CLASS) != C_EXT) continue;
X  		if (u_flag && stbl->n_sclass & N_SECT != N_UNDF) continue;
X  
X  		n_sclass = stbl->n_sclass & N_SECT;
X***************
X*** 184,193 ****
X  		else if (n_sclass == N_DATA) type = 'd';
X  		else if (n_sclass == N_BSS) type = 'b';
X  		else type = 'u';
X! 		if (stbl->n_sclass & C_EXT) type += 'A' -'a';
X  		strncpy(name, stbl->n_name, 8);
X! 		if (o_flag) printf("%s:%04X %c %s\n", file, 
X  				stbl->n_value, type, name);
X! 		else printf("%04X %c %s\n", stbl->n_value, type, name);
X  	}
X  }
X--- 177,186 ----
X  		else if (n_sclass == N_DATA) type = 'd';
X  		else if (n_sclass == N_BSS) type = 'b';
X  		else type = 'u';
X! 		if ((stbl->n_sclass & N_CLASS) == C_EXT) type += 'A' -'a';
X  		strncpy(name, stbl->n_name, 8);
X! 		if (o_flag) printf("%s:%08X  %c %s\n", file, 
X  				stbl->n_value, type, name);
X! 		else printf("%08X  %c %s\n", stbl->n_value, type, name);
X  	}
X  }
END_OF_FILE
if test 2075 -ne `wc -c <'nm.c.cdif'`; then
    echo shar: \"'nm.c.cdif'\" unpacked with wrong size!
fi
# end of 'nm.c.cdif'
fi
if test -f 'strip.c.cdif' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'strip.c.cdif'\"
else
echo shar: Extracting \"'strip.c.cdif'\" \(846 characters\)
sed "s/^X//" >'strip.c.cdif' <<'END_OF_FILE'
X*** ../strip.c	Sun Jun 19 03:09:09 1988
X--- strip.c	Sat Jul 16 14:44:53 1988
X***************
X*** 129,146 ****
X  int fd1, fd2;
X  long size;
X  {
X- 	long count;
X  	int length;
X  
X! 	count = 0;
X! 	while (count < size) {
X! 		length = (int) (size - count);
X! 		if (length > sizeof(buffer)) length = sizeof(buffer);
X! 		length = read(fd1, buffer, length);
X! 		if (length == 0) break;
X  		if (write(fd2, buffer, length) != length) return(1);
X! 		count += length;
X  	}
X- 	if (count < size) return(1);
X  	return(0);
X  }
X--- 129,144 ----
X  int fd1, fd2;
X  long size;
X  {
X  	int length;
X  
X! 	while (size > 0) {
X! 		if (size < sizeof(buffer))
X! 			length = size;
X! 		else
X! 			length = sizeof(buffer);
X! 		if (read(fd1, buffer, length) != length) return(1);
X  		if (write(fd2, buffer, length) != length) return(1);
X! 		size -= length;
X  	}
X  	return(0);
X  }
END_OF_FILE
if test 846 -ne `wc -c <'strip.c.cdif'`; then
    echo shar: \"'strip.c.cdif'\" unpacked with wrong size!
fi
# end of 'strip.c.cdif'
fi
echo shar: End of shell archive.
exit 0

Bruce Evans
Internet: brucee@runx.ips.oz.au    UUCP: uunet!runx.ips.oz.au!brucee