]> granicus.if.org Git - strace/commitdiff
Added support for old*stat syscalls for Linux
authorWichert Akkerman <wichert@deephackmode.org>
Fri, 16 Apr 1999 00:21:26 +0000 (00:21 +0000)
committerWichert Akkerman <wichert@deephackmode.org>
Fri, 16 Apr 1999 00:21:26 +0000 (00:21 +0000)
Changed referenced to LINUX to linux in file.c
Fix include for ldt.h in mem.c while we're at it

ChangeLog
file.c
linux/dummy.h
mem.c

index 612848dfcc5421994c9ac56fdcacaee069d9fc77..76069ad06c41ce5a92861139e78ee4c620a9e2ae 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Fri Apr 16 02:18:05 CEST 1999 Wichert Akkerman <wakkerma@debian.org>
+
+  * Add support for old_*stat functions for Linux. Note to self:
+    check osf_*stat functions for Linux alpha.
+  * Change references to LINUX into linux in file.c
+  * Fix include for LDT in mem.c
 
 Thu Apr 15 22:28:15 CEST 1999 Wichert Akkerman <wakkerma@debian.org>
 
diff --git a/file.c b/file.c
index df6c5511bbe74608dcc9b4af5b95402add61b8b5..e528bf28ad14eeb207e29c9d465e7f2b40caac3f 100644 (file)
--- a/file.c
+++ b/file.c
@@ -34,6 +34,9 @@
 #include <dirent.h>
 
 #include <sys/stat.h>
+#ifdef linux
+#include <asm/stat.h>
+#endif
 #include <fcntl.h>
 
 #ifdef SVR4
@@ -267,7 +270,7 @@ struct tcb *tcp;
        return RVAL_UDECIMAL;
 }
 
-#ifdef LINUX
+#ifdef linux
 int
 sys_llseek (tcp)
 struct tcb *tcp;
@@ -453,21 +456,70 @@ int addr;
 }
 #endif
 
-#ifdef LINUX
-/* Get the kernel's idea of struct stat. */
-#define stat kernel_stat
-#include <asm/stat.h>
-#undef stat
-#else /* LINUX */
-#define kernel_stat stat
-#endif /* LINUX */
+static void
+realprintstat(tcp, statbuf)
+struct tcb *tcp;
+#ifdef linux
+struct new_stat *statbuf;
+#else
+struct stat *statbuf;
+#endif
+{
+    if (!abbrev(tcp)) {
+           tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
+                   (unsigned long) major(statbuf->st_dev),
+                   (unsigned long) minor(statbuf->st_dev),
+                   (unsigned 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);
+#ifdef HAVE_ST_BLKSIZE
+           tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
+#endif /* HAVE_ST_BLKSIZE */
+#ifdef HAVE_ST_BLOCKS
+           tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
+#endif /* HAVE_ST_BLOCKS */
+    }
+    else
+           tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
+    switch (statbuf->st_mode & S_IFMT) {
+    case S_IFCHR: case S_IFBLK:
+#ifdef HAVE_ST_RDEV
+           tprintf("st_rdev=makedev(%lu, %lu), ",
+                   (unsigned long) major(statbuf->st_rdev),
+                   (unsigned long) minor(statbuf->st_rdev));
+#else /* !HAVE_ST_RDEV */
+           tprintf("st_size=makedev(%lu, %lu), ",
+                   (unsigned long) major(statbuf->st_size),
+                   (unsigned long) minor(statbuf->st_size));
+#endif /* !HAVE_ST_RDEV */
+           break;
+    default:
+           tprintf("st_size=%lu, ", 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));
+    }
+    else
+           tprintf("...}");
+}
+
 
 static void
 printstat(tcp, addr)
 struct tcb *tcp;
 int addr;
 {
-       struct kernel_stat statbuf;
+#ifdef linux
+       struct new_stat statbuf;
+#else
+       struct stat statbuf;
+#endif
 
 #ifdef LINUXSPARC
        if (current_personality == 1) {
@@ -488,49 +540,67 @@ int addr;
                tprintf("{...}");
                return;
        }
-       if (!abbrev(tcp)) {
-               tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
-                       (unsigned long) major(statbuf.st_dev),
-                       (unsigned long) minor(statbuf.st_dev),
-                       (unsigned 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);
-#ifdef HAVE_ST_BLKSIZE
-               tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
-#endif /* HAVE_ST_BLKSIZE */
-#ifdef HAVE_ST_BLOCKS
-               tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
-#endif /* HAVE_ST_BLOCKS */
+
+       realprintstat(tcp, &statbuf);
+}
+
+#ifdef linux
+static void
+convertoldstat(oldbuf, newbuf)
+const struct old_stat *oldbuf;
+struct new_stat *newbuf;
+{
+    newbuf->st_dev=oldbuf->st_dev;
+    newbuf->st_ino=oldbuf->st_ino;
+    newbuf->st_mode=oldbuf->st_mode;
+    newbuf->st_nlink=oldbuf->st_nlink;
+    newbuf->st_uid=oldbuf->st_uid;
+    newbuf->st_gid=oldbuf->st_gid;
+    newbuf->st_rdev=oldbuf->st_rdev;
+    newbuf->st_size=oldbuf->st_size;
+    newbuf->st_atime=oldbuf->st_atime;
+    newbuf->st_mtime=oldbuf->st_mtime;
+    newbuf->st_ctime=oldbuf->st_ctime;
+    newbuf->st_blksize=0;      /* not supported in old_stat */
+    newbuf->st_blocks=0;               /* not supported in old_stat */
+}
+#endif
+
+
+#ifdef linux
+static void
+printoldstat(tcp, addr)
+struct tcb *tcp;
+int addr;
+{
+       struct old_stat statbuf;
+       struct new_stat newstatbuf;
+
+#ifdef LINUXSPARC
+       if (current_personality == 1) {
+               printstatsol(tcp, addr);
+               return;
+       }
+#endif /* LINUXSPARC */
+
+       if (!addr) {
+               tprintf("NULL");
+               return;
        }
-       else
-               tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
-       switch (statbuf.st_mode & S_IFMT) {
-       case S_IFCHR: case S_IFBLK:
-#ifdef HAVE_ST_RDEV
-               tprintf("st_rdev=makedev(%lu, %lu), ",
-                       (unsigned long) major(statbuf.st_rdev),
-                       (unsigned long) minor(statbuf.st_rdev));
-#else /* !HAVE_ST_RDEV */
-               tprintf("st_size=makedev(%lu, %lu), ",
-                       (unsigned long) major(statbuf.st_size),
-                       (unsigned long) minor(statbuf.st_size));
-#endif /* !HAVE_ST_RDEV */
-               break;
-       default:
-               tprintf("st_size=%lu, ", statbuf.st_size);
-               break;
+       if (syserror(tcp) || !verbose(tcp)) {
+               tprintf("%#x", addr);
+               return;
        }
-       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));
+       if (umove(tcp, addr, &statbuf) < 0) {
+               tprintf("{...}");
+               return;
        }
-       else
-               tprintf("...}");
+
+       convertoldstat(&statbuf, &newstatbuf);
+       realprintstat(tcp, &newstatbuf);
 }
