Example #1
0
static int rtems_jffs2_rename(
	const rtems_filesystem_location_info_t *oldparentloc,
	const rtems_filesystem_location_info_t *oldloc,
	const rtems_filesystem_location_info_t *newparentloc,
	const char *name,
	size_t namelen
)
{
	struct _inode *old_dir_i = rtems_jffs2_get_inode_by_location(oldparentloc);
	struct _inode *new_dir_i = rtems_jffs2_get_inode_by_location(newparentloc);
	struct _inode *d_inode = rtems_jffs2_get_inode_by_location(oldloc);
	char *oldname;
	size_t oldnamelen;
	int eno = rtems_jffs2_cache_fd_name(d_inode, &oldname, &oldnamelen);

	if (eno == 0) {
		eno = -jffs2_rename(old_dir_i, d_inode, oldname, oldnamelen, new_dir_i, name, namelen);
	}

	return rtems_jffs2_eno_to_rv_and_errno(eno);
}
Example #2
0
static int dfs_jffs2_rename(struct dfs_filesystem* fs, 
                     const char* oldpath,
					 const char* newpath)
{
	int result;
	cyg_mtab_entry * mte;
			
	result = _find_fs(&mte, fs->dev_id);		
	if (result) 
		return -DFS_STATUS_ENOENT;
			
	if (*oldpath == '/')
		oldpath += 1;
	if (*newpath == '/')
		newpath += 1;
	rt_mutex_take(&jffs2_lock, RT_WAITING_FOREVER);
	result = jffs2_rename(mte, mte->root, oldpath, mte->root, newpath);
	rt_mutex_release(&jffs2_lock);
	if (result)
		return jffs2_result_to_dfs(result);
	return 0;
}