Skip to content

Commit

Permalink
client: allow create on existing file
Browse files Browse the repository at this point in the history
  • Loading branch information
adammoody committed Dec 9, 2022
1 parent a13edaf commit 0ed6a7d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 17 deletions.
13 changes: 0 additions & 13 deletions client/src/unifyfs-sysio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 2 additions & 4 deletions client/src/unifyfs_fid.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0ed6a7d

Please sign in to comment.