Deleted Added
full compact
subr_fattime.c (302408) subr_fattime.c (331503)
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: stable/11/sys/kern/subr_fattime.c 275985 2014-12-21 05:07:11Z imp $
26 * $FreeBSD: stable/11/sys/kern/subr_fattime.c 331503 2018-03-24 23:01:10Z ian $
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, uint16_t *ddp, uint16_t *dtp, uint8_t *dhp)
138timespec2fattime(const struct timespec *tsp, int utc, uint16_t *ddp,
139 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

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

210 DCOD(NOV, 2, 1), DCOD(DEC, 2, 1), 0, 0,
211 0, DCOD( 0, 3, 1), DCOD(JAN, 3, 1), DCOD(FEB, 3, 1),
212 DCOD(MAR, 3, 1), DCOD(APR, 3, 1), DCOD(MAY, 3, 1), DCOD(JUN, 3, 1),
213 DCOD(JUL, 3, 1), DCOD(AUG, 3, 1), DCOD(SEP, 3, 1), DCOD(OCT, 3, 1),
214 DCOD(NOV, 3, 1), DCOD(DEC, 3, 1), 0, 0
215};
216
217void
140{
141 time_t t1;
142 unsigned t2, l, m;
143
144 t1 = tsp->tv_sec;
145 if (!utc)
146 t1 -= utc_offset();
147

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

211 DCOD(NOV, 2, 1), DCOD(DEC, 2, 1), 0, 0,
212 0, DCOD( 0, 3, 1), DCOD(JAN, 3, 1), DCOD(FEB, 3, 1),
213 DCOD(MAR, 3, 1), DCOD(APR, 3, 1), DCOD(MAY, 3, 1), DCOD(JUN, 3, 1),
214 DCOD(JUL, 3, 1), DCOD(AUG, 3, 1), DCOD(SEP, 3, 1), DCOD(OCT, 3, 1),
215 DCOD(NOV, 3, 1), DCOD(DEC, 3, 1), 0, 0
216};
217
218void
218fattime2timespec(unsigned dd, unsigned dt, unsigned dh, int utc, struct timespec *tsp)
219fattime2timespec(unsigned dd, unsigned dt, unsigned dh, int utc,
220 struct timespec *tsp)
219{
220 unsigned day;
221
222 /* Unpack time fields */
223 tsp->tv_sec = (dt & 0x1f) << 1;
224 tsp->tv_sec += ((dt & 0x7e0) >> 5) * 60;
225 tsp->tv_sec += ((dt & 0xf800) >> 11) * 3600;
226 tsp->tv_sec += dh / 100;

--- 81 unchanged lines hidden ---
221{
222 unsigned day;
223
224 /* Unpack time fields */
225 tsp->tv_sec = (dt & 0x1f) << 1;
226 tsp->tv_sec += ((dt & 0x7e0) >> 5) * 60;
227 tsp->tv_sec += ((dt & 0xf800) >> 11) * 3600;
228 tsp->tv_sec += dh / 100;

--- 81 unchanged lines hidden ---