Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top