Armadilloフォーラム

USB(VFAT)にArmadilloが作成したファイルのタイムスタンプについて

nemo

2016年9月13日 1時15分

何時もお世話になっております。
根本と申します。

Armadillo-420を使っているのですが
初歩的な事で申し訳ありません。
Armadillo-420USBメモリ(VFAT)にファイルを作成しデータを書き込んだ時の
タイムスタンプをWindowsで見た時に問題ない様にする方法についてお尋ね致します。

過去に同じ様な質問があるのではないかと思い検索したのですが
見つける事が出来ませんでした。

MLの中に
”"VFAT 9時間"や"VFAT UTC"などで探すとみつかると思います。”
とも書いてあったのですが。検索しましたが答えが見つけられませんでした。
申し訳ありません。

ArmadilloとWindowsで作成したファイルを各々で見ると以下の様になっていいました。
( Armadillo側ではdate -s で時刻に合わせてあります。 )
9時間の差があるようです。

【Armadillo-420で見た時】

[root@armadillo420-0 (ttymxc1) ~]# ls -l /mnt/
-rwxr-xr-x 1 root root 29 Sep 12 22:18 armadillo_make.txt*
-rwxr-xr-x 1 root root 16 Sep 13 2016 win_make.txt*

【Windows7で見た時】

ドライブ E のボリューム ラベルがありません。
ボリューム シリアル番号は 7D1E-6DE8 です

e:\ のディレクトリ

2016/09/12 13:18 29 armadillo_make.txt
2016/09/12 22:08 16 win_make.txt
2 個のファイル 45 バイト
0 個のディレクトリ 7,742,631,936 バイトの空き領域

一応この対策としては、date -u (日本時間)で時刻設定してやり、ファイルをArmadilloで作成して、
Windowsでタイムスタンプを見ると問題ないタイムスタンプに見れる様です。
USB上のファイルの対策はこの方法で行きたいと思っています。
( 最終的にWindows側で見るファイルなのでファイルの更新時間を合わせたいと思っております。)

ただ、この方法だとエラー等ののログ時刻をdate >> /mnt/err_log でUSBに取ると9時間ずれるので
こちらは、date -u | sed -e "s/UTC/JST/" >> /mnt/err_log
にしようとかと思っています。
素人が思い付く対策はこんなところです。

過去に出た対策の方法を教えて頂けないでしょうか。

宜しくお願い致します。

以上

コメント

y.nakamura

2016年9月13日 3時55分

中村です。

> MLの中に
> ”"VFAT 9時間"や"VFAT UTC"などで探すとみつかると思います。”

私が書いた、これですね。
http://lists.atmark-techno.com/pipermail/armadillo/2012-December/008495…

> とも書いてあったのですが。検索しましたが答えが見つけられませんでした。

次の記事が「みつかると思います」と当時は書いたのですが・・・
[Armadillo:01366] Re: VFATのタイムスタンプについて
http://lists.atmark-techno.com/pipermail/armadillo/2006-November/001365…

この記事で紹介されている
| とすると、良さそうなページがありました。
| http://homepage3.nifty.com/k-takata/diary/2005-12.html
のページがなくなってますね。

私のメモによると、消えてしまったサイトのに書いてあったのは、
次のような内容だったようです。

起動時に、hwclock の代わりに、settimeofday() を呼んでタイムゾーンだけを
セットするプログラムを実行させるようにしておけば良さそうである。
プログラムはこんな感じ。
 
#include <stdio.h>
#include <time.h>
#include <sys/time.h>
 
int main(int argc, char *argv[])
{
    struct timezone tz = {0, 0};
 
    tzset();
    settimeofday(NULL, &tz);
    tz.tz_minuteswest = timezone / 60;
    settimeofday(NULL, &tz);
    return 0;
}
 
settimeofday() には、Linux 特有の事情があるので念のため2回に分けて
呼び出すようにしてある。

RTCが無い場合は、
export TZ=JST-9
したあとに上のソースをコンパイルしたものを実行します。

RTCがあるときには、
export TZ=JST-9
hwclock --hctosys --utc
でOKです。
上に書いたソースは使いません。

Armadillo起動時にrc.localなどで1度だけ実行です。

ただし、busybox-1.00のhwclockには、
これに関係する部分にバグがあって(たぶん今もあります)、
ここ(↓)に書いてあるパッチが必要だと思います。
[Armadillo:07255] busybox のhwclockのバグ
http://lists.atmark-techno.com/pipermail/armadillo/2011-May/007258.html

それから、上のソースをArmadillo-4x0でコンパイルするとき、
こんな問題(↓)が出ていたのですけど、今はどうなんでしょう。。。
http://lists.atmark-techno.com/pipermail/armadillo/2013-January/008509…

--
なかむら

nemo

2016年9月13日 14時30分

中村様ご教授ありがとうございます。
根本です。

そうです、このMLです。
ご教授して頂いた様にやってみました。
上手く行きました。ありがとうございました。

