Hi,
Felix Zielcke wrote:
> > I just tried to test it with TZ set.
> > But I always get the same binaries. No matter to what I change TZ or
> > /etc/timezone between the builds.
Vagrant Cascadian wrote:
> I can reproduce the issue in a debian sid chroot with pcmemtest 1.5-3
> from debian
I don't have newest Debian in reach today and am too lazy to set up
pcmemtest package building anyways. :o)
So i rather tested near to the bottom, i.e. mcopy(1) and localtime(3).
Both react on TZ here.
If Felix Zielcke and Vagrant Cascadian get the same result, then i
wonder why TZ does not have an influence in the Makefile of pcmemtest.
-------------------------------------------------------------------
Test of mcopy(1):
Using rather outdated libc (i.e. localtime(3)) and rather young locally
compiled mtools-4.0.37 (source of january 2022):
/sbin/mkdosfs -i 12345678 -n MEMTEST-ESP -F12 -C fat.img 1024
./mcopy -s -i fat.img x ::/x
TZ=UTF ./mcopy -s -i fat.img x ::/y
TZ=UTF+3 ./mcopy -s -i fat.img x ::/z
This yields after mounting fat.img :
-rwxr-xr-x 1 root root 9931 Mar 26 09:29 x
-rwxr-xr-x 1 root root 9931 Mar 26 08:29 y
-rwxr-xr-x 1 root root 9931 Mar 26 05:29 z
which is somewhat wrong because my local time (CET = UTF-1) was
$ date
Sat Mar 26 10:29:49 CET 2022
mdir from mtools does it better (but other than ls -l it does not
react on TZ):
$ mdir -i fat.img
...
x 9931 2022-03-26 10:29
y 9931 2022-03-26 9:29
z 9931 2022-03-26 6:29
Whatever, the mcopy command reacts on TZ.
-------------------------------------------------------------------
Test of localtime(3):
In order to directly check the influence of TZ on localtime(3), which
does the time format conversion in mtools--4.0.37/directory.c function
mk_entry(), i wrote a test program:
----------------------- File start
/*
cc -g -o localtime_test localtime_test.c
*/
#include <stdio.h>
#include <time.h>
int main()
{
time_t now;
struct tm *res;
now= time(NULL);
res= localtime(&now);
printf("%d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d (%d)\n",
1900 + res->tm_year, 1 + res->tm_mon, res->tm_mday,
res->tm_hour, res->tm_min, res->tm_sec,
res->tm_isdst);
return(0);
}
----------------------- File end
After
cc -g -o localtime_test localtime_test.c
i get plausible results:
$ ./localtime_test
2022/03/26 10:43:05 (0)
$ TZ=UTC ./localtime_test
2022/03/26 09:43:14 (0)
$ TZ=UTC+3 ./localtime_test
2022/03/26 06:43:18 (0)
-------------------------------------------------------------------
Have a nice day :)
Thomas