[Armadillo:03159] Re: Armadillo-240のUSB使用可能か判断に関して

吉岡 email@hidden
2008年 7月 17日 (木) 10:09:10 JST


fsckコマンドでUSBデバイスの確認をしてみました。
下記がその結果ですが、USBを挿し込んだ状態と挿さない状態の
終了コードが”8”と同じ値になっています。

Armadilloが起動時にプログラムを起動するシェルが呼ばれるようにするので
シェル内で判断するか、プログラムで判断しなければいけません。
終了コードでは判断できそうもないので
grepか何かで挿し込んでいるかを判断するのでしょうか?
それともfsckにオプションを付ければ簡単に判定できるのでしょうか?

申し訳ありませんが、ご教授お願いします。


〇USBを挿し込んだ状態
    [email@hidden (ttyAM0) ~]# fsck /dev/sda1
    fsck 1.25 (20-Sep-2001)
    e2fsck 1.25 (20-Sep-2001)
    Couldn't find ext2 superblock, trying backup blocks...
    fsck.ext2: Bad magic number in super-block while trying to open
/dev/sda1

    The superblock could not be read or does not describe a correct ext2
    filesystem.  If the device is valid and it really contains an ext2
    filesystem (and not swap or ufs or something else), then the superblock
    is corrupt, and you might try running e2fsck with an alternate
superblock:
        e2fsck -b 8193 <device>

    [email@hidden (ttyAM0) ~]# echo $?
    8



〇USBを挿さない状態
    [email@hidden (ttyAM0) ~]# fsck /dev/sda1
    fsck 1.25 (20-Sep-2001)
    e2fsck 1.25 (20-Sep-2001)
    fsck.ext2: No such device or address while trying to open /dev/sda1
    Possibly non-existent or swap device?

    [email@hidden (ttyAM0) ~]# echo $?
    8



> 齊藤と申します
>
> Yasushi SHOJI さんは書きました:
> > それも okです。コマンドのmountを使わないで、システムコールの mount()を
> > 使って、アプリの中で確認しても良いと思います。
> >
> > freedesktop.orgで開発している halというツールでは open()で確認している
> > みたいです。
>
> 僕は、fsckでチェックするというのをやったことがあります。
> 指されたUSBメモリがFAT32かどうかはopenではわからない
> ので。
>
>
> -- 
> 齊藤明紀 email@hidden
> _______________________________________________
> armadillo mailing list
> email@hidden
> http://lists.atmark-techno.com/mailman/listinfo/armadillo




armadillo メーリングリストの案内