Skip to content

uapi16: more fixes from the 0.1.0 review - #4

Merged
brauner merged 2 commits into
mainfrom
contents-checks
Nov 24, 2026
Merged

brauner merged 2 commits into
mainfrom
contents-checks

Conversation

@brauner

@brauner brauner commented Nov 23, 2026

Copy link
Copy Markdown
Member

Two more fixes for contents objects, on top of #3. Both turned up after
#3 was pushed. 0.1.0 isn't published yet, so they go into it as well,
and it is published from the top once this and #3 are merged.

  • A writer took a contents object whose file is the name of the root
    and wrote "file":"", which a reader refuses. The writer now refuses
    it with the error a reader gives for that record, and set_contents()
    fills in nothing from it.
  • set_contents() still filled in from more than MAX_CONTENTS contents
    objects, although a reader and a writer refuse such an object. Now
    nothing is filled in at all then.

With both, set_contents() agrees with a reader on all 3168800 file
objects of the sweep. For a record a reader takes it gives the object
the reader reads, and for one it refuses it fills in nothing.

Every commit builds and passes clippy and the tests with rustc 1.85 and
the current stable, and for the cross targets, musl and i686.

@brauner
brauner added this pull request to stack #5 November 23, 2026 20:52
Base automatically changed from consistency to main November 23, 2026 21:01
A writer takes a contents object whose file is the name of the root and
writes

    {"contents":[{"file":""}],"name":"x"}

which a reader refuses:

    manifest object 1: contents file reference: name is empty: ''

Every name is one a reader takes for a file but the root's, which is
empty, and ContentsSource::File() can hold it: Name::ROOT,
Name::default() and the parent of a name at the top are all the name of
the root. So refuse such a contents object in ContentsObject::check(),
which checks the values of a contents object as a reader does, with the
error a reader gives for the record. That error moves into
Error::invalid_file_reference() so that the reader and the writer share
it. The message only differs in the name of the object, which a reader
doesn't know yet when it reads the contents objects.

Since the previous commit set_contents() runs ContentsObject::check()
as well, through ContentsObject::check_values(). So it now fills in
nothing from such a contents object either. Before, the file "" with
the original size 5 gave the object the size 5 and the contents object
the encoded size 5, both marked as filled in.

The sweep of the previous commit agrees once it has the name of the
root among its files. Before this change 15718 of its file objects with
one or two contents objects didn't agree with a reader, and the writer
took 9741 objects whose records a reader refuses. Now all of them agree,
and where a reader takes the record nothing changes.

Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
A reader refuses the record of a file object with more than
MAX_CONTENTS contents objects:

    manifest object 1: more than 256 contents entries

and so does a writer. But set_contents() still fills in from them: 257
contents objects with the file "a" and the original size 5 give each of
them the encoded size 5 and the object the size 5, all marked as filled
in. With 256 of them a reader takes the record, and set_contents() gives
the object the reader reads.

Nothing follows from contents objects a reader doesn't take. So with
more than MAX_CONTENTS of them set_contents() fills in nothing at all,
neither for the object nor for any of them, and doesn't check them
either.

Of the 3168800 file objects of the sweep, 4000 have 256 or 257 contents
objects. Before this change 42 of them didn't agree with a reader. Now
none of the file objects of the sweep disagrees, and where a reader
takes the record nothing changes.

Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
@brauner
brauner merged commit f3fc6f3 into main Nov 24, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant