# Cd/ls through the directory layer?

**URL:** <https://forums.foundationdb.org/t/cd-ls-through-the-directory-layer/5154>\
**Category:** Using FoundationDB\
**Created:** [December 30, 2025, 9:58pm UTC](https://forums.foundationdb.org/t/cd-ls-through-the-directory-layer/5154 "2025-12-30T21:58:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tkxue](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/tkxue/32/2069_2.png) [@tkxue](https://forums.foundationdb.org/u/tkxue)\
**Post date:** [December 30, 2025, 9:58pm UTC](https://forums.foundationdb.org/t/cd-ls-through-the-directory-layer/5154/1 "2025-12-30T21:58:11Z")

</div>

To be clear: I **do not** want to list all the kv pairs.

Imagine a vfs consisted solely of directories (but no files, no kv pairs) consisting of the DirectoryLayer directories we have defined in fdb.

Is there a way, in the fdbcli (or some other tool) to cd/ls through this vfs ? I just want to be able to cd into sub directories, `cd ..` to parent dir, `ls` to see all sub directories. The goal is to get a gist / high level view of fdb directory layer structure, without looking at any kv pairs.

Thanks!

---

<div class="post-metadata">

**Author:** ![janderland](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/janderland/32/517_2.png) [@janderland](https://forums.foundationdb.org/u/janderland)\
**Post date:** [December 30, 2025, 10:38pm UTC](https://forums.foundationdb.org/t/cd-ls-through-the-directory-layer/5154/2 "2025-12-30T22:38:00Z")

</div>

It’s a bit cumbersome in it’s current form, but you can use [FQL](https://github.com/janderland/fql) (my query language) to do this. Currently, I doesn’t have the concept of a “current directory” so you’ll need to query the directories at the root:

```auto
/<>

```

```auto
/users
/tasks
/auth

```

Then you’ll query them at the second layer, etc:

```auto
/users/<>

```

```auto
/user/name
/user/address
/user/bio

```

Let me know what you think. It’s still a work in progress.

---

<div class="post-metadata">

**Author:** ![tkxue](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/tkxue/32/2069_2.png) [@tkxue](https://forums.foundationdb.org/u/tkxue)\
**Post date:** [January 1, 2026, 2:29am UTC](https://forums.foundationdb.org/t/cd-ls-through-the-directory-layer/5154/3 "2026-01-01T02:29:15Z")

</div>

> [@janderland](#):
>
> Let me know what you think. It’s still a work in progress.

> <https://github.com/janderland/fql/blob/main/readme.md>

is one of my favorite pieces of documentation. It shows the command, followed by the crux of the golang impl. I’m going to LLM convert this to Rust, then bind it to Elixir via rustler. 🙂

---

<div class="post-metadata">

**Author:** ![janderland](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/janderland/32/517_2.png) [@janderland](https://forums.foundationdb.org/u/janderland)\
**Post date:** [January 1, 2026, 3:20am UTC](https://forums.foundationdb.org/t/cd-ls-through-the-directory-layer/5154/4 "2026-01-01T03:20:15Z")

</div>

I have plans to port this to rust and integrate with Elixir somehow. Been meaning to write a project in that language, and Rust will be better for connecting it to all programming languages.

---

<div class="post-metadata">

**Author:** ![tkxue](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/tkxue/32/2069_2.png) [@tkxue](https://forums.foundationdb.org/u/tkxue)\
**Post date:** [January 1, 2026, 3:29am UTC](https://forums.foundationdb.org/t/cd-ls-through-the-directory-layer/5154/5 "2026-01-01T03:29:15Z")

</div>

```auto
iex(1)> SFfi.KVDir.ls("") │
│kv_dir_ls: started │
│kv_dir_ls: done │
│path: "" │
│line0 │
│ Timeout │
│:ok │
│iex(2)> SFfi.KVDir.ls("resumee") │
│kv_dir_ls: started │
│kv_dir_ls: done │
│path: "resumee" │
│line0 │
│line1 │
│data: ["doc_to_term", "inv_index", "inv_indx", "ptrs", "term_to_doc", "word_to_doc"] │
│ ["doc_to_term", "inv_index", "inv_indx", "ptrs", "term_to_doc", "word_to_doc"] │
│iex(3)> SFfi.KVDir.ls("") │
│kv_dir_ls: started │
│kv_dir_ls: done │
│path: ""                               

```

I have this very weird situation, where ls(““) hangs, but ls(“resumee”) works fine.  
The fact the latter works means everything is working fine with fdb connection.  
As for the former hanging, I trace it down to this line:

```auto
    async fn ls<'a>(path: String) -> Result<Vec<String>, DirectoryError> {
        print!("path: {:?}\n\r", path);
        let trx: Transaction = G_SFfi_Global.get().unwrap().db.create_trx()?;
        print!("line0\n\r");
        let fdbo_root = KVDir_Obj::new(&trx, &path).await?;
        print!("line1\n\r");
        let data = fdbo_root.obj_root.dir.list(&trx, &[]).await?;
        print!("data: {:?}\n\r", data);
        Ok(data)
    }

```

which boils down to calling create\_or\_open on a empty &[] path.

Is this a known issue? That we can not create\_or\_open on “fdb root” ?

---

<div class="post-metadata">

**Author:** ![tkxue](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/tkxue/32/2069_2.png) [@tkxue](https://forums.foundationdb.org/u/tkxue)\
**Post date:** [January 1, 2026, 4:57am UTC](https://forums.foundationdb.org/t/cd-ls-through-the-directory-layer/5154/6 "2026-01-01T04:57:03Z")

</div>

just got ls/rm working

---

<div class="post-metadata">

**Author:** ![janderland](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/janderland/32/517_2.png) [@janderland](https://forums.foundationdb.org/u/janderland)\
**Post date:** [January 1, 2026, 7:16pm UTC](https://forums.foundationdb.org/t/cd-ls-through-the-directory-layer/5154/7 "2026-01-01T19:16:55Z")

</div>

> [@tkxue](#):
>
> That we can not create\_or\_open on “fdb root” ?

I have never tried to open an empty dir. If there is a bug it would be in the Rust bindings. FDB doesn’t have any knowledge of directories. It only sees the key-value byte strings.
