Skip to content

Please develop a filesystem specification (fsspec) #207

Closed

Description

@bdrung

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:

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: for mode:, etc

Decisions to make:

  • fixed amount of fields (plus additional optional ones) or mostly optional
  • terse or verbose format
  • escaping

Activity

  1. poettering commented on Feb 11, 2026

    @poettering
    Collaborator

    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.

  2. Foxboron commented on Feb 11, 2026

    @Foxboron
    Member

    Would totes use this for mkinitcpio as well. A lot of the execution time currently is the fairly convoluted code to run mkdir and install to ensure things inside the initramfs is consistent. https://gitlab.archlinux.org/archlinux/mkinitcpio/mkinitcpio/-/blob/master/functions?ref_type=heads#L770

    Someone experimented with an mkinitcpio fork using a tool called archivegen for a similar purpose. However it used the tmpfiles.d syntax and not the mtree syntax.

    https://github.com/tlahdekorpi/archivegen

  3. cyphar commented on Feb 11, 2026

    @cyphar
    Contributor

    I worked on go-mtree a fair bit over the years, my only comment that I would suggest only supporting FullTypes because the state-based version (which is the default thing most mtree implementations output) is really quite annoying to parse and somewhat annoying to generate.

    (Also, vis(3) and unvis(3) are really quite ugly quoting formats, but we will need to support them if we want to be mtree(8)-compatible.)

  4. Foxboron commented on Feb 11, 2026

    @Foxboron
    Member

    Could I propose the tmpfiles.d syntax? What do we lack there to support this?

  5. hsiangkao commented on Feb 11, 2026

    @hsiangkao

    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.

    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.)

  6. poettering commented on Apr 22, 2026

    @poettering
    Collaborator

    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.

  7. daandemeyer commented on Apr 22, 2026

    @daandemeyer
    Member

    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

  8. Foxboron commented on Apr 22, 2026

    @Foxboron
    Member

    I'm still of the opinion that the tmpfiles.d syntax can work? We could also define a json structure for that format?

  9. poettering commented on May 10, 2026

    @poettering
    Collaborator

    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.

  10. poettering commented on May 12, 2026

    @poettering
    Collaborator

    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.

  11. Foxboron commented on May 12, 2026

    @Foxboron
    Member

    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.

    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 initramfs generator 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.

    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'll take a look.

    I did opt for JSON for that though. It feal 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...

    /me looks at his pile of shell scripts.

    Right.

  12. poettering commented on May 12, 2026

    @poettering
    Collaborator

    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 initramfs generator 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.

    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.

  13. Foxboron commented on May 12, 2026

    @Foxboron
    Member

    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.

    Ah, right. Then I'm onboard. Supporting a hash is useful for multiple purposes. Yes.

  14. poettering commented on Nov 13, 2026

    @poettering
    Collaborator

    #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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions