From bbc1a10935d10fb04b2da032a7f9a81b8e3a3331 Mon Sep 17 00:00:00 2001 From: Ralf Corsepius Date: Fri, 25 Feb 2011 02:13:21 +0000 Subject: =?UTF-8?q?2011-02-25=09Ralf=20Cors=C3=A9pius=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * libcsupport/src/opendir.c, libcsupport/src/closedir.c, libcsupport/src/readdir.c, libcsupport/src/rewinddir.c, libcsupport/src/scandir.c, libcsupport/src/seekdir.c, libcsupport/src/telldir.c: Remove. * libcsuppport/Makefile.am: Reflect changes above. * configure.ac: Error out if libc doesn't provide opendir, closedir, readdir, rewinddir, scandir, seekdir, telldir. --- cpukit/libcsupport/Makefile.am | 3 - cpukit/libcsupport/src/closedir.c | 78 ----------------- cpukit/libcsupport/src/opendir.c | 93 -------------------- cpukit/libcsupport/src/readdir.c | 95 --------------------- cpukit/libcsupport/src/rewinddir.c | 42 ---------- cpukit/libcsupport/src/scandir.c | 168 ------------------------------------- cpukit/libcsupport/src/seekdir.c | 47 ----------- cpukit/libcsupport/src/telldir.c | 49 ----------- 8 files changed, 575 deletions(-) delete mode 100644 cpukit/libcsupport/src/closedir.c delete mode 100644 cpukit/libcsupport/src/opendir.c delete mode 100644 cpukit/libcsupport/src/readdir.c delete mode 100644 cpukit/libcsupport/src/rewinddir.c delete mode 100644 cpukit/libcsupport/src/scandir.c delete mode 100644 cpukit/libcsupport/src/seekdir.c delete mode 100644 cpukit/libcsupport/src/telldir.c (limited to 'cpukit/libcsupport') diff --git a/cpukit/libcsupport/Makefile.am b/cpukit/libcsupport/Makefile.am index 39a32f4cde..a92d440d2d 100644 --- a/cpukit/libcsupport/Makefile.am +++ b/cpukit/libcsupport/Makefile.am @@ -76,9 +76,6 @@ SYSTEM_CALL_C_FILES += src/readv.c src/writev.c endif DIRECTORY_SCAN_C_FILES = -## 20 Nov 2008: Now using these from newlib's posix directory -DIRECTORY_SCAN_C_FILES += src/opendir.c src/closedir.c src/readdir.c \ - src/rewinddir.c src/scandir.c src/seekdir.c src/telldir.c ## Newlib SHOULD have provided this one DIRECTORY_SCAN_C_FILES += src/readdir_r.c ## Comment out when using these from newlib's unix directory diff --git a/cpukit/libcsupport/src/closedir.c b/cpukit/libcsupport/src/closedir.c deleted file mode 100644 index 0ea9e8daa4..0000000000 --- a/cpukit/libcsupport/src/closedir.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * closedir() - POSIX 1003.1b - XXX - * - * This was copied from Newlib 1.8.0. - * - * - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)closedir.c 5.9 (Berkeley) 2/23/91"; -#endif /* LIBC_SCCS and not lint */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#ifndef HAVE_CLOSEDIR - -#include -#include -#include -#include -#include - -#include -#include - -/* - * close a directory. - */ -int -closedir( - DIR *dirp ) -{ - int fd; - - if ( !dirp ) - rtems_set_errno_and_return_minus_one( EBADF ); - - fd = dirp->dd_fd; - dirp->dd_fd = -1; - dirp->dd_loc = 0; - (void)free((void *)dirp->dd_buf); - (void)free((void *)dirp); - return(close(fd)); -} - -#endif diff --git a/cpukit/libcsupport/src/opendir.c b/cpukit/libcsupport/src/opendir.c deleted file mode 100644 index 95d9f0a574..0000000000 --- a/cpukit/libcsupport/src/opendir.c +++ /dev/null @@ -1,93 +0,0 @@ -/* - * opendir() - POSIX 1003.1b - XXX - * - * This was copied from Newlib 1.8.0. - * - * - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)opendir.c 5.11 (Berkeley) 2/23/91"; -#endif /* LIBC_SCCS and not lint */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#ifndef HAVE_OPENDIR - -#include -#include -#include -#include - -/* - * open a directory. - */ -DIR * -opendir( - const char *name ) -{ - register DIR *dirp; - register int fd; - - if ((fd = open(name, 0)) == -1) - return NULL; - if (fcntl(fd, F_SETFD, 1) == -1 || - (dirp = (DIR *)malloc(sizeof(DIR))) == NULL) { - close (fd); - return NULL; - } - /* - * If CLSIZE is an exact multiple of DIRBLKSIZ, use a CLSIZE - * buffer that it cluster boundary aligned. - * Hopefully this can be a big win someday by allowing page trades - * to user space to be done by getdirentries() - */ - dirp->dd_buf = malloc (512); - dirp->dd_len = 512; - - if (dirp->dd_buf == NULL) { - close (fd); - return NULL; - } - dirp->dd_fd = fd; - dirp->dd_loc = 0; - dirp->dd_seek = 0; - /* - * Set up seek point for rewinddir. - */ - return dirp; -} - -#endif diff --git a/cpukit/libcsupport/src/readdir.c b/cpukit/libcsupport/src/readdir.c deleted file mode 100644 index e72797d0cc..0000000000 --- a/cpukit/libcsupport/src/readdir.c +++ /dev/null @@ -1,95 +0,0 @@ -/* - * readdir() - POSIX 1003.1b - XXX - * - * This was copied from Newlib 1.8.0. - * - * - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)readdir.c 5.7 (Berkeley) 6/1/90"; -#endif /* LIBC_SCCS and not lint */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#ifndef HAVE_READDIR - -#include -#include - -extern int getdents( - int dd_fd, - char *dd_buf, - int dd_len -); - -/* - * get next entry in a directory. - */ -struct dirent * -readdir( DIR *dirp ) -{ - register struct dirent *dp; - - if ( !dirp ) - return NULL; - - for (;;) { - if (dirp->dd_loc == 0) { - dirp->dd_size = getdents (dirp->dd_fd, - dirp->dd_buf, - dirp->dd_len); - - if (dirp->dd_size <= 0) - return NULL; - } - if (dirp->dd_loc >= dirp->dd_size) { - dirp->dd_loc = 0; - continue; - } - dp = (struct dirent *)(dirp->dd_buf + dirp->dd_loc); - if ((intptr_t)dp & 03) /* bogus pointer check */ - return NULL; - if (dp->d_reclen <= 0 || - dp->d_reclen > dirp->dd_len + 1 - dirp->dd_loc) - return NULL; - dirp->dd_loc += dp->d_reclen; - if (dp->d_ino == 0) - continue; - return (dp); - } -} - -#endif diff --git a/cpukit/libcsupport/src/rewinddir.c b/cpukit/libcsupport/src/rewinddir.c deleted file mode 100644 index 329efcc102..0000000000 --- a/cpukit/libcsupport/src/rewinddir.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - * rewinddir() - POSIX 1003.1b - XXX - * - * COPYRIGHT (c) 1989-2010. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.com/license/LICENSE. - * - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#ifndef HAVE_REWINDDIR - -#include -#include -#include -#include -#include - -void rewinddir( - DIR *dirp -) -{ - off_t status; - - if ( !dirp ) - return; - - status = lseek( dirp->dd_fd, 0, SEEK_SET ); - - if( status == -1 ) - return; - - dirp->dd_loc = 0; -} - -#endif diff --git a/cpukit/libcsupport/src/scandir.c b/cpukit/libcsupport/src/scandir.c deleted file mode 100644 index 59ad02a280..0000000000 --- a/cpukit/libcsupport/src/scandir.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - * scandir() - POSIX 1003.1b - XXX - * - * This was copied from Newlib 1.8.0. - * - * - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)scandir.c 5.10 (Berkeley) 2/23/91"; -#endif /* LIBC_SCCS and not lint */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -/* - * Scan the directory dirname calling select to make a list of selected - * directory entries then sort using qsort and compare routine dcomp. - * Returns the number of entries and a pointer to a list of pointers to - * struct dirent (through namelist). Returns -1 if there were any errors. - */ - -#ifndef HAVE_SCANDIR - -#include -#include -#include -#include -#include - -/* - * The DIRSIZ macro gives the minimum record length which will hold - * the directory entry. This requires the amount of space in struct dirent - * without the d_name field, plus enough space for the name with a terminating - * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary. - */ -#undef DIRSIZ -/* -#define DIRSIZ(dp) \ - ((sizeof (struct dirent) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3)) -*/ - -#define DIRSIZ(dp) \ - ((sizeof (struct dirent) - (NAME_MAX+1)) + (((dp)->d_namlen+1 + 3) &~ 3)) - -int -scandir( - const char *dirname, - struct dirent ***namelist, - int (*select)(struct dirent *), - int (*dcomp)(const struct dirent **, const struct dirent **)) -{ - register struct dirent *d = NULL; - register struct dirent *p = NULL; - register struct dirent **names = NULL; - register size_t nitems = 0; - struct stat stb; - size_t arraysz; - DIR *dirp = NULL; - int i; - - if ((dirp = opendir(dirname)) == NULL) - return(-1); - if (fstat(dirp->dd_fd, &stb) < 0) - goto cleanup_and_bail; - - /* - * estimate the array size by taking the size of the directory file - * and dividing it by a multiple of the minimum size entry. - */ - arraysz = (stb.st_size / 24); - names = (struct dirent **)malloc(arraysz * sizeof(struct dirent *)); - if (names == NULL) - goto cleanup_and_bail; - - while ((d = readdir(dirp)) != NULL) { - if (select != NULL && !(*select)(d)) - continue; /* just selected names */ - /* - * Make a minimum size copy of the data - */ - p = (struct dirent *)malloc(DIRSIZ(d)); - if (p == NULL) - goto cleanup_and_bail; - p->d_ino = d->d_ino; - p->d_reclen = d->d_reclen; - p->d_namlen = d->d_namlen; - strncpy(p->d_name, d->d_name, p->d_namlen + 1); - /* - * Check to make sure the array has space left and - * realloc the maximum size. - */ - if (++nitems >= arraysz) { - if (fstat(dirp->dd_fd, &stb) < 0) - goto cleanup_and_bail; /* just might have grown */ - arraysz = stb.st_size / 12; - names = (struct dirent **)realloc((char *)names, - arraysz * sizeof(struct dirent *)); - if (names == NULL) - goto cleanup_and_bail; - } - names[nitems-1] = p; - } - closedir(dirp); - if (nitems && dcomp != NULL){ - qsort(names, nitems, sizeof(struct dirent *), - (int (*)(const void *, const void *)) dcomp); - } - *namelist = names; - return(nitems); - -cleanup_and_bail: - - if ( dirp ) - closedir( dirp ); - - if ( names ) { - for (i=0; i < nitems; i++ ) - free( names[i] ); - free( names ); - } - - return(-1); -} - -/* - * Alphabetic order comparison routine for those who want it. - */ -int -alphasort( - const void *d1, - const void *d2 ) -{ - return(strcmp((*(struct dirent **)d1)->d_name, - (*(struct dirent **)d2)->d_name)); -} -#endif diff --git a/cpukit/libcsupport/src/seekdir.c b/cpukit/libcsupport/src/seekdir.c deleted file mode 100644 index 390ca03ba2..0000000000 --- a/cpukit/libcsupport/src/seekdir.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * seekdir() - POSIX 1003.1b - XXX - * - * COPYRIGHT (c) 1989-2010. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.com/license/LICENSE. - * - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#ifndef HAVE_SEEKDIR - -#include -#include -#include -#include -#include - -void seekdir( - DIR *dirp, - long loc -) -{ - off_t status; - - if ( !dirp ) - return; - - status = lseek( dirp->dd_fd, loc, SEEK_SET ); - - /* - * This is not a nice way to error out, but we have no choice here. - */ - - if ( status == -1 ) - return; - - dirp->dd_loc = 0; -} - -#endif diff --git a/cpukit/libcsupport/src/telldir.c b/cpukit/libcsupport/src/telldir.c deleted file mode 100644 index 05000ae552..0000000000 --- a/cpukit/libcsupport/src/telldir.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * telldir() - XXX - * - * COPYRIGHT (c) 1989-2010. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.com/license/LICENSE. - * - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#ifndef HAVE_TELLDIR - -#include -#include -#include -#include -#include - -#include -#include - -long telldir( - DIR *dirp -) -{ - rtems_libio_t *iop; - - if ( !dirp ) - rtems_set_errno_and_return_minus_one( EBADF ); - - /* - * Get the file control block structure associated with the - * file descriptor - */ - - iop = rtems_libio_iop( dirp->dd_fd ); - if ( !iop ) - rtems_set_errno_and_return_minus_one( EBADF ); - - return (long)( iop->offset ); -} - -#endif -- cgit v1.2.3