diff options
author | Keith Bostic <keith@wiredtiger.com> | 2016-04-19 14:17:33 -0400 |
---|---|---|
committer | Keith Bostic <keith@wiredtiger.com> | 2016-04-19 14:17:33 -0400 |
commit | 1f5a2e6506e8a7b1a1f6a0a8575d87a6875ba7a7 (patch) | |
tree | 05183ddfa6b99ae9272383eddb8b6d786d487a45 /src/os_posix | |
parent | ebb9e42dc231834259ed65b46ffdf0de7cbecd42 (diff) | |
parent | 8c145ec156a2daf6651c8df89e971ac034650a70 (diff) | |
download | mongo-1f5a2e6506e8a7b1a1f6a0a8575d87a6875ba7a7.tar.gz |
Merge branch 'develop' into wt-2539
Diffstat (limited to 'src/os_posix')
-rw-r--r-- | src/os_posix/os_fs.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/os_posix/os_fs.c b/src/os_posix/os_fs.c index c43a3babd2c..3e571c14bdf 100644 --- a/src/os_posix/os_fs.c +++ b/src/os_posix/os_fs.c @@ -83,10 +83,8 @@ __posix_directory_sync(WT_SESSION_IMPL *session, const char *path) #ifdef __linux__ WT_DECL_RET; int fd, tret; - const char *dir; - char *copy; + char *copy, *dir; - tret = 0; /* * POSIX 1003.1 does not require that fsync of a file handle ensures the * entry in the directory containing the file has also reached disk (and @@ -94,16 +92,20 @@ __posix_directory_sync(WT_SESSION_IMPL *session, const char *path) * fsync on a file descriptor for the directory to be sure. */ copy = NULL; - if (path == NULL || (dir = strrchr(path, '/')) == NULL) + if (path == NULL || strchr(path, '/') == NULL) path = S2C(session)->home; else { /* - * Copy the directory name, leaving the trailing slash in place, - * so a path of "/foo" doesn't result in an empty string. + * File name construction should not return a path without any + * slash separator, but caution isn't unreasonable. */ - WT_RET(__wt_strndup( - session, path, (size_t)(dir - path) + 1, ©)); - path = copy; + WT_RET(__wt_filename(session, path, ©)); + if ((dir = strrchr(copy, '/')) == NULL) + path = S2C(session)->home; + else { + dir[1] = '\0'; + path = copy; + } } WT_SYSCALL_RETRY(( |