rust-libzfs icon indicating copy to clipboard operation
rust-libzfs copied to clipboard

ZPool.datasets() doesn't list all available datasets

Open mskarbek opened this issue 7 years ago • 2 comments

Quite possibly I don't understand something, I have just begun my Rust adventure ;) and right away started playing with libraries that are touching filesystems but this seems to be straightforward yet does not work as I imagine it should.

Simple code:

extern crate libzfs;

use libzfs::{Libzfs};

fn main() {
    let mut libzfs = Libzfs::new();
    let pools = libzfs.get_imported_pools().unwrap();
    for pool in pools {
        let datasets = pool.datasets().unwrap();
        for dataset in datasets {
            println!("{:?}", dataset.name());
        }
    }
}

Result:

"d1226526151549b6a14a18c6217f17bf/home"
"d1226526151549b6a14a18c6217f17bf/var"

Expected:

"d1226526151549b6a14a18c6217f17bf"
"d1226526151549b6a14a18c6217f17bf/home"
"d1226526151549b6a14a18c6217f17bf/home/core"
"d1226526151549b6a14a18c6217f17bf/var"
"d1226526151549b6a14a18c6217f17bf/var/lib"
"d1226526151549b6a14a18c6217f17bf/var/lib/containers"
"d1226526151549b6a14a18c6217f17bf/var/lib/containers/83abdad1a6e9eae57f0ce0eb803b21bc9f246196e52716f1ea96ec70a6fe7b9e"
"d1226526151549b6a14a18c6217f17bf/var/lib/docker"

Used:

  • zfs: zfs-0.7.11-1.fc28.x86_64
  • libzfs: 0.6.13

Interestingly I am able to access not listed datasets by calling dataset_by_name() for example libzfs.dataset_by_name("d1226526151549b6a14a18c6217f17bf/home/core").unwrap() works fine and returns correct data.

mskarbek avatar Nov 17 '18 01:11 mskarbek

Hi @mskarbek,

This is a case we haven't needed yet (nested datasets) so we haven't implemented this.

We'd be happy to a take a PR that implements this functionality if you'd like to add it.

jgrund avatar Nov 20 '18 16:11 jgrund

OK, I'll try but as I said I just began playing with Rust. ;)

mskarbek avatar Nov 21 '18 12:11 mskarbek