O_EXCLなしでオープンループデバイスを持つファイルをサポートします。

O_EXCLなしでオープンループデバイスを持つファイルをサポートします。

ループデバイスは、Linuxで通常のファイルをブロックデバイスとして扱う基本的な方法です(おそらく唯一の方法)。奇妙なことに、代替ファイルはO_EXCLフラグで保護されていません。なぜそんなことですか?なぜ誰も文句を言わないのですか?

たとえば、ツールはファイルがインストールwipefsされたことを認識しませんでした。

[il@reallin ~]$ touch me
[il@reallin ~]$ truncate -s10G me
[il@reallin ~]$ mkfs.ext3 me
...
Writing superblocks and filesystem accounting information: done

[il@reallin ~]$ sudo mount -oloop me /mnt

[il@reallin ~]$ mount | grep /mnt
/home/il/me on /mnt type ext3 (rw,relatime,data=ordered)

[il@reallin ~]$ wipefs -a /dev/loop0
wipefs: error: /dev/loop0: probing initialization failed: Device or resource busy

[il@reallin ~]$ wipefs -a me
me: 2 bytes were erased at offset 0x00000438 (ext2): 53 ef

[il@reallin ~]$ uname -a
Linux reallin.basin 4.2.4-1-ARCH #1 SMP PREEMPT Fri Oct 23 07:32:38 CEST 2015 x86_64 GNU/Linux

同じファイルを複数回マウントするには、losetupまず排他モードを試してから警告を出力し、このフラグを使用しないものに置き換える必要があります。

ベストアンサー1

おすすめ記事