rem: if (st != STREAM_TYPE_ANY && st != v->stream.type) { err = ERR_VFS_WRONG_STREAM_TYPE; goto err; }
add: cookie = kmalloc(sizeof(struct devfs_cookie)); if (cookie == NULL) return ENOMEM;
context: static int devfs_open(fs_cookie _fs, fs_vnode _v, file_cookie *_cookie, stream_type st, int oflags){	struct devfs *fs = _fs;	struct devfs_vnode *v = _v;	struct devfs_cookie *cookie;	int err = 0;	TRACE(("devfs_open: vnode 0x%x, oflags 0x%x\n", v, oflags));	if (st != STREAM_TYPE_ANY && st != v->stream.type) {		err = ERR_VFS_WRONG_STREAM_TYPE;		goto err;	}	cookie = kmalloc(sizeof(struct devfs_cookie));	if (cookie == NULL) {		err = ENOMEM;		goto err;	}	mutex_lock(&fs->lock);	cookie->s = &v->stream;	switch(v->stream.type) {		case STREAM_TYPE_DIR:			cookie->u.dir.ptr = v->stream.u.dir.dir_head;			break;		case STREAM_TYPE_DEVICE:			// call the device call, but unlock the devfs first			mutex_unlock(&fs->lock);			err = v->stream.u.dev.calls->open(v->name, oflags, &cookie->u.dev.dcookie);			mutex_lock(&fs->lock);			break;		default:			err = ERR_VFS_WRONG_STREAM_TYPE;			kfree(cookie);	}	*_cookie = cookie;	mutex_unlock(&fs->lock);err:	return err;}