Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
remove FileImpl \o/
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 22 Nov 2017 10:28:23 +0000 (11:28 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 22 Nov 2017 10:28:23 +0000 (11:28 +0100)
13 files changed:
examples/msg/io-file/io-file.tesh
examples/msg/io-remote/io-remote.tesh
include/simgrid/forward.h
include/simgrid/s4u/File.hpp
src/msg/msg_io.cpp
src/s4u/s4u_file.cpp
src/simix/smx_io.cpp
src/surf/FileImpl.cpp [deleted file]
src/surf/FileImpl.hpp [deleted file]
src/surf/HostImpl.cpp
src/surf/storage_n11.hpp
src/xbt/log.c
tools/cmake/DefinePackages.cmake

index e0483eb..d3700af 100644 (file)
@@ -5,9 +5,6 @@ $ ${bindir:=.}/io-file ${srcdir:=.}/storage/storage.xml "--log=root.fmt:[%10.6r]
 > [  0.000000] (1:host@alice)  Open file 'c:\Windows\setupact.log'
 > [  0.000000] (2:host@bob)    Open file '/home/doc/simgrid/examples/platforms/nancy.xml'
 > [  0.000000] (3:host@carl)   Open file '/home/doc/simgrid/examples/platforms/g5k_cabinets.xml'
 > [  0.000000] (1:host@alice)  Open file 'c:\Windows\setupact.log'
 > [  0.000000] (2:host@bob)    Open file '/home/doc/simgrid/examples/platforms/nancy.xml'
 > [  0.000000] (3:host@carl)   Open file '/home/doc/simgrid/examples/platforms/g5k_cabinets.xml'
-> [  0.000000] (1:host@alice)  Capacity of the storage element 'c:\Windows\setupact.log' is stored on: 2391537133 / 536870912000
-> [  0.000000] (2:host@bob)    Capacity of the storage element '/home/doc/simgrid/examples/platforms/nancy.xml' is stored on: 36933331 / 536870912000
-> [  0.000000] (3:host@carl)   Capacity of the storage element '/home/doc/simgrid/examples/platforms/g5k_cabinets.xml' is stored on: 36933331 / 536870912000
 > [  0.000000] (4:host@denise) File Descriptor information:
 >              Full path: '/home/doc/simgrid/examples/platforms/g5k.xml'
 >              Size: 17028
 > [  0.000000] (4:host@denise) File Descriptor information:
 >              Full path: '/home/doc/simgrid/examples/platforms/g5k.xml'
 >              Size: 17028
@@ -16,6 +13,9 @@ $ ${bindir:=.}/io-file ${srcdir:=.}/storage/storage.xml "--log=root.fmt:[%10.6r]
 >              Storage Type: 'single_SSD'
 >              File Descriptor Id: 0
 > [  0.000000] (4:host@denise)         Open file '/home/doc/simgrid/examples/platforms/g5k.xml'
 >              Storage Type: 'single_SSD'
 >              File Descriptor Id: 0
 > [  0.000000] (4:host@denise)         Open file '/home/doc/simgrid/examples/platforms/g5k.xml'
+> [  0.000000] (1:host@alice)  Capacity of the storage element 'c:\Windows\setupact.log' is stored on: 2391537133 / 536870912000
+> [  0.000000] (2:host@bob)    Capacity of the storage element '/home/doc/simgrid/examples/platforms/nancy.xml' is stored on: 36933331 / 536870912000
+> [  0.000000] (3:host@carl)   Capacity of the storage element '/home/doc/simgrid/examples/platforms/g5k_cabinets.xml' is stored on: 36933331 / 536870912000
 > [  0.000000] (4:host@denise)         Capacity of the storage element '/home/doc/simgrid/examples/platforms/g5k.xml' is stored on: 13221994 / 536870912000
 > [  0.000040] (2:host@bob)    Have read 4028 from '/home/doc/simgrid/examples/platforms/nancy.xml'
 > [  0.000085] (4:host@denise)         Have read 17028 from '/home/doc/simgrid/examples/platforms/g5k.xml'
 > [  0.000000] (4:host@denise)         Capacity of the storage element '/home/doc/simgrid/examples/platforms/g5k.xml' is stored on: 13221994 / 536870912000
 > [  0.000040] (2:host@bob)    Have read 4028 from '/home/doc/simgrid/examples/platforms/nancy.xml'
 > [  0.000085] (4:host@denise)         Have read 17028 from '/home/doc/simgrid/examples/platforms/g5k.xml'
index 46b251e..390369c 100644 (file)
@@ -4,9 +4,6 @@ $ ${bindir:=.}/io-remote$EXEEXT ${srcdir:=.}/storage/remote_io.xml ${srcdir:=.}/
 > [  0.000000] (0@     ) Init: 12 MiB used on 'Disk1'
 > [  0.000000] (0@     ) Init: 2280 MiB used on 'Disk2'
 > [  0.000000] (1@alice) Opened file 'c:\Windows\setupact.log'
 > [  0.000000] (0@     ) Init: 12 MiB used on 'Disk1'
 > [  0.000000] (0@     ) Init: 2280 MiB used on 'Disk2'
 > [  0.000000] (1@alice) Opened file 'c:\Windows\setupact.log'
-> [  0.000000] (2@  bob) Opened file '/scratch/lib/libsimgrid.so.3.6.2'
-> [  0.000000] (3@ carl) Opened file '/scratch/lib/libsimgrid.so.3.6.2'
-> [  0.000000] (4@ dave) Opened file 'c:\Windows\bootstat.dat'
 > [  0.000000] (1@alice) File Descriptor information:
 >              Full path: 'c:\Windows\setupact.log'
 >              Size: 101663
 > [  0.000000] (1@alice) File Descriptor information:
 >              Full path: 'c:\Windows\setupact.log'
 >              Size: 101663
@@ -14,6 +11,8 @@ $ ${bindir:=.}/io-remote$EXEEXT ${srcdir:=.}/storage/remote_io.xml ${srcdir:=.}/
 >              Storage Id: 'Disk2'
 >              Storage Type: 'SATA-II_HDD'
 >              File Descriptor Id: 0
 >              Storage Id: 'Disk2'
 >              Storage Type: 'SATA-II_HDD'
 >              File Descriptor Id: 0
+> [  0.000000] (1@alice) Try to read 101663 from 'c:\Windows\setupact.log'
+> [  0.000000] (2@  bob) Opened file '/scratch/lib/libsimgrid.so.3.6.2'
 > [  0.000000] (2@  bob) File Descriptor information:
 >              Full path: '/scratch/lib/libsimgrid.so.3.6.2'
 >              Size: 12710497
 > [  0.000000] (2@  bob) File Descriptor information:
 >              Full path: '/scratch/lib/libsimgrid.so.3.6.2'
 >              Size: 12710497
@@ -21,6 +20,8 @@ $ ${bindir:=.}/io-remote$EXEEXT ${srcdir:=.}/storage/remote_io.xml ${srcdir:=.}/
 >              Storage Id: 'Disk1'
 >              Storage Type: 'SATA-II_HDD'
 >              File Descriptor Id: 0
 >              Storage Id: 'Disk1'
 >              Storage Type: 'SATA-II_HDD'
 >              File Descriptor Id: 0
+> [  0.000000] (2@  bob) Try to read 12710497 from '/scratch/lib/libsimgrid.so.3.6.2'
+> [  0.000000] (3@ carl) Opened file '/scratch/lib/libsimgrid.so.3.6.2'
 > [  0.000000] (3@ carl) File Descriptor information:
 >              Full path: '/scratch/lib/libsimgrid.so.3.6.2'
 >              Size: 12710497
 > [  0.000000] (3@ carl) File Descriptor information:
 >              Full path: '/scratch/lib/libsimgrid.so.3.6.2'
 >              Size: 12710497
@@ -28,6 +29,8 @@ $ ${bindir:=.}/io-remote$EXEEXT ${srcdir:=.}/storage/remote_io.xml ${srcdir:=.}/
 >              Storage Id: 'Disk1'
 >              Storage Type: 'SATA-II_HDD'
 >              File Descriptor Id: 0
 >              Storage Id: 'Disk1'
 >              Storage Type: 'SATA-II_HDD'
 >              File Descriptor Id: 0
+> [  0.000000] (3@ carl) Try to read 12710497 from '/scratch/lib/libsimgrid.so.3.6.2'
+> [  0.000000] (4@ dave) Opened file 'c:\Windows\bootstat.dat'
 > [  0.000000] (4@ dave) File Descriptor information:
 >              Full path: 'c:\Windows\bootstat.dat'
 >              Size: 67584
 > [  0.000000] (4@ dave) File Descriptor information:
 >              Full path: 'c:\Windows\bootstat.dat'
 >              Size: 67584
@@ -35,9 +38,6 @@ $ ${bindir:=.}/io-remote$EXEEXT ${srcdir:=.}/storage/remote_io.xml ${srcdir:=.}/
 >              Storage Id: 'Disk2'
 >              Storage Type: 'SATA-II_HDD'
 >              File Descriptor Id: 0
 >              Storage Id: 'Disk2'
 >              Storage Type: 'SATA-II_HDD'
 >              File Descriptor Id: 0
-> [  0.000000] (1@alice) Try to read 101663 from 'c:\Windows\setupact.log'
-> [  0.000000] (2@  bob) Try to read 12710497 from '/scratch/lib/libsimgrid.so.3.6.2'
-> [  0.000000] (3@ carl) Try to read 12710497 from '/scratch/lib/libsimgrid.so.3.6.2'
 > [  0.000000] (4@ dave) Try to read 67584 from 'c:\Windows\bootstat.dat'
 > [  0.001469] (4@ dave) Have read 67584 from 'c:\Windows\bootstat.dat'. Offset is now at: 67584
 > [  0.001469] (4@ dave) Seek back to the begining of the stream...
 > [  0.000000] (4@ dave) Try to read 67584 from 'c:\Windows\bootstat.dat'
 > [  0.001469] (4@ dave) Have read 67584 from 'c:\Windows\bootstat.dat'. Offset is now at: 67584
 > [  0.001469] (4@ dave) Seek back to the begining of the stream...
index c59cd23..9a996b9 100644 (file)
@@ -56,7 +56,6 @@ namespace surf {
   class HostImpl;
   class StorageImpl;
   class StorageType;
   class HostImpl;
   class StorageImpl;
   class StorageType;
-  class FileImpl;
 }
 namespace trace_mgr {
   class trace;
 }
 namespace trace_mgr {
   class trace;
index dca7d83..70249e3 100644 (file)
@@ -27,10 +27,10 @@ XBT_PUBLIC_CLASS File
 public:
   File(std::string fullpath, void* userdata);
   File(std::string fullpath, sg_host_t host, void* userdata);
 public:
   File(std::string fullpath, void* userdata);
   File(std::string fullpath, sg_host_t host, void* userdata);
-  ~File();
+  ~File() = default;
 
   /** Retrieves the path to the file */
 
   /** Retrieves the path to the file */
-  const char* getPath() { return path_.c_str(); }
+  const char* getPath() { return fullpath_.c_str(); }
 
   /** Simulates a local read action. Returns the size of data actually read */
   sg_size_t read(sg_size_t size);
 
   /** Simulates a local read action. Returns the size of data actually read */
   sg_size_t read(sg_size_t size);
@@ -59,14 +59,16 @@ public:
   /** Remove a file from disk */
   int unlink();
 
   /** Remove a file from disk */
   int unlink();
 
-  std::string mount_point;
-  Storage* localStorage;
   int desc_id = 0;
   int desc_id = 0;
+  Storage* localStorage;
+  std::string mount_point_;
 
 private:
 
 private:
-  simgrid::surf::FileImpl* pimpl_ = nullptr;
+  sg_size_t size_;
   std::string path_;
   std::string path_;
-  void* userdata_ = nullptr;
+  std::string fullpath_;
+  sg_size_t current_position_ = SEEK_SET;
+  void* userdata_             = nullptr;
 };
 }
 } // namespace simgrid::s4u
 };
 }
 } // namespace simgrid::s4u
index 18390a6..1024125 100644 (file)
@@ -73,7 +73,7 @@ void MSG_file_dump (msg_file_t fd){
            "\t\tStorage Id: '%s'\n"
            "\t\tStorage Type: '%s'\n"
            "\t\tFile Descriptor Id: %d",
            "\t\tStorage Id: '%s'\n"
            "\t\tStorage Type: '%s'\n"
            "\t\tFile Descriptor Id: %d",
-           fd->getPath(), fd->size(), fd->mount_point.c_str(), fd->localStorage->getCname(),
+           fd->getPath(), fd->size(), fd->mount_point_.c_str(), fd->localStorage->getCname(),
            fd->localStorage->getType(), fd->desc_id);
 }
 
            fd->localStorage->getType(), fd->desc_id);
 }
 
index af4a32d..5615bac 100644 (file)
@@ -9,7 +9,6 @@
 #include "simgrid/s4u/Host.hpp"
 #include "simgrid/s4u/Storage.hpp"
 #include "simgrid/simix.hpp"
 #include "simgrid/s4u/Host.hpp"
 #include "simgrid/s4u/Storage.hpp"
 #include "simgrid/simix.hpp"
-#include "src/surf/FileImpl.hpp"
 #include "src/surf/HostImpl.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_file,"S4U files");
 #include "src/surf/HostImpl.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_file,"S4U files");
@@ -19,96 +18,139 @@ namespace s4u {
 
 File::File(std::string fullpath, void* userdata) : File(fullpath, Host::current(), userdata){};
 
 
 File::File(std::string fullpath, void* userdata) : File(fullpath, Host::current(), userdata){};
 
-File::File(std::string fullpath, sg_host_t host, void* userdata) : path_(fullpath), userdata_(userdata)
+File::File(std::string fullpath, sg_host_t host, void* userdata) : fullpath_(fullpath), userdata_(userdata)
 {
   // this cannot fail because we get a xbt_die if the mountpoint does not exist
   Storage* st                  = nullptr;
   size_t longest_prefix_length = 0;
 {
   // this cannot fail because we get a xbt_die if the mountpoint does not exist
   Storage* st                  = nullptr;
   size_t longest_prefix_length = 0;
-  std::string path;
   XBT_DEBUG("Search for storage name for '%s' on '%s'", fullpath.c_str(), host->getCname());
 
   for (auto const& mnt : host->getMountedStorages()) {
     XBT_DEBUG("See '%s'", mnt.first.c_str());
   XBT_DEBUG("Search for storage name for '%s' on '%s'", fullpath.c_str(), host->getCname());
 
   for (auto const& mnt : host->getMountedStorages()) {
     XBT_DEBUG("See '%s'", mnt.first.c_str());
-    mount_point = fullpath.substr(0, mnt.first.length());
+    mount_point_ = fullpath.substr(0, mnt.first.length());
 
 
-    if (mount_point == mnt.first && mnt.first.length() > longest_prefix_length) {
+    if (mount_point_ == mnt.first && mnt.first.length() > longest_prefix_length) {
       /* The current mount name is found in the full path and is bigger than the previous*/
       longest_prefix_length = mnt.first.length();
       st                    = mnt.second;
     }
   }
   if (longest_prefix_length > 0) { /* Mount point found, split fullpath into mount_name and path+filename*/
       /* The current mount name is found in the full path and is bigger than the previous*/
       longest_prefix_length = mnt.first.length();
       st                    = mnt.second;
     }
   }
   if (longest_prefix_length > 0) { /* Mount point found, split fullpath into mount_name and path+filename*/
-    mount_point = fullpath.substr(0, longest_prefix_length);
-    path        = fullpath.substr(longest_prefix_length, fullpath.length());
+    mount_point_ = fullpath.substr(0, longest_prefix_length);
+    path_        = fullpath.substr(longest_prefix_length, fullpath.length());
   } else
     xbt_die("Can't find mount point for '%s' on '%s'", fullpath.c_str(), host->getCname());
 
   } else
     xbt_die("Can't find mount point for '%s' on '%s'", fullpath.c_str(), host->getCname());
 
-  pimpl_ =
-      simgrid::simix::kernelImmediate([this, st, path] { return new simgrid::surf::FileImpl(st, path, mount_point); });
   localStorage = st;
   localStorage = st;
-}
 
 
-File::~File()
-{
-  simgrid::simix::kernelImmediate([this] { delete pimpl_; });
+  XBT_DEBUG("\tOpen file '%s'", path_.c_str());
+  std::map<std::string, sg_size_t>* content = localStorage->getContent();
+  // if file does not exist create an empty file
+  auto sz = content->find(path_);
+  if (sz != content->end()) {
+    size_ = sz->second;
+  } else {
+    size_ = 0;
+    content->insert({path_, size_});
+    XBT_DEBUG("File '%s' was not found, file created.", path_.c_str());
+  }
 }
 
 sg_size_t File::read(sg_size_t size)
 {
   XBT_DEBUG("READ %s on disk '%s'", getPath(), localStorage->getCname());
   // if the current position is close to the end of the file, we may not be able to read the requested size
 }
 
 sg_size_t File::read(sg_size_t size)
 {
   XBT_DEBUG("READ %s on disk '%s'", getPath(), localStorage->getCname());
   // if the current position is close to the end of the file, we may not be able to read the requested size
-  sg_size_t read_size = localStorage->read(std::min(size, this->size() - this->tell()));
-  pimpl_->incrPosition(read_size);
+  sg_size_t read_size = localStorage->read(std::min(size, size_ - current_position_));
+  current_position_ += read_size;
   return read_size;
 }
 
 sg_size_t File::write(sg_size_t size)
 {
   return read_size;
 }
 
 sg_size_t File::write(sg_size_t size)
 {
-  XBT_DEBUG("WRITE %s on disk '%s'. size '%llu/%llu'", getPath(), localStorage->getCname(), size, this->size());
+  XBT_DEBUG("WRITE %s on disk '%s'. size '%llu/%llu'", getPath(), localStorage->getCname(), size, size_);
   // If the storage is full before even starting to write
   if (localStorage->getSizeUsed() >= localStorage->getSize())
     return 0;
   /* Substract the part of the file that might disappear from the used sized on the storage element */
   // If the storage is full before even starting to write
   if (localStorage->getSizeUsed() >= localStorage->getSize())
     return 0;
   /* Substract the part of the file that might disappear from the used sized on the storage element */
-  localStorage->decrUsedSize(this->size() - this->tell());
+  localStorage->decrUsedSize(size_ - current_position_);
 
   sg_size_t write_size = localStorage->write(size);
 
   sg_size_t write_size = localStorage->write(size);
-  pimpl_->incrPosition(write_size);
-  pimpl_->setSize(this->tell());
+  current_position_ += write_size;
+  size_ = current_position_;
 
 
-  localStorage->getContent()->erase(pimpl_->getName());
-  localStorage->getContent()->insert({pimpl_->getName(), this->size()});
+  localStorage->getContent()->erase(path_);
+  localStorage->getContent()->insert({path_, size_});
 
   return write_size;
 }
 
 sg_size_t File::size()
 {
 
   return write_size;
 }
 
 sg_size_t File::size()
 {
-  return simgrid::simix::kernelImmediate([this] { return pimpl_->size(); });
+  return size_;
 }
 
 }
 
-void File::seek(sg_offset_t pos)
+void File::seek(sg_offset_t offset)
 {
 {
-  simgrid::simix::kernelImmediate([this, pos] { pimpl_->seek(pos, SEEK_SET); });
+  current_position_ = offset;
 }
 
 }
 
-void File::seek(sg_offset_t pos, int origin)
+void File::seek(sg_offset_t offset, int origin)
 {
 {
-  simgrid::simix::kernelImmediate([this, pos, origin] { pimpl_->seek(pos, origin); });
+  switch (origin) {
+    case SEEK_SET:
+      current_position_ = offset;
+      break;
+    case SEEK_CUR:
+      current_position_ += offset;
+      break;
+    case SEEK_END:
+      current_position_ = size_ + offset;
+      break;
+    default:
+      break;
+  }
 }
 
 sg_size_t File::tell()
 {
 }
 
 sg_size_t File::tell()
 {
-  return simgrid::simix::kernelImmediate([this] { return pimpl_->tell(); });
+  return current_position_;
 }
 
 void File::move(std::string fullpath)
 {
 }
 
 void File::move(std::string fullpath)
 {
-  simgrid::simix::kernelImmediate([this, fullpath] { pimpl_->move(fullpath); });
+  /* Check if the new full path is on the same mount point */
+  if (not strncmp(mount_point_.c_str(), fullpath.c_str(), mount_point_.length())) {
+    std::map<std::string, sg_size_t>* content = localStorage->getContent();
+    auto sz = content->find(path_);
+    if (sz != content->end()) { // src file exists
+      sg_size_t new_size = sz->second;
+      content->erase(path_);
+      std::string path = fullpath.substr(mount_point_.length(), fullpath.length());
+      content->insert({path.c_str(), new_size});
+      XBT_DEBUG("Move file from %s to %s, size '%llu'", path_.c_str(), fullpath.c_str(), new_size);
+    } else {
+      XBT_WARN("File %s doesn't exist", path_.c_str());
+    }
+  } else {
+    XBT_WARN("New full path %s is not on the same mount point: %s.", fullpath.c_str(), mount_point_.c_str());
+  }
 }
 
 int File::unlink()
 {
 }
 
 int File::unlink()
 {
-  return simgrid::simix::kernelImmediate([this] { return pimpl_->unlink(); });
+  /* Check if the file is on local storage */
+  if (localStorage->getContent()->find(path_) == localStorage->getContent()->end()) {
+    XBT_WARN("File %s is not on disk %s. Impossible to unlink", path_.c_str(), localStorage->getCname());
+    return -1;
+  } else {
+    XBT_DEBUG("UNLINK %s on disk '%s'", path_.c_str(), localStorage->getCname());
+    localStorage->decrUsedSize(size_);
+
+    // Remove the file from storage
+    localStorage->getContent()->erase(fullpath_);
+
+    return 0;
+  }
 }
 
 }} // namespace simgrid::s4u
 }
 
 }} // namespace simgrid::s4u
index 1f35bf2..39c13a1 100644 (file)
@@ -9,7 +9,6 @@
 
 #include "simgrid/s4u/Host.hpp"
 #include "simgrid/s4u/Storage.hpp"
 
 #include "simgrid/s4u/Host.hpp"
 #include "simgrid/s4u/Storage.hpp"
-#include "src/surf/FileImpl.hpp"
 #include "src/surf/HostImpl.hpp"
 #include "src/surf/StorageImpl.hpp"
 #include "surf/surf.hpp"
 #include "src/surf/HostImpl.hpp"
 #include "src/surf/StorageImpl.hpp"
 #include "surf/surf.hpp"
diff --git a/src/surf/FileImpl.cpp b/src/surf/FileImpl.cpp
deleted file mode 100644 (file)
index 4a85e3d..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/* Copyright (c) 2017. 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. */
-
-#include "src/surf/FileImpl.hpp"
-#include "src/surf/StorageImpl.hpp"
-
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_file, surf, "Logging specific to the SURF file module");
-namespace simgrid {
-namespace surf {
-
-FileImpl::FileImpl(sg_storage_t st, std::string path, std::string mount) : path_(path), mount_point_(mount)
-{
-  XBT_DEBUG("\tOpen file '%s'", path.c_str());
-  location_ = st->getImpl();
-  std::map<std::string, sg_size_t>* content = location_->getContent();
-  // if file does not exist create an empty file
-  auto sz = content->find(path);
-  if (sz != content->end()) {
-    size_ = sz->second;
-  } else {
-    size_ = 0;
-    content->insert({path, size_});
-    XBT_DEBUG("File '%s' was not found, file created.", path.c_str());
-  }
-}
-
-int FileImpl::seek(sg_offset_t offset, int origin)
-{
-  switch (origin) {
-    case SEEK_SET:
-      current_position_ = offset;
-      return 0;
-    case SEEK_CUR:
-      current_position_ += offset;
-      return 0;
-    case SEEK_END:
-      current_position_ = size_ + offset;
-      return 0;
-    default:
-      return -1;
-  }
-}
-
-int FileImpl::unlink()
-{
-  /* Check if the file is on this storage */
-  if (location_->getContent()->find(path_) == location_->getContent()->end()) {
-    XBT_WARN("File %s is not on disk %s. Impossible to unlink", getCname(), location_->getCname());
-    return -1;
-  } else {
-    XBT_DEBUG("UNLINK %s on disk '%s'", getCname(), location_->getCname());
-    location_->usedSize_ -= size_;
-
-    // Remove the file from storage
-    location_->getContent()->erase(path_);
-
-    return 0;
-  }
-}
-
-void FileImpl::move(std::string fullpath)
-{
-  /* Check if the new full path is on the same mount point */
-  if (not strncmp(mount_point_.c_str(), fullpath.c_str(), mount_point_.size())) {
-    std::map<std::string, sg_size_t>* content = location_->getContent();
-    auto sz = content->find(path_);
-    if (sz != content->end()) { // src file exists
-      sg_size_t new_size = sz->second;
-      content->erase(path_);
-      std::string path = fullpath.substr(mount_point_.length(), fullpath.length());
-      content->insert({path.c_str(), new_size});
-      XBT_DEBUG("Move file from %s to %s, size '%llu'", path_.c_str(), fullpath.c_str(), new_size);
-    } else {
-      XBT_WARN("File %s doesn't exist", path_.c_str());
-    }
-  } else {
-    XBT_WARN("New full path %s is not on the same mount point: %s.", fullpath.c_str(), mount_point_.c_str());
-  }
-}
-}
-}
diff --git a/src/surf/FileImpl.hpp b/src/surf/FileImpl.hpp
deleted file mode 100644 (file)
index b7acf36..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Copyright (c) 2017. 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. */
-
-#ifndef SRC_SURF_FILEIMPL_HPP_
-#define SRC_SURF_FILEIMPL_HPP_
-
-#include "surf/surf.hpp"
-#include <string>
-
-namespace simgrid {
-namespace surf {
-
-class FileImpl {
-public:
-  FileImpl(sg_storage_t st, std::string path, std::string mount);
-  ~FileImpl() = default;
-
-  const std::string& getName() const { return path_; }
-  const char* getCname() const { return path_.c_str(); }
-  const char* mount() { return mount_point_.c_str(); }
-  sg_size_t size() { return size_; }
-  void setSize(sg_size_t size) { size_ = size; }
-  void setPosition(sg_size_t size) { current_position_ = size; }
-  void incrPosition(sg_size_t incr) { current_position_ += incr; }
-  sg_size_t tell() { return current_position_; }
-  int seek(sg_offset_t offset, int origin);
-  int unlink();
-  void move(std::string fullpath);
-
-private:
-  StorageImpl* location_;
-  std::string path_;
-  std::string mount_point_;
-  sg_size_t size_;
-  sg_size_t current_position_ = SEEK_SET;
-};
-}
-}
-#endif /* SRC_SURF_FILEIMPL_HPP_ */
index 18bf4bc..97bd943 100644 (file)
@@ -4,7 +4,6 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "src/plugins/vm/VirtualMachineImpl.hpp"
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "src/plugins/vm/VirtualMachineImpl.hpp"
-#include "src/surf/FileImpl.hpp"
 #include <string>
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_host, surf, "Logging specific to the SURF host module");
 #include <string>
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_host, surf, "Logging specific to the SURF host module");
index 5e3ff38..b6d8c4f 100644 (file)
@@ -6,7 +6,6 @@
 
 #include <xbt/base.h>
 
 
 #include <xbt/base.h>
 
-#include "FileImpl.hpp"
 #include "StorageImpl.hpp"
 
 #ifndef STORAGE_N11_HPP_
 #include "StorageImpl.hpp"
 
 #ifndef STORAGE_N11_HPP_
index 6969b59..767f883 100644 (file)
@@ -238,7 +238,6 @@ static void xbt_log_connect_categories(void)
   XBT_LOG_CONNECT(surf_cpu_cas);
   XBT_LOG_CONNECT(surf_cpu_ti);
   XBT_LOG_CONNECT(surf_energy);
   XBT_LOG_CONNECT(surf_cpu_cas);
   XBT_LOG_CONNECT(surf_cpu_ti);
   XBT_LOG_CONNECT(surf_energy);
-  XBT_LOG_CONNECT(surf_file);
   XBT_LOG_CONNECT(surf_kernel);
   XBT_LOG_CONNECT(surf_lagrange);
   XBT_LOG_CONNECT(surf_lagrange_dichotomy);
   XBT_LOG_CONNECT(surf_kernel);
   XBT_LOG_CONNECT(surf_lagrange);
   XBT_LOG_CONNECT(surf_lagrange_dichotomy);
index cff4bca..510bb81 100644 (file)
@@ -53,7 +53,6 @@ set(EXTRA_DIST
   src/surf/xml/simgrid_dtd.c
   src/surf/xml/surfxml_sax_cb.cpp
 
   src/surf/xml/simgrid_dtd.c
   src/surf/xml/surfxml_sax_cb.cpp
 
-  src/surf/FileImpl.hpp
   src/surf/StorageImpl.hpp
   src/surf/storage_n11.hpp
   src/surf/surf_interface.hpp
   src/surf/StorageImpl.hpp
   src/surf/storage_n11.hpp
   src/surf/surf_interface.hpp
@@ -335,7 +334,6 @@ set(SURF_SRC
   src/surf/cpu_interface.cpp
   src/surf/cpu_ti.cpp
   src/surf/fair_bottleneck.cpp
   src/surf/cpu_interface.cpp
   src/surf/cpu_ti.cpp
   src/surf/fair_bottleneck.cpp
-  src/surf/FileImpl.cpp
   src/surf/instr_routing.cpp
   src/surf/instr_surf.cpp
   src/surf/lagrange.cpp
   src/surf/instr_routing.cpp
   src/surf/instr_surf.cpp
   src/surf/lagrange.cpp