如果 linux 中的 USB 设备中的文件系统发生任何更改或如何递归使用 inotify,如何获得通知
How to get notified if there is any changes in file system in USB device in linux or how to use recursively inotify
谁能告诉我是否有任何实用程序可以检测连接的 USB 文件系统是否有任何变化?
要么
谁能递归地提供 inotify 的示例代码。
USB 存储设备在摘要中不包含 "files"。
但它通常有一些file system (often VFAT, but that could be something else; I do format USB keys with ext4 FS sometimes, and I do have a USB disk with both a VFAT and an ext4 file systems on it). That file system should be mounted供您在上面读取或写入文件。
I want a utility which will notify me if there is any change in file system too.
也许您想在这样一个已挂载的文件系统上使用 inotify(7) 工具;这个问题与 USB 设备无关,SATA 磁盘及其上的文件系统也是如此;一些文件系统——特别是像 NFS 这样的远程文件系统——不能很好地与 inotify
.
一起工作
请注意,USB 存储器可以用作 raw disk as a block device (even if it is usually not used that way). In that case, your question don't makes any sense. Also, a USB storage could have several partitions,因此 多个 文件系统。您可能需要确定要处理的文件系统和分区。
您可能想先确定从您的 USB 存储器挂载的文件系统(例如使用 proc(5),也许 /proc/mounts
...),然后使用 inotify
来查看其中的变化。
If i will add or delete 1 GB from it ,Is there any utility to get notified ?
您添加文件(通过 inode(7)-s) into your VFAT file systems (you can't add 1Gb without files). You could use df(1) to measure its occupation (and you might use watch(1) or crontab(5) to repeat that measure). You could also use inotify
thru incron
command. You could even format your USB disk with ext4 file system and use disk quota 设施。
您可能想阅读更多有关操作系统的一般信息。我强烈推荐Operating Systems: Three Easy Pieces. If you are interested in C or C++ system programming on Linux, read some book on that (perhaps the old ALP, or something newer) then read intro(2) and syscalls(2)。
谁能告诉我是否有任何实用程序可以检测连接的 USB 文件系统是否有任何变化? 要么 谁能递归地提供 inotify 的示例代码。
USB 存储设备在摘要中不包含 "files"。
但它通常有一些file system (often VFAT, but that could be something else; I do format USB keys with ext4 FS sometimes, and I do have a USB disk with both a VFAT and an ext4 file systems on it). That file system should be mounted供您在上面读取或写入文件。
I want a utility which will notify me if there is any change in file system too.
也许您想在这样一个已挂载的文件系统上使用 inotify(7) 工具;这个问题与 USB 设备无关,SATA 磁盘及其上的文件系统也是如此;一些文件系统——特别是像 NFS 这样的远程文件系统——不能很好地与 inotify
.
请注意,USB 存储器可以用作 raw disk as a block device (even if it is usually not used that way). In that case, your question don't makes any sense. Also, a USB storage could have several partitions,因此 多个 文件系统。您可能需要确定要处理的文件系统和分区。
您可能想先确定从您的 USB 存储器挂载的文件系统(例如使用 proc(5),也许 /proc/mounts
...),然后使用 inotify
来查看其中的变化。
If i will add or delete 1 GB from it ,Is there any utility to get notified ?
您添加文件(通过 inode(7)-s) into your VFAT file systems (you can't add 1Gb without files). You could use df(1) to measure its occupation (and you might use watch(1) or crontab(5) to repeat that measure). You could also use inotify
thru incron
command. You could even format your USB disk with ext4 file system and use disk quota 设施。
您可能想阅读更多有关操作系统的一般信息。我强烈推荐Operating Systems: Three Easy Pieces. If you are interested in C or C++ system programming on Linux, read some book on that (perhaps the old ALP, or something newer) then read intro(2) and syscalls(2)。