SCCS-vsn: lib/libc/gen/closedir.c 4.4
SCCS-vsn: lib/libc/gen/readdir.c 4.4
SCCS-vsn: lib/libc/gen/seekdir.c 4.5
SCCS-vsn: lib/libc/gen/telldir.c 4.3
SCCS-vsn: lib/libc/gen/ttyname.c 4.3
/* Copyright (c) 1982 Regents of the University of California */
/* Copyright (c) 1982 Regents of the University of California */
-static char sccsid[] = "@(#)closedir.c 4.3 %G%";
+static char sccsid[] = "@(#)closedir.c 4.4 %G%";
/* Copyright (c) 1982 Regents of the University of California */
/* Copyright (c) 1982 Regents of the University of California */
-static char sccsid[] = "@(#)readdir.c 4.3 %G%";
+static char sccsid[] = "@(#)readdir.c 4.4 %G%";
-#include <ndir.h>
-
-/*
- * read an old stlye directory entry and present it as a new one
- */
-#define ODIRSIZ 14
-
-struct olddirect {
- ino_t d_ino;
- char d_name[ODIRSIZ];
-};
/*
* get next entry in a directory.
/*
* get next entry in a directory.
readdir(dirp)
register DIR *dirp;
{
readdir(dirp)
register DIR *dirp;
{
- register struct olddirect *dp;
- static struct direct dir;
+ register struct direct *dp;
for (;;) {
if (dirp->dd_loc == 0) {
for (;;) {
if (dirp->dd_loc == 0) {
dirp->dd_loc = 0;
continue;
}
dirp->dd_loc = 0;
continue;
}
- dp = (struct olddirect *)(dirp->dd_buf + dirp->dd_loc);
- dirp->dd_loc += sizeof(struct olddirect);
+ dp = (struct direct *)(dirp->dd_buf + dirp->dd_loc);
+ if (dp->d_reclen <= 0 ||
+ dp->d_reclen > DIRBLKSIZ + 1 - dirp->dd_loc)
+ return NULL;
+ dirp->dd_loc += dp->d_reclen;
if (dp->d_ino == 0)
continue;
if (dp->d_ino == 0)
continue;
- dir.d_ino = dp->d_ino;
- strncpy(dir.d_name, dp->d_name, ODIRSIZ);
- dir.d_name[ODIRSIZ] = '\0'; /* insure null termination */
- dir.d_namlen = strlen(dir.d_name);
- dir.d_reclen = DIRSIZ(&dir);
- return (&dir);
/* Copyright (c) 1982 Regents of the University of California */
/* Copyright (c) 1982 Regents of the University of California */
-static char sccsid[] = "@(#)seekdir.c 4.4 %G%";
+static char sccsid[] = "@(#)seekdir.c 4.5 %G%";
/*
* seek to an entry in a directory.
/*
* seek to an entry in a directory.
/* Copyright (c) 1982 Regents of the University of California */
/* Copyright (c) 1982 Regents of the University of California */
-static char sccsid[] = "@(#)telldir.c 4.2 %G%";
+static char sccsid[] = "@(#)telldir.c 4.3 %G%";
/*
* return a pointer into a directory
/*
* return a pointer into a directory
-/* @(#)ttyname.c 4.2 (Berkeley) %G% */
+/* @(#)ttyname.c 4.3 (Berkeley) %G% */
/*
* ttyname(f): return "/dev/ttyXX" which the the name of the
* tty belonging to file f.
/*
* ttyname(f): return "/dev/ttyXX" which the the name of the
* tty belonging to file f.
#define NULL 0
#include <sys/param.h>
#define NULL 0
#include <sys/param.h>
#include <sys/stat.h>
static char dev[] = "/dev/";
#include <sys/stat.h>
static char dev[] = "/dev/";