Commits

tludewig committed b21b577

user quota human readable support added

Comments (0)

Files changed (3)

libzfs/src/main/java/org/jvnet/solaris/libzfs/ZFSFileSystem.java

  */
 package org.jvnet.solaris.libzfs;
 
+import com.sun.jna.Memory;
 import com.sun.jna.ptr.LongByReference;
+import java.io.File;
+import org.jvnet.solaris.libzfs.jna.libzfs;
 import static org.jvnet.solaris.libzfs.jna.libzfs.LIBZFS;
-
-import java.io.File;
-
 import org.jvnet.solaris.libzfs.jna.zfs_handle_t;
 import org.jvnet.solaris.libzfs.jna.zfs_prop_t;
 import org.jvnet.solaris.mount.MountFlags;
       return r.getValue();
     }
 
+    public String getUserQuota( String userId, boolean literal )
+    {
+      String value = null;
+      Memory propbuf = new Memory(libzfs.ZFS_MAXPROPLEN);
+      int ret = LIBZFS.zfs_prop_get_userquota(handle, "userquota@" + userId, propbuf, libzfs.ZFS_MAXPROPLEN, literal );
+      if ( ret == 0 )
+      {
+        value = propbuf.getString(0);
+      }
+      return value;
+    }
+
     public long getUserUsed( String userId )
     {
       LongByReference r = new LongByReference();
       return r.getValue();
     }
 
+    public String getUserUsed( String userId, boolean literal )
+    {
+      String value = null;
+      Memory propbuf = new Memory(libzfs.ZFS_MAXPROPLEN);
+      int ret = LIBZFS.zfs_prop_get_userquota(handle, "userused@" + userId, propbuf, libzfs.ZFS_MAXPROPLEN, literal );
+      if ( ret == 0 )
+      {
+        value = propbuf.getString(0);
+      }
+      return value;
+    }
+
     public void setUserQuota( String userId, String quota )
     {
       setProperty("userquota@" + userId, quota );  

libzfs/src/main/java/org/jvnet/solaris/libzfs/jna/libzfs.java

 int zfs_prop_get_numeric(zfs_handle_t handle, zfs_prop_t prop, LongByReference r,
     /*zprop_source_t* */ IntByReference _4, char[] _5, NativeLong _6);
 long zfs_prop_get_int(zfs_handle_t handle, zfs_prop_t prop);
+
+int zfs_prop_get_userquota(zfs_handle_t handle, String propertyName, Pointer buf, long len, boolean literal );
 long zfs_prop_get_userquota_int(zfs_handle_t handle, String propertyName, LongByReference r);
+
 int zfs_prop_inherit(zfs_handle_t handle, String _2);
 String zfs_prop_values(zfs_prop_t prop);
 int zfs_prop_is_string(zfs_prop_t prop);

libzfs/src/test/java/org/jvnet/solaris/libzfs/UserQuotaTest.java

       
       System.out.println( zFileSystem.getUserQuota(TEST_USER));
       System.out.println( zFileSystem.getUserUsed(TEST_USER));
+      System.out.println( zFileSystem.getUserQuota(TEST_USER,true));
+      System.out.println( zFileSystem.getUserUsed(TEST_USER,true));
     }
 
 }