Update of /cvsroot/libsysio/libsysio/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4518/src
Modified Files:
dev.c getdirentries.c
Log Message:
Removed the internal getdirentries inode operation. The getdirentries
function does not return the *next* block in it's basep argument. It
simply return the cookie for the current block.
We needed one that returns the *next*, so a new interface called filldirentries
is present with this change. It takes, as it's second argument, a pointer
to a value/result pair. The value should be set to the position to be
read. The result is the position of the next block.
All the included drivers have been updated. External drivers will require
similar updates.
Index: dev.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/dev.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -w -b -B -p -r1.9 -r1.10
--- dev.c 27 Jul 2004 15:00:43 -0000 1.9
+++ dev.c 4 Aug 2005 20:17:10 -0000 1.10
@@ -56,7 +56,7 @@ const struct inode_ops _sysio_nodev_ops
_sysio_nodev_inop_lookup,
_sysio_nodev_inop_getattr,
_sysio_nodev_inop_setattr,
- _sysio_nodev_getdirentries,
+ _sysio_nodev_filldirentries,
_sysio_nodev_inop_mkdir,
_sysio_nodev_inop_rmdir,
_sysio_nodev_inop_symlink,
Index: getdirentries.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/getdirentries.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -w -b -B -p -r1.19 -r1.20
--- getdirentries.c 2 Aug 2005 20:25:25 -0000 1.19
+++ getdirentries.c 4 Aug 2005 20:17:10 -0000 1.20
@@ -85,20 +85,25 @@
#endif
static ssize_t
-filldirents(int fd, char *buf, size_t nbytes, _SYSIO_OFF_T * __restrict basep)
+filldirents(struct file *fil,
+ char *buf, size_t nbytes,
+ _SYSIO_OFF_T *__restrict basep)
{
- struct file *fil;
-
- fil = _sysio_fd_find(fd);
- if (!(fil && fil->f_ino))
- return -EBADF;
+ _SYSIO_OFF_T opos;
+ ssize_t cc;
if (!S_ISDIR(fil->f_ino->i_stbuf.st_mode))
return -ENOTDIR;
- return (*fil->f_ino->i_ops.inop_getdirentries)(fil->f_ino,
- buf, nbytes,
- basep);
+ opos = fil->f_pos;
+ cc =
+ (*fil->f_ino->i_ops.inop_filldirentries)(fil->f_ino,
+ &fil->f_pos,
+ buf, nbytes);
+ if (cc < 0)
+ return cc;
+ *basep = opos;
+ return cc;
}
static ssize_t
@@ -108,12 +113,17 @@ PREPEND(_, SYSIO_INTERFACE_NAME(getdiren
_SYSIO_OFF_T * __restrict
basep)
{
+ struct file *fil;
ssize_t cc;
SYSIO_INTERFACE_DISPLAY_BLOCK;
SYSIO_INTERFACE_ENTER;
- cc = filldirents(fd, buf, nbytes, basep);
+ fil = _sysio_fd_find(fd);
+ if (!(fil && fil->f_ino))
+ return -EBADF;
+
+ cc = filldirents(fil, buf, nbytes, basep);
SYSIO_INTERFACE_RETURN(cc < 0 ? -1 : cc, cc < 0 ? (int )cc : 0);
}
@@ -167,6 +177,7 @@ SYSIO_INTERFACE_NAME(getdirentries)(int
long * __restrict basep)
#endif
{
+ struct file *fil;
_SYSIO_OFF_T b;
ssize_t cc, count;
struct dirent64 *d64p, d64;
@@ -178,8 +189,11 @@ SYSIO_INTERFACE_NAME(getdirentries)(int
SYSIO_INTERFACE_ENTER;
- b = *basep;
- count = cc = filldirents(fd, buf, nbytes, &b);
+ fil = _sysio_fd_find(fd);
+ if (!(fil && fil->f_ino))
+ return -EBADF;
+
+ count = cc = filldirents(fil, buf, nbytes, &b);
d64p = (void *)buf;
dp = (void *)buf;
reclen = 0;
@@ -213,7 +227,7 @@ SYSIO_INTERFACE_NAME(getdirentries)(int
}
break;
}
- *basep = dp->d_off;
+ fil->f_pos = dp->d_off;
dp->d_type = d64.d_type;
dp->d_reclen = reclen;
/*
@@ -238,6 +252,7 @@ SYSIO_INTERFACE_NAME(getdirentries)(int
if (cc < 0)
SYSIO_INTERFACE_RETURN(-1, cc);
cc = (char *)dp - buf;
+ *basep = b;
SYSIO_INTERFACE_RETURN(cc, 0);
}
#else /* !defined(DIRENT64_IS_NATURAL) */
|