brufuse/src/server/fuse-iface.cpp
/**
 * Maps a Brufs status code to a Unix errno.
 *
 * NB: there is no direct 1:1 relation between the codes, you may have to return a different
 * errno for a status code in some cases.
 *
 * The worst case is E_WRONG_INODE_TYPE, which is translated to ENOTDIR by default since there is no
 * corresponding context-sensitive errno. Tweak this value using the following parameter:
 *
 * @param on_wrong_inode_type the errno to return if the status is E_WRONG_INODE_TYPE
 *
 * @param status [description]
 * @return [description]
 */
Maps a Brufs status code to a Unix errno.
NB: there is no direct 1:1 relation between the codes, you may have to return a different
errno for a status code in some cases.

The worst case is E_WRONG_INODE_TYPE, which is translated to ENOTDIR by default since there is no
corresponding context-sensitive errno. Tweak this value using the following parameter.

@param on_wrong_inode_type the errno to return if the status is E_WRONG_INODE_TYPE

@param status [description]
@return [description]
Maps a Brufs status code to a Unix errno . NB : there is no direct 1 : 1 relation between the codes you may have to return a different errno for a status code in some cases . The worst case is E_WRONG_INODE_TYPE which is translated to ENOTDIR by default since there is no corresponding context - sensitive errno . Tweak this value using the following parameter . @param on_wrong_inode_type the errno to return if the status is E_WRONG_INODE_TYPE @param status [ description ] @return [ description ]
static int status_to_errno_trace(
    const char *func, unsigned int line,
    Brufs::Status status, int on_wrong_inode_type = ENOTDIR
) {
    fprintf(stderr, "Translating error %s (%d) into errno in %s:%u\n",
        Brufuse::fs_io->strstatus(status), status, func, line
    );
    switch (status) {
        case Brufs::Status::E_INTERNAL: ;
        case Brufs::Status::E_NO_MEM: return ENOMEM;
        case Brufs::Status::E_DISK_TRUNCATED: return EIO;
        case Brufs::Status::E_BAD_MAGIC: return EIO;
        case Brufs::Status::E_FS_FROM_FUTURE: return EIO;
        case Brufs::Status::E_HEADER_TOO_BIG: return EIO;
        case Brufs::Status::E_HEADER_TOO_SMALL: return EIO;
        case Brufs::Status::E_CHECKSUM_MISMATCH: return EIO;
        case Brufs::Status::E_NO_SPACE: return ENOSPC;
        case Brufs::Status::E_WONT_FIT: return EFBIG;
        case Brufs::Status::E_NOT_FOUND: return ENOENT;
        case Brufs::Status::E_TOO_MANY_RETRIES: return EDEADLK;
        case Brufs::Status::E_AT_MAX_LEVEL: return ENOSPC;
        case Brufs::Status::E_CANT_ADOPT: return ENOSPC;
        case Brufs::Status::E_MISALIGNED: return EINVAL;
        case Brufs::Status::E_NO_FBT: return EIO;
        case Brufs::Status::E_NO_RHT: return EIO;
        case Brufs::Status::E_EXISTS: return EEXIST;
        case Brufs::Status::E_PILEUP: return ENOSPC;
        case Brufs::Status::E_BEYOND_EOF: return EINVAL;
        case Brufs::Status::E_STOPPED: return ECANCELED;
        case Brufs::Status::E_WRONG_INODE_TYPE: return on_wrong_inode_type;
        case Brufs::Status::OK: return 0;
        case Brufs::Status::RETRY: return ERESTART;
        case Brufs::Status::STOP: return 0;
        default: return -1;
    }
}
static int status_to_errno_trace ( const char * func , unsigned int line , Brufs :: Status status , int on_wrong_inode_type = ENOTDIR ) { fprintf ( stderr , " \n " , Brufuse :: fs_io -> strstatus ( status ) , status , func , line ) ; switch ( status ) { case Brufs :: Status :: E_INTERNAL : ; case Brufs :: Status :: E_NO_MEM : return ENOMEM ; case Brufs :: Status :: E_DISK_TRUNCATED : return EIO ; case Brufs :: Status :: E_BAD_MAGIC : return EIO ; case Brufs :: Status :: E_FS_FROM_FUTURE : return EIO ; case Brufs :: Status :: E_HEADER_TOO_BIG : return EIO ; case Brufs :: Status :: E_HEADER_TOO_SMALL : return EIO ; case Brufs :: Status :: E_CHECKSUM_MISMATCH : return EIO ; case Brufs :: Status :: E_NO_SPACE : return ENOSPC ; case Brufs :: Status :: E_WONT_FIT : return EFBIG ; case Brufs :: Status :: E_NOT_FOUND : return ENOENT ; case Brufs :: Status :: E_TOO_MANY_RETRIES : return EDEADLK ; case Brufs :: Status :: E_AT_MAX_LEVEL : return ENOSPC ; case Brufs :: Status :: E_CANT_ADOPT : return ENOSPC ; case Brufs :: Status :: E_MISALIGNED : return EINVAL ; case Brufs :: Status :: E_NO_FBT : return EIO ; case Brufs :: Status :: E_NO_RHT : return EIO ; case Brufs :: Status :: E_EXISTS : return EEXIST ; case Brufs :: Status :: E_PILEUP : return ENOSPC ; case Brufs :: Status :: E_BEYOND_EOF : return EINVAL ; case Brufs :: Status :: E_STOPPED : return ECANCELED ; case Brufs :: Status :: E_WRONG_INODE_TYPE : return on_wrong_inode_type ; case Brufs :: Status :: OK : return 0 ; case Brufs :: Status :: RETRY : return ERESTART ; case Brufs :: Status :: STOP : return 0 ; default : return -1 ; } }
Maps a Brufs status code to a Unix errno.
Maps a Brufs status code to a Unix errno .