🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.bugs.2bsd
Article #275

CSS/Harvard 2.9BSD bug report #12

#275
From: Keith Bostic
Date: Tue, 22 Oct 1985 00:07
135 lines
3943 bytes
Subject: csh
Index:	bin/csh/sh.exec.c, bin/csh/sh.glob.c, bin/csh/sh.h 2.9BSD

Description:
	The csh should use the new directory reading subroutines.
Fix:
	The previous postings regarding reading directories applies to
	csh.  The following diffs can replace the old directory reading
	code with the new directory reading subroutines, if you're so
	inclined.
----------------------------------------------------------------------

diff sh.exec.c.wrong sh.exec.right
253,255c253,255
< 	struct direct dirbuf[BUFSIZ / sizeof (struct direct)];
< 	char d_name[MAXNAMLEN + 1];
< 	register int dirf, cnt;
---
> 	DIR *dirp;
> 	register struct direct *dp;
> 	register int cnt;
268,269c268,269
< 		dirf = open(*pv, 0);
< 		if (dirf < 0)
---
> 		dirp = opendir(*pv);
> 		if (dirp == NULL)
271,272c271,272
< 		if (fstat(dirf, &stb) < 0 || !isdir(stb)) {
< 			close(dirf);
---
> 		if (fstat(dirp->dd_fd, &stb) < 0 || !isdir(stb)) {
> 			closedir(dirp);
275,283c275,282
< 		while ((cnt = read(dirf, (char *) dirbuf, sizeof dirbuf)) >= sizeof dirbuf[0]) {
< 			register struct direct *ep = dirbuf;
< 
< 			for (cnt /= sizeof(struct direct); cnt > 0; cnt--, ep++) {
< 				if (ep->d_ino == 0)
< 					continue;
< 				copdent(d_name, ep->d_name);
< 				xhash[hash(d_name)] |= (1 << i);
< 			}
---
> 		while ((dp = readdir(dirp)) != NULL) {
> 			if (dp->d_ino == 0)
> 				continue;
> 			if (dp->d_name[0] == '.' &&
> 			    (dp->d_name[1] == '\0' ||
> 			     dp->d_name[1] == '.' && dp->d_name[2] == '\0'))
> 				continue;
> 			xhash[hash(dp->d_name)] |= (1 << i);
285c284
< 		close(dirf);
---
> 		closedir(dirp);
----------------------------------------------------------------------

diff sh.glob.wrong sh.glob.right
173,175c173,174
< 	struct direct dirbuf[BUFSIZ / sizeof (struct direct)];
< 	char d_name[MAXNAMLEN+1];
< 	register int dirf, cnt;
---
> 	register struct direct *dp;
> 	register DIR *dirp;
177,178c176,177
< 	dirf = open(gpath, 0);
< 	if (dirf < 0) {
---
> 	dirp = opendir(gpath);
> 	if (dirp == NULL) {
181c180
< 		goto patherr;
---
> 		goto patherr2;
183,184c182,183
< 	if (fstat(dirf, &stb) < 0)
< 		goto patherr;
---
> 	if (fstat(dirp->dd_fd, &stb) < 0)
> 		goto patherr1;
187c186
< 		goto patherr;
---
> 		goto patherr1;
189,199c188,193
< 	while ((cnt = read(dirf, (char *) dirbuf, sizeof dirbuf)) >= sizeof dirbuf[0]) {
< 		register struct direct *ep = dirbuf;
< 
< 		for (cnt /= sizeof (struct direct); cnt > 0; cnt--, ep++) {
< 			if (ep->d_ino == 0)
< 				continue;
< 			copdent(d_name, ep->d_name);
< 			if (match(d_name, pattern)) {
< 				Gcat(gpath, d_name);
< 				globcnt++;
< 			}
---
> 	while ((dp = readdir(dirp)) != NULL) {
> 		if (dp->d_ino == 0)
> 			continue;
> 		if (match(dp->d_name, pattern)) {
> 			Gcat(gpath, dp->d_name);
> 			globcnt++;
202c196
< 	close(dirf);
---
> 	closedir(dirp);
205c199,201
< patherr:
---
> patherr1:
> 	closedir(dirp);
> patherr2:
207,217d202
< }
< 
< copdent(to, from)
< 	register char *to, *from;
< {
< 	register int cnt = MAXNAMLEN;
< 
< 	do
< 		*to++ = *from++;
< 	while (--cnt);
< 	*to = 0;

----------------------------------------------------------------------
diff sh.h.wrong sh.h.right

19d20
< #define KERNEL
20d22
< #undef KERNEL
Technical Details
Message-ID: <495@seismo.CSS.GOV>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!ucbvax!ucdavis!lll-crg!seismo!keith

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site seismo.CSS.GOV
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!ucbvax!ucdavis!lll-crg!seismo!keith
From: keith@seismo.CSS.GOV (Keith Bostic)
Newsgroups: net.bugs.2bsd
Subject: CSS/Harvard 2.9BSD bug report #12
Message-ID: <495@seismo.CSS.GOV>
Date: Mon, 21-Oct-85 20:07:49 EDT
Article-I.D.: seismo.495
Posted: Mon Oct 21 20:07:49 1985
Date-Received: Wed, 23-Oct-85 03:51:35 EDT
Organization: Center for Seismic Studies, Arlington, VA
Lines: 135
Keywords: csh, DIR, new directory reading subroutines