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]

[PATCH 1/2] Squashing-64bit-file-inode-into-32bit-inode-field


Replace returning EOVERFLOW by squashing long inodes.

ChangeLog:

2014-02-15  Denis Obrezkov  <reprofy@etersoft.ru>

	* sysdeps/unix/sysv/linux/xstatconv.c (squash_inode): Squashing file's
	inode if it's too long.
	(__xstat32_conv): Squashing long inodes instead of EOVERFLOW returning.


---
 sysdeps/unix/sysv/linux/xstatconv.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/xstatconv.c b/sysdeps/unix/sysv/linux/xstatconv.c
index 858b911..aa52d37 100644
--- a/sysdeps/unix/sysv/linux/xstatconv.c
+++ b/sysdeps/unix/sysv/linux/xstatconv.c
@@ -178,6 +178,14 @@ __xstat64_conv (int vers, struct kernel_stat *kbuf, void *ubuf)
 #endif
 }
 
+static ino_t
+squash_inode (ino_t ino32, ino64_t ino64)
+{
+  ino32 ^= ino64 >> (sizeof (ino64_t) - sizeof (ino_t)) * 8;
+  return ino32;
+}
+
+
 int
 __xstat32_conv (int vers, struct stat64 *kbuf, struct stat *buf)
 {
@@ -202,8 +210,7 @@ __xstat32_conv (int vers, struct stat64 *kbuf, struct stat *buf)
 	    if (sizeof (buf->st_ino) != sizeof (kbuf->st_ino)
 		&& buf->st_ino != kbuf->st_ino)
 	      {
-		__set_errno (EOVERFLOW);
-		return -1;
+		buf->st_ino = squash_inode (buf->st_ino, kbuf->st_ino);
 	      }
 	  }
 #else
@@ -211,8 +218,7 @@ __xstat32_conv (int vers, struct stat64 *kbuf, struct stat *buf)
 	if (sizeof (buf->st_ino) != sizeof (kbuf->st_ino)
 	    && buf->st_ino != kbuf->st_ino)
 	  {
-	    __set_errno (EOVERFLOW);
-	    return -1;
+		buf->st_ino = squash_inode (buf->st_ino, kbuf->st_ino);
 	  }
 #endif
 	buf->st_mode = kbuf->st_mode;
-- 
1.8.4.5


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