UNBINDABLEマウント
mount --make-unbindable mntすると、mntのbind mountをできなくします。再度有効とするには、--make-bindableオプションは無く、--make-shared/--make-privateするとbindableとなります。--make-unbindableは、mount private下の実装で、既にbindされているshare/slaveにリストされているクローンmntは取り消されます。
検証
実装
検証
[root@localhost loop]# mount --make-unbindable mnt1
[root@localhost loop]# mount --bind mnt1 mnt2
mount: 間違ったファイルシステムタイプ、不正なオプション、
/mnt/loop/mnt1 のスーパーブロックが不正、コードページまたは
ヘルパープログラムの未指定、或いは他のエラー
In some cases useful info is found in syslog - try
dmesg | tail or so
[root@localhost loop]# mount --make-unbindable mnt1 [root@localhost loop]# mount --make-shared mnt1 [root@localhost loop]# mount --bind mnt1 mnt2 [root@localhost loop]# ls mnt2 lost+found mnt1.txt submnt
[root@localhost loop]# mount --make-unbindable mnt1 [root@localhost loop]# mount --make-private mnt1 [root@localhost loop]# mount --bind mnt1 mnt2 [root@localhost loop]# ls mnt2 lost+found mnt1.txt submnt
[root@localhost loop]# mount --make-unbindable mnt1
[root@localhost loop]# mount --make-slave mnt1
[root@localhost loop]# mount --bind mnt1 mnt2
mount: 間違ったファイルシステムタイプ、不正なオプション、
/mnt/loop/mnt1 のスーパーブロックが不正、コードページまたは
ヘルパープログラムの未指定、或いは他のエラー
In some cases useful info is found in syslog - try
dmesg | tail or so
dmesg | tail or soはmountコマンドでの表示で、mount --bind mnt1 mnt2時のカーネルエラーは無く、dmesgには掛かる情報はありません。実装
type = flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE);
void change_mnt_propagation(struct mount *mnt, int type)
{
if (type == MS_SHARED) {
set_mnt_shared(mnt);
return;
}
do_make_slave(mnt);
if (type != MS_SLAVE) {
list_del_init(&mnt->mnt_slave);
mnt->mnt_master = NULL;
if (type == MS_UNBINDABLE)
mnt->mnt.mnt_flags |= MNT_UNBINDABLE;
else
mnt->mnt.mnt_flags &= ~MNT_UNBINDABLE;
}
}
#define MNT_SHARED_MASK (MNT_UNBINDABLE)
static inline void set_mnt_shared(struct mount *mnt)
{
mnt->mnt.mnt_flags &= ~MNT_SHARED_MASK;
mnt->mnt.mnt_flags |= MNT_SHARED;
}





