~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/isofs/util.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php