【結果】

【armadillo でファイルを作成しました】

armadillo420-0 login: root
Password:
[root@armadillo420-0 (ttymxc1) ~]# echo $TZ
JST-9
[root@armadillo420-0 (ttymxc1) ~]# date -s 091313592016
Tue Sep 13 13:59:00 JST 2016
[root@armadillo420-0 (ttymxc1) ~]# date
Tue Sep 13 13:59:02 JST 2016
[root@armadillo420-0 (ttymxc1) ~]# usb 1-1: new full speed USB device using fsl-ehci and address 2
usb 1-1: not running at top speed; connect to a high speed hub
usb 1-1: configuration #1 chosen from 1 choice
scsi0 : SCSI emulation for USB Mass Storage devices
scsi 0:0:0:0: Direct-Access I-O DATA USB Flash Disk 1100 PQ: 0 ANSI: 4
sd 0:0:0:0: [sda] 15155200 512-byte hardware sectors (7759 MB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Assuming drive cache: write through
sd 0:0:0:0: [sda] 15155200 512-byte hardware sectors (7759 MB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Assuming drive cache: write through
sda: sda1
sd 0:0:0:0: [sda] Attached SCSI removable disk

[root@armadillo420-0 (ttymxc1) ~]# mount -t vfat /dev/sda1 /mnt/
[root@armadillo420-0 (ttymxc1) ~]# mount
/dev/ram0 on / type ext2 (rw)
proc on /proc type proc (rw)
usbfs on /proc/bus/usb type usbfs (rw)
sysfs on /sys type sysfs (rw)
udev on /dev type tmpfs (rw)
ramfs on /home/ftp/pub type ramfs (rw)
/dev/sda1 on /mnt type vfat (rw,fmask=0022,dmask=0022,codepage=cp437,iocharset=iso8859-1)
[root@armadillo420-0 (ttymxc1) ~]# ls -l /mnt/
-rwxr-xr-x 1 root root 10 Sep 13 13:29 test_usb.txt*
[root@armadillo420-0 (ttymxc1) ~]# date > /mnt/armadillo_test.txt
[root@armadillo420-0 (ttymxc1) ~]# cat /mnt/armadillo_test.txt
Tue Sep 13 14:00:24 JST 2016
[root@armadillo420-0 (ttymxc1) ~]# sync
[root@armadillo420-0 (ttymxc1) ~]# sync
[root@armadillo420-0 (ttymxc1) ~]# umount /mnt/
[root@armadillo420-0 (ttymxc1) ~]# mount
/dev/ram0 on / type ext2 (rw)
proc on /proc type proc (rw)
usbfs on /proc/bus/usb type usbfs (rw)
sysfs on /sys type sysfs (rw)
udev on /dev type tmpfs (rw)
ramfs on /home/ftp/pub type ramfs (rw)
[root@armadillo420-0 (ttymxc1) ~]# mount -t vfat /dev/sda1 /mnt/
[root@armadillo420-0 (ttymxc1) ~]# mount
/dev/ram0 on / type ext2 (rw)
proc on /proc type proc (rw)
usbfs on /proc/bus/usb type usbfs (rw)
sysfs on /sys type sysfs (rw)
udev on /dev type tmpfs (rw)
ramfs on /home/ftp/pub type ramfs (rw)
/dev/sda1 on /mnt type vfat (rw,fmask=0022,dmask=0022,codepage=cp437,iocharset=iso8859-1)
[root@armadillo420-0 (ttymxc1) ~]# ls -l /mnt/
-rwxr-xr-x 1 root root 29 Sep 13 14:00 armadillo_test.txt*
-rwxr-xr-x 1 root root 10 Sep 13 13:29 test_usb.txt*
[root@armadillo420-0 (ttymxc1) ~]# cat /mnt/armadillo_test.txt
Tue Sep 13 14:00:24 JST 2016
[root@armadillo420-0 (ttymxc1) ~]# umount /mnt/
[root@armadillo420-0 (ttymxc1) ~]# mount
/dev/ram0 on / type ext2 (rw)
proc on /proc type proc (rw)
usbfs on /proc/bus/usb type usbfs (rw)
sysfs on /sys type sysfs (rw)
udev on /dev type tmpfs (rw)
ramfs on /home/ftp/pub type ramfs (rw)
[root@armadillo420-0 (ttymxc1) ~]# usb 1-1: USB disconnect, address 2

【Windows7 で作成したファイルのタイムスタンプを見てみました】

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\nemo>dir e:\
ドライブ E のボリューム ラベルがありません。
ボリューム シリアル番号は 245A-AECA です

e:\ のディレクトリ

2016/09/13 14:00 29 armadillo_test.txt
2016/09/13 13:29 10 test_usb.txt
2 個のファイル 39 バイト
0 個のディレクトリ 7,742,644,224 バイトの空き領域

C:\Users\nemo>type e:\armadillo_test.txt
Tue Sep 13 14:00:24 JST 2016

     以上