+#endif
+
 
 int
 sys_stat(tcp)
@@ -545,6 +615,21 @@ struct tcb *tcp;
        return 0;
 }
 
+#ifdef linux
+int
+sys_oldstat(tcp)
+struct tcb *tcp;
+{
+       if (entering(tcp)) {
+               printpath(tcp, tcp->u_arg[0]);
+               tprintf(", ");
+       } else {
+               printoldstat(tcp, tcp->u_arg[1]);
+       }
+       return 0;
+}
+#endif
+
 int
 sys_fstat(tcp)
 struct tcb *tcp;
@@ -557,6 +642,20 @@ struct tcb *tcp;
        return 0;
 }
 
+#ifdef linux
+int
+sys_oldfstat(tcp)
+struct tcb *tcp;
+{
+       if (entering(tcp))
+               tprintf("%ld, ", tcp->u_arg[0]);
+       else {
+               printoldstat(tcp, tcp->u_arg[1]);
+       }
+       return 0;
+}
+#endif
+
 int
 sys_lstat(tcp)
 struct tcb *tcp;
@@ -570,6 +669,22 @@ struct tcb *tcp;
        return 0;
 }
 
+#ifdef linux
+int
+sys_oldlstat(tcp)
+struct tcb *tcp;
+{
+       if (entering(tcp)) {
+               printpath(tcp, tcp->u_arg[0]);
+               tprintf(", ");
+       } else {
+               printoldstat(tcp, tcp->u_arg[1]);
+       }
+       return 0;
+}
+#endif
+
+
 #if defined(SVR4) || defined(LINUXSPARC)
 
 int
@@ -643,7 +758,7 @@ struct tcb *tcp;
 
 #endif /* SVR4 || LINUXSPARC */
 
