Verified Commit e0099267 authored by Marc Vef's avatar Marc Vef
Browse files

Stop leaking internal errno during client init

This was previously causing an errno of 115 during tests. While an errno of 0 is not guaranteed on success, all errno's within GKFS should be kept internal.
parent 4e873c61
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -1017,7 +1017,6 @@ int gkfs_getdents64(unsigned int fd,
 * @return 0 on success or -1 on error
 */
int gkfs_mk_symlink(const std::string& path, const std::string& target_path) {
    gkfs::preload::init_ld_env_if_needed();
    /* The following check is not POSIX compliant.
     * In POSIX the target is not checked at all.
    *  Here if the target is a directory we raise a NOTSUP error.
@@ -1064,7 +1063,6 @@ int gkfs_mk_symlink(const std::string& path, const std::string& target_path) {
 * @return 0 on success or -1 on error
 */
int gkfs_readlink(const std::string& path, char* buf, int bufsize) {
    gkfs::preload::init_ld_env_if_needed();
    auto md = gkfs::util::get_metadata(path, false);
    if (md == nullptr) {
        LOG(DEBUG, "Named link doesn't exist");
+1 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ extern "C" {

namespace {

// TODO replace all internal gkfs errno variable usage with LEAF
inline int with_errno(int ret) {
    return (ret < 0) ? -errno : ret;
}
+3 −0
Original line number Diff line number Diff line
@@ -220,6 +220,8 @@ void init_ld_env_if_needed() {
 * Called initially ONCE when preload library is used with the LD_PRELOAD environment variable
 */
void init_preload() {
    // The original errno value will be restored after initialization to not leak internal error codes
    auto oerrno = errno;

    CTX->enable_interception();
    gkfs::preload::start_self_interception();
@@ -252,6 +254,7 @@ void init_preload() {
#endif

    gkfs::preload::start_interception();
    errno = oerrno;
}

/**