projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Wrong reason was reported for cd'ing to a directory with no permission
[unix-history]
/
usr
/
src
/
bin
/
csh
/
dir.c
diff --git
a/usr/src/bin/csh/dir.c
b/usr/src/bin/csh/dir.c
index
cf4cdc9
..
9907f25
100644
(file)
--- a/
usr/src/bin/csh/dir.c
+++ b/
usr/src/bin/csh/dir.c
@@
-6,21
+6,34
@@
*/
#ifndef lint
*/
#ifndef lint
-static char sccsid[] = "@(#)dir.c 5.
7
(Berkeley) %G%";
+static char sccsid[] = "@(#)dir.c 5.
12
(Berkeley) %G%";
#endif /* not lint */
#endif /* not lint */
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#if __STDC__
+# include <stdarg.h>
+#else
+# include <varargs.h>
+#endif
+
#include "csh.h"
#include "dir.h"
#include "extern.h"
/* Directory management. */
#include "csh.h"
#include "dir.h"
#include "extern.h"
/* Directory management. */
-static struct directory *dfind();
-static Char *dfollow();
-static void printdirs();
-static Char *dgoto();
-static void dnewcwd();
-static void dset();
+static struct directory
+ *dfind __P((Char *));
+static Char *dfollow __P((Char *));
+static void printdirs __P((void));
+static Char *dgoto __P((Char *));
+static void dnewcwd __P((struct directory *));
+static void dset __P((Char *));
struct directory dhead; /* "head" of loop */
int printd; /* force name to be printed */
struct directory dhead; /* "head" of loop */
int printd; /* force name to be printed */
@@
-48,13
+61,13
@@
dinit(hp)
tcp = short2str(hp);
(void) xprintf(emsg, tcp);
if (chdir(tcp) == -1)
tcp = short2str(hp);
(void) xprintf(emsg, tcp);
if (chdir(tcp) == -1)
- cp =
(Char *) 0
;
+ cp =
NULL
;
else
cp = hp;
}
else
else
cp = hp;
}
else
- cp =
(Char *) 0
;
- if (cp ==
(Char *) 0
) {
+ cp =
NULL
;
+ if (cp ==
NULL
) {
(void) xprintf(emsg, "/");
if (chdir("/") == -1)
/* I am not even try to print an error message! */
(void) xprintf(emsg, "/");
if (chdir("/") == -1)
/* I am not even try to print an error message! */
@@
-378,6
+391,7
@@
dfollow(cp)
register Char *dp;
struct varent *c;
char ebuf[MAXPATHLEN];
register Char *dp;
struct varent *c;
char ebuf[MAXPATHLEN];
+ int serrno;
cp = globone(cp, G_ERROR);
/*
cp = globone(cp, G_ERROR);
/*
@@
-392,6
+406,7
@@
dfollow(cp)
xfree((ptr_t) dp);
if (chdir(short2str(cp)) >= 0)
return dgoto(cp);
xfree((ptr_t) dp);
if (chdir(short2str(cp)) >= 0)
return dgoto(cp);
+ serrno = errno;
}
if (cp[0] != '/' && !prefix(STRdotsl, cp) && !prefix(STRdotdotsl, cp)
}
if (cp[0] != '/' && !prefix(STRdotsl, cp) && !prefix(STRdotdotsl, cp)
@@
-421,7
+436,7
@@
dfollow(cp)
}
(void) strcpy(ebuf, short2str(cp));
xfree((ptr_t) cp);
}
(void) strcpy(ebuf, short2str(cp));
xfree((ptr_t) cp);
- stderror(ERR_SYSTEM, ebuf, strerror(errno));
+ stderror(ERR_SYSTEM, ebuf, strerror(
s
errno));
return (NULL);
}
return (NULL);
}
@@
-594,7
+609,7
@@
dcanon(cp, p)
Char tmpdir[MAXPATHLEN];
p1 = value(STRcwd);
Char tmpdir[MAXPATHLEN];
p1 = value(STRcwd);
- if (p1 ==
(Char *) 0
|| *p1 != '/')
+ if (p1 ==
NULL
|| *p1 != '/')
abort();
if (Strlen(p1) + Strlen(cp) + 1 >= MAXPATHLEN)
abort();
abort();
if (Strlen(p1) + Strlen(cp) + 1 >= MAXPATHLEN)
abort();
@@
-797,11
+812,11
@@
dcanon(cp, p)
/*
* See if we're not in a subdir of STRhome
*/
/*
* See if we're not in a subdir of STRhome
*/
- if (p1 && *p1 &&
+ if (p1 && *p1
== '/'
&&
(Strncmp(p1, cp, cc) != 0 || (cp[cc] != '/' && cp[cc] != '\0'))) {
static ino_t home_ino = -1;
static dev_t home_dev = -1;
(Strncmp(p1, cp, cc) != 0 || (cp[cc] != '/' && cp[cc] != '\0'))) {
static ino_t home_ino = -1;
static dev_t home_dev = -1;
- static Char *home_ptr =
(Char *) 0
;
+ static Char *home_ptr =
NULL
;
struct stat statbuf;
/*
struct stat statbuf;
/*
@@
-817,7
+832,7
@@
dcanon(cp, p)
* Start comparing dev & ino backwards
*/
p2 = Strcpy(link, cp);
* Start comparing dev & ino backwards
*/
p2 = Strcpy(link, cp);
- for (sp =
(Char *) 0
; *p2 && stat(short2str(p2), &statbuf) != -1;) {
+ for (sp =
NULL
; *p2 && stat(short2str(p2), &statbuf) != -1;) {
if (statbuf.st_dev == home_dev &&
statbuf.st_ino == home_ino) {
sp = (Char *) - 1;
if (statbuf.st_dev == home_dev &&
statbuf.st_ino == home_ino) {
sp = (Char *) - 1;
@@
-829,7
+844,7
@@
dcanon(cp, p)
/*
* See if we found it
*/
/*
* See if we found it
*/
- if (*p2 && sp == (Char *) -
1) {
+ if (*p2 && sp == (Char *) -1) {
/*
* Use STRhome to make '~' work
*/
/*
* Use STRhome to make '~' work
*/