More generally, files created on tmpfs file systems always need to be copied to be able to replay across reboots.  I'd prefer to check for that with an `fstatfs`, but I'll need to check if that's going to be awkward here.  Otherwise this looks pretty much OK; I would change the condition to `filename == strstr(filename, "/tmp/")`, but that's just a nit.

brb