From 0ed6a7dc6758902f68ecab902c6dcbb31ee637d8 Mon Sep 17 00:00:00 2001 From: Adam Moody Date: Fri, 9 Dec 2022 09:55:17 -0800 Subject: [PATCH] client: allow create on existing file --- client/src/unifyfs-sysio.c | 13 ------------- client/src/unifyfs_fid.c | 6 ++---- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/client/src/unifyfs-sysio.c b/client/src/unifyfs-sysio.c index 96805721c..8fa130b07 100644 --- a/client/src/unifyfs-sysio.c +++ b/client/src/unifyfs-sysio.c @@ -1115,11 +1115,6 @@ static int posix_create(char* upath, mode_t mode) int flags = O_WRONLY | O_CREAT | O_TRUNC; off_t pos; int rc = unifyfs_fid_open(posix_client, upath, flags, mode, &fid, &pos); - if (rc == EEXIST) { - /* POSIX allows O_CREAT on existing file */ - flags = O_WRONLY | O_TRUNC; - rc = unifyfs_fid_open(posix_client, upath, flags, mode, &fid, &pos); - } if (rc != UNIFYFS_SUCCESS) { errno = unifyfs_rc_errno(rc); return -1; @@ -1199,14 +1194,6 @@ int UNIFYFS_WRAP(open)(const char* path, int flags, ...) off_t pos; int rc = unifyfs_fid_open(posix_client, upath, flags, mode, &fid, &pos); - if (rc == EEXIST) { - /* POSIX allows O_CREAT on existing file */ - if ((flags & O_CREAT) && !(flags & O_EXCL)) { - flags -= O_CREAT; - rc = unifyfs_fid_open(posix_client, upath, flags, mode, - &fid, &pos); - } - } if (rc != UNIFYFS_SUCCESS) { errno = unifyfs_rc_errno(rc); return -1; diff --git a/client/src/unifyfs_fid.c b/client/src/unifyfs_fid.c index 7316ae114..30d472ad0 100644 --- a/client/src/unifyfs_fid.c +++ b/client/src/unifyfs_fid.c @@ -487,10 +487,8 @@ int unifyfs_fid_open( * Update our local cache using that metadata. */ unifyfs_fid_update_file_meta(client, fid, &gfattr); - if (!found_local) { - /* it's ok if another client created the shared file */ - ret = UNIFYFS_SUCCESS; - } + /* O_CREAT is valid on an existing file, so long as O_EXCL is not set */ + ret = UNIFYFS_SUCCESS; } else { /* Failed to get metadata for a file that should exist. * Perhaps it was since deleted. We could try to create