我如何知道 USB 驱动器的内容是否已更改
我正在编写一个嵌入式系统多媒体应用程序,其中支持从 USB 驱动器播放。通常,当插入 USB 驱动器时,应用程序会解析整个 USB 驱动器以列出驱动器中存在的所有歌曲和视频。该列表存储在数据库中。如果稍后连接同一驱动器,应用程序将使用数据库中的列表。
使用 USB 设备描述符中的序列号来识别驱动器。但问题是如何检测是否添加了任何新内容或删除了任何现有内容? 目前我的目标是仅支持 FAT32 格式的 USB 驱动器。
有没有办法检测驱动器内容的变化?比如上次访问的时间戳或上次修改的集群?
I am writing an embedded system multimedia application where support to play from USB drive is there. Generally when a USB drive is inserted, the application parses the entire USB drive to list all songs and videos present in the drive. This list is stored in a database. In case the same drive is connected later, the application uses the list from the database.
Identification of the drive is done using the serial number from the USB device descriptor. But the problem is how do I detect that any new content is added or any existing content is deleted?
Currently I am targeting for supporting FAT32 formatted USB drives only.
Is there any way to detect the change in the content of the drive? Like last accessed time-stamp or last modified cluster?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您有权访问原始块设备,则可以缓存 FS 信息扇区的相关部分。空闲集群的数量或最近分配的集群数量的变化都会告诉您某些内容发生了变化,尽管您必须手动追踪具体内容。目录表中最后修改的条目可能对此有用,但我认为它不一定可靠 - 这取决于写入设备的严格程度。
If you've got access to the raw block device, you could cache the relevant parts of the FS information sector. Either the number of free clusters or the number of the most recently allocated cluster changing will tell you that something changed, although you'd have to track down what that was manually. The last modified entry in the directory table might be useful for this, but I don't think it's necessarily reliable - that depends on how stringent whatever wrote to the device was.