From dba32fdf7860589c52fa73fa3a9a3b798f0eb56e Mon Sep 17 00:00:00 2001 From: Takeshi Nakatani Date: Tue, 11 Oct 2016 10:06:21 +0000 Subject: [PATCH] Trim symbolic link original path in file. --- src/s3fs.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/s3fs.cpp b/src/s3fs.cpp index c886ddf..6e33caa 100644 --- a/src/s3fs.cpp +++ b/src/s3fs.cpp @@ -866,6 +866,11 @@ static int s3fs_readlink(const char* path, char* buf, size_t size) } buf[ressize] = '\0'; + // check buf if it has space words. + string strTmp = trim(string(buf)); + ressize = strTmp.length(); + strcpy(buf, strTmp.c_str()); + FdManager::get()->Close(ent); S3FS_MALLOCTRIM(0); @@ -1172,9 +1177,10 @@ static int s3fs_symlink(const char* from, const char* to) S3FS_PRN_ERR("could not open tmpfile(errno=%d)", errno); return -errno; } - // write - ssize_t from_size = strlen(from); - if(from_size != ent->Write(from, 0, from_size)){ + // write(without space words) + string strFrom = trim(string(from)); + ssize_t from_size = strFrom.size(); + if(from_size != ent->Write(strFrom.c_str(), 0, from_size)){ S3FS_PRN_ERR("could not write tmpfile(errno=%d)", errno); FdManager::get()->Close(ent); return -errno;