diff options
author | Dale Rahn <drahn@cvs.openbsd.org> | 2007-02-09 14:51:14 +0000 |
---|---|---|
committer | Dale Rahn <drahn@cvs.openbsd.org> | 2007-02-09 14:51:14 +0000 |
commit | 1a9603dabab238e2d113a6b277c20a84c4fadcf3 (patch) | |
tree | 92a73183a7344617946c6d3d7bcf86900800aaf5 /libexec/ld.so | |
parent | 87a420ac4a8ce469b56a43e63c58ced04dafbc04 (diff) |
readdir buffers should not get a fixed buffer size, but should be dependant
on the block size of the filesystem. Rounded up to page size for efficiency.
similar to change in libc yesterday. Should fix PR 5364.
Diffstat (limited to 'libexec/ld.so')
-rw-r--r-- | libexec/ld.so/dir.c | 16 | ||||
-rw-r--r-- | libexec/ld.so/util.c | 3 | ||||
-rw-r--r-- | libexec/ld.so/util.h | 4 |
3 files changed, 6 insertions, 17 deletions
diff --git a/libexec/ld.so/dir.c b/libexec/ld.so/dir.c index 40747894ef0..c061d8f4a0a 100644 --- a/libexec/ld.so/dir.c +++ b/libexec/ld.so/dir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dir.c,v 1.12 2007/02/08 18:47:32 millert Exp $ */ +/* $OpenBSD: dir.c,v 1.13 2007/02/09 14:51:13 drahn Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -59,7 +59,6 @@ _dl_opendir(const char *name) DIR *dirp; int fd; struct stat sb; - int incr; if ((fd = _dl_open(name, O_RDONLY | O_NONBLOCK)) < 0) return (NULL); @@ -73,18 +72,7 @@ _dl_opendir(const char *name) return (NULL); } - /* - * If the machine's page size is an exact multiple of DIRBLKSIZ, - * use a buffer that is cluster boundary aligned. - * Hopefully this can be a big win someday by allowing page trades - * to user space to be done by getdirentries() - * - not done in ld.so. - */ - incr = DIRBLKSIZ; - - /* UNION mount support removed */ - - dirp->dd_len = incr; + dirp->dd_len = _dl_round_page(sb.st_blksize); dirp->dd_buf = _dl_malloc(dirp->dd_len); if (dirp->dd_buf == NULL) { _dl_free(dirp); diff --git a/libexec/ld.so/util.c b/libexec/ld.so/util.c index 0920dd3efc3..a5e8c75c59f 100644 --- a/libexec/ld.so/util.c +++ b/libexec/ld.so/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.18 2004/06/14 15:07:36 millert Exp $ */ +/* $OpenBSD: util.c,v 1.19 2007/02/09 14:51:13 drahn Exp $ */ /* * Copyright (c) 1998 Per Fogelstrom, Opsycon AB @@ -66,7 +66,6 @@ _dl_strdup(const char *orig) return (newstr); } -#define _dl_round_page(x) (((x) + (__LDPGSZ - 1)) & ~(__LDPGSZ - 1)) /* * The following malloc/free code is a very simplified implementation diff --git a/libexec/ld.so/util.h b/libexec/ld.so/util.h index 10bf117ed2d..ecc5efbff16 100644 --- a/libexec/ld.so/util.h +++ b/libexec/ld.so/util.h @@ -1,4 +1,4 @@ -/* $OpenBSD: util.h,v 1.19 2004/10/17 03:56:49 drahn Exp $ */ +/* $OpenBSD: util.h,v 1.20 2007/02/09 14:51:13 drahn Exp $ */ /* * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> @@ -45,6 +45,8 @@ ssize_t _dl_write(int fd, const char* buf, size_t len); long _dl_strtol(const char *nptr, char **endptr, int base); +#define _dl_round_page(x) (((x) + (__LDPGSZ - 1)) & ~(__LDPGSZ - 1)) + /* * The following functions are declared inline so they can * be used before bootstrap linking has been finished. |