当我尝试查找链接到 /tmp 文件夹的所有文件/目录时,我尝试
ls -di /tmp
Run Code Online (Sandbox Code Playgroud)
这给了我索引4194305节点/tmp
现在我会找到链接到该索引节点的所有文件
find / -follow -path /media -prune -inum $(ls -di /tmp |cut -d" " -f1)
Run Code Online (Sandbox Code Playgroud)
但这会给我数千个文件系统循环检测到的警告:
find: File system loop detected; `/sys/devices/platform/reg-dummy
/subsystem/devices/serial8250/tty/ttyS2/subsystem/ttyS0/device/firmware_node/subsystem/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0C:00/input/input1/subsystem/event2/device/device/driver/PNP0C0C:00' is part of the same file system loop as `/sys/devices/platform/reg-dummy/subsystem/devices/serial8250/tty/ttyS2/subsystem/ttyS0/device/firmware_node/subsystem/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0C:00'.
find: File system loop detected; `/sys/devices/platform/reg-dummy/subsystem/devices/serial8250/tty/ttyS2/subsystem/ttyS0/device/firmware_node/subsystem/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0C:00/input/input1/subsystem/event2/device/device/driver/LNXPWRBN:00' is part of the same file system loop as `/sys/devices/platform/reg-dummy/subsystem/devices/serial8250/tty/ttyS2/subsystem/ttyS0/device/firmware_node/subsystem/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0C:00/input/input1/subsystem/event2/device/device'.
find: File system loop detected; `/sys/devices/platform/reg-dummy/subsystem/devices/serial8250/tty/ttyS2/subsystem/ttyS0/device/firmware_node/subsystem/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0C:00/input/input1/subsystem/event2/device/device/input/input2' is part of the same file system loop as `/sys/devices/platform/reg-dummy/subsystem/devices/serial8250/tty/ttyS2/subsystem/ttyS0/device/firmware_node/subsystem/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0C:00/input/input1/subsystem/event2/device'.
find: File system loop detected; `/sys/devices/platform/reg-dummy/subsystem/devices/serial8250/tty/ttyS2/subsystem/ttyS0/device/firmware_node/subsystem/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0C:00/input/input1/subsystem/event2/device/event2' is part of the same file system loop as `/sys/devices/platform/reg-dummy/subsystem/devices/serial8250/tty/ttyS2/subsystem/ttyS0/device/firmware_node/subsystem/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0C:00/input/input1/subsystem/event2'.
find: File system loop detected; `/sys/devices/platform/reg-dummy/subsystem/devices/serial8250/tty/ttyS2/subsystem/ttyS0/device/firmware_node/subsystem/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0C:00/input/input1/device' is part of the same file system loop as `/sys/devices/platform/reg-dummy/subsystem/devices/serial8250/tty/ttyS2/subsystem/ttyS0/device/firmware_node/subsystem/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0C:00'.
find: File system loop detected; `/sys/devices/platform/reg-dummy/subsystem/devices/serial8250/tty/ttyS2/subsystem/ttyS0/device/firmware_node/subsystem/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0C:00/input/input1/event1/subsystem/mice/subsystem' is part of the same file system loop as `/sys/devices/platform/reg-dummy/subsystem/devices/serial8250/tty/ttyS2/subsystem/ttyS0/device/firmware_node/subsystem/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0C:00/input/input1/event1/subsystem'.
Run Code Online (Sandbox Code Playgroud)
我如何忽略这些错误?
这些循环是显示内核数据结构和设备的sysfs伪文件系统的一部分。如果您只是寻找常规文件,您可能不想陷入其中(或/proc就此而言)。
您可以使用-prune子树,就像您从搜索中删除它一样,因为它不太可能包含指向 的/sys链接。使用,您还可以阻止从一个文件系统移动到另一个文件系统,但由于符号链接可以跨文件系统,因此您需要在命令行上单独列出所有文件系统。也就是说,类似/media/tmp-xdevfind
find -L / /home /tmp -xdev -inum $inodenum
Run Code Online (Sandbox Code Playgroud)
/假设您除了、/home和 之外没有其他文件系统/tmp。这也应该消除修剪的需要/media,因为那里的东西可能是单独的安装座。
| 归档时间: |
|
| 查看次数: |
4590 次 |
| 最近记录: |