0

I'm developping a "MP3 player"-like USB device. It is seen as a Mass Storage device by the USB host (Windows). I'd like to be able to keep the current song playing while the device is connected. In an ideal world, the user should be able to delete every mp3 files using his file explorer but the one currently playing, which would be seen as "in use" by Windows.

The filesystem is FAT, I use FatFS for reading files on the device.

Does FAT allow such thing (mark a file as "in use") ? Any smarter idea ?

Julien
  • 1,181
  • 10
  • 31
  • No, this is not supported, nor really is continuing to play while the storage is USB mounted to a PC. Unlike a network file system, FAT is based on the assumption that only one system can access the raw storage at a time, and most implementations will make use of that allowance - for example, files might be re-located even when not modified, written data may not be immediately committed, etc. – Chris Stratton Apr 17 '13 at 15:13
  • Given the FAT constraint, one thought would be to always cache the current file in RAM, just in case the user happens to plug in and want to delete files, etc. Of course that's a huge hit on resources for what is probably a corner case. – Ross Apr 17 '13 at 16:07
  • I do not have enough RAM for that indeed. Thanks for your inputs. – Julien Apr 18 '13 at 05:46

1 Answers1

1

Like every filesystem that isn't specifically designed for this purpose, FAT isn't a cluster filesystem. As such, there are no provisions for mounting it from more than one host at a time. So it can't be mounted from the USB host's operating system and from the USB device's embedded operating system at the same time. The concept of a file being "in use" at the filesystem level is moot for a non-cluster filesystem.

For examples of cluster filesystems, look at OCFS2 or GFS2. But those require things like network lock managers and it is very unlikely that you can easily use them for an application like a USB device.

Celada
  • 21,627
  • 4
  • 64
  • 78