VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   32 Branches   54 Tags
b24413180f560 (Greg Kroah-Hartman    2017-11-01 15:07:57 +0100  1) // SPDX-License-Identifier: GPL-2.0
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700  2) /*
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700  3)  *  linux/fs/isofs/util.c
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700  4)  */
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700  5) 
e4a93be6cb281 (Oscar Forner Martinez 2015-01-06 16:54:19 -0800  6) #include <linux/time.h>
94f2f715771d0 (Al Viro               2005-04-25 18:32:12 -0700  7) #include "isofs.h"
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700  8) 
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700  9) /* 
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 10)  * We have to convert from a MM/DD/YY format to the Unix ctime format.
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 11)  * We have to take into account leap years and all of that good stuff.
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 12)  * Unfortunately, the kernel does not have the information on hand to
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 13)  * take into account daylight savings time, but it shouldn't matter.
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 14)  * The time stored should be localtime (with or without DST in effect),
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 15)  * and the timezone offset should hold the offset required to get back
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 16)  * to GMT.  Thus  we should always be correct.
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 17)  */
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 18) 
34be4dbf87fc3 (Arnd Bergmann         2017-10-19 16:47:48 +0200 19) int iso_date(u8 *p, int flag)
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 20) {
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 21) 	int year, month, day, hour, minute, second, tz;
e4a93be6cb281 (Oscar Forner Martinez 2015-01-06 16:54:19 -0800 22) 	int crtime;
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 23) 
e4a93be6cb281 (Oscar Forner Martinez 2015-01-06 16:54:19 -0800 24) 	year = p[0];
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 25) 	month = p[1];
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 26) 	day = p[2];
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 27) 	hour = p[3];
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 28) 	minute = p[4];
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 29) 	second = p[5];
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 30) 	if (flag == 0) tz = p[6]; /* High sierra has no time zone */
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 31) 	else tz = 0;
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 32) 	
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 33) 	if (year < 0) {
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 34) 		crtime = 0;
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 35) 	} else {
e4a93be6cb281 (Oscar Forner Martinez 2015-01-06 16:54:19 -0800 36) 		crtime = mktime64(year+1900, month, day, hour, minute, second);
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 37) 
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 38) 		/* sign extend */
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 39) 		if (tz & 0x80)
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 40) 			tz |= (-1 << 8);
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 41) 		
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 42) 		/* 
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 43) 		 * The timezone offset is unreliable on some disks,
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 44) 		 * so we make a sanity check.  In no case is it ever
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 45) 		 * more than 13 hours from GMT, which is 52*15min.
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 46) 		 * The time is always stored in localtime with the
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 47) 		 * timezone offset being what get added to GMT to
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 48) 		 * get to localtime.  Thus we need to subtract the offset
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 49) 		 * to get to true GMT, which is what we store the time
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 50) 		 * as internally.  On the local system, the user may set
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 51) 		 * their timezone any way they wish, of course, so GMT
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 52) 		 * gets converted back to localtime on the receiving
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 53) 		 * system.
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 54) 		 *
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 55) 		 * NOTE: mkisofs in versions prior to mkisofs-1.10 had
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 56) 		 * the sign wrong on the timezone offset.  This has now
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 57) 		 * been corrected there too, but if you are getting screwy
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 58) 		 * results this may be the explanation.  If enough people
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 59) 		 * complain, a user configuration option could be added
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 60) 		 * to add the timezone offset in with the wrong sign
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 61) 		 * for 'compatibility' with older discs, but I cannot see how
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 62) 		 * it will matter that much.
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 63) 		 *
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 64) 		 * Thanks to kuhlmav@elec.canterbury.ac.nz (Volker Kuhlmann)
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 65) 		 * for pointing out the sign error.
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 66) 		 */
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 67) 		if (-52 <= tz && tz <= 52)
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 68) 			crtime -= tz * 15 * 60;
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 69) 	}
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 70) 	return crtime;
^1da177e4c3f4 (Linus Torvalds        2005-04-16 15:20:36 -0700 71) }