aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/clock.h
diff options
context:
space:
mode:
authorPoul-Henning Kamp <phk@FreeBSD.org>2006-10-22 18:19:08 +0000
committerPoul-Henning Kamp <phk@FreeBSD.org>2006-10-22 18:19:08 +0000
commitb39be1b35ced251ca5f39addb70d3c28e6fd2d54 (patch)
tree0f4a309eda4fb9acf94037357f9d13df379af6c7 /sys/sys/clock.h
parentecbbc8eeb2a4468fccc4662694ea56369fdee3c6 (diff)
downloadsrc-b39be1b35ced251ca5f39addb70d3c28e6fd2d54.tar.gz
src-b39be1b35ced251ca5f39addb70d3c28e6fd2d54.zip
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.
Notes
Notes: svn path=/head/; revision=163611
Diffstat (limited to 'sys/sys/clock.h')
-rw-r--r--sys/sys/clock.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/sys/sys/clock.h b/sys/sys/clock.h
index 072328d9503f..5c0252dfcc43 100644
--- a/sys/sys/clock.h
+++ b/sys/sys/clock.h
@@ -93,6 +93,9 @@ void clock_register(device_t, long);
/* Traditional POSIX base year */
#define POSIX_BASE_YEAR 1970
+void timet2fattime(struct timespec *tsp, u_int16_t *ddp, u_int16_t *dtp, u_int8_t *dhp);
+void fattime2timet(unsigned dd, unsigned dt, unsigned dh, struct timespec *tsp);
+
#endif /* _KERNEL */
#endif /* !_SYS_CLOCK_H_ */