Commit 3bebfc0b authored by Ramon Nou's avatar Ramon Nou
Browse files

Merge branch 'rnou/44-integrate-expand' into 'main'

Draft: Resolve "Integrate expand"

Closes #44

See merge request !31
parents d97afd3d 5b791554
Loading
Loading
Loading
Loading
Loading
+15 −11
Original line number Diff line number Diff line
################################################################################
# Copyright 2022-2023, Barcelona Supercomputing Center (BSC), Spain            #
# Copyright 2018-2024, Barcelona Supercomputing Center (BSC), Spain            #
# Copyright 2015-2024, Johannes Gutenberg Universitaet Mainz, Germany          #
#                                                                              #
# This software was partially supported by the EuroHPC-funded project ADMIRE   #
#   (Project ID: 956748, https://www.admire-eurohpc.eu).                       #
# This software was partially supported by the                                 #
# EC H2020 funded project NEXTGenIO (Project ID: 671951, www.nextgenio.eu).    #
#                                                                              #
# This file is part of cargo.                                                  #
# This software was partially supported by the                                 #
# ADA-FS project under the SPPEXA project funded by the DFG.                   #
#                                                                              #
# cargo is free software: you can redistribute it and/or modify                #
# This file is part of GekkoFS.                                                #
#                                                                              #
# GekkoFS is free software: you can redistribute it and/or modify              #
# it under the terms of the GNU General Public License as published by         #
# the Free Software Foundation, either version 3 of the License, or            #
# (at your option) any later version.                                          #
#                                                                              #
# cargo is distributed in the hope that it will be useful,                     #
# GekkoFS is distributed in the hope that it will be useful,                   #
# but WITHOUT ANY WARRANTY; without even the implied warranty of               #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                #
# GNU General Public License for more details.                                 #
#                                                                              #
# You should have received a copy of the GNU General Public License            #
# along with cargo.  If not, see <https://www.gnu.org/licenses/>.              #
# along with GekkoFS.  If not, see <https://www.gnu.org/licenses/>.            #
#                                                                              #
# SPDX-License-Identifier: GPL-3.0-or-later                                    #
################################################################################


find_path(Expand_INCLUDE_DIR
  NAMES user_functions.hpp
  PREFIX gkfs
  NAMES xpn.h
  PREFIX xpn
)

find_library(Expand_LIBRARY
  NAMES libexpand_user_lib.so
  NAMES libxpn.so
)

include(FindPackageHandleStandardArgs)
+22 −9
Original line number Diff line number Diff line
@@ -3,17 +3,28 @@
#include "expand_plugin.hpp"


#ifdef __cplusplus
extern "C" {
#endif

#include "xpn.h"

#ifdef __cplusplus
}
#endif


#include <iostream>
namespace cargo {
expand_plugin::expand_plugin() {
    int result = expand_init();
    int result = xpn_init();
    if (result != 0) {
        std::cerr << "Failed to initialize expand" << std::endl;
    }
}

expand_plugin::~expand_plugin() {
    int result = expand_end();
    int result = xpn_destroy();
    if (result != 0) {
        std::cerr << "Failed to finalize expand" << std::endl;
    }
@@ -21,36 +32,38 @@ expand_plugin::~expand_plugin() {
// Override the open function
int
expand_plugin::open(const std::string& path, int flags, unsigned int mode) {
    return expand_open(path, flags, mode);
    return xpn_open(path, flags, mode);
}

// Override the pread function
ssize_t
expand_plugin::pread(int fd, void* buf, size_t count, off_t offset) {
    return expand_pread_ws(fd, buf, count, offset);
    xpn_lseek(fd, offset, SEEK_SET);
    return xpn_read(fd, buf, count);
}

// Override the pwrite function
ssize_t
expand_plugin::pwrite(int fd, const void* buf, size_t count, off_t offset) {
    return expand_pwrite_ws(fd, buf, count, offset);
    xpn_lseek(fd, offset, SEEK_SET);
    return xpn_write(fd, buf, count);
}


bool
expand_plugin::mkdir(const std::string& path, mode_t mode) {
    int result = expand_create(path, mode | S_IFDIR);
    int result = xpn_mkdir(path, mode);
    return result;
}

bool
expand_plugin::close(int fd) {
    return expand_close(fd);
    return xpn_close(fd);
}

off_t
expand_plugin::lseek(int fd, off_t offset, int whence) {
    return expand_lseek(fd, offset, whence);
    return xpn_lseek(fd, offset, whence);
}

off_t
+1 −0
Original line number Diff line number Diff line


#ifndef EXPAND_PLUGIN_HPP
#define EXPAND_PLUGIN_HPP