]> granicus.if.org Git - strace/blobdiff - file.c
replace wimpy get64 by powerful LONG_LONG :-)
[strace] / file.c
diff --git a/file.c b/file.c
index 3ec97e314b3d0c67b633aefd4b9a6829d5ee4b0e..e618b0360cf8061beb5740d29127a0204df6a078 100644 (file)
--- a/file.c
+++ b/file.c
@@ -1,4 +1,5 @@
 /*
+#ifdef linux
  * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
  * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
  * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
@@ -131,6 +132,22 @@ struct stat {
 #include <sys/stat.h>
 #endif
 
+#if HAVE_LONG_LONG_OFF_T
+/*
+ * Ugly hacks for systems that have typedef long long off_t
+ */
+
+#define stat64 stat
+#define HAVE_STAT64 1  /* Ugly hack */
+
+#define        sys_stat64      sys_stat
+#define sys_fstat64    sys_fstat
+#define sys_lstat64    sys_lstat
+#define sys_lseek64    sys_lseek
+#define sys_truncate64 sys_truncate
+#define sys_ftruncate64        sys_ftruncate
+#endif
+
 #ifdef MAJOR_IN_SYSMACROS
 #include <sys/sysmacros.h>
 #endif
@@ -350,6 +367,7 @@ static struct xlat whence[] = {
        { 0,            NULL            },
 };
 
+#ifndef HAVE_LONG_LONG_OFF_T
 int
 sys_lseek(tcp)
 struct tcb *tcp;
@@ -359,30 +377,17 @@ struct tcb *tcp;
 
        if (entering(tcp)) {
                tprintf("%ld, ", tcp->u_arg[0]);
-#ifndef FREEBSD
                offset = tcp->u_arg[1];
                _whence = tcp->u_arg[2];
                if (_whence == SEEK_SET)
                        tprintf("%lu, ", offset);
                else
                        tprintf("%ld, ", offset);               
-#else /* FREEBSD */
-               offset = ((off_t) tcp->u_arg[1] << 32) +  tcp->u_arg[2];
-               _whence = tcp->u_arg[4];
-               if (_whence == SEEK_SET)
-                       tprintf("%llu, ", offset);
-               else
-                       tprintf("%lld, ", offset);              
-#endif         
                printxval(whence, _whence, "SEEK_???");
        } 
-#ifdef FREEBSD
-       else
-               if (!syserror(tcp))
-                       return RVAL_LUDECIMAL;
-#endif /* FREEBSD */
        return RVAL_UDECIMAL;
 }
+#endif
 
 #ifdef linux
 int
@@ -411,13 +416,15 @@ struct tcb *tcp;
 }
 #endif
 
-#if _LFS_LARGEFILE
+#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
 int
 sys_lseek64 (tcp)
 struct tcb *tcp;
 {
        if (entering(tcp)) {
-               long long offset = get64(tcp->u_arg [1], tcp->u_arg[2]);
+               long long offset;
+               ALIGN64 (tcp, 1);       /* FreeBSD aligns off_t args */
+               offset = LONG_LONG(tcp->u_arg [1], tcp->u_arg[2]);
                if (tcp->u_arg[3] == SEEK_SET)
                        tprintf("%ld, %llu, ", tcp->u_arg[0], offset);
                else
@@ -428,35 +435,58 @@ struct tcb *tcp;
 }
 #endif
 
+#ifndef HAVE_LONG_LONG_OFF_T
 int
 sys_truncate(tcp)
 struct tcb *tcp;
 {
        if (entering(tcp)) {
                printpath(tcp, tcp->u_arg[0]);
-#ifndef FREEBSD
                tprintf(", %lu", tcp->u_arg[1]);
-#else
-               tprintf(", %llu", ((off_t) tcp->u_arg[1] << 32) + tcp->u_arg[2]);
-#endif         
        }
        return 0;
 }
+#endif
+
+#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
+int
+sys_truncate64(tcp)
+struct tcb *tcp;
+{
+       if (entering(tcp)) {
+               ALIGN64 (tcp, 1);
+               printpath(tcp, tcp->u_arg[0]);
+               tprintf(", %llu", LONG_LONG(tcp->u_arg[1],tcp->u_arg[2]));
+       }
+       return 0;
+}
+#endif
 
+#ifndef HAVE_LONG_LONG_OFF_T
 int
 sys_ftruncate(tcp)
 struct tcb *tcp;
 {
        if (entering(tcp)) {
-#ifndef FREEBSD
                tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
-#else
+       }
+       return 0;
+}
+#endif
+
+#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
+int
+sys_ftruncate64(tcp)
+struct tcb *tcp;
+{
+       if (entering(tcp)) {
+               ALIGN64 (tcp, 1);
                tprintf("%ld, %llu", tcp->u_arg[0],
-                       ((off_t) tcp->u_arg[1] << 32) + tcp->u_arg[2]);
-#endif         
+                       LONG_LONG(tcp->u_arg[1] ,tcp->u_arg[2]));
        }
        return 0;
 }
