rem: file_cookie cookie;
add: fs_cookie cookie;
context: dir_vnode_to_path(struct vnode *vnode, char *buffer, size_t bufferSize){	/* this implementation is currently bound to SYS_MAX_PATH_LEN */	char path[SYS_MAX_PATH_LEN];	int32 insert = sizeof(path);	int32 maxLevel = 256;	int32 length;	status_t status;	if (vnode == NULL || buffer == NULL)		return EINVAL;	// we don't use get_vnode() here because this call is more	// efficient and does all we need from get_vnode()	inc_vnode_ref_count(vnode);	path[--insert] = '\0';		while (true) {		// the name buffer is also used for fs_read_dir()		char nameBuffer[sizeof(struct dirent) + B_FILE_NAME_LENGTH];		char *name = &((struct dirent *)nameBuffer)->d_name[0];		struct vnode *parentVnode;		vnode_id parentID, id;		int type;		// lookup the parent vnode		status = FS_CALL(vnode,fs_lookup)(vnode->mount->cookie,vnode->private_node,"..",&parentID,&type);		if (status < B_OK)			goto out;		mutex_lock(&gVnodeMutex);		parentVnode = lookup_vnode(vnode->fs_id, parentID);		mutex_unlock(&gVnodeMutex);				if (parentVnode == NULL) {			panic("dir_vnode_to_path: could not lookup vnode (fsid 0x%x vnid 0x%Lx)\n", vnode->fs_id, parentID);			status = B_ENTRY_NOT_FOUND;			goto out;		}		// Does the file system support getting the name of a vnode?		// If so, get it here...		if (status == B_OK && FS_CALL(vnode,fs_get_vnode_name))			status = FS_CALL(vnode,fs_get_vnode_name)(vnode->mount->cookie,vnode->private_node,name,B_FILE_NAME_LENGTH);		// ... if not, find it out later (by iterating through		// the parent directory, searching for the id)		id = vnode->id;		// release the current vnode, we only need its parent from now on		put_vnode(vnode);		vnode = parentVnode;		if (status < B_OK)			goto out;		// ToDo: add an explicit check for loops in about 10 levels to do		// real loop detection		// don't go deeper as 'maxLevel' to prevent circular loops		if (maxLevel-- < 0) {			status = ELOOP;			goto out;		}		if (parentID == id) {			// we have reached the root level directory of this file system			// which means we have constructed the full path			break;		}		if (!FS_CALL(vnode,fs_get_vnode_name)) {			// If we don't got the vnode's name yet, we have to search for it			// in the parent directory now			file_cookie cookie;			status = FS_CALL(vnode,fs_open_dir)(vnode->mount->cookie,vnode->private_node,&cookie);			if (status >= B_OK) {				struct dirent *dirent = (struct dirent *)nameBuffer;				while (true) {					uint32 num = 1;					status = FS_CALL(vnode,fs_read_dir)(vnode->mount->cookie,vnode->private_node,cookie,dirent,sizeof(nameBuffer),&num);					if (status < B_OK)						break;										if (id == dirent->d_ino)						// found correct entry!						break;				}				FS_CALL(vnode,fs_close_dir)(vnode->mount->cookie,vnode->private_node,cookie);			}			if (status < B_OK)				goto out;		}		// add the name infront of the current path		name[B_FILE_NAME_LENGTH - 1] = '\0';		length = strlen(name);		insert -= length;		if (insert <= 0) {			status = ENOBUFS;			goto out;		}		memcpy(path + insert, name, length);		path[--insert] = '/';	}	// add the mountpoint	length = strlen(vnode->mount->mount_point);	if (bufferSize - (sizeof(path) - insert) < length + 1) {		status = ENOBUFS;		goto out;	}	memcpy(buffer, vnode->mount->mount_point, length);	if (insert != sizeof(path))		memcpy(buffer + length, path + insert, sizeof(path) - insert);out:	put_vnode(vnode);	return status;}