挂载链接在一起的多个文件夹

Mount multiple folders linked together

我有三个文件夹,/ftp/A、/ftp/B、/ftp/C 但逻辑上 C 是 B 的子目录,B 是 A 的子目录。

我尝试在系统启动时使用绑定文件夹的脚本来解决这个问题。 我在 /ftp/dirFolder 中有一个文本文件,其中包含文件夹之间的关系。喜欢

B C
A B C
A B

第一列是父亲,第二列是儿子,第三列是侄子。 脚本是这样的:

case "" in
start)  while IFS=' ' read -r x y z
    do
        if [ -z "$z" ]; then
            mkdir -p /ftp/$x/$y
            mount -t none --bind /ftp/$y /ftp/$x/$y  > /dev/null 2>&1
        else
            mkdir -p /ftp/$x/$y/$z
            mount -t none --bind /ftp/$z /ftp/$x/$y/$z  > /dev/null 2>&1
        fi
    done < /ftp/dirFolder
    ;;
stop)   while IFS=' ' read -r x y z
    do
        if [ -z "$z" ]; then
            umount /ftp/$x/$y  > /dev/null 2>&1
        else
            umount /ftp/$x/$y/$z  > /dev/null 2>&1
        fi
    done < /ftp/dirFolder
    ;;

问题是:当我启动脚本时,文件夹被正确创建和挂载,但是如果在 C 中有文件夹或文件,它在 /ftp/A/B/ 中是不可见的C 但他们会在 /ftp/B/C.

里面

mount 命令给我这个:

/ftp/C on /ftp/B/C type none (rw,bind)
/ftp/C on /ftp/A/B/C type none (rw,bind)

有没有办法让文件夹 C 从文件夹 A 和 B 都可用?

已解决,dirFolder 文件出错。

首先需要将侄子的文件夹挂载到儿子的文件夹中,然后再将儿子的文件夹挂载到父亲的文件夹中。

我是:

B C
A B C
A B

应该是:

B C
A B
A B C

希望对大家有所帮助!