zfs
  1. zfs
  2. ZFS-1

zfs_prop_get() implementation.

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: current
    • Fix Version/s: milestone 1
    • Component/s: www
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: Sun

    • Issuezilla Id:
      1

      Description

      I'd like to get the system property method zfs_prop_get() working ... I've tried
      a few things, but no luck, not familiar enough with jna ... Can you take a look
      at this implementing this method in your library ? here's what I've tried:

      in libzfs.java, I changed the definition to:
      int zfs_prop_get(zfs_handle_t handle, int prop, Pointer _4, int cbSize,
      /zprop_source_t */ IntByReference _5, char[] _6, NativeLong _7, boolean _8);

      And have been experimenting with permutations of the following to retrieve a
      user property:

      in main():
      /* arg is the zfs filesystem name */
      for (String arg: args ) {
      LibZFS zfs = new LibZFS();
      ZFSObject fs = zfs.open(arg);
      zfs_handle_t handle = LIBZFS.zfs_open(zfs.getHandle(), arg,
      zfs_type_t.DATASET);

      System.out.println("Request system prop");
      Memory propbuf = new Memory(libzfs.ZFS_MAXPROPLEN);
      String propstr = null;
      char[] buf = null;
      IntByReference ibr = null;
      for (int i=0; i < 20; i++) {
      int ret = LIBZFS.zfs_prop_get(handle, i, propbuf,
      libzfs.ZFS_MAXPROPLEN, ibr, buf, new NativeLong(0), true);
      if ( ret != 0 )

      { propstr = "-"; }

      else

      { propstr = String.valueOf(propbuf.getCharArray(0,libzfs.ZFS_MAXPROPLEN)); }

      System.out.println(i+" = "+propstr);

      Do you have any suggestions ?

      Thanks,
      Jay

        Activity

        Hide
        nhoj_p added a comment -

        Jay,

        Can you see if the unit test output at the bottom display the type of
        information that you where after?

        I've update the unit test 'testGetZfsProperties' which produced this output.

        John

        Code Snippet:

        // Create list of all properties
        List<zfs_prop_t> props = new ArrayList<zfs_prop_t>();
        for (zfs_prop_t prop : EnumSet.allOf(zfs_prop_t.class))

        { props.add(prop); }

        LibZFS zfs = new LibZFS();

        // Iterate over all root zfs pools and display their zfs properties
        for (ZFSPool pool : zfs.roots()) {
        System.out.println("pool :" + pool.getName());
        Hashtable<zfs_prop_t, String> zfsPoolProps = pool.getZfsProperty(props);
        for (zfs_prop_t prop : zfsPoolProps.keySet())

        { System.out.println("zfs_prop_t " + prop + "(" + prop.ordinal() + ") = " + zfsPoolProps.get(prop)); }

        }

        // Open specific zfs pool and display its zfs properties
        ZFSObject o = zfs.open("rpool/kohsuke");
        System.out.println("pool :" + o.getName());
        Hashtable<zfs_prop_t, String> zfsPoolProps = o.getZfsProperty(props);
        for (zfs_prop_t prop : zfsPoolProps.keySet())

        { System.out.println("zfs_prop_t " + prop + "(" + prop.ordinal() + ") = " + zfsPoolProps.get(prop)); }

        Outputs:

        pool :rpool
        zfs_prop_t ZFS_PROP_SNAPDIR(23) = hidden
        zfs_prop_t ZFS_PROP_REFERENCED(4) = 77312
        zfs_prop_t ZFS_PROP_XATTR(31) = on
        zfs_prop_t ZFS_PROP_SHARESMB(40) = off
        zfs_prop_t ZFS_PROP_DEVICES(18) = on
        zfs_prop_t ZFS_PROP_REFRESERVATION(42) = 0
        zfs_prop_t ZFS_PROP_UTF8ONLY(35) = off
        zfs_prop_t ZFS_PROP_ISCSIOPTIONS(30) = -
        zfs_prop_t ZFS_PROP_ORIGIN(7) = -
        zfs_prop_t ZFS_PROP_COMPRESSRATIO(5) = 1.00x
        zfs_prop_t ZFS_PROP_SETUID(20) = on
        zfs_prop_t ZFS_PROP_ACLINHERIT(25) = restricted
        zfs_prop_t ZFS_PROP_VSCAN(38) = off
        zfs_prop_t ZFS_PROP_CASE(37) = sensitive
        zfs_prop_t ZFS_PROP_CANMOUNT(28) = on
        zfs_prop_t ZFS_PROP_NAME(27) = rpool
        zfs_prop_t ZFS_PROP_COPIES(33) = 1
        zfs_prop_t ZFS_PROP_SHARENFS(14) = off
        zfs_prop_t ZFS_PROP_CHECKSUM(15) = on
        zfs_prop_t ZFS_PROP_USED(2) = 9396951040
        zfs_prop_t ZFS_PROP_RECORDSIZE(12) = 131072
        zfs_prop_t ZFS_PROP_AVAILABLE(3) = 22576228352
        zfs_prop_t ZFS_PROP_ATIME(17) = on
        zfs_prop_t ZFS_PROP_ZONED(22) = off
        zfs_prop_t ZFS_PROP_TYPE(0) = filesystem
        zfs_prop_t ZFS_PROP_NORMALIZE(36) = none
        zfs_prop_t ZFS_PROP_QUOTA(8) = 0
        zfs_prop_t ZFS_PROP_MOUNTPOINT(13) = /rpool
        zfs_prop_t ZFS_PROP_VOLSIZE(10) = -
        zfs_prop_t ZFS_PROP_VOLBLOCKSIZE(11) = -
        zfs_prop_t ZFS_PROP_MOUNTED(6) = yes
        zfs_prop_t ZFS_PROP_CREATION(1) = 1230371419
        zfs_prop_t ZFS_PROP_SHAREISCSI(29) = off
        zfs_prop_t ZFS_PROP_CREATETXG(26) = 1
        zfs_prop_t ZFS_PROP_COMPRESSION(16) = off
        zfs_prop_t ZFS_PROP_REFQUOTA(41) = 0
        zfs_prop_t ZFS_PROP_NUMCLONES(32) = -
        zfs_prop_t ZFS_PROP_VERSION(34) = 3
        zfs_prop_t ZFS_PROP_ACLMODE(24) = groupmask
        zfs_prop_t ZFS_PROP_EXEC(19) = on
        zfs_prop_t ZFS_NUM_PROPS(43) = 17907303855270970026
        zfs_prop_t ZFS_PROP_NBMAND(39) = off
        zfs_prop_t ZFS_PROP_READONLY(21) = off
        zfs_prop_t ZFS_PROP_RESERVATION(9) = 0
        pool :rpool/kohsuke
        zfs_prop_t ZFS_PROP_SNAPDIR(23) = hidden
        zfs_prop_t ZFS_PROP_REFERENCED(4) = 18432
        zfs_prop_t ZFS_PROP_XATTR(31) = on
        zfs_prop_t ZFS_PROP_SHARESMB(40) = off
        zfs_prop_t ZFS_PROP_DEVICES(18) = on
        zfs_prop_t ZFS_PROP_REFRESERVATION(42) = 0
        zfs_prop_t ZFS_PROP_UTF8ONLY(35) = off
        zfs_prop_t ZFS_PROP_ISCSIOPTIONS(30) = -
        zfs_prop_t ZFS_PROP_ORIGIN(7) = -
        zfs_prop_t ZFS_PROP_COMPRESSRATIO(5) = 1.00x
        zfs_prop_t ZFS_PROP_SETUID(20) = on

        Show
        nhoj_p added a comment - Jay, Can you see if the unit test output at the bottom display the type of information that you where after? I've update the unit test 'testGetZfsProperties' which produced this output. John Code Snippet: // Create list of all properties List<zfs_prop_t> props = new ArrayList<zfs_prop_t>(); for (zfs_prop_t prop : EnumSet.allOf(zfs_prop_t.class)) { props.add(prop); } LibZFS zfs = new LibZFS(); // Iterate over all root zfs pools and display their zfs properties for (ZFSPool pool : zfs.roots()) { System.out.println("pool :" + pool.getName()); Hashtable<zfs_prop_t, String> zfsPoolProps = pool.getZfsProperty(props); for (zfs_prop_t prop : zfsPoolProps.keySet()) { System.out.println("zfs_prop_t " + prop + "(" + prop.ordinal() + ") = " + zfsPoolProps.get(prop)); } } // Open specific zfs pool and display its zfs properties ZFSObject o = zfs.open("rpool/kohsuke"); System.out.println("pool :" + o.getName()); Hashtable<zfs_prop_t, String> zfsPoolProps = o.getZfsProperty(props); for (zfs_prop_t prop : zfsPoolProps.keySet()) { System.out.println("zfs_prop_t " + prop + "(" + prop.ordinal() + ") = " + zfsPoolProps.get(prop)); } Outputs: pool :rpool zfs_prop_t ZFS_PROP_SNAPDIR(23) = hidden zfs_prop_t ZFS_PROP_REFERENCED(4) = 77312 zfs_prop_t ZFS_PROP_XATTR(31) = on zfs_prop_t ZFS_PROP_SHARESMB(40) = off zfs_prop_t ZFS_PROP_DEVICES(18) = on zfs_prop_t ZFS_PROP_REFRESERVATION(42) = 0 zfs_prop_t ZFS_PROP_UTF8ONLY(35) = off zfs_prop_t ZFS_PROP_ISCSIOPTIONS(30) = - zfs_prop_t ZFS_PROP_ORIGIN(7) = - zfs_prop_t ZFS_PROP_COMPRESSRATIO(5) = 1.00x zfs_prop_t ZFS_PROP_SETUID(20) = on zfs_prop_t ZFS_PROP_ACLINHERIT(25) = restricted zfs_prop_t ZFS_PROP_VSCAN(38) = off zfs_prop_t ZFS_PROP_CASE(37) = sensitive zfs_prop_t ZFS_PROP_CANMOUNT(28) = on zfs_prop_t ZFS_PROP_NAME(27) = rpool zfs_prop_t ZFS_PROP_COPIES(33) = 1 zfs_prop_t ZFS_PROP_SHARENFS(14) = off zfs_prop_t ZFS_PROP_CHECKSUM(15) = on zfs_prop_t ZFS_PROP_USED(2) = 9396951040 zfs_prop_t ZFS_PROP_RECORDSIZE(12) = 131072 zfs_prop_t ZFS_PROP_AVAILABLE(3) = 22576228352 zfs_prop_t ZFS_PROP_ATIME(17) = on zfs_prop_t ZFS_PROP_ZONED(22) = off zfs_prop_t ZFS_PROP_TYPE(0) = filesystem zfs_prop_t ZFS_PROP_NORMALIZE(36) = none zfs_prop_t ZFS_PROP_QUOTA(8) = 0 zfs_prop_t ZFS_PROP_MOUNTPOINT(13) = /rpool zfs_prop_t ZFS_PROP_VOLSIZE(10) = - zfs_prop_t ZFS_PROP_VOLBLOCKSIZE(11) = - zfs_prop_t ZFS_PROP_MOUNTED(6) = yes zfs_prop_t ZFS_PROP_CREATION(1) = 1230371419 zfs_prop_t ZFS_PROP_SHAREISCSI(29) = off zfs_prop_t ZFS_PROP_CREATETXG(26) = 1 zfs_prop_t ZFS_PROP_COMPRESSION(16) = off zfs_prop_t ZFS_PROP_REFQUOTA(41) = 0 zfs_prop_t ZFS_PROP_NUMCLONES(32) = - zfs_prop_t ZFS_PROP_VERSION(34) = 3 zfs_prop_t ZFS_PROP_ACLMODE(24) = groupmask zfs_prop_t ZFS_PROP_EXEC(19) = on zfs_prop_t ZFS_NUM_PROPS(43) = 17907303855270970026 zfs_prop_t ZFS_PROP_NBMAND(39) = off zfs_prop_t ZFS_PROP_READONLY(21) = off zfs_prop_t ZFS_PROP_RESERVATION(9) = 0 pool :rpool/kohsuke zfs_prop_t ZFS_PROP_SNAPDIR(23) = hidden zfs_prop_t ZFS_PROP_REFERENCED(4) = 18432 zfs_prop_t ZFS_PROP_XATTR(31) = on zfs_prop_t ZFS_PROP_SHARESMB(40) = off zfs_prop_t ZFS_PROP_DEVICES(18) = on zfs_prop_t ZFS_PROP_REFRESERVATION(42) = 0 zfs_prop_t ZFS_PROP_UTF8ONLY(35) = off zfs_prop_t ZFS_PROP_ISCSIOPTIONS(30) = - zfs_prop_t ZFS_PROP_ORIGIN(7) = - zfs_prop_t ZFS_PROP_COMPRESSRATIO(5) = 1.00x zfs_prop_t ZFS_PROP_SETUID(20) = on

          People

          • Assignee:
            zfs-issues
            Reporter:
            jd22761
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: