1 /* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #include <simgrid/plugins/file_system.h>
7 #include <simgrid/s4u.hpp>
10 #define INMEGA (1024 * 1024)
12 XBT_LOG_NEW_DEFAULT_CATEGORY(remote_io, "Messages specific for this io example");
14 static void host(int argc, char* argv[])
16 simgrid::s4u::File file(argv[1], nullptr);
17 const char* filename = file.get_path();
18 XBT_INFO("Opened file '%s'", filename);
20 XBT_INFO("Try to write %llu MiB to '%s'", file.size() / 1024, filename);
21 sg_size_t write = file.write(file.size() * 1024);
22 XBT_INFO("Have written %llu MiB to '%s'.", write / (1024 * 1024), filename);
25 if (std::stoi(argv[4]) != 0) {
26 XBT_INFO("Move '%s' (of size %llu) from '%s' to '%s'", filename, file.size(),
27 simgrid::s4u::Host::current()->get_cname(), argv[2]);
28 file.remote_move(simgrid::s4u::Host::by_name(argv[2]), argv[3]);
30 XBT_INFO("Copy '%s' (of size %llu) from '%s' to '%s'", filename, file.size(),
31 simgrid::s4u::Host::current()->get_cname(), argv[2]);
32 file.remote_copy(simgrid::s4u::Host::by_name(argv[2]), argv[3]);
37 int main(int argc, char** argv)
39 simgrid::s4u::Engine e(&argc, argv);
40 sg_storage_file_system_init();
41 e.load_platform(argv[1]);
42 e.register_function("host", host);
43 e.load_deployment(argv[2]);
44 std::vector<simgrid::s4u::Host*> all_hosts = e.get_all_hosts();
46 for (auto const& h : all_hosts) {
47 for (auto const& d : h->get_disks())
48 XBT_INFO("Init: %s: %llu/%llu MiB used/free on '%s@%s'", h->get_cname(), sg_disk_get_size_used(d) / INMEGA,
49 sg_disk_get_size_free(d) / INMEGA, d->get_cname(), d->get_host()->get_cname());
54 for (auto const& h : all_hosts) {
55 for (auto const& d : h->get_disks())
56 XBT_INFO("End: %llu/%llu MiB used/free on '%s@%s'", sg_disk_get_size_used(d) / INMEGA,
57 sg_disk_get_size_free(d) / INMEGA, d->get_cname(), h->get_cname());
60 XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());