Skip to content

Commit

Permalink
Fix errno management from Go to C layer
Browse files Browse the repository at this point in the history
set errno in Go based on errors from redisfs layer
C fetch errno from Go
  • Loading branch information
JCapul committed Mar 19, 2019
1 parent 6e23b41 commit 054dd09
Show file tree
Hide file tree
Showing 4 changed files with 196 additions and 169 deletions.
18 changes: 15 additions & 3 deletions src/c/pdwfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,11 @@ int open(const char *pathname, int flags, ...) {
CALL_REAL_OP("open", real_open, pathname, flags, mode)
}

return Open(filename, flags, mode);
int ret = Open(filename, flags, mode);
if (ret < 0) {
errno = GetErrno();
}
return ret;
}

int close(int fd) {
Expand Down Expand Up @@ -286,7 +290,11 @@ int open64(const char *pathname, int flags, ...) {
TRACE("calling libc open64\n");
CALL_REAL_OP("open64", real_open64, pathname, flags, mode)
}
return Open(filename, flags, mode);
int ret = Open(filename, flags, mode);
if (ret < 0) {
errno = GetErrno();
}
return ret;
}

int creat(const char *pathname, mode_t mode) {
Expand Down Expand Up @@ -597,7 +605,11 @@ int unlink(const char *pathname) {
TRACE("calling libc unlink\n");
CALL_REAL_OP("unlink", real_unlink, pathname)
}
return Unlink(filename);
int ret = Unlink(filename);
if (ret < 0) {
errno = GetErrno();
}
return ret;
}


Expand Down
Loading

0 comments on commit 054dd09

Please sign in to comment.