Thread: [Libsysio-commit] HEAD: libsysio/src getdirentries.c
Brought to you by:
lward
From: Lee W. <lw...@us...> - 2004-01-26 16:49:32
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15788/src Modified Files: getdirentries.c Log Message: Problems with the patch from Kevin Pedretti. I *think* this is what he intended. Index: getdirentries.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/getdirentries.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -w -b -B -p -r1.6 -r1.7 --- getdirentries.c 26 Jan 2004 16:34:54 -0000 1.6 +++ getdirentries.c 26 Jan 2004 16:48:34 -0000 1.7 @@ -99,11 +99,11 @@ getdirentries(int fd, #define _dbaselen ((size_t )&((struct dirent *)0)->d_name[0]) -#ifdef __GLIBC +#ifdef __GLIBC__ #define _dreclen(namlen) \ ((_dbaselen + (namlen) + __alignof__ (struct dirent)) & \ ~(__alignof__ (struct dirent) - 1)) -#else /* !define(__GLIBC__) */ +#else /* !defined(__GLIBC__) */ #define _dreclen(namlen) \ _rndup(_dbaselen + (namlen) + 1, sizeof(int)) #endif @@ -230,11 +230,10 @@ out: sysio_sym_strong_alias(_getdirentries64, getdirentries) #endif -#endif - #ifdef REDSTORM #undef __getdirentries sysio_sym_weak_alias(getdirentries, __getdirentries) +#endif #if defined(BSD) || defined(REDSTORM) #undef _getdirentries sysio_sym_weak_alias(getdirentries, _getdirentries) |
From: Lee W. <lw...@us...> - 2004-04-14 16:03:56
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2080 Modified Files: getdirentries.c Log Message: Shouldn't call getdirentries inode operation on anything but directories. The default device operation behavior is to abort (it's an illegal op). Index: getdirentries.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/getdirentries.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -w -b -B -p -r1.9 -r1.10 --- getdirentries.c 31 Mar 2004 17:43:18 -0000 1.9 +++ getdirentries.c 14 Apr 2004 16:03:48 -0000 1.10 @@ -1,3 +1,4 @@ +#include <unistd.h> #include <stdlib.h> #ifdef __GLIBC__ #include <alloca.h> @@ -5,6 +6,7 @@ #include <string.h> #include <errno.h> #include <sys/types.h> +#include <sys/stat.h> #include <dirent.h> #include <sys/queue.h> @@ -32,6 +34,11 @@ _getdirentries64(int fd, return -1; } + if (!S_ISDIR(fil->f_ino->i_mode)) { + errno = ENOTDIR; + return -1; + } + cc = (*fil->f_ino->i_ops.inop_getdirentries)(fil->f_ino, buf, |
From: Lee W. <lw...@us...> - 2004-04-14 16:05:44
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2485 Modified Files: getdirentries.c Log Message: Added copyright headers. Must have forgotten them in the original deposit. Index: getdirentries.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/getdirentries.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -w -b -B -p -r1.10 -r1.11 --- getdirentries.c 14 Apr 2004 16:03:48 -0000 1.10 +++ getdirentries.c 14 Apr 2004 16:05:36 -0000 1.11 @@ -1,3 +1,68 @@ +/* + * This Cplant(TM) source code is the property of Sandia National + * Laboratories. + * + * This Cplant(TM) source code is copyrighted by Sandia National + * Laboratories. + * + * The redistribution of this Cplant(TM) source code is subject to the + * terms of the GNU Lesser General Public License + * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) + * + * Cplant(TM) Copyright 1998-2004 Sandia Corporation. + * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive + * license for use of this work by or on behalf of the US Government. + * Export of this program may require a license from the United States + * Government. + */ + +/* + * ############################################################################# + * # + * # This Cplant(TM) source code is the property of Sandia National + * # Laboratories. + * # + * # This Cplant(TM) source code is copyrighted by Sandia National + * # Laboratories. + * # + * # The redistribution of this Cplant(TM) source code is subject to the + * # terms of the GNU Lesser General Public License + * # (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) + * # + * # Cplant(TM) Copyright 1998-2004 Sandia Corporation. + * # Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive + * # license for use of this work by or on behalf of the US Government. + * # Export of this program may require a license from the United States + * # Government. + * # + * ############################################################################# + */ + +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Questions or comments about this library should be sent to: + * + * Lee Ward + * Sandia National Laboratories, New Mexico + * P.O. Box 5800 + * Albuquerque, NM 87185-1110 + * + * le...@sa... + */ + #include <unistd.h> #include <stdlib.h> #ifdef __GLIBC__ |
From: Lee W. <lw...@us...> - 2004-05-25 17:53:54
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19311/src Modified Files: getdirentries.c Log Message: +Changes for Red Storm from Kevin Pedretti +Fix in fs_native.c to conditionally compile DIR_STREAMED code properly. We were always including it -- Even when using getdirentries. Oops. Index: getdirentries.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/getdirentries.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -w -b -B -p -r1.14 -r1.15 --- getdirentries.c 28 Apr 2004 21:15:58 -0000 1.14 +++ getdirentries.c 25 May 2004 17:53:43 -0000 1.15 @@ -109,7 +109,7 @@ PREPEND(_, SYSIO_INTERFACE_NAME(getdiren buf, nbytes, basep); - SYSIO_INTERFACE_RETURN(cc < 0 ? -1 : cc, (int )cc); + SYSIO_INTERFACE_RETURN(cc < 0 ? -1 : cc, cc < 0 ? (int )cc : 0); } #if _LARGEFILE64_SOURCE @@ -156,7 +156,7 @@ SYSIO_INTERFACE_NAME(getdirentries)(int _SYSIO_OFF_T ibase; ssize_t cc; struct dirent *dp, *nxtdp; -#if defined(BSD) || defined(REDSTORM) +#if defined(BSD) int off; #endif struct intnl_dirent *od64p, *d64p; @@ -176,16 +176,16 @@ SYSIO_INTERFACE_NAME(getdirentries)(int _rndup(_dbaselen + (namlen) + 1, sizeof(int)) #endif -#if defined(__GLIBC__) && !(defined(REDSTORM)) +#if defined(__GLIBC__) #define _fast_alloc(n) alloca(n) #define _fast_free(p) -#else /* !defined(__GLIBC__) || defined(REDSTORM) */ +#else /* !defined(__GLIBC__) */ #define _fast_alloc(n) malloc(n) #define _fast_free(p) free(p) #endif SYSIO_INTERFACE_ENTER; -#if defined(BSD) || defined(REDSTORM) +#if defined(BSD) if (nbytes < 0) SYSIO_INTERFACE_RETURN(-1, -EINVAL); #endif @@ -219,7 +219,7 @@ SYSIO_INTERFACE_NAME(getdirentries)(int goto out; } -#if defined(BSD) || defined(REDSTORM) +#if defined(BSD) off = *basep; #endif od64p = NULL; @@ -236,13 +236,13 @@ SYSIO_INTERFACE_NAME(getdirentries)(int if (reclen >= (unsigned )nbytes) break; dp->d_ino = (ino_t )d64p->d_ino; -#if !(defined(BSD) || defined(REDSTORM)) +#if !(defined(BSD)) dp->d_off = (off_t )d64p->d_off; #endif if ((sizeof(dp->d_ino) != sizeof(d64p->d_ino) && dp->d_ino != d64p->d_ino) || -#if !(defined(BSD) || defined(REDSTORM)) +#if !(defined(BSD)) (sizeof(dp->d_off) != sizeof(d64p->d_off) && dp->d_off != d64p->d_off) #else @@ -262,7 +262,7 @@ SYSIO_INTERFACE_NAME(getdirentries)(int od64p = d64p; d64p = (struct dirent64 *)((char *)d64p + d64p->d_reclen); nbytes -= reclen; -#if defined(BSD) || defined(REDSTORM) +#if defined(BSD) off += reclen; #endif dp = nxtdp; @@ -276,7 +276,7 @@ out: cc = (char *)dp - buf; if (cc) *basep = -#if !(defined(BSD) || defined(REDSTORM)) +#if !(defined(BSD)) od64p->d_off; #else off; |
From: Lee W. <lw...@us...> - 2005-08-02 20:25:34
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8877/src Modified Files: getdirentries.c Log Message: Simplified and, hopefully, a bug corrected. Both Jim Schutt, at Sandia, and Oleg Drokin, at CFS, reported that getdirentries fails with Lustre as the base pointer is being reset improperly. The base pointer is now advanced as the directory entries are processed by giving it the value from the d_off field prior to advancing. Index: getdirentries.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/getdirentries.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -w -b -B -p -r1.18 -r1.19 --- getdirentries.c 21 Sep 2004 16:18:30 -0000 1.18 +++ getdirentries.c 2 Aug 2005 20:25:25 -0000 1.19 @@ -85,30 +85,35 @@ #endif static ssize_t +filldirents(int fd, 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; + + 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); +} + +static ssize_t PREPEND(_, SYSIO_INTERFACE_NAME(getdirentries64))(int fd, char *buf, size_t nbytes, _SYSIO_OFF_T * __restrict basep) { - struct file *fil; ssize_t cc; SYSIO_INTERFACE_DISPLAY_BLOCK; SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!(fil && fil->f_ino)) - SYSIO_INTERFACE_RETURN(-1, -EBADF); - - if (!S_ISDIR(fil->f_ino->i_stbuf.st_mode)) - SYSIO_INTERFACE_RETURN(-1, -ENOTDIR); - - cc = - (*fil->f_ino->i_ops.inop_getdirentries)(fil->f_ino, - buf, - nbytes, - basep); + cc = filldirents(fd, buf, nbytes, basep); SYSIO_INTERFACE_RETURN(cc < 0 ? -1 : cc, cc < 0 ? (int )cc : 0); } @@ -137,6 +142,17 @@ sysio_sym_strong_alias(PREPEND(_, SYSIO_ ((((n) + (boundary) - 1 ) / (boundary)) * (boundary)) #endif +#define _dbaselen ((size_t )&((struct dirent *)0)->d_name[0]) + +#ifdef __GLIBC__ +#define _dreclen(namlen) \ + ((_dbaselen + (namlen) + __alignof__ (struct dirent)) & \ + ~(__alignof__ (struct dirent) - 1)) +#else /* !defined(__GLIBC__) */ +#define _dreclen(namlen) \ + _rndup(_dbaselen + (namlen) + 1, sizeof(int)) +#endif + #ifndef BSD ssize_t SYSIO_INTERFACE_NAME(getdirentries)(int fd, @@ -151,144 +167,78 @@ SYSIO_INTERFACE_NAME(getdirentries)(int long * __restrict basep) #endif { - size_t inbytes; - void *ibuf; - _SYSIO_OFF_T ibase; - ssize_t cc; - struct dirent *dp, *nxtdp; -#if defined(BSD) - int off; -#endif - struct intnl_dirent *od64p, *d64p; - size_t n; - size_t reclen; + _SYSIO_OFF_T b; + ssize_t cc, count; + struct dirent64 *d64p, d64; + struct dirent *dp; + size_t n, reclen; + void *p; char *cp; SYSIO_INTERFACE_DISPLAY_BLOCK; -#define _dbaselen ((size_t )&((struct dirent *)0)->d_name[0]) - -#ifdef __GLIBC__ -#define _dreclen(namlen) \ - ((_dbaselen + (namlen) + __alignof__ (struct dirent)) & \ - ~(__alignof__ (struct dirent) - 1)) -#else /* !defined(__GLIBC__) */ -#define _dreclen(namlen) \ - _rndup(_dbaselen + (namlen) + 1, sizeof(int)) -#endif - -#if defined(__GLIBC__) -#define _fast_alloc(n) alloca(n) -#define _fast_free(p) -#else /* !defined(__GLIBC__) */ -#define _fast_alloc(n) malloc(n) -#define _fast_free(p) free(p) -#endif - SYSIO_INTERFACE_ENTER; -#if defined(BSD) - if (nbytes < 0) - SYSIO_INTERFACE_RETURN(-1, -EINVAL); -#endif - inbytes = nbytes; - if (inbytes > 8 * 1024) { + b = *basep; + count = cc = filldirents(fd, buf, nbytes, &b); + d64p = (void *)buf; + dp = (void *)buf; + reclen = 0; + while (cc > 0) { + n = _namlen(d64p); + reclen = _dreclen(n); + d64.d_ino = d64p->d_ino; + d64.d_off = d64p->d_off; + d64.d_type = d64p->d_type; + d64.d_reclen = d64p->d_reclen; /* - * Limit stack use. + * Copy name first. + */ + (void )memcpy(dp->d_name, d64p->d_name, n); + /* + * Then, the rest. + */ + dp->d_ino = d64.d_ino; + dp->d_off = d64.d_off; + if (dp->d_ino != d64.d_ino || + dp->d_off != d64.d_off) { + /* + * If conversion failure then we are done. + */ + if (cc == count) { + /* + * Couldn't process any entries. We return + * the error now. */ - inbytes = 8 * 1024; - } - ibuf = _fast_alloc(inbytes); - if (!ibuf) - SYSIO_INTERFACE_RETURN(-1, -ENOMEM); - - dp = (struct dirent *)buf; - - ibase = *basep; - cc = - PREPEND(_, SYSIO_INTERFACE_NAME(getdirentries64))(fd, - ibuf, - inbytes, - &ibase); - if (cc < 0) { - cc = -errno; - goto out; - } - *basep = (off_t )ibase; - if (sizeof(*basep) != sizeof(ibase) && *basep != ibase) { cc = -EOVERFLOW; - goto out; } - -#if defined(BSD) - off = *basep; -#endif - od64p = NULL; - d64p = ibuf; - for (;;) { - if (!cc) - break; -#ifdef HAVE_D_NAMLEN - n = d64p->d_namlen; -#else - n = strlen(d64p->d_name); -#endif - reclen = _dreclen(n); - if (reclen >= (unsigned )nbytes) - break; - dp->d_ino = (ino_t )d64p->d_ino; -#if !(defined(BSD)) - dp->d_off = (off_t )d64p->d_off; -#endif - if ((sizeof(dp->d_ino) != sizeof(d64p->d_ino) && - dp->d_ino != d64p->d_ino) - || -#if !(defined(BSD)) - (sizeof(dp->d_off) != sizeof(d64p->d_off) && - dp->d_off != d64p->d_off) -#else - (off + (int )reclen < off) -#endif - ) { - cc = -EOVERFLOW; break; } - dp->d_type = d64p->d_type; + *basep = dp->d_off; + dp->d_type = d64.d_type; dp->d_reclen = reclen; - nxtdp = (struct dirent *)((char *)dp + dp->d_reclen); - (void )memcpy(dp->d_name, d64p->d_name, n); - for (cp = dp->d_name + n; cp < (char *)nxtdp; *cp++ = '\0') - ; - cc -= d64p->d_reclen; - od64p = d64p; - d64p = (struct dirent64 *)((char *)d64p + d64p->d_reclen); - nbytes -= reclen; -#if defined(BSD) - off += reclen; + /* + * Fill the remainder with zeros. + */ + p = (char *)dp + dp->d_reclen; +#ifdef HAVE_D_NAMLEN + dp->d_namlen = n; #endif - dp = nxtdp; + cp = dp->d_name + n; + do { + *cp++ = 0; + } while (cp < (char *)p); + /* + * Advance. + */ + dp = p; + cc -= d64.d_reclen; + d64p = (struct dirent64 *)((char *)d64p + d64.d_reclen); } -out: - _fast_free(ibuf); - - if (dp == (struct dirent *)buf && cc < 0) - SYSIO_INTERFACE_RETURN(-1, (int )cc); + if (cc < 0) + SYSIO_INTERFACE_RETURN(-1, cc); cc = (char *)dp - buf; - if (cc) - *basep = -#if !(defined(BSD)) - od64p->d_off; -#else - off; -#endif SYSIO_INTERFACE_RETURN(cc, 0); - -#ifdef __GLIBC__ -#undef _fast_alloc -#undef _fast_free -#endif -#undef _dreclen -#undef _dbaselen } #else /* !defined(DIRENT64_IS_NATURAL) */ sysio_sym_strong_alias(PREPEND(_, SYSIO_INTERFACE_NAME(getdirentries64), |
From: Lee W. <lw...@us...> - 2007-03-13 23:41:31
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv4187 Modified Files: getdirentries.c Log Message: Removed redundant copyright notice. Index: getdirentries.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/getdirentries.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -w -b -B -p -r1.20 -r1.21 --- getdirentries.c 4 Aug 2005 20:17:10 -0000 1.20 +++ getdirentries.c 13 Mar 2007 23:41:24 -0000 1.21 @@ -17,28 +17,6 @@ */ /* - * ############################################################################# - * # - * # This Cplant(TM) source code is the property of Sandia National - * # Laboratories. - * # - * # This Cplant(TM) source code is copyrighted by Sandia National - * # Laboratories. - * # - * # The redistribution of this Cplant(TM) source code is subject to the - * # terms of the GNU Lesser General Public License - * # (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * # - * # Cplant(TM) Copyright 1998-2004 Sandia Corporation. - * # Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * # license for use of this work by or on behalf of the US Government. - * # Export of this program may require a license from the United States - * # Government. - * # - * ############################################################################# - */ - -/* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either |
From: Lee W. <lw...@us...> - 2007-03-14 20:16:34
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv23822 Modified Files: getdirentries.c Log Message: Cray SPR 734717 reports (as the 2nd bug discussed) that the return and errno are incorrect if a bad file descriptor is passed to getdirentries(). Fixed, using supplied patch. Index: getdirentries.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/getdirentries.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -w -b -B -p -r1.21 -r1.22 --- getdirentries.c 13 Mar 2007 23:41:24 -0000 1.21 +++ getdirentries.c 14 Mar 2007 20:16:31 -0000 1.22 @@ -98,8 +98,9 @@ PREPEND(_, SYSIO_INTERFACE_NAME(getdiren SYSIO_INTERFACE_ENTER; fil = _sysio_fd_find(fd); - if (!(fil && fil->f_ino)) - return -EBADF; + if (!(fil && fil->f_ino)) { + SYSIO_INTERFACE_RETURN(-1, -EBADF); + } cc = filldirents(fil, buf, nbytes, basep); SYSIO_INTERFACE_RETURN(cc < 0 ? -1 : cc, cc < 0 ? (int )cc : 0); @@ -168,8 +169,9 @@ SYSIO_INTERFACE_NAME(getdirentries)(int SYSIO_INTERFACE_ENTER; fil = _sysio_fd_find(fd); - if (!(fil && fil->f_ino)) - return -EBADF; + if (!(fil && fil->f_ino)) { + SYSIO_INTERFACE_RETURN(-1, -EBADF); + } count = cc = filldirents(fil, buf, nbytes, &b); d64p = (void *)buf; |
From: Lee W. <lw...@us...> - 2007-11-15 15:05:39
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv11638 Modified Files: getdirentries.c Log Message: The getdirentries function was converted to blindly convert the 64-bit directory entry structure. When the native format is the same layout this resulted in a memcpy of the name in overlapping regions. That's a no-no. Changed, now, to use memmove, which allows overlapping copies. Index: getdirentries.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/getdirentries.c,v retrieving revision 1.25 retrieving revision 1.26 diff -u -w -b -B -p -r1.25 -r1.26 --- getdirentries.c 2 Jul 2007 18:58:16 -0000 1.25 +++ getdirentries.c 15 Nov 2007 15:05:34 -0000 1.26 @@ -182,7 +182,7 @@ SYSIO_INTERFACE_NAME(getdirentries)(int /* * Copy name first. */ - (void )memcpy(dp->d_name, d64p->d_name, n); + (void )memmove(dp->d_name, d64p->d_name, n); /* * Then, the rest. */ |
From: Ruth K. <rk...@us...> - 2009-09-25 22:23:59
|
Update of /cvsroot/libsysio/libsysio/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv7793 Modified Files: getdirentries.c Log Message: need _getdirentries symbol for catamount build Index: getdirentries.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/getdirentries.c,v retrieving revision 2.0 retrieving revision 2.1 diff -u -w -b -B -p -r2.0 -r2.1 --- getdirentries.c 10 Apr 2009 21:30:02 -0000 2.0 +++ getdirentries.c 25 Sep 2009 22:23:29 -0000 2.1 @@ -173,7 +173,7 @@ _p_getdirentries(struct pnode *pno, } static ssize_t -_getdirentries(int fd, +getdirentries_common(int fd, char *buf, size_t nbytes, _SYSIO_OFF_T * __restrict basep, @@ -258,7 +258,7 @@ PREPEND(_, SYSIO_INTERFACE_NAME(getdiren off_t * __restrict basep) { - return _getdirentries(fd, buf, nbytes, basep, (filldir_t )filldir64); + return getdirentries_common(fd, buf, nbytes, basep, (filldir_t )filldir64); } #undef getdirentries64 @@ -332,7 +332,7 @@ SYSIO_INTERFACE_NAME(getdirentries)(int #endif pos = *basep; - cc = _getdirentries(fd, buf, nbytes, &pos, (filldir_t )filldir); + cc = getdirentries_common(fd, buf, nbytes, &pos, (filldir_t )filldir); if (cc > 0) *basep = pos; return _cast cc; |
From: Lee W. <lw...@us...> - 2009-12-17 17:41:28
|
Update of /cvsroot/libsysio/libsysio/src In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv20980/src Modified Files: getdirentries.c Log Message: Fixed for 32-bit build. The 64-bit getdirentries routines in both the regular source and the file handles interface assumed 64-bit _SYSIO_OFF_T. Fixed, now. They will return (-1, EINVAL) if given a base pointer outside what is supported by the internal offset. Index: getdirentries.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/getdirentries.c,v retrieving revision 2.1 retrieving revision 2.2 diff -u -w -b -B -p -r2.1 -r2.2 --- getdirentries.c 25 Sep 2009 22:23:29 -0000 2.1 +++ getdirentries.c 17 Dec 2009 17:41:17 -0000 2.2 @@ -255,10 +255,26 @@ static ssize_t PREPEND(_, SYSIO_INTERFACE_NAME(getdirentries64))(int fd, char *buf, size_t nbytes, - off_t * __restrict basep) + off64_t * __restrict basep) { + _SYSIO_OFF_T ibase; + ssize_t cc; + + ibase = *basep; + if (ibase != *basep) { + errno = EINVAL; + return -1; + } - return getdirentries_common(fd, buf, nbytes, basep, (filldir_t )filldir64); + cc = + getdirentries_common(fd, + buf, + nbytes, + &ibase, + (filldir_t )filldir64); + if (cc >= 0) + *basep = ibase; + return cc; } #undef getdirentries64 |