Exemplo n.º 1
0
int os_sem_wait_intr(os_sem_t *sem)
{
    if (sem_wait(sem) == 0)
        return 0;

    /* XXX Nowhere in Exanodes is the return code checked, so we just assert */
    OS_ASSERT_VERBOSE(errno == EINTR, "sem_wait() failed: error 0x%02x", errno);

    return -EINTR;
}
Exemplo n.º 2
0
static int do_status(const char *path, char op, const char *status_str)
{
    rdev_req_status_t status;
    int use_count = -1;
    int err = 0;

    switch (op)
    {
    case 'g':
        /* Get the disk status */
        err = exa_rdev_under_the_hood_do(path, 'g', &status, &use_count);
        if (err != 0)
        {
            fprintf(stderr, "failed getting status of %s: error %d\n", path, err);
            return err;
        }
        printf("use_count = %d\n", use_count);
        printf("status    = %s (%d)\n", status_info_str(status), status);
        break;

    case 's':
        /* Set the disk status */
        err = rdev_status_from_str(&status, status_str);
        if (err != 0)
        {
            fprintf(stderr, "invalid status: %s\n", status_str);
            return err;
        }
        err = exa_rdev_under_the_hood_do(path, 's', &status, &use_count);
        if (err != 0)
        {
            fprintf(stderr, "failed setting status of %s: error %d\n", path, err);
            return err;
        }
        break;

    default:
        OS_ASSERT_VERBOSE(false, "invalid op: '%c'", op);
    }

    return err;
}