rem: return EBADF;
add: return FS_EBADF;
context: remove_fd(bool kernel, int fd, int type){    ofile       *f;    fdarray     *fds;    long        cnt;    int         err;    f = NULL;    if (kernel)        fds = global_fds;    else        fds = get_cur_ioctx()->fds;    LOCK(fds->lock);    if ((fd >= 0) && (fd < fds->num) && fds->fds[fd]) {        f = fds->fds[fd];        if (f->type == type) {            SETBIT(fds->alloc, fd, 0);            fds->fds[fd] = NULL;        } else            f = NULL;    }    UNLOCK(fds->lock);    if (f == NULL)        return EBADF;    err = 0;    cnt = atomic_add(&f->ocnt, -1);    if (cnt == 1)        err = invoke_close(f);    cnt = atomic_add(&f->rcnt, -1);    if (cnt == 1)        invoke_free(f);    return err;}