diff mbox

[BZ,15514] Use statvfs64() for pathconf(_PC_NAME_MAX).

Message ID 87ioqk270z.fsf@harrington.peter-b.co.uk
State New
Headers show

Commit Message

Peter TB Brett April 7, 2014, 8:56 p.m. UTC
pathconf(_PC_NAME_MAX) was implemented on top of statfs().  The 32bit
version therefore fails EOVERFLOW if the filesystem blockcount is
sufficiently large.

Most pathconf() queries use statvfs64(), which avoids this issue.  This
patch modifies pathconf(_PC_NAME_MAX) to do likewise.

                                         Peter

P.S. I haven't completed FSF copyright assignment.

Comments

Ondřej Bílka April 8, 2014, 3:10 p.m. UTC | #1
On Mon, Apr 07, 2014 at 09:56:12PM +0100, Peter TB Brett wrote:
> 
> pathconf(_PC_NAME_MAX) was implemented on top of statfs().  The 32bit
> version therefore fails EOVERFLOW if the filesystem blockcount is
> sufficiently large.
> 
> Most pathconf() queries use statvfs64(), which avoids this issue.  This
> patch modifies pathconf(_PC_NAME_MAX) to do likewise.
> 
>                                          Peter
> 
> P.S. I haven't completed FSF copyright assignment.
> 
Looks ok for me. 

Copyright assignment is not needed yet. As this is under 15 lines 
its not legally significant.

http://www.gnu.org/prep/maintain/maintain.html#Legally-Significant
Mike Frysinger April 8, 2014, 11:10 p.m. UTC | #2
On Mon 07 Apr 2014 21:56:12 Peter TB Brett wrote:
> pathconf(_PC_NAME_MAX) was implemented on top of statfs().  The 32bit
> version therefore fails EOVERFLOW if the filesystem blockcount is
> sufficiently large.
> 
> Most pathconf() queries use statvfs64(), which avoids this issue.  This
> patch modifies pathconf(_PC_NAME_MAX) to do likewise.

lgtm
-mike
diff mbox

Patch

From 39df7d3a6414920e6c241c23655acecb31bee0de Mon Sep 17 00:00:00 2001
From: Peter TB Brett <peter@peter-b.co.uk>
Date: Sun, 6 Apr 2014 10:51:05 +0100
Subject: [PATCH] Use statvfs64() for pathconf(_PC_NAME_MAX). [Bug #15514]

---
 ChangeLog                |  6 ++++++
 sysdeps/posix/pathconf.c | 14 +++-----------
 2 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a0bb465..5b94808 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@ 
+2014-04-06  Peter Brett  <peter@peter-b.co.uk>
+
+	[BZ #15514]
+	* sysdeps/posix/pathconf.c (__pathconf): Use statvfs64() for
+	pathconf(_PC_NAME_MAX).
+
 2014-04-04  Chris Metcalf  <cmetcalf@tilera.com>
 
 	* sysdeps/tile/dl-runtime.c (_dl_unmap): Fix cut-and-paste bug
diff --git a/sysdeps/posix/pathconf.c b/sysdeps/posix/pathconf.c
index 8aa55e0..ac617d4 100644
--- a/sysdeps/posix/pathconf.c
+++ b/sysdeps/posix/pathconf.c
@@ -65,10 +65,10 @@  __pathconf (const char *path, int name)
     case _PC_NAME_MAX:
 #ifdef	NAME_MAX
       {
-	struct statfs buf;
+	struct statvfs64 sv;
 	int save_errno = errno;
 
-	if (__statfs (path, &buf) < 0)
+	if (__statvfs64 (path, &sv) < 0)
 	  {
 	    if (errno == ENOSYS)
 	      {
@@ -79,15 +79,7 @@  __pathconf (const char *path, int name)
 	  }
 	else
 	  {
-#ifdef _STATFS_F_NAMELEN
-	    return buf.f_namelen;
-#else
-# ifdef _STATFS_F_NAME_MAX
-	    return buf.f_name_max;
-# else
-	    return NAME_MAX;
-# endif
-#endif
+	    return sv.f_namemax;
 	  }
       }
 #else
-- 
1.9.0