-#ifdef LINUX
+#ifdef linux
 
 static struct xlat fsmagic[] = {
        { 0xef51,       "EXT2_OLD_SUPER_MAGIC"  },
@@ -660,7 +775,7 @@ static struct xlat fsmagic[] = {
        { 0,            NULL                    },
 };
 
-#endif /* LINUX */
+#endif /* linux */
 
 #ifndef SVR4
 
@@ -669,7 +784,7 @@ sprintfstype(magic)
 int magic;
 {
        static char buf[32];
-#ifdef LINUX
+#ifdef linux
        char *s;
 
        s = xlookup(fsmagic, magic);
@@ -677,7 +792,7 @@ int magic;
                sprintf(buf, "\"%s\"", s);
                return buf;
        }
-#endif /* LINUX */
+#endif /* linux */
        sprintf(buf, "%#x", magic);
        return buf;
 }
@@ -713,9 +828,9 @@ long addr;
        tprintf("f_files=%lu, f_ffree=%lu",
                (unsigned long)statbuf.f_files,
                (unsigned long)statbuf.f_ffree);
-#ifdef LINUX
+#ifdef linux
        tprintf(", f_namelen=%lu}", (unsigned long)statbuf.f_namelen);
-#endif /* LINUX */
+#endif /* linux */
 #endif /* !ALPHA */
        tprintf("}");
 }
@@ -745,8 +860,7 @@ struct tcb *tcp;
        return 0;
 }
 
-#ifdef LINUX
-#ifdef ALPHA
+#if defined(linux) && defined(alpha)
 
 int
 osf_statfs(tcp)
@@ -774,8 +888,7 @@ struct tcb *tcp;
        }
        return 0;
 }
-#endif /* ALPHA */
-#endif /* LINUX */
+#endif /* linux && alpha */
 
 #endif /* !SVR4 */
 
@@ -1067,7 +1180,7 @@ struct tcb *tcp;
        return 0;
 }
 
-#ifdef LINUX
+#ifdef linux
 
 static void
 printdir(tcp, addr)
@@ -1085,14 +1198,6 @@ long addr;
                return;
        }
        tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino);
-#ifndef LINUX
-       /* This contains garbage under Linux.  */
-       tprintf("d_off=%d, ", d.d_off);
-#endif /* !LINUX */
-#ifndef LINUX
-       /* No point in printing this out since the syscall returns it. */
-       tprintf("d_reclen=%u, ", d.d_reclen);
-#endif /* !LINUX */
        tprintf("d_name=");
        printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen);
        tprintf("}");
@@ -1116,7 +1221,7 @@ struct tcb *tcp;
        return 0;
 }
 
-#endif /* LINUX */
+#endif /* linux */
 
 int
 sys_getdents(tcp)
@@ -1153,14 +1258,14 @@ struct tcb *tcp;
                tprintf("{");
        for (i = 0; i < len;) {
                struct dirent *d = (struct dirent *) &buf[i];
-#ifdef LINUX
+#ifdef linux
                if (!abbrev(tcp)) {
                        tprintf("%s{d_ino=%lu, d_off=%lu, ",
                                i ? " " : "", d->d_ino, d->d_off);
                        tprintf("d_reclen=%u, d_name=\"%s\"}",
                                d->d_reclen, d->d_name);
                }
-#endif /* LINUX */
+#endif /* linux */
 #ifdef SVR4
                if (!abbrev(tcp)) {
                        tprintf("%s{d_ino=%lu, d_off=%lu, ",
@@ -1190,7 +1295,7 @@ struct tcb *tcp;
        return 0;
 }
 
-#ifdef LINUX
+#ifdef linux
 
 int
 sys_getcwd(tcp)
@@ -1205,7 +1310,7 @@ struct tcb *tcp;
     }
     return 0;
 }
-#endif /* LINUX */
+#endif /* linux */
 
 #ifdef HAVE_SYS_ASYNCH_H
 
index 7f7d34d3f4c5cd41e9ed7cdcefd1da6acf369a32..3cc87fbe33cf7078c652e8ed646cea4a8c8a8c34 100644 (file)
 #define        sys_break               printargs
 
 /* deprecated */
-#define        sys_oldstat             printargs
-#define        sys_oldlstat            printargs
-#define        sys_oldfstat            printargs
 #define        sys_olduname            printargs
 #define        sys_oldolduname         printargs
 
diff --git a/mem.c b/mem.c
index 730761631644e69c4061f7897da3fa0ad7722356..ed0599dc92955b03595b0309c04335bc5ecf60b1 100644 (file)
--- a/mem.c
+++ b/mem.c
@@ -38,7 +38,7 @@
 #endif
 
 #if defined(LINUX) && defined(__i386__)
-#include <asm/ldt.h>
+#include <linux/ldt.h>
 #endif
 
 int