Commit 0dbabf61 authored by Ben Avison's avatar Ben Avison
Browse files

Fixed timestamping

Detail:
  Renamed function "localTIME" to "get_RISCOS_TIME" since it has nothing to do
  with local time. This function used to call the C library function
  localtime(), but until recently the C library was non-conformant to the
  C standard, and simply produced a year/month/day/hour/minute/second breakdown
  as UTC. When this was fixed (RISC_OSLib 5.68) it changed DOSFS's behaviour;
  it was first detected because the reverse operation is implemented locally
  within DOSFS, so a read-modify-write of file attributes leads to the
  modification time being skewed by an amount equal to the difference between
  UTC and local time. Arguments can be made either to treat the on-disc time as
  local time (for compatibility with Windows and Mac OS) or as UTC (for
  compatibility with Linux or older RISC OS systems); I have opted to return
  behaviour to UTC. Also placed a lower limit on dates of the earliest date
  supported by FAT (1980), so for example if your system clock is set to 1970,
  as it will be if there is no RTC and NetTime is not operational, then you
  don't end up creating dates in the far future due to underflow.
Admin:
  Tested on a beagleboard

Version 0.90. Tagged as 'DOSFS-0_90'
parent 438c1b47
/* (0.89)
/* (0.90)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 0.89
#define Module_MajorVersion_CMHG 0.90
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 14 Apr 2012
#define Module_Date_CMHG 10 Jun 2012
#define Module_MajorVersion "0.89"
#define Module_Version 89
#define Module_MajorVersion "0.90"
#define Module_Version 90
#define Module_MinorVersion ""
#define Module_Date "14 Apr 2012"
#define Module_Date "10 Jun 2012"
#define Module_ApplicationDate "14-Apr-12"
#define Module_ApplicationDate "10-Jun-12"
#define Module_ComponentName "DOSFS"
#define Module_ComponentPath "castle/RiscOS/Sources/FileSys/ImageFS/DOSFS"
#define Module_FullVersion "0.89"
#define Module_HelpVersion "0.89 (14 Apr 2012)"
#define Module_LibraryVersionInfo "0:89"
#define Module_FullVersion "0.90"
#define Module_HelpVersion "0.90 (10 Jun 2012)"
#define Module_LibraryVersionInfo "0:90"
......@@ -805,7 +805,7 @@ static _kernel_oserror *FSSWI_LayoutStructure(_kernel_swi_regs *rset,void *priva
DOS_direntry *dentry = (DOS_direntry *)sector ;
time5byte formTIME ;
localTIME(&formTIME) ;
get_RISCOS_TIME(&formTIME) ;
/* place the default disc name into the first slot */
put_FILE_time(dentry->FILE_time,dentry->FILE_timeHI,RISCOStoTIME(&formTIME)) ;
......
......@@ -1858,7 +1858,7 @@ static int saveFILE(char *fname,char *leafname,word ld,word ex,char *bs,word len
if ((int)len < 0)
return_error0(int, err_discfull);
localTIME(&saveTIME) ;
get_RISCOS_TIME(&saveTIME) ;
dprintf(("","saveFILE: \"%s\" len &%08X (*cdir = &%08X)\n",leafname,len,(int)(*cdir)));
......@@ -4698,7 +4698,7 @@ int DOSFS_namedisc(char *newname,DOSdisc *ihand)
/* mark the directory entry as a "volume" */
dentry->FILE_attribute = (FILE_volume | FILE_archive) ;
localTIME(&nameTIME) ;
get_RISCOS_TIME(&nameTIME) ;
put_FILE_time(dentry->FILE_time,dentry->FILE_timeHI,RISCOStoTIME(&nameTIME)) ;
put_FILE_date(dentry->FILE_date,dentry->FILE_dateHI,RISCOStoDATE(&nameTIME)) ;
put_FILE_cluster(dentry,0x00000000,ihand) ;
......
......@@ -79,10 +79,11 @@ static void addleapday(word *lo4bytes,word *hi1byte,word yearLO,word yearHI)
* be able to generate this one
*/
#define to1970 INT64_C(0x336E996A00)
#define to1980 INT64_C(0x3AC7524200)
/*---------------------------------------------------------------------------*/
int BCDto5byte(BCDtime *intime,time5byte *outtime)
static int BCDto5byte(BCDtime *intime,time5byte *outtime)
{
byte standardmonthlens[12] = {
31, /* Jan */
......@@ -183,12 +184,12 @@ int BCDto5byte(BCDtime *intime,time5byte *outtime)
return(0) ;
}
int convert5bytetoBCD(time5byte *intime,BCDtime *outtime)
static int convert5bytetoBCD(time5byte *intime,BCDtime *outtime)
{
/* convert the 5byte centisecond time from 00:00:00 1 Jan 1900 into BCD */
/* NOTE: this can be done by calculating the centi-second time from
* 00:00:00 1 Jan 1970 (i.e. the UNIX representation) and using the
* library function "struct tm *localtime(time_t *timer)" to convert
* library function "struct tm *gmtime(time_t *timer)" to convert
* to a BCD form...
*
* "00:00:00 1 Jan 1900" -> "00:00:00 1 Jan 1970" = &336E996A00
......@@ -203,9 +204,11 @@ int convert5bytetoBCD(time5byte *intime,BCDtime *outtime)
tracef2("convert5bytetoBCD: 1970 &%010"PRIx64"\n",to1970) ;
#endif
/* calculate centi-second difference (This code assumes that the current
* time is later than "00:00:00 1 Jan 1970" */
/* calculate centi-second difference (limit it at "00:00:00 1 Jan 1970"
* to ensure it can be represented as a DOS time) */
delta = ((int64_t) intime->hi << 32) + intime->lo - to1970 ;
if (delta < to1980 - to1970)
delta = to1980 - to1970;
#ifdef TIMEWORK
tracef2("convert5bytetoBCD: delta &%010"PRIx64"\n",delta) ;
......@@ -225,7 +228,7 @@ int convert5bytetoBCD(time5byte *intime,BCDtime *outtime)
since1970 = (time_t) quotient ; /* largest possible for the moment */
unixtime = localtime(&since1970) ;
unixtime = gmtime(&since1970) ;
/* transfer the data from the library structure */
outtime->year = unixtime->tm_year + 1900 ;
......@@ -346,9 +349,9 @@ word RISCOStoDATE(time5byte *ROStime)
}
/*---------------------------------------------------------------------------*/
/* return RISC OS centi-second time */
/* return RISC OS centi-second time (based at 1 Jan 1900, UTC) */
time5byte *localTIME(time5byte *timebuff)
time5byte *get_RISCOS_TIME(time5byte *timebuff)
{
time5byte *newTIME ;
_kernel_swi_regs reglist ;
......
......@@ -81,9 +81,7 @@ typedef struct {
/*-------------------------------------------------------------------------*/
time5byte *localTIME(time5byte *time_buffer) ;
int BCDto5byte(BCDtime *intime,time5byte *outtime) ;
int convert5bytetoBCD(time5byte *intime,BCDtime *outtime) ;
time5byte *get_RISCOS_TIME(time5byte *time_buffer) ;
void MSDOStoRISCOS(word DOStime,word DOSdate,time5byte *outtime) ;
char *MSDOStoSTRING(word DOStime,word DOSdate) ;
word RISCOStoTIME(time5byte *intime) ;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment