]> granicus.if.org Git - strace/commitdiff
x32: fix build regressions introduced by commit v4.7-96-g8435d67
authorDmitry V. Levin <ldv@altlinux.org>
Wed, 1 May 2013 16:37:08 +0000 (16:37 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 1 May 2013 22:39:10 +0000 (22:39 +0000)
* desc.c (printflock) [X32]: Add special handling required for
this architecture with sizeof(long) < sizeof(off_t).
* file.c [X32] (struct stat64): Add __attribute__((packed)).
[X32] (HAVE_STAT64): Define.
(printstat) [X32]: Redirect to printstat64.
(printstat64) [X32]: Use "struct stat" instead of "struct stat64".
[X32] (realprintstat64): Rename to printstat64_x32.
(sys_stat64, sys_fstat64) [X32]: Remove second definitions of these
functions.  Call printstat64_x32 instead of printstat64
* linux/x32/syscallent.h: Fix handlers for truncate and ftruncate.

desc.c
file.c
linux/x32/syscallent.h

diff --git a/desc.c b/desc.c
index cd2c85724d7694e3d4a7fded98abe450c8972834..a420febcdc01e766a6487908815686fb804b6e2d 100644 (file)
--- a/desc.c
+++ b/desc.c
@@ -223,6 +223,29 @@ static const struct xlat perf_event_open_flags[] = {
        { 0,                            NULL                    },
 };
 
+#if _LFS64_LARGEFILE
+/* fcntl/lockf */
+static void
+printflock64(struct tcb *tcp, long addr, int getlk)
+{
+       struct flock64 fl;
+
+       if (umove(tcp, addr, &fl) < 0) {
+               tprints("{...}");
+               return;
+       }
+       tprints("{type=");
+       printxval(lockfcmds, fl.l_type, "F_???");
+       tprints(", whence=");
+       printxval(whence_codes, fl.l_whence, "SEEK_???");
+       tprintf(", start=%lld, len=%lld", (long long) fl.l_start, (long long) fl.l_len);
+       if (getlk)
+               tprintf(", pid=%lu}", (unsigned long) fl.l_pid);
+       else
+               tprints("}");
+}
+#endif
+
 /* fcntl/lockf */
 static void
 printflock(struct tcb *tcp, long addr, int getlk)
@@ -230,6 +253,12 @@ printflock(struct tcb *tcp, long addr, int getlk)
        struct flock fl;
 
 #if SUPPORTED_PERSONALITIES > 1
+# ifdef X32
+       if (current_personality == 0) {
+               printflock64(tcp, addr, getlk);
+               return;
+       }
+# endif
        if (current_wordsize != sizeof(fl.l_start)) {
                if (current_wordsize == 4) {
                        /* 32-bit x86 app on x86_64 and similar cases */
@@ -267,36 +296,17 @@ printflock(struct tcb *tcp, long addr, int getlk)
        printxval(lockfcmds, fl.l_type, "F_???");
        tprints(", whence=");
        printxval(whence_codes, fl.l_whence, "SEEK_???");
+#ifdef X32
+       tprintf(", start=%lld, len=%lld", fl.l_start, fl.l_len);
+#else
        tprintf(", start=%ld, len=%ld", fl.l_start, fl.l_len);
+#endif
        if (getlk)
                tprintf(", pid=%lu}", (unsigned long) fl.l_pid);
        else
                tprints("}");
 }
 
-#if _LFS64_LARGEFILE
-/* fcntl/lockf */
-static void
-printflock64(struct tcb *tcp, long addr, int getlk)
-{
-       struct flock64 fl;
-
-       if (umove(tcp, addr, &fl) < 0) {
-               tprints("{...}");
-               return;
-       }
-       tprints("{type=");
-       printxval(lockfcmds, fl.l_type, "F_???");
-       tprints(", whence=");
-       printxval(whence_codes, fl.l_whence, "SEEK_???");
-       tprintf(", start=%lld, len=%lld", (long long) fl.l_start, (long long) fl.l_len);
-       if (getlk)
-               tprintf(", pid=%lu}", (unsigned long) fl.l_pid);
-       else
-               tprints("}");
-}
-#endif
-
 int
 sys_fcntl(struct tcb *tcp)
 {
diff --git a/file.c b/file.c
index 837bfed6c2d04d55242f86406817a90b5bf7aef8..35f2b710f0347055c91bca9a0979e665a8960ff8 100644 (file)
--- a/file.c
+++ b/file.c
@@ -117,7 +117,8 @@ struct stat64 {
        unsigned long           st_ctime;
        unsigned long           st_ctime_nsec;
        unsigned long long      st_ino;
-};
+} __attribute__((packed));
+# define HAVE_STAT64   1
 
 struct __old_kernel_stat {
        unsigned short st_dev;
@@ -982,6 +983,7 @@ realprintstat(struct tcb *tcp, struct stat *statbuf)
                tprints("...}");
 }
 
+#ifndef X32
 static void
 printstat(struct tcb *tcp, long addr)
 {
@@ -1023,6 +1025,9 @@ printstat(struct tcb *tcp, long addr)
 
        realprintstat(tcp, &statbuf);
 }
+#else /* X32 */
+# define printstat printstat64
+#endif
 
 #if !defined HAVE_STAT64 && defined X86_64
 /*
@@ -1060,7 +1065,11 @@ struct stat64 {
 static void
 printstat64(struct tcb *tcp, long addr)
 {
+#ifdef X32
+       struct stat statbuf;
+#else
        struct stat64 statbuf;
+#endif
 
 #ifdef STAT64_SIZE
        (void) sizeof(char[sizeof statbuf == STAT64_SIZE ? 1 : -1]);
@@ -1239,6 +1248,63 @@ sys_stat(struct tcb *tcp)
        return 0;
 }
 
+#ifdef X32
+static void
+printstat64_x32(struct tcb *tcp, long addr)
+{
+       struct stat64 statbuf;
+
+       if (!addr) {
+               tprints("NULL");
+               return;
+       }
+       if (syserror(tcp) || !verbose(tcp)) {
+               tprintf("%#lx", addr);
+               return;
+       }
+
+       if (umove(tcp, addr, &statbuf) < 0) {
+               tprints("{...}");
+               return;
+       }
+
+       if (!abbrev(tcp)) {
+               tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
+                       (unsigned long) major(statbuf.st_dev),
+                       (unsigned long) minor(statbuf.st_dev),
+                       (unsigned long long) statbuf.st_ino,
+                       sprintmode(statbuf.st_mode));
+               tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
+                       (unsigned long) statbuf.st_nlink,
+                       (unsigned long) statbuf.st_uid,
+                       (unsigned long) statbuf.st_gid);
+               tprintf("st_blksize=%lu, ",
+                       (unsigned long) statbuf.st_blksize);
+               tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
+       }
+       else
+               tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
+       switch (statbuf.st_mode & S_IFMT) {
+       case S_IFCHR: case S_IFBLK:
+               tprintf("st_rdev=makedev(%lu, %lu), ",
+                       (unsigned long) major(statbuf.st_rdev),
+                       (unsigned long) minor(statbuf.st_rdev));
+               break;
+       default:
+               tprintf("st_size=%llu, ", (unsigned long long) statbuf.st_size);
+               break;
+       }
+       if (!abbrev(tcp)) {
+               tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
+               tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
+               tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
+               tprints("}");
+       }
+       else
+               tprints("...}");
+}
+#endif /* X32 */
+
 int
 sys_stat64(struct tcb *tcp)
 {
@@ -1247,7 +1313,11 @@ sys_stat64(struct tcb *tcp)
                printpath(tcp, tcp->u_arg[0]);
                tprints(", ");
        } else {
+# ifdef X32
+               printstat64_x32(tcp, tcp->u_arg[1]);
+# else
                printstat64(tcp, tcp->u_arg[1]);
+# endif
        }
        return 0;
 #else
@@ -1338,7 +1408,11 @@ sys_fstat64(struct tcb *tcp)
                printfd(tcp, tcp->u_arg[0]);
                tprints(", ");
        } else {
+# ifdef X32
+               printstat64_x32(tcp, tcp->u_arg[1]);
+# else
                printstat64(tcp, tcp->u_arg[1]);
+# endif
        }
        return 0;
 #else
@@ -2722,88 +2796,3 @@ sys_swapon(struct tcb *tcp)
        }
        return 0;
 }
