Repository navigation
Description
There are multiple tools (like cpio, 3cpio, tar, mksquashfs, etc.) that create a filesystem archive. Many of those tools can take a directory or tarball is input. User (like dracut and initramfs-tools) create the content of the archive in a temporary directory and then call the archive tool. This step could be avoided if the archive tools would support a way to specify the content and map filenames. Sadly every tool supports a different way to (partially) do that:
3cpiosupports a manifest file: https://github.com/bdrung/3cpio/blob/main/man/3cpio.1.adoc#manifestgensquashfs(from squashfs-tools-ng) support a pack file: https://manpages.debian.org/trixie/squashfs-tools-ng/gensquashfs.1.en.html#PACK_FILE_FORMATmkfshas a special proto format: https://www.unix.com/man-page/v7/1M/mkfsmkprotohas prototype files: https://www.ibm.com/docs/en/aix/7.3.0?topic=m-mkproto-commandmksquashfs(from squashfs-tools >= 4.5) support a pseudo file: https://manpages.debian.org/unstable/squashfs-tools/mksquashfs.1.en.html#PSEUDO_FILE_DEFINITION_FORMATtarhas--transform- The Linux kernel has
gen_init_cpio: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/usr/gen_init_cpio.c#n570
Can we agree on a specification that would satisfy all those tools and use UAPI for publishing such spec? Some discussion has started in erofs/erofs-utils#37 already. I am the author of 3cpio and would love to switch to a common format.
From looking at the existing formats, I propose following properties:
- text file (probably UTF-8)
- line based (one line per file) (no JSON or such)
- allows comments (e.g. starting with #)
- bonus point: extensible
- bonus point: constructable with
find . | sed '$simplerule'
One possible format
#fsspec v1
# First line is a filesystem specification marker (needed for detection and highlighting)
# comments start with #
<filename> f [mode:<mode>] [uid:<uid>] [gid:<gid>] [mtime:<mtime>] [size:<filesize>] [source:<souce_filename>]
<filename> d [mode:<mode>] [uid:<uid>] [gid:<gid>] [mtime:<mtime>]
<filename> b <major> <minor> [mode:<mode>] [uid:<uid>] [gid:<gid>] [mtime:<mtime>]
<filename> c <major> <minor> [mode:<mode>] [uid:<uid>] [gid:<gid>] [mtime:<mtime>]
<filename> l <target> [mode:<mode>] [uid:<uid>] [gid:<gid>] [mtime:<mtime>]
<filename> p [mode:<mode>] [uid:<uid>] [gid:<gid>] [mtime:<mtime>]
<filename> s [mode:<mode>] [uid:<uid>] [gid:<gid>] [mtime:<mtime>]
- filename: Path in the archive
- f = file, d = directory, b =block device, c = character device, l = symbolic link, p = pipe/fifo, s = socket
- mode: File mode specified in octal (e.g. 2755)
- uid: User ID (owner) of the file specified in decimal.
- gid: Group ID of the file specified in decimal.
- mtime: Modification time of the file specified as seconds since the Epoch (1970-01-01 00:00 UTC).
- filesize: Size of the input file in bytes.
- major: Major block/character device number in decimal.
- minor: Minor block/character device number in decimal.
- target: Target of the symbolic link.
Rules:
- Tokens are separated by space or tab.
- filename, source_filename, target can be quoted (to include spaces)
Example 1:
. d mode:755 uid:0 gid:0 mtime:1754575213
bin l usr/bin mode:755 uid:0 gid:0 mtime:1647786132
etc d mode:755 uid:0 gid:0 mtime:1754575213
etc/passwd f mode:644 source:/etc/passwd uid:0 gid:0
dev d mode:755 uid:0 gid:0 mtime:1754575213
dev/console c 5 1 mode:644 uid:0 gid:0
Example 2:
. d mode:755 uid:0 gid:0
bin l usr/bin
etc d
etc/passwd f mode:644 source:/etc/passwd
dev d
dev/console c 5 1 mode:644 uid:0 gid:0
Alternatives:
- the marker could be made shorter
m:formode:, etc
Decisions to make:
- fixed amount of fields (plus additional optional ones) or mostly optional
- terse or verbose format
- escaping
Activity
hsiangkao commentedon Feb 11, 2026
https://man.freebsd.org/cgi/man.cgi?query=mtree&apropos=0&sektion=1&manpath=4.3BSD+Reno
https://man.freebsd.org/cgi/man.cgi?query=mtree&apropos=0&sektion=5&manpath=FreeBSD+15.0-RELEASE
https://github.com/vbatts/go-mtree
https://man.minix3.org/cgi-bin/man.cgi?query=mkfs&apropos=0&sektion=0&manpath=Minix+3.1.5&arch=default&format=html
https://man7.org/linux/man-pages/man8/xfs_protofile.8.html
cgwalters commentedon Feb 11, 2026
Also in this space: https://github.com/composefs/composefs/blob/main/man/composefs-dump.md
poettering commentedon Feb 11, 2026
What about just using bsd's mtree format? It's quite ok, already established, easy to parse and extensible.
https://man.freebsd.org/cgi/man.cgi?mtree(5)
We could certainly put a linux-focussed spec derived from that here, that adds a couple of fields that linux knows and bsd doesnt.
poettering commentedon Feb 11, 2026
we could pick up fields from here:
https://github.com/vbatts/go-mtree
and from here:
https://github.com/systemd/casync/blob/main/src/casync-tool.c#L1822
Foxboron commentedon Feb 11, 2026
Would totes use this for
mkinitcpioas well. A lot of the execution time currently is the fairly convoluted code to runmkdirandinstallto ensure things inside the initramfs is consistent. https://gitlab.archlinux.org/archlinux/mkinitcpio/mkinitcpio/-/blob/master/functions?ref_type=heads#L770Someone experimented with an
mkinitcpiofork using a tool calledarchivegenfor a similar purpose. However it used thetmpfiles.dsyntax and not themtreesyntax.https://github.com/tlahdekorpi/archivegen
cyphar commentedon Feb 11, 2026
I worked on
go-mtreea fair bit over the years, my only comment that I would suggest only supportingFullTypes because the state-based version (which is the default thing mostmtreeimplementations output) is really quite annoying to parse and somewhat annoying to generate.(Also,
vis(3)andunvis(3)are really quite ugly quoting formats, but we will need to support them if we want to bemtree(8)-compatible.)Foxboron commentedon Feb 11, 2026
Could I propose the
tmpfiles.dsyntax? What do we lack there to support this?hsiangkao commentedon Feb 11, 2026
It doesn't matter as long as the manifest formats have common audience and well-defined then either mtree or proto sounds good to me,
but it is just another code-monkey work, so I have to seek extra time working on this (maybe just reusing some BSD code as the start since it's license-friendly.)
poettering commentedon Apr 22, 2026
I started working on a manifest spec in #213. It has a different usecase than what is requested here though: it focuses on listing files in a way they can easily be downloaded.
We can probably build on that though, and make the spec from #213 also work for the usecase of #207. That all said, note that the proposed spec is JSON, because it's 2026.
daandemeyer commentedon Apr 22, 2026
Not sure JSON would be ideal since a bunch of tools were this would be used are old bespoke C tooling without access to a JSON impl without adding a new dep. But like you said, it's also 2026.
tmpfiles syntax would still do the trick as well though
Foxboron commentedon Apr 22, 2026
I'm still of the opinion that the
tmpfiles.dsyntax can work? We could also define a json structure for that format?poettering commentedon May 10, 2026
i am not convinced tmpfiles.d is the right answer to this problem. i.e a sensible manifest should include secure hashes of the files in a tree, and i don't really think that we could could reasonably shoehorn that into tmpfiles.d.
poettering commentedon May 12, 2026
btw i reworked #213 now so that it should also be able to address this usecase. Would be great if you could have a look and comment there!
I did opt for JSON for that though. It fealt really wrong to me to use a non-JSON format in 2026. JSON is kinda ubiquitous even in the C world these days (look at util-linux for example), I am not convinced that it really makes sense for a new spec to cater too much for what I'd call a legacy model of thinking there...
The spec i put together in #213 should be good enough to even for hardlinks, so you could even create a reasonable manifest for stuff such as ostree.
Foxboron commentedon May 12, 2026
I'm not completely sure if I'm onboard with the fact that it needs hashes. You are describing the layout of the files, and with an
initramfsgenerator you do not really care about the hashes of the files as this is just an intermediate step to assembling the archive. You are hashing the archive at the end anyway.I'll take a look.
/me looks at his pile of shell scripts.
Right.
poettering commentedon May 12, 2026
oh, i am absolutely sure that for some usecases hashes are not useful, but I am pretty sure the format should support them because for many other usecases this is extremely relevant. It's a matter of devising something here that only works one a single usecase vs. something that works for four or five similar ones.
I added a generator for the manifest to systemd in systemd/systemd#41990 – and there i also made the hash generation optional, just to prove the point that I also think you might not need it for all cases. but for the cases you do need it for i think it matters a lot.
Foxboron commentedon May 12, 2026
Ah, right. Then I'm onboard. Supporting a hash is useful for multiple purposes. Yes.
poettering commentedon Nov 13, 2026
#213 has been merged btw, I think we can close this. It's – as mentioned – JSON based, but I am very very sure it should be, see above. Closing.