X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/4c753f8d4cabd4104f3f7109823f16be2ebdcce3..8c6bbb14f44b8daed5ea43d80880c6bf2155118b:/src/plugins/file_system/s4u_FileSystem.cpp diff --git a/src/plugins/file_system/s4u_FileSystem.cpp b/src/plugins/file_system/s4u_FileSystem.cpp index 31f743a4f5..15f1871d4b 100644 --- a/src/plugins/file_system/s4u_FileSystem.cpp +++ b/src/plugins/file_system/s4u_FileSystem.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2015-2022. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2015-2023. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -11,18 +11,16 @@ #include #include #include +#include #include #include -#include "src/surf/surf_interface.hpp" - #include #include #include #include XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_file, s4u, "S4U files"); -int sg_storage_max_file_descriptors = 1024; /** @defgroup plugin_filesystem Plugin FileSystem * @@ -37,6 +35,7 @@ template class xbt::Extendable; namespace s4u { simgrid::xbt::Extension FileSystemDiskExt::EXTENSION_ID; simgrid::xbt::Extension FileDescriptorHostExt::EXTENSION_ID; +int FileDescriptorHostExt::max_file_descriptors; const Disk* File::find_local_disk_on(const Host* host) { @@ -77,9 +76,9 @@ File::File(const std::string& fullpath, const_sg_host_t host, void* userdata) : local_disk_ = find_local_disk_on(host); // assign a file descriptor id to the newly opened File - auto* ext = host->extension(); + auto* ext = host->extension(); if (ext->file_descriptor_table == nullptr) { - ext->file_descriptor_table = std::make_unique>(sg_storage_max_file_descriptors); + ext->file_descriptor_table = std::make_unique>(FileDescriptorHostExt::max_file_descriptors); std::iota(ext->file_descriptor_table->rbegin(), ext->file_descriptor_table->rend(), 0); // Fill with ..., 1, 0. } xbt_assert(not ext->file_descriptor_table->empty(), "Too much files are opened! Some have to be closed."); @@ -118,8 +117,7 @@ File* File::open(const std::string& fullpath, const_sg_host_t host, void* userda void File::close() { - std::vector* desc_table = - Host::current()->extension()->file_descriptor_table.get(); + std::vector* desc_table = Host::current()->extension()->file_descriptor_table.get(); kernel::actor::simcall_answered([this, desc_table] { desc_table->push_back(this->desc_id); }); delete this; } @@ -247,7 +245,7 @@ sg_size_t File::tell() const void File::move(const std::string& fullpath) const { /* Check if the new full path is on the same mount point */ - if (fullpath.compare(0, mount_point_.length(), mount_point_) == 0) { + if (fullpath.rfind(mount_point_, 0) == 0) { std::map>* content = nullptr; content = local_disk_->extension()->get_content(); if (content) { @@ -363,9 +361,9 @@ std::map>* FileSystemDiskExt::parse_content( auto* parse_content = new std::map>(); - auto fs = std::unique_ptr(surf_ifsopen(filename)); + auto fs = std::unique_ptr(simgrid::xbt::path_ifsopen(filename)); xbt_assert(not fs->fail(), "Cannot open file '%s' (path=%s)", filename.c_str(), - (boost::join(surf_path, ":")).c_str()); + simgrid::xbt::path_to_string().c_str()); std::string line; std::vector tokens; @@ -469,8 +467,8 @@ static void on_simulation_end() */ void sg_storage_file_system_init() { - sg_storage_max_file_descriptors = 1024; - simgrid::config::bind_flag(sg_storage_max_file_descriptors, "storage/max_file_descriptors", + FileDescriptorHostExt::max_file_descriptors = 1024; + simgrid::config::bind_flag(FileDescriptorHostExt::max_file_descriptors, "storage/max_file_descriptors", "Maximum number of concurrently opened files per host. Default is 1024"); if (not FileSystemDiskExt::EXTENSION_ID.valid()) {