update to new fs
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Sat, 8 May 1982 11:38:54 +0000 (03:38 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Sat, 8 May 1982 11:38:54 +0000 (03:38 -0800)
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

usr/src/lib/libc/gen/closedir.c
usr/src/lib/libc/gen/readdir.c
usr/src/lib/libc/gen/seekdir.c
usr/src/lib/libc/gen/telldir.c
usr/src/lib/libc/gen/ttyname.c

index 88c854a..93ee9e4 100644 (file)
@@ -1,9 +1,9 @@
 /* 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%";
 
 #include <sys/param.h>
 
 #include <sys/param.h>
-#include <ndir.h>
+#include <dir.h>
 
 /*
  * close a directory.
 
 /*
  * close a directory.
index d4ec732..58f05ea 100644 (file)
@@ -1,19 +1,9 @@
 /* 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 <sys/param.h>
 
 #include <sys/param.h>
-#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];
-};
+#include <dir.h>
 
 /*
  * get next entry in a directory.
 
 /*
  * get next entry in a directory.
@@ -22,8 +12,7 @@ struct direct *
 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) {
@@ -36,15 +25,13 @@ readdir(dirp)
                        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);
+               return (dp);
        }
 }
        }
 }
index 04accf8..8fc0344 100644 (file)
@@ -1,9 +1,9 @@
 /* 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%";
 
 #include <sys/param.h>
 
 #include <sys/param.h>
-#include <ndir.h>
+#include <dir.h>
 
 /*
  * seek to an entry in a directory.
 
 /*
  * seek to an entry in a directory.
index 278ffe7..66a747a 100644 (file)
@@ -1,9 +1,9 @@
 /* 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%";
 
 #include <sys/param.h>
 
 #include <sys/param.h>
-#include <ndir.h>
+#include <dir.h>
 
 /*
  * return a pointer into a directory
 
 /*
  * return a pointer into a directory
index 951f79f..09cb76a 100644 (file)
@@ -1,4 +1,4 @@
-/* @(#)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.
@@ -7,7 +7,7 @@
 
 #define        NULL    0
 #include <sys/param.h>
 
 #define        NULL    0
 #include <sys/param.h>
-#include <sys/ndir.h>
+#include <sys/dir.h>
 #include <sys/stat.h>
 
 static char    dev[]   = "/dev/";
 #include <sys/stat.h>
 
 static char    dev[]   = "/dev/";