On Sun, 5 Aug 2001, Poul-Henning Kamp wrote:
...
> Open a PR so I don't forget and please include how I can reproduce it
> while I test.
Done.
In the meantime a first (but yet untested) patch to devfs_vnops.c is
attached.

Bye!
----
Michael Reifenberger
^.*Plaut.*$, IT, R/3 Basis, GPS
--- devfs_vnops.c.orig  Sun Aug  5 14:08:13 2001
+++ devfs_vnops.c       Sun Aug  5 15:45:41 2001
@@ -500,12 +500,12 @@
        struct devfs_dirent *de;
        struct devfs_mount *dmp;
-       off_t off;
+       off_t off, oldoff;
+       int ncookies = 0;
+       u_long *cookiebuf, *cookiep;
+       struct dirent *dps, *dpe;
 
        if (ap->a_vp->v_type != VDIR)
                return (ENOTDIR);
 
-       if (ap->a_ncookies)
-               return (EOPNOTSUPP);
-
        uio = ap->a_uio;
        if (uio->uio_offset < 0)
@@ -518,4 +518,5 @@
        de = ap->a_vp->v_data;
        off = 0;
+       oldoff = uio->uio_offset;
        TAILQ_FOREACH(dd, &de->de_dlist, de_list) {
                if (dd->de_flags & DE_WHITEOUT) 
@@ -530,4 +531,5 @@
                dp->d_fileno = de->de_inode;
                if (off >= uio->uio_offset) {
+                       ncookies++;
                        error = uiomove((caddr_t)dp, dp->d_reclen, uio);
                        if (error)
@@ -536,4 +538,20 @@
                off += dp->d_reclen;
        }
+       if( !error && ap->a_ncookies != NULL && ap->a_cookies != NULL ) {
+               MALLOC(cookiebuf, u_long *, ncookies * sizeof(u_long),
+                       M_TEMP, M_WAITOK);
+               cookiep = cookiebuf;
+               dps = (struct dirent *) 
+                       (uio->uio_iov->iov_base - (uio->uio_offset - oldoff));
+               dpe = (struct dirent *) uio->uio_iov->iov_base;
+               for( dp = dps; 
+                       dp < dpe; 
+                       dp = (struct dirent *)((caddr_t) dp + dp->d_reclen)) {
+                               oldoff += dp->d_reclen;
+                               *cookiep++ = (u_long) oldoff;
+               }
+               *ap->a_ncookies = ncookies;
+               *ap->a_cookies = cookiebuf;
+    }
        lockmgr(&dmp->dm_lock, LK_RELEASE, 0, curproc);
        uio->uio_offset = off;

Reply via email to