-
-#ifdef X32
-# undef stat64
-# undef sys_fstat64
-# undef sys_stat64
-
-static void
-realprintstat64(struct tcb *tcp, long addr)
-{
-       struct stat64 statbuf;
-
-       if (!addr) {
-               tprints("NULL");
-               return;
-       }
-       if (syserror(tcp) || !verbose(tcp)) {
-               tprintf("%#lx", addr);
-               return;
-       }
-
-       if (umove(tcp, addr, &statbuf) < 0) {
-               tprints("{...}");
-               return;
-       }
-
-       if (!abbrev(tcp)) {
-               tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
-                       (unsigned long) major(statbuf.st_dev),
-                       (unsigned long) minor(statbuf.st_dev),
-                       (unsigned long long) statbuf.st_ino,
-                       sprintmode(statbuf.st_mode));
-               tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
-                       (unsigned long) statbuf.st_nlink,
-                       (unsigned long) statbuf.st_uid,
-                       (unsigned long) statbuf.st_gid);
-               tprintf("st_blksize=%lu, ",
-                       (unsigned long) statbuf.st_blksize);
-               tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
-       }
-       else
-               tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
-       switch (statbuf.st_mode & S_IFMT) {
-       case S_IFCHR: case S_IFBLK:
-               tprintf("st_rdev=makedev(%lu, %lu), ",
-                       (unsigned long) major(statbuf.st_rdev),
-                       (unsigned long) minor(statbuf.st_rdev));
-               break;
-       default:
-               tprintf("st_size=%llu, ", (unsigned long long) statbuf.st_size);
-               break;
-       }
-       if (!abbrev(tcp)) {
-               tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
-               tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
-               tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
-               tprints("}");
-       }
-       else
-               tprints("...}");
-}
-
-int
-sys_fstat64(struct tcb *tcp)
-{
-       if (entering(tcp)) {
-               printfd(tcp, tcp->u_arg[0]);
-               tprints(", ");
-       } else {
-               realprintstat64(tcp, tcp->u_arg[1]);
-       }
-       return 0;
-}
-
-int
-sys_stat64(struct tcb *tcp)
-{
-       if (entering(tcp)) {
-               printpath(tcp, tcp->u_arg[0]);
-               tprints(", ");
-       } else {
-               realprintstat64(tcp, tcp->u_arg[1]);
-       }
-       return 0;
-}
-#endif
index 4adf66b7addcadc33ac47ab9422c73d0af3e3d26..0098e764fe3ad270752c4ea1017b744a87a3ff6a 100644 (file)
@@ -74,8 +74,8 @@
        { 2,    TD,     sys_flock,              "flock"         },  /* 73 */
        { 1,    TD,     sys_fsync,              "fsync"         },  /* 74 */
        { 1,    TD,     sys_fdatasync,          "fdatasync"     },  /* 75 */
-       { 2,    TF,     sys_truncate,           "truncate"      },  /* 76 */
-       { 2,    TD,     sys_ftruncate,          "ftruncate"     },  /* 77 */
+       { 2,    TF,     sys_truncate64,         "truncate"      },  /* 76 */
+       { 2,    TD,     sys_ftruncate64,        "ftruncate"     },  /* 77 */
        { 3,    TD,     sys_getdents,           "getdents"      }, /* 78 */
        { 2,    TF,     sys_getcwd,             "getcwd"        },  /* 79 */
        { 1,    TF,     sys_chdir,              "chdir"         },  /* 80 */