This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Avoid local PLT for dirfd


Running make check I noticed a local PLT failure:

cat elf/check-localplt.out 
--- ../scripts/data/localplt-generic.data       2009-06-03 09:17:46.000000000 +0200
+++ -   2012-02-28 12:16:38.670783466 +0100
@@ -1,4 +1,5 @@
 libc.so: calloc
+libc.so: dirfd
 libc.so: free
 libc.so: malloc
 libc.so: memalign

I'm appending a patch to fix this. Tested on Linux/x86-64.

Ok to commit?

Andreas

2012-02-28  Andreas Jaeger  <aj@suse.de>


	* dirent/dirfd.c: Rename dirfd to __dirfd, add weak_alias.
	* sysdeps/unix/dirfd.c: Likewise.
	* sysdeps/mach/hurd/dirfd.c: Likewise.

	* include/dirent.h: Add __dirfd prototype.

	* posix/glob.c (glob_in_dir): Avoid local PLT for dirfd.
	* io/fts.c (fts_build): Likewise.
	* io/ftw.c (__attribute): Likewise.
	* sysdeps/unix/sysv/linux/grantpt.c (close_all_fds): Likewise.

diff --git a/dirent/dirfd.c b/dirent/dirfd.c
index 026421f..569484c 100644
--- a/dirent/dirfd.c
+++ b/dirent/dirfd.c
@@ -1,5 +1,5 @@
 /* Return the file descriptor used by a DIR stream.  Stub version.
-   Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 2012 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
@@ -21,12 +21,13 @@
 #include <errno.h>
 
 int
-dirfd (dirp)
+__dirfd (dirp)
      DIR *dirp;
 {
   __set_errno (ENOSYS);
   return -1;
 }
+weak_alias(__dirfd, dirfd)
 
 stub_warning (dirfd)
 #include <stub-tag.h>
diff --git a/include/dirent.h b/include/dirent.h
index 2e88005..80199d6 100644
--- a/include/dirent.h
+++ b/include/dirent.h
@@ -41,6 +41,7 @@ extern DIR *__alloc_dir (int fd, bool close_fd, int flags,
 			 const struct stat64 *statp)
      internal_function;
 extern void __scandir_cancel_handler (void *arg);
+extern int __dirfd (DIR *__dirp);
 
 libc_hidden_proto (rewinddir)
 libc_hidden_proto (scandirat)
diff --git a/io/fts.c b/io/fts.c
index 5ba202b..11c5707 100644
--- a/io/fts.c
+++ b/io/fts.c
@@ -654,7 +654,7 @@ fts_build(sp, type)
 	 */
 	cderrno = 0;
 	if (nlinks || type == BREAD) {
-		if (fts_safe_changedir(sp, cur, dirfd(dirp), NULL)) {
+		if (fts_safe_changedir(sp, cur, __dirfd(dirp), NULL)) {
 			if (nlinks && type == BREAD)
 				cur->fts_errno = errno;
 			cur->fts_flags |= FTS_DONTCHDIR;
diff --git a/io/ftw.c b/io/ftw.c
index ee3ba88..9d6eb71 100644
--- a/io/ftw.c
+++ b/io/ftw.c
@@ -1,5 +1,5 @@
 /* File tree walker functions.
-   Copyright (C) 1996-2004, 2006-2008, 2010 Free Software Foundation, Inc.
+   Copyright (C) 1996-2004, 2006-2008, 2010, 2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
 
@@ -365,7 +365,7 @@ open_dir_stream (int *dfdp, struct ftw_data *data, struct dir_data *dirp)
 	result = -1;
       else
 	{
-	  dirp->streamfd = dirfd (dirp->stream);
+	  dirp->streamfd = __dirfd (dirp->stream);
 	  dirp->content = NULL;
 	  data->dirstreams[data->actdir] = dirp;
 
@@ -524,7 +524,7 @@ fail:
   /* If necessary, change to this directory.  */
   if (data->flags & FTW_CHDIR)
     {
-      if (__fchdir (dirfd (dir.stream)) < 0)
+      if (__fchdir (__dirfd (dir.stream)) < 0)
 	{
 	  result = -1;
 	  goto fail;
@@ -604,7 +604,7 @@ fail:
       /* Change back to the parent directory.  */
       int done = 0;
       if (old_dir->stream != NULL)
-	if (__fchdir (dirfd (old_dir->stream)) == 0)
+	if (__fchdir (__dirfd (old_dir->stream)) == 0)
 	  done = 1;
 
       if (!done)
diff --git a/posix/glob.c b/posix/glob.c
index 68ea205..b92dc24 100644
--- a/posix/glob.c
+++ b/posix/glob.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2011
+/* Copyright (C) 1991-2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2011, 2012
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -1545,7 +1545,7 @@ glob_in_dir (const char *pattern, const char *directory, int flags,
 	{
 #ifdef _LIBC
 	  int dfd = (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)
-		     ? -1 : dirfd ((DIR *) stream));
+		     ? -1 : __dirfd ((DIR *) stream));
 #endif
 	  int fnm_flags = ((!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0)
 			   | ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0)
diff --git a/sysdeps/mach/hurd/dirfd.c b/sysdeps/mach/hurd/dirfd.c
index 587ae7b..975bc02 100644
--- a/sysdeps/mach/hurd/dirfd.c
+++ b/sysdeps/mach/hurd/dirfd.c
@@ -1,5 +1,5 @@
 /* dirfd -- Return the file descriptor used by a DIR stream.  Hurd version.
-   Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 2012 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
@@ -22,7 +22,7 @@
 #include <errno.h>
 
 int
-dirfd (DIR *dirp)
+__dirfd (DIR *dirp)
 {
   int fd;
   __mutex_lock (&_hurd_dtable_lock);
@@ -38,3 +38,4 @@ dirfd (DIR *dirp)
 
   return fd;
 }
+weak_alias(__dirfd, dirfd)
diff --git a/sysdeps/unix/dirfd.c b/sysdeps/unix/dirfd.c
index 536c44e..0cdacf9 100644
--- a/sysdeps/unix/dirfd.c
+++ b/sysdeps/unix/dirfd.c
@@ -1,5 +1,5 @@
 /* Return the file descriptor used by a DIR stream.  Unix version.
-   Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 2012 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
@@ -22,8 +22,9 @@
 #undef dirfd
 
 int
-dirfd (dirp)
+__dirfd (dirp)
      DIR *dirp;
 {
   return dirp->fd;
 }
+weak_alias(__dirfd, dirfd)
diff --git a/sysdeps/unix/sysv/linux/grantpt.c b/sysdeps/unix/sysv/linux/grantpt.c
index 0a3cd47..06b696b 100644
--- a/sysdeps/unix/sysv/linux/grantpt.c
+++ b/sysdeps/unix/sysv/linux/grantpt.c
@@ -25,7 +25,7 @@ close_all_fds (void)
 	  {
 	    char *endp;
 	    long int fd = strtol (d->d_name, &endp, 10);
-	    if (*endp == '\0' && fd != PTY_FILENO && fd != dirfd (dir))
+	    if (*endp == '\0' && fd != PTY_FILENO && fd != __dirfd (dir))
 	      close_not_cancel_no_status (fd);
 	  }
 

-- 
 Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi
  SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
   GF: Jeff Hawn,Jennifer Guild,Felix Imendörffer,HRB16746 (AG Nürnberg)
    GPG fingerprint = 93A3 365E CE47 B889 DF7F  FED1 389A 563C C272 A126


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]