[jbossnative-commits] JBoss Native SVN: r972 - trunk/sight/native/os/linux.

jbossnative-commits at lists.jboss.org jbossnative-commits at lists.jboss.org
Wed Sep 5 06:08:21 EDT 2007


Author: mladen.turk at jboss.com
Date: 2007-09-05 06:08:21 -0400 (Wed, 05 Sep 2007)
New Revision: 972

Modified:
   trunk/sight/native/os/linux/volume.c
Log:
Linux volume size

Modified: trunk/sight/native/os/linux/volume.c
===================================================================
--- trunk/sight/native/os/linux/volume.c	2007-09-05 09:06:55 UTC (rev 971)
+++ trunk/sight/native/os/linux/volume.c	2007-09-05 10:08:21 UTC (rev 972)
@@ -34,7 +34,7 @@
 
 #include <mntent.h>
 #include <sys/statfs.h>
-#include <sys/vfs.h>
+#include <sys/statvfs.h>
 
 /*
  * Network adapter implementation
@@ -160,7 +160,7 @@
     if (!(e = (volume_enum_t *)sight_calloc(_E,
                                sizeof(volume_enum_t),
                                THROW_FMARK))) {
-        return NULL;
+        return 0;
     }
     return P2J(e);
 }
@@ -195,6 +195,7 @@
                                           jlong handle)
 {
     struct mntent ent;
+    struct statvfs sv;
     char buf[SIGHT_MBUFFER_SIZ];
     volume_enum_t *e = J2P(handle, volume_enum_t *);
 
@@ -208,11 +209,19 @@
         SET_IFIELD_S(0002, thiz, ent.mnt_dir);        
         CALL_METHOD1(0000, thiz, sight_get_fs_type(ent.mnt_type));
         
+        if (!statvfs(ent.mnt_dir, &sv)) {
+            SET_IFIELD_I(0004, thiz, sv.f_bsize);
+            SET_IFIELD_J(0005, thiz, sv.f_frsize * sv.f_bavail);
+            SET_IFIELD_J(0006, thiz, sv.f_frsize * sv.f_blocks);
+            SET_IFIELD_J(0007, thiz, sv.f_frsize * sv.f_bfree);
+        }
+        else
+            SET_IFIELD_I(0003, thiz, -1);
         if (strstr(ent.mnt_opts, "ro"))
             flags |= SIGHT_READ_ONLY_VOLUME;
         if (strstr(ent.mnt_opts, "rw"))
             flags |= SIGHT_READ_WRITE_VOLUME;
-
+       
        CALL_METHOD1(0001, thiz, flags);
     }
 }




More information about the jbossnative-commits mailing list