public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/3544] New: getgroups() makes a useless system call
@ 2006-11-20 16:45 bruno at clisp dot org
2006-11-20 16:46 ` [Bug libc/3544] " bruno at clisp dot org
2006-11-20 22:47 ` drepper at redhat dot com
0 siblings, 2 replies; 3+ messages in thread
From: bruno at clisp dot org @ 2006-11-20 16:45 UTC (permalink / raw)
To: glibc-bugs
glibc-2.3.6 on Linux-2.4.x/i386 makes a useless system call when the
getgroups() function is called.
Test program:
===================================================================
#include <sys/types.h>
#include <unistd.h>
int main ()
{
gid_t buf[10];
getgroups (10, buf);
return 0;
}
===================================================================
strace shows:
open("/proc/sys/kernel/ngroups_max", O_RDONLY) = -1 ENOENT (No such file or
directory)
getgroups32(0xa, 0xbfffe4c0) = 3
This open() call, coming from a __sysconf() call, is useless, because the
getgroups32 system call exists; there is no need to allocate a kernel_groups[]
array since there is no translation to do.
Proposed fix (untested):
2006-11-18 Bruno Haible <bruno@clisp.org>
* sysdeps/unix/sysv/linux/i386/getgroups.c (__getgroups): Invoke
__sysconf only after having tried to call getgroups32.
--- sysdeps/unix/sysv/linux/i386/getgroups.c.bak 2003-09-03
05:21:27.000000000 +0200
+++ sysdeps/unix/sysv/linux/i386/getgroups.c 2006-11-18 15:35:59.000000000
+0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 1998, 2000, 2001, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1998, 2000, 2001, 2003, 2006 Free Software Foundation,
Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -52,8 +52,6 @@
}
else
{
- int i, ngids;
- __kernel_gid_t kernel_groups[n = MIN (n, __sysconf (_SC_NGROUPS_MAX))];
# ifdef __NR_getgroups32
if (__libc_missing_32bit_uids <= 0)
{
@@ -69,6 +67,9 @@
}
# endif /* __NR_getgroups32 */
+ int i, ngids;
+ __kernel_gid_t kernel_groups[n = MIN (n, __sysconf (_SC_NGROUPS_MAX))];
+
ngids = INLINE_SYSCALL (getgroups, 2, n, CHECK_N (kernel_groups, n));
if (n != 0 && ngids > 0)
for (i = 0; i < ngids; i++)
--
Summary: getgroups() makes a useless system call
Product: glibc
Version: 2.3.6
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: bruno at clisp dot org
CC: glibc-bugs at sources dot redhat dot com
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://sourceware.org/bugzilla/show_bug.cgi?id=3544
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug libc/3544] getgroups() makes a useless system call
2006-11-20 16:45 [Bug libc/3544] New: getgroups() makes a useless system call bruno at clisp dot org
@ 2006-11-20 16:46 ` bruno at clisp dot org
2006-11-20 22:47 ` drepper at redhat dot com
1 sibling, 0 replies; 3+ messages in thread
From: bruno at clisp dot org @ 2006-11-20 16:46 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From bruno at clisp dot org 2006-11-20 16:46 -------
Created an attachment (id=1428)
--> (http://sourceware.org/bugzilla/attachment.cgi?id=1428&action=view)
fix
--
http://sourceware.org/bugzilla/show_bug.cgi?id=3544
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug libc/3544] getgroups() makes a useless system call
2006-11-20 16:45 [Bug libc/3544] New: getgroups() makes a useless system call bruno at clisp dot org
2006-11-20 16:46 ` [Bug libc/3544] " bruno at clisp dot org
@ 2006-11-20 22:47 ` drepper at redhat dot com
1 sibling, 0 replies; 3+ messages in thread
From: drepper at redhat dot com @ 2006-11-20 22:47 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From drepper at redhat dot com 2006-11-20 22:47 -------
Applied to trunk.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
http://sourceware.org/bugzilla/show_bug.cgi?id=3544
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-11-20 22:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-20 16:45 [Bug libc/3544] New: getgroups() makes a useless system call bruno at clisp dot org
2006-11-20 16:46 ` [Bug libc/3544] " bruno at clisp dot org
2006-11-20 22:47 ` drepper at redhat dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).