diff --git a/fs/vfs/fs_dir.c b/fs/vfs/fs_dir.c index 243116ad06..1f1ad3a5ba 100644 --- a/fs/vfs/fs_dir.c +++ b/fs/vfs/fs_dir.c @@ -24,6 +24,7 @@ #include +#include #include #include @@ -571,6 +572,7 @@ int dir_allocate(FAR struct file *filep, FAR const char *relpath) { FAR struct fs_dirent_s *dir; FAR struct inode *inode = filep->f_inode; + char path_prefix[PATH_MAX]; int ret; /* Is this a node in the pseudo filesystem? Or a mountpoint? */ @@ -596,7 +598,8 @@ int dir_allocate(FAR struct file *filep, FAR const char *relpath) } } - dir->fd_path = strdup(relpath); + inode_getpath(inode, path_prefix); + asprintf(&dir->fd_path, "%s%s/", path_prefix, relpath); filep->f_inode = &g_dir_inode; filep->f_priv = dir; inode_addref(&g_dir_inode);