>Long ago somebody came up with the excellent idea of error return codes so you could see why an operation failed without having to dig through a logfile. It's unfortunate that the return code is just a single integer, which doesn't give much information. The system call needs to return an error string as well.
Error strings are not good. Exceptions are really what you need, they can provide both programmatic and textual description of a problem. And they should be inheritable, so your code can check for generic FileSystemProblemException or for fine-grained FilePermissionException.
Adding C-language interface with exception support is possible, though a bit clumsy.