Pass the file descriptor to callbacks when PATCHing files
Clean up the error codes a bit