you need to have a converter for the errno global to convert stream I/O errors into brackets return values.  Otherwise you might be returning ERR_INVALID_PARAMS for ENOENT.  You could also just ERR_CANT_WRITE but it is nice to report why the write failed.