+#endif
 
 /* several stats */
 
@@ -638,6 +668,7 @@ struct tcb *tcp;
 }
 #endif
 
+#ifndef HAVE_LONG_LONG_OFF_T
 static void
 realprintstat(tcp, statbuf)
 struct tcb *tcp;
@@ -681,17 +712,7 @@ struct stat *statbuf;
     if (!abbrev(tcp)) {
            tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
            tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
-#ifndef FREEBSD
            tprintf("st_ctime=%s}", sprinttime(statbuf->st_ctime));
-#else /* FREEBSD */
-           tprintf("st_ctime=%s, ", sprinttime(statbuf->st_ctime));
-           tprintf("st_flags=");
-           if (statbuf->st_flags) {
-                   printflags(fileflags, statbuf->st_flags);
-           } else
-                   tprintf("0");
-           tprintf(", st_gen=%u}", statbuf->st_gen);
-#endif /* FREEBSD */
     }
     else
            tprintf("...}");
@@ -727,6 +748,7 @@ long addr;
 
        realprintstat(tcp, &statbuf);
 }
+#endif /* !HAVE_LONG_LONG_OFF_T */
 
 #ifdef HAVE_STAT64
 static void
@@ -803,7 +825,17 @@ long addr;
        if (!abbrev(tcp)) {
                tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
                tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
+#ifndef FREEBSD
                tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
+#else /* FREEBSD */
+               tprintf("st_ctime=%s, ", sprinttime(statbuf.st_ctime));
+               tprintf("st_flags=");
+               if (statbuf.st_flags) {
+                       printflags(fileflags, statbuf.st_flags);
+               } else
+                       tprintf("0");
+               tprintf(", st_gen=%u}", statbuf.st_gen);
+#endif /* FREEBSD */
        }
        else
                tprintf("...}");
@@ -865,7 +897,7 @@ long addr;
 }
 #endif /* linux && !IA64 */
 
-
+#ifndef HAVE_LONG_LONG_OFF_T
 int
 sys_stat(tcp)
 struct tcb *tcp;
@@ -878,8 +910,8 @@ struct tcb *tcp;
        }
        return 0;
 }
+#endif
 
-#ifdef linux
 int
 sys_stat64(tcp)
 struct tcb *tcp;
@@ -897,6 +929,7 @@ struct tcb *tcp;
 #endif
 }
 
+#ifdef linux
 # if !defined(IA64)
 int
 sys_oldstat(tcp)
@@ -913,6 +946,7 @@ struct tcb *tcp;
 # endif /* !IA64 */
 #endif /* linux */
 
+#ifndef HAVE_LONG_LONG_OFF_T
 int
 sys_fstat(tcp)
 struct tcb *tcp;
@@ -924,8 +958,8 @@ struct tcb *tcp;
        }
        return 0;
 }
+#endif
 
-#ifdef linux
 int
 sys_fstat64(tcp)
 struct tcb *tcp;
@@ -942,6 +976,7 @@ struct tcb *tcp;
 #endif
 }
 
+#ifdef linux
 # if !defined(IA64)
 int
 sys_oldfstat(tcp)
@@ -957,6 +992,7 @@ struct tcb *tcp;
 # endif /* !IA64 */
 #endif
 
+#ifndef HAVE_LONG_LONG_OFF_T
 int
 sys_lstat(tcp)
 struct tcb *tcp;
@@ -969,8 +1005,8 @@ struct tcb *tcp;
        }
        return 0;
 }
+#endif
 
-#ifdef linux
 int
 sys_lstat64(tcp)
 struct tcb *tcp;
@@ -988,6 +1024,7 @@ struct tcb *tcp;
 #endif
 }
 
+#ifdef linux
 # if !defined(IA64)
 int
 sys_oldlstat(tcp)