Line data Source code
1 : /* 2 : Copyright 2018-2024, Barcelona Supercomputing Center (BSC), Spain 3 : Copyright 2015-2024, Johannes Gutenberg Universitaet Mainz, Germany 4 : 5 : This software was partially supported by the 6 : EC H2020 funded project NEXTGenIO (Project ID: 671951, www.nextgenio.eu). 7 : 8 : This software was partially supported by the 9 : ADA-FS project under the SPPEXA project funded by the DFG. 10 : 11 : This file is part of GekkoFS' POSIX interface. 12 : 13 : GekkoFS' POSIX interface is free software: you can redistribute it and/or 14 : modify it under the terms of the GNU Lesser General Public License as 15 : published by the Free Software Foundation, either version 3 of the License, 16 : or (at your option) any later version. 17 : 18 : GekkoFS' POSIX interface is distributed in the hope that it will be useful, 19 : but WITHOUT ANY WARRANTY; without even the implied warranty of 20 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 : GNU Lesser General Public License for more details. 22 : 23 : You should have received a copy of the GNU Lesser General Public License 24 : along with GekkoFS' POSIX interface. If not, see 25 : <https://www.gnu.org/licenses/>. 26 : 27 : SPDX-License-Identifier: LGPL-3.0-or-later 28 : */ 29 : 30 : #ifndef GEKKOFS_PRELOAD_UTIL_HPP 31 : #define GEKKOFS_PRELOAD_UTIL_HPP 32 : 33 : #include <client/preload.hpp> 34 : #include <common/metadata.hpp> 35 : #include <string> 36 : #include <iostream> 37 : #include <map> 38 : #include <type_traits> 39 : #include <optional> 40 : 41 : namespace gkfs::metadata { 42 : 43 : struct MetadentryUpdateFlags { 44 : bool atime = false; 45 : bool mtime = false; 46 : bool ctime = false; 47 : bool uid = false; 48 : bool gid = false; 49 : bool mode = false; 50 : bool link_count = false; 51 : bool size = false; 52 : bool blocks = false; 53 : bool path = false; 54 : }; 55 : 56 : } // namespace gkfs::metadata 57 : 58 : // Hermes instance 59 : namespace hermes { 60 : class async_engine; 61 : } 62 : 63 : extern std::unique_ptr<hermes::async_engine> ld_network_service; 64 : 65 : // function definitions 66 : namespace gkfs::utils { 67 : template <typename E> 68 : constexpr typename std::underlying_type<E>::type 69 47 : to_underlying(E e) { 70 : return static_cast<typename std::underlying_type<E>::type>(e); 71 : } 72 : 73 : std::optional<gkfs::metadata::Metadata> 74 : get_metadata(const std::string& path, bool follow_links = false); 75 : 76 : int 77 : metadata_to_stat(const std::string& path, const gkfs::metadata::Metadata& md, 78 : struct stat& attr); 79 : 80 : void 81 : load_hosts(); 82 : 83 : void 84 : load_forwarding_map(); 85 : 86 : std::vector<std::pair<std::string, std::string>> 87 : read_hosts_file(); 88 : 89 : void 90 : connect_to_hosts(const std::vector<std::pair<std::string, std::string>>& hosts); 91 : 92 : } // namespace gkfs::utils 93 : 94 : #endif // GEKKOFS_PRELOAD_UTIL_HPP