From 8c4cf3f2c944b77b941acaef01efdab8d61b01ee Mon Sep 17 00:00:00 2001 From: ligd Date: Sun, 26 Aug 2018 12:12:16 -0600 Subject: [PATCH] fs/hostfs/hostfs.c: Support remote directory names without a trailing '/' --- fs/hostfs/hostfs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fs/hostfs/hostfs.c b/fs/hostfs/hostfs.c index 25534941c0..06050923b4 100644 --- a/fs/hostfs/hostfs.c +++ b/fs/hostfs/hostfs.c @@ -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);