fs/hostfs/hostfs.c: Support remote directory names without a trailing '/'

This commit is contained in:
ligd 2018-08-26 12:12:16 -06:00 committed by Gregory Nutt
parent be542d530a
commit 8c4cf3f2c9
1 changed files with 6 additions and 3 deletions

View File

@ -931,7 +931,7 @@ static int hostfs_bind(FAR struct inode *blkdriver, FAR const void *data,
*/
options = (const char *) data;
if ((strncmp(options, "fs=", 3) != 0) || (strlen(options) < 5))
if ((strncmp(options, "fs=", 3) != 0) || (strlen(options) < 4))
{
return -ENODEV;
}
@ -973,7 +973,7 @@ static int hostfs_bind(FAR struct inode *blkdriver, FAR const void *data,
strncpy(fs->fs_root, &options[3], sizeof(fs->fs_root));
len = strlen(fs->fs_root);
if (len && fs->fs_root[len-1] == '/')
if (len > 1 && fs->fs_root[len - 1] == '/')
{
/* Remove trailing '/' */
@ -992,7 +992,10 @@ static int hostfs_bind(FAR struct inode *blkdriver, FAR const void *data,
/* Append a '/' to the name now */
strcat(fs->fs_root, "/");
if (fs->fs_root[len-1] != '/')
{
strcat(fs->fs_root, "/");
}
*handle = (FAR void *)fs;
hostfs_semgive(fs);