On 8/17/2011 09:31, ekgnkb3d wrote:
Hello Mark,
according my last tests, setting error_print and error_level will not change
the errno return behavior. It will create (much) more output, readable by a
human from console or syslog.
But I'm searching for a error handling within my application and do some
things based on different error types. So it looks like there are a lot of
different errors bundled in the errno=2

Is there somewhere a documentation, maybe in the sources, what the meaning
is of the different errno?

I don't know of any documentation on this. It will take a code read of each function.

According to my read of the source, errno is set to a negative value of an internal return code and the return value is set to -1 on an error. Some functions are wrapped around ReturnAndErrno(), some use ReturnAndZero(), etc.

   static ssize_t ReturnAndErrno(ssize_t ret)
   {
        if (ret < 0) {
            errno = -ret;
            return -1;
        } else {
            errno = 0;
            return ret;
        }
   }

Digging further into the code (I took fs_write() as an example) I see the following docs:

   /* Note on return values: */
   /* Top level FS_write will return size if ok, else a negative number */
   /* Each lower level function called will return 0 if ok, else
   non-zero */


And the function itself is rather instructive:

   /* return size if ok, else negative */
   SIZE_OR_ERROR FS_write(const char *path, const char *buf, const
   size_t size, const off_t offset)
   {
        ZERO_OR_ERROR write_return;
        OWQ_allocate_struct_and_pointer(owq);

        LEVEL_CALL("path=%s size=%d offset=%d", SAFESTRING(path), (int)
   size, (int) offset);

        // parsable path?
        if ( OWQ_create(path, owq) != 0 ) { // for write
            return -ENOENT;
        }
        OWQ_assign_write_buffer(buf, size, offset, owq) ;
        write_return = FS_write_postparse(owq);
        OWQ_destroy(owq);
        return write_return;        /* here's where the size is used! */
   }


Note that ENOENT (No such file or directory) is returned if the path/file does not exist.

As for internal errors in the OWC API library itself, I suspect the logging will have to do.

You might consider, as it seems the pattern is to use the standard error codes, to parse these against errno on negative return from an OWCApi call.

/m

------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system, 
user administration capabilities and model configuration. Take 
the hassle out of deploying and managing Subversion and the 
tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
_______________________________________________
Owfs-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/owfs-developers

Reply via email to