- 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 (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*/
+ 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->get_cname());
+
+ return st;
+}
+
+Disk* File::find_local_disk_on(const Host* host)
+{
+ Disk* d = nullptr;
+ size_t longest_prefix_length = 0;
+ for (auto const& disk : host->get_disks()) {
+ std::string current_mount;
+ if (disk->get_host() != host)
+ current_mount = disk->extension<FileSystemDiskExt>()->get_mount_point(disk->get_host());
+ else
+ current_mount = disk->extension<FileSystemDiskExt>()->get_mount_point();
+ mount_point_ = fullpath_.substr(0, current_mount.length());
+ if (mount_point_ == current_mount && current_mount.length() > longest_prefix_length) {
+ /* The current mount name is found in the full path and is bigger than the previous*/
+ longest_prefix_length = current_mount.length();
+ d = disk;