fs/vfs: Add a new argument(size_t len) to inode_getpath
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
0f243bde33
commit
08ababd704
|
@ -224,13 +224,14 @@ static int binfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ret = inode_getpath(filep->f_inode, ptr);
|
ret = inode_getpath(filep->f_inode, ptr, PATH_MAX);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcat(ptr, builtin_getname((int)((uintptr_t)filep->f_priv)));
|
strlcat(ptr, builtin_getname((int)((uintptr_t)filep->f_priv)),
|
||||||
|
PATH_MAX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int inode_getpath(FAR struct inode *node, FAR char *path)
|
int inode_getpath(FAR struct inode *node, FAR char *path, size_t len)
|
||||||
{
|
{
|
||||||
if (path == NULL)
|
if (path == NULL)
|
||||||
{
|
{
|
||||||
|
@ -55,17 +55,17 @@ int inode_getpath(FAR struct inode *node, FAR char *path)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int ret = inode_getpath(node->i_parent, path);
|
int ret = inode_getpath(node->i_parent, path, len);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
strcat(path, node->i_name);
|
strlcat(path, node->i_name, len);
|
||||||
if (node->i_child || INODE_IS_MOUNTPT(node))
|
if (node->i_child || INODE_IS_MOUNTPT(node))
|
||||||
{
|
{
|
||||||
strcat(path, "/");
|
strlcat(path, "/", len);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
|
|
@ -279,7 +279,7 @@ int inode_chstat(FAR struct inode *inode,
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int inode_getpath(FAR struct inode *node, FAR char *path);
|
int inode_getpath(FAR struct inode *node, FAR char *path, size_t len);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: inode_free
|
* Name: inode_free
|
||||||
|
|
|
@ -599,8 +599,8 @@ static int romfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||||
if (cmd == FIOC_FILEPATH)
|
if (cmd == FIOC_FILEPATH)
|
||||||
{
|
{
|
||||||
FAR char *ptr = (FAR char *)((uintptr_t)arg);
|
FAR char *ptr = (FAR char *)((uintptr_t)arg);
|
||||||
inode_getpath(filep->f_inode, ptr);
|
inode_getpath(filep->f_inode, ptr, PATH_MAX);
|
||||||
strcat(ptr, rf->rf_path);
|
strlcat(ptr, rf->rf_path, PATH_MAX);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -599,7 +599,7 @@ int dir_allocate(FAR struct file *filep, FAR const char *relpath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inode_getpath(inode, path_prefix);
|
inode_getpath(inode, path_prefix, sizeof(path_prefix));
|
||||||
ret = asprintf(&dir->fd_path, "%s%s/", path_prefix, relpath);
|
ret = asprintf(&dir->fd_path, "%s%s/", path_prefix, relpath);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -105,7 +105,7 @@ int file_vioctl(FAR struct file *filep, int req, va_list ap)
|
||||||
case FIOC_FILEPATH:
|
case FIOC_FILEPATH:
|
||||||
if (ret == -ENOTTY && !INODE_IS_MOUNTPT(inode))
|
if (ret == -ENOTTY && !INODE_IS_MOUNTPT(inode))
|
||||||
{
|
{
|
||||||
ret = inode_getpath(inode, (FAR char *)(uintptr_t)arg);
|
ret = inode_getpath(inode, (FAR char *)(uintptr_t)arg, PATH_MAX);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue