Package: android-tools-adb
Version: 4.1.1+git20120801-1
Severity: normal
Tags: lfs patch


If one tries to create files bigger than 2GB, adb fails and files remain
fixed at 2.00 GB.

for example, doing "adb backup -all -apk -system -shared" on big enough
phone would create "backup.ab" size 2.0GB, and would not proceed. 

stracing reveals that "backup.ab" is created using creat(2) 
(via adb_creat() in core/adb/sysdeps.h)

And linux 2.6.32 source code in fs/open.c defines creat(2) as:

SYSCALL_DEFINE2(creat, const char __user *, pathname, int, mode)
{
        return sys_open(pathname, O_CREAT | O_WRONLY | O_TRUNC, mode);
}

which does not use or support O_LARGEFILE, hence the files created with it
are limited to 2GB.

Attached patch allows such backups to finish.

-- System Information:
Debian Release: 6.0.6
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 2.6.32-5-686 (SMP w/2 CPU cores)
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages android-tools-adb depends on:
ii  libc6                   2.11.3-4         Embedded GNU C Library: Shared lib
ii  zlib1g                  1:1.2.3.4.dfsg-3 compression library - runtime

android-tools-adb recommends no packages.

android-tools-adb suggests no packages.

-- no debconf information
Description: O_LARGEFILE support for >2GB files
 Allowd adb backup and other commands ability to create files bigger than 2GB.
 Author: Matija Nalis <mnalis-deb...@voyager.hr>
 .

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: http://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: <YYYY-MM-DD>

--- android-tools-4.1.1+git20120801.orig/core/adb/sysdeps.h
+++ android-tools-4.1.1+git20120801/core/adb/sysdeps.h
@@ -324,6 +324,19 @@
     return open( pathname, options, mode );
 }
 
+static __inline__  int  adb_creat(const char*  path, int  mode)
+{
+    int  fd = open(path, O_CREAT | O_WRONLY | O_TRUNC | O_LARGEFILE, mode);
+
+    if ( fd < 0 )
+        return -1;
+
+    close_on_exec(fd);
+    return fd;
+}
+
+#undef   creat
+#define  creat  ___xxx_creat
 
 static __inline__ int  adb_open( const char*  pathname, int  options )
 {
@@ -380,18 +393,6 @@
 #undef  unlink
 #define unlink  ___xxx_unlink
 
-static __inline__  int  adb_creat(const char*  path, int  mode)
-{
-    int  fd = creat(path, mode);
-
-    if ( fd < 0 )
-        return -1;
-
-    close_on_exec(fd);
-    return fd;
-}
-#undef   creat
-#define  creat  ___xxx_creat
 
 static __inline__ int  adb_socket_accept(int  serverfd, struct sockaddr*  
addr, socklen_t  *addrlen)
 {
--- android-tools-4.1.1+git20120801.orig/core/adb/makefile
+++ android-tools-4.1.1+git20120801/core/adb/makefile
@@ -35,6 +35,7 @@
 CPPFLAGS+= -DHAVE_FORKEXEC=1
 CPPFLAGS+= -DHAVE_SYMLINKS
 CPPFLAGS+= -DHAVE_TERMIO_H
+CPPFLAGS+= -D_LARGEFILE64_SOURCE
 CPPFLAGS+= -I.
 CPPFLAGS+= -I../include
 CPPFLAGS+= -I../../../external/zlib

Reply via email to