git: sys/kern: Bring in timespec2fattime()/fattime2timespec() from FreeBSD

Tomohiro Kusumi tkusumi at crater.dragonflybsd.org
Wed Sep 25 08:43:25 PDT 2019


commit 64804e6ca80c1307d8c5c9d6b55ad7c6fbb0ee58
Author: Tomohiro Kusumi <kusumi.tomohiro at gmail.com>
Date:   Thu Sep 26 01:20:18 2019 +0900

    sys/kern: Bring in timespec2fattime()/fattime2timespec() from FreeBSD
    
    freebsd/freebsd at e74f0ab1401b205bfe9ee22d26d1800157598185
    freebsd/freebsd at cc74fcabb418a714919dc9abc75e57e47b0a058c
    says
    
    """
        Add two new functions to convert FAT filesystem format timestamps
        to and from struct timespec, to replace the crummy conversion
        function which have been copy&pasted into three different
        filesystems already.
    
        Apart from general crummyness as indicated by code like:
    
                for (year = 1970;; year++) {
                        inc = year & 0x03 ? 365 : 366;
                        if (days < inc)
                                break;
                        days -= inc;
                }
    
        They also contain specialized crummyness which tries to compensate
        for the general crummyness by caching recent conversion results,
        with no regard for locking or consistency.
    
        These replacement functions are smaller, O(1) and handle the Y2.1K
        leap-year correctly.
    
        Ideally, these functions should live in a module of their own,
        which the three offending filesystems would depend on, but the
        size is 877 bytes of code (on i386), so that would be false
        economy.
    """
    
    Note that utc argument is ignored in DragonFly (unused by FAT).

Summary of changes:
 sys/conf/files          |   1 +
 sys/kern/subr_fattime.c | 310 ++++++++++++++++++++++++++++++++++++++++++++++++
 sys/sys/time.h          |   5 +
 3 files changed, 316 insertions(+)
 create mode 100644 sys/kern/subr_fattime.c

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/64804e6ca80c1307d8c5c9d6b55ad7c6fbb0ee58


-- 
DragonFly BSD source repository


More information about the Commits mailing list