[Libsysio-commit] HEAD: libsysio/drivers/native fs_native.c
Brought to you by:
lward
From: Lee W. <lw...@us...> - 2004-04-27 06:33:31
|
Update of /cvsroot/libsysio/libsysio/drivers/native In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16048 Modified Files: fs_native.c Log Message: Fix a bug in getdirentries. Found by inspection after a conversation about a similar bug in glibc. The content of *basep was not updated after a successful call. Also, streamlined native_filldirentries a bit. Index: fs_native.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v retrieving revision 1.36 retrieving revision 1.37 diff -u -w -b -B -p -r1.36 -r1.37 --- fs_native.c 17 Apr 2004 21:15:03 -0000 1.36 +++ fs_native.c 27 Apr 2004 06:33:22 -0000 1.37 @@ -917,9 +917,7 @@ native_filldirentries(struct native_inod size_t nbytes, _SYSIO_OFF_T *basep) { -#if !DIR_STREAMED - _SYSIO_OFF_T result; -#endif + int err; ssize_t cc; if (*basep < 0) @@ -930,17 +928,13 @@ native_filldirentries(struct native_inod * Stream-oriented access requires that we reposition prior to the * fill call. */ - result = *basep; - if (*basep != nino->ni_fpos && - (cc = native_pos(nino->ni_fd, &result, SEEK_SET)) != 0) - return cc; - nino->ni_fpos = result; -#else - nino->ni_fpos = *basep; + if ((err = native_pos(nino->ni_fd, basep, SEEK_SET)) != 0) + return err; #endif + nino->ni_fpos = *basep; -#if defined(SYS_getdirentries) cc = +#if defined(SYS_getdirentries) syscall(SYS_getdirentries, nino->ni_fd, buf, @@ -948,14 +942,23 @@ native_filldirentries(struct native_inod basep, &nino->ni_fpos); #elif defined(SYS_getdents64) - cc = syscall(SYS_getdents64, nino->ni_fd, buf, nbytes); + syscall(SYS_getdents64, nino->ni_fd, buf, nbytes); #elif defined(SYS_getdents) - cc = syscall(SYS_getdents, nino->ni_fd, buf, nbytes); + syscall(SYS_getdents, nino->ni_fd, buf, nbytes); #endif if (cc < 0) return -errno; - nino->ni_fpos += cc; +#if !DIR_STREAMED + /* + * Stream-oriented access requires that we discover where we are + * after the call. + */ + *basep = 0; + if ((err = native_pos(nino->ni_fd, basep, SEEK_CUR)) != 0) + return err; +#endif + nino->ni_fpos = *basep; return cc; } |