Deleted Added
full compact
subr_fattime.c (163646) subr_fattime.c (209390)
1/*-
2 * Copyright (c) 2006 Poul-Henning Kamp
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 2006 Poul-Henning Kamp
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/sys/kern/subr_fattime.c 163646 2006-10-24 10:27:23Z phk $
26 * $FreeBSD: head/sys/kern/subr_fattime.c 209390 2010-06-21 09:55:56Z ed $
27 *
28 * Convert MS-DOS FAT format timestamps to and from unix timespecs
29 *
30 * FAT filestamps originally consisted of two 16 bit integers, encoded like
31 * this:
32 *
33 * yyyyyyymmmmddddd (year - 1980, month, day)
34 *

--- 95 unchanged lines hidden (view full) ---

130 { MAY + 3 * YEAR + 1, ENC(3, 6) }, { JUN + 3 * YEAR + 1, ENC(3, 7) },
131 { JUL + 3 * YEAR + 1, ENC(3, 8) }, { AUG + 3 * YEAR + 1, ENC(3, 9) },
132 { SEP + 3 * YEAR + 1, ENC(3, 10) }, { OCT + 3 * YEAR + 1, ENC(3, 11) },
133 { NOV + 3 * YEAR + 1, ENC(3, 12) }
134};
135
136
137void
27 *
28 * Convert MS-DOS FAT format timestamps to and from unix timespecs
29 *
30 * FAT filestamps originally consisted of two 16 bit integers, encoded like
31 * this:
32 *
33 * yyyyyyymmmmddddd (year - 1980, month, day)
34 *

--- 95 unchanged lines hidden (view full) ---

130 { MAY + 3 * YEAR + 1, ENC(3, 6) }, { JUN + 3 * YEAR + 1, ENC(3, 7) },
131 { JUL + 3 * YEAR + 1, ENC(3, 8) }, { AUG + 3 * YEAR + 1, ENC(3, 9) },
132 { SEP + 3 * YEAR + 1, ENC(3, 10) }, { OCT + 3 * YEAR + 1, ENC(3, 11) },
133 { NOV + 3 * YEAR + 1, ENC(3, 12) }
134};
135
136
137void
138timespec2fattime(struct timespec *tsp, int utc, u_int16_t *ddp, u_int16_t *dtp, u_int8_t *dhp)
138timespec2fattime(struct timespec *tsp, int utc, uint16_t *ddp, uint16_t *dtp, uint8_t *dhp)
139{
140 time_t t1;
141 unsigned t2, l, m;
142
143 t1 = tsp->tv_sec;
144 if (!utc)
145 t1 -= utc_offset();
146

--- 111 unchanged lines hidden (view full) ---

258
259int
260main(int argc __unused, char **argv __unused)
261{
262 int i;
263 struct timespec ts;
264 struct tm tm;
265 double a;
139{
140 time_t t1;
141 unsigned t2, l, m;
142
143 t1 = tsp->tv_sec;
144 if (!utc)
145 t1 -= utc_offset();
146

--- 111 unchanged lines hidden (view full) ---

258
259int
260main(int argc __unused, char **argv __unused)
261{
262 int i;
263 struct timespec ts;
264 struct tm tm;
265 double a;
266 u_int16_t d, t;
267 u_int8_t p;
266 uint16_t d, t;
267 uint8_t p;
268 char buf[100];
269
270 for (i = 0; i < 10000; i++) {
271 do {
272 ts.tv_sec = random();
273 } while (ts.tv_sec < T1980 * 86400);
274 ts.tv_nsec = random() % 1000000000;
275

--- 32 unchanged lines hidden ---
268 char buf[100];
269
270 for (i = 0; i < 10000; i++) {
271 do {
272 ts.tv_sec = random();
273 } while (ts.tv_sec < T1980 * 86400);
274 ts.tv_nsec = random() % 1000000000;
275

--- 32 unchanged lines hidden ---