Page MenuHomeFreeBSD

fusefs: fix invalid value for st_birthtime.tv_nsec
ClosedPublic

Authored by asomers on Jan 25 2024, 3:23 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sep 27 2024, 8:05 AM
Unknown Object (File)
Sep 26 2024, 4:25 AM
Unknown Object (File)
Sep 24 2024, 6:31 AM
Unknown Object (File)
Sep 19 2024, 8:54 PM
Unknown Object (File)
Sep 19 2024, 11:21 AM
Unknown Object (File)
Sep 16 2024, 11:24 AM
Unknown Object (File)
Sep 2 2024, 1:35 PM
Unknown Object (File)
Sep 1 2024, 7:50 PM
Subscribers

Details

Summary

If a file system's on-disk format does not support st_birthtime, it
isn't clear what value it should return in stat(2). Neither our man
page nor the OpenGroup specifies. But our convention for UFS and
msdosfs is to return { .tv_sec = -1, .tv_nsec = 0 }. fusefs is
different. It returns { .tv_sec = -1, .tv_nsec = -1 }. It's done that
ever since the initial import in SVN r241519.

Most software apparently handles this just fine. It must, because we've
had no complaints. But the Rust standard library will panic when
reading such a timestamp during std::fs::metadata, even if the caller
doesn't care about that particular value. That's a separate bug, and
should be fixed.

Change our invalid value to match msdosfs and ufs, pacifying the Rust
standard library.

PR: 276602
MFC after: 1 week
Sponsored by: Axcient

Test Plan

additional assertions added to existing test cases

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

I think this is good but I wonder if we should have a trivial macro/inline for recording an unset/invalid va_birthtime?

I think this is good but I wonder if we should have a trivial macro/inline for recording an unset/invalid va_birthtime?

What would you call it?

@emaste what about something like this?

#define VA_NOTIME(ts) { \
    ts->tv_sec = -1; \
    ts->tv_nsec = 0; \
}

@emaste what about something like this?

#define VA_NOTIME(ts) { \
    ts->tv_sec = -1; \
    ts->tv_nsec = 0; \
}

Seems reasonable to me as a potential followup.

sys/fs/fuse/fuse_internal.c
328

va_gen and va_vaflags not set in the block below, comparing with vattr_null?

This revision is now accepted and ready to land.Feb 4 2024, 7:48 PM
sys/fs/fuse/fuse_internal.c
328

That's because they get set by vop_stdstat, which sets them first and then calls VOP_GETATTR.