示例#1
0
static s32_t ramfs_rename(struct vnode_t * dnode1, struct vnode_t * node1, char * name1, struct vnode_t *dnode2, struct vnode_t * node2, char * name2)
{
	struct ramfs_node *n, *old_n;
	s32_t error;

	if(node2)
	{
		/* remove destination file, first */
		error = ramfs_remove_node(dnode2->v_data, node2->v_data);
		if(error != 0)
			return error;
	}

	/* same directory */
	if(dnode1 == dnode2)
	{
		/* change the name of existing file */
		error = ramfs_rename_node(node1->v_data, name2);
		if(error)
			return error;
	}
	else
	{
		/* create new file or directory */
		old_n = node1->v_data;
		n = ramfs_add_node(dnode2->v_data, name2, VREG);
		if(n == NULL)
			return ENOMEM;

		if(node1->v_type == VREG)
		{
			/* copy file data */
			n->buf = old_n->buf;
			n->size = old_n->size;
			n->buf_len = old_n->buf_len;
		}

		/* remove source file */
		ramfs_remove_node(dnode1->v_data, node1->v_data);
	}

	return 0;
}
示例#2
0
static s32_t ramfs_remove(struct vnode_t * dnode, struct vnode_t * node, char * name)
{
	struct ramfs_node * n;
	s32_t error;

	error = ramfs_remove_node(dnode->v_data, node->v_data);
	if(error != 0)
		return error;

	n = node->v_data;
	if(n->buf != NULL)
		free(n->buf);
	return 0;
}
示例#3
0
文件: ramfs_vnops.c 项目: Zabrane/osv
static int
ramfs_rename(struct vnode *dvp1, struct vnode *vp1, char *name1,
	     struct vnode *dvp2, struct vnode *vp2, char *name2)
{
	struct ramfs_node *np, *old_np;
	int error;

	if (vp2) {
		/* Remove destination file, first */
		error = ramfs_remove_node(dvp2->v_data, vp2->v_data);
		if (error)
			return error;
	}
	/* Same directory ? */
	if (dvp1 == dvp2) {
		/* Change the name of existing file */
		error = ramfs_rename_node(vp1->v_data, name2);
		if (error)
			return error;
	} else {
		/* Create new file or directory */
		old_np = vp1->v_data;
		np = ramfs_add_node(dvp2->v_data, name2, VREG);
		if (np == NULL)
			return ENOMEM;

		if (vp1->v_type == VREG) {
			/* Copy file data */
			np->rn_buf = old_np->rn_buf;
			np->rn_size = old_np->rn_size;
			np->rn_bufsize = old_np->rn_bufsize;
		}
		/* Remove source file */
		ramfs_remove_node(dvp1->v_data, vp1->v_data);
	}
	return 0;
}
示例#4
0
/* Remove a file */
static int ramfs_remove(vnode_t dvp, vnode_t vp, char *name)
{
  struct ramfs_node *np;
  int error;

  DPRINTF(AFSDB_CORE, ("remove %s in %s\n", name, dvp->v_path));
  error = ramfs_remove_node(dvp->v_data, vp->v_data);
  if (error)
    return error;

  np = vp->v_data;
  if (np->rn_buf != NULL)
    vm_free(getpid(), np->rn_buf, np->rn_bufsize);
  return 0;
}
示例#5
0
文件: ramfs_vnops.c 项目: Zabrane/osv
/* Remove a file */
static int
ramfs_remove(struct vnode *dvp, struct vnode *vp, char *name)
{
	struct ramfs_node *np;
	int error;

	DPRINTF(("remove %s in %s\n", name, dvp->v_path));
	error = ramfs_remove_node(dvp->v_data, vp->v_data);
	if (error)
		return error;

	np = vp->v_data;
	if (np->rn_buf != NULL)
		free(np->rn_buf);
	return 0;
}
示例#6
0
/* Remove a file */
static int
ramfs_remove(vnode_t dvp, vnode_t vp, char *name)
{
	struct ramfs_node *np;

	DPRINTF(("remove %s in %s\n", name, dvp->v_path));
	np = vp->v_data;
	if (np->rn_buf != NULL) {
		if (vp->v_type == VFIFO)
			free(np->rn_buf);
		else
			vm_free(task_self(), np->rn_buf);
		np->rn_buf = NULL; /* incase remove_node fails */
		np->rn_bufsize = 0;
	}
	vp->v_size = 0;
	return ramfs_remove_node(dvp->v_data, np);
}
示例#7
0
/*
 * Create fifo.
 */
static int
ramfs_mkfifo(vnode_t dvp, char *name, mode_t mode)
{
	struct ramfs_node *node;

	DPRINTF(("mkfifo %s in %s\n", name, dvp->v_path));
	if (!S_ISFIFO(mode))
		return EINVAL;

	node = ramfs_add_node(dvp->v_data, name, VFIFO);
	if (node == NULL)
		return ENOMEM;

	node->rn_buf = malloc(PIPE_BUF);
	/* NOTE: node->bufsize node->size abused as fifo read / write counts */
	if (node->rn_buf == NULL) {
		ramfs_remove_node(dvp->v_data, node);
		return ENOMEM;
	}
	return 0;
}
示例#8
0
/* Remove a directory */
static int ramfs_rmdir(vnode_t dvp, vnode_t vp, char *name)
{
  return ramfs_remove_node(dvp->v_data, vp->v_data);
}
示例#9
0
文件: ramfs_vnops.c 项目: Zabrane/osv
/* Remove a directory */
static int
ramfs_rmdir(struct vnode *dvp, struct vnode *vp, char *name)
{

	return ramfs_remove_node(dvp->v_data, vp->v_data);
}
示例#10
0
文件: ramfs_vnops.c 项目: alexcmd/osv
/* Remove a file */
static int
ramfs_remove(struct vnode *dvp, struct vnode *vp, char *name)
{
	DPRINTF(("remove %s in %s\n", name, dvp->v_path));
	return ramfs_remove_node(dvp->v_data, vp->v_data);
}
示例#11
0
static s32_t ramfs_rmdir(struct vnode_t * dnode, struct vnode_t * node, char * name)
{
	return ramfs_remove_node(dnode->v_data, node->v_data);
}