Conditional Unlink

From: Fox, Kevin M
Date: Fri Sep 21 2012 - 14:32:38 EST


Quick question:
Is there a syscall or some algorithm that would allow an unlink that would only happen if no writes to the file have occurred between a stat and an unlink, race free?

Background:
I'm writing a program that sync's files up to a server. I would like to unlink the files that have successfully been uploaded. There is a race though. If the file changed after uploading but before the unlink (I do not control who can write to the files), the next upload should take care of things and the unlink should fail. Otherwise, data could be lost!

Thanks,
Kevin
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/