whamcloud / rust-libzfs

Bindings to libzfs from rust
MIT License
27 stars 12 forks source link

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

Open mskarbek opened 5 years ago

mskarbek commented 5 years ago

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:

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.

jgrund commented 5 years ago

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.

mskarbek commented 5 years ago

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