---
name: "OpenBSD::Mtree"
section: "3p"
platform: "openbsd"
package: "man"
version: "8.0-current-20261101"
release: "OpenBSD 8.0-current (2026-11-01)"
platforms: ["openbsd"]
url: "https://new.carta.tech/OpenBSD::Mtree"
---

# OpenBSD::Mtree(3p)

simple "mtree(8)" spec parser

## NAME

OpenBSD::Mtree - simple "[mtree(8)](/mtree/8.md)" spec parser

## SYNOPSIS

```
    use OpenBSD::Mtree;
    my %hier;
    OpenBSD::Mtree::parse(\%hier, "/", "/etc/mtree/4.4BSD.dist", $extra);
```

## DESCRIPTION

`"OpenBSD::Mtree"` is a parser for `mtree(8)` specifications that can reconstruct directory hierarchies.

The basic function `"OpenBSD::Mtree::parse_fh(\%hash, $basedir, $fh, $extra)"` will populate the hash `$hash` with defined entries for each directory seen while reading from `$fh`, assuming the specification is to be interpreted relative to `$basedir` (some canonicalization of directory names will occur).

If `$extra` is non null, each entry will itself be an empty hash.

`"OpenBSD::Mtree:parse(\%hash, $basedir, $filename, $extra)"` is a convenience function which also handles opening the filehandle from `$filename` and closing it after reading the specification.
