Author: bdrewery
Date: Sat Oct  3 18:57:15 2015
New Revision: 288625
URL: https://svnweb.freebsd.org/changeset/base/288625

Log:
  Add decoding for struct statfs.
  
  Reviewed by:  jhb (briefly)

Modified:
  head/usr.bin/truss/syscall.h
  head/usr.bin/truss/syscalls.c

Modified: head/usr.bin/truss/syscall.h
==============================================================================
--- head/usr.bin/truss/syscall.h        Sat Oct  3 18:40:27 2015        
(r288624)
+++ head/usr.bin/truss/syscall.h        Sat Oct  3 18:57:15 2015        
(r288625)
@@ -10,6 +10,7 @@
  * BinString -- pointer to an array of chars, printed via strvisx().
  * Ptr -- pointer to some unspecified structure.  Just print as hex for now.
  * Stat -- a pointer to a stat buffer.  Prints a couple fields.
+ * StatFs -- a pointer to a statfs buffer.  Prints a few fields.
  * Ioctl -- an ioctl command.  Woefully limited.
  * Quad -- a double-word value.  e.g., lseek(int, offset_t, int)
  * Signal -- a signal number.  Prints the signal name (SIGxxx)
@@ -38,7 +39,7 @@
 enum Argtype { None = 1, Hex, Octal, Int, LongHex, Name, Ptr, Stat, Ioctl, 
Quad,
        Signal, Sockaddr, StringArray, Timespec, Timeval, Itimerval, Pollfd,
        Fd_set, Sigaction, Fcntl, Mprot, Mmapflags, Whence, Readlinkres,
-       Sigset, Sigprocmask, Kevent, Sockdomain, Socktype, Open,
+       Sigset, Sigprocmask, StatFs, Kevent, Sockdomain, Socktype, Open,
        Fcntlflag, Rusage, BinString, Shutdown, Resource, Rlimit, Timeval2,
        Pathconf, Rforkflags, ExitStatus, Waitoptions, Idtype, Procctl,
        LinuxSockArgs, Umtxop, Atfd, Atflags, Timespec2, Accessmode, Long,

Modified: head/usr.bin/truss/syscalls.c
==============================================================================
--- head/usr.bin/truss/syscalls.c       Sat Oct  3 18:40:27 2015        
(r288624)
+++ head/usr.bin/truss/syscalls.c       Sat Oct  3 18:57:15 2015        
(r288625)
@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/event.h>
 #include <sys/ioccom.h>
 #include <sys/mman.h>
+#include <sys/mount.h>
 #include <sys/procctl.h>
 #include <sys/ptrace.h>
 #include <sys/resource.h>
@@ -182,6 +183,10 @@ static struct syscall syscalls[] = {
                    { Atflags, 3 } } },
        { .name = "stat", .ret_type = 1, .nargs = 2,
          .args = { { Name | IN, 0 }, { Stat | OUT, 1 } } },
+       { .name = "statfs", .ret_type = 1, .nargs = 2,
+         .args = { { Name | IN, 0 }, { StatFs | OUT, 1 } } },
+       { .name = "fstatfs", .ret_type = 1, .nargs = 2,
+         .args = { { Int, 0 }, { StatFs | OUT, 1 } } },
        { .name = "lstat", .ret_type = 1, .nargs = 2,
          .args = { { Name | IN, 0 }, { Stat | OUT, 1 } } },
        { .name = "linux_newstat", .ret_type = 1, .nargs = 2,
@@ -1444,6 +1449,29 @@ print_arg(struct syscall_args *sc, unsig
                }
                break;
        }
+       case StatFs: {
+               unsigned int i;
+               struct statfs buf;
+               if (get_struct(pid, (void *)args[sc->offset], &buf,
+                   sizeof(buf)) != -1) {
+                       char fsid[17];
+
+                       bzero(fsid, sizeof(fsid));
+                       if (buf.f_fsid.val[0] != 0 || buf.f_fsid.val[1] != 0) {
+                               for (i = 0; i < sizeof(buf.f_fsid); i++)
+                                       snprintf(&fsid[i*2],
+                                           sizeof(fsid) - (i*2), "%02x",
+                                           ((u_char *)&buf.f_fsid)[i]);
+                       }
+                       fprintf(fp,
+                           "{ fstypename=%s,mntonname=%s,mntfromname=%s,"
+                           "fsid=%s }", buf.f_fstypename, buf.f_mntonname,
+                           buf.f_mntfromname, fsid);
+               } else
+                       fprintf(fp, "0x%lx", args[sc->offset]);
+               break;
+       }
+
        case Rusage: {
                struct rusage ru;
 
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to