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)
Thu, May 16, 7:03 PM
Unknown Object (File)
Mon, May 13, 4:27 AM
Unknown Object (File)
Sat, May 11, 7:58 AM
Unknown Object (File)
Sat, May 11, 2:48 AM
Unknown Object (File)
Tue, May 7, 3:31 AM
Unknown Object (File)
Sun, May 5, 8:54 PM
Unknown Object (File)
Sun, May 5, 8:53 PM
Unknown Object (File)
Sun, Apr 28, 9:25 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.