mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-11-01 00:48:50 +00:00
f14fc0ccee
Pull quota, ext2, isofs and udf fixes from Jan Kara: - two small quota error handling fixes - two isofs fixes for architectures with signed char - several udf block number overflow and signedness fixes - ext2 rework of mount option handling to avoid GFP_KERNEL allocation with spinlock held - ... it also contains a patch to implement auditing of responses to fanotify permission events. That should have been in the fanotify pull request but I mistakenly merged that patch into a wrong branch and noticed only now at which point I don't think it's worth rebasing and redoing. * 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs: quota: be aware of error from dquot_initialize quota: fix potential infinite loop isofs: use unsigned char types consistently isofs: fix timestamps beyond 2027 udf: Fix some sign-conversion warnings udf: Fix signed/unsigned format specifiers udf: Fix 64-bit sign extension issues affecting blocks > 0x7FFFFFFF udf: Remove some outdate references from documentation udf: Avoid overflow when session starts at large offset ext2: Fix possible sleep in atomic during mount option parsing ext2: Parse mount options into a dedicated structure audit: Record fanotify access control decisions
71 lines
2.2 KiB
C
71 lines
2.2 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* linux/fs/isofs/util.c
|
|
*/
|
|
|
|
#include <linux/time.h>
|
|
#include "isofs.h"
|
|
|
|
/*
|
|
* We have to convert from a MM/DD/YY format to the Unix ctime format.
|
|
* We have to take into account leap years and all of that good stuff.
|
|
* Unfortunately, the kernel does not have the information on hand to
|
|
* take into account daylight savings time, but it shouldn't matter.
|
|
* The time stored should be localtime (with or without DST in effect),
|
|
* and the timezone offset should hold the offset required to get back
|
|
* to GMT. Thus we should always be correct.
|
|
*/
|
|
|
|
int iso_date(u8 *p, int flag)
|
|
{
|
|
int year, month, day, hour, minute, second, tz;
|
|
int crtime;
|
|
|
|
year = p[0];
|
|
month = p[1];
|
|
day = p[2];
|
|
hour = p[3];
|
|
minute = p[4];
|
|
second = p[5];
|
|
if (flag == 0) tz = p[6]; /* High sierra has no time zone */
|
|
else tz = 0;
|
|
|
|
if (year < 0) {
|
|
crtime = 0;
|
|
} else {
|
|
crtime = mktime64(year+1900, month, day, hour, minute, second);
|
|
|
|
/* sign extend */
|
|
if (tz & 0x80)
|
|
tz |= (-1 << 8);
|
|
|
|
/*
|
|
* The timezone offset is unreliable on some disks,
|
|
* so we make a sanity check. In no case is it ever
|
|
* more than 13 hours from GMT, which is 52*15min.
|
|
* The time is always stored in localtime with the
|
|
* timezone offset being what get added to GMT to
|
|
* get to localtime. Thus we need to subtract the offset
|
|
* to get to true GMT, which is what we store the time
|
|
* as internally. On the local system, the user may set
|
|
* their timezone any way they wish, of course, so GMT
|
|
* gets converted back to localtime on the receiving
|
|
* system.
|
|
*
|
|
* NOTE: mkisofs in versions prior to mkisofs-1.10 had
|
|
* the sign wrong on the timezone offset. This has now
|
|
* been corrected there too, but if you are getting screwy
|
|
* results this may be the explanation. If enough people
|
|
* complain, a user configuration option could be added
|
|
* to add the timezone offset in with the wrong sign
|
|
* for 'compatibility' with older discs, but I cannot see how
|
|
* it will matter that much.
|
|
*
|
|
* Thanks to kuhlmav@elec.canterbury.ac.nz (Volker Kuhlmann)
|
|
* for pointing out the sign error.
|
|
*/
|
|
if (-52 <= tz && tz <= 52)
|
|
crtime -= tz * 15 * 60;
|
|
}
|
|
return crtime;
|
|
}
|