Exemplo n.º 1
0
Arquivo: io.c Projeto: atikinn/EOS
int kclose(int fd) {
    char fbuf[256];
    if (fd_table[fd] == NULL) { 
        sprintf(fbuf, "fd #%d is not opened\r\n", fd);
        kprintf(STDOUT, fbuf);
        return -2;
    }

    fd_table[fd]->vn->ops->close(fd_table[fd]->vn);
    fd_destroy(fd_table[fd]);
    fd_table[fd] = NULL;
    return 0;
}
Exemplo n.º 2
0
int close(int fildes)
{
    fd_t *fd_obj = fd_get(fildes);

    if (!fd_obj) {
        errno = EBADF;
        return -1;
    }

    if (fd_obj->close(fd_obj->internal_fd) < 0) {
        errno = EIO;    // EINTR may not occur since RIOT has no signals yet.
        return -1;
    }

    fd_destroy(fd_obj->internal_fd);

    return 0;
}