Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
create the loopback after the right configuration is set
[simgrid.git] / src / surf / FileImpl.cpp
1 /* Copyright (c) 2017. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include "src/surf/FileImpl.hpp"
8 #include "src/surf/HostImpl.hpp"
9
10 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_file, surf, "Logging specific to the SURF file module");
11 namespace simgrid {
12 namespace surf {
13
14 int FileImpl::seek(sg_offset_t offset, int origin)
15 {
16   switch (origin) {
17     case SEEK_SET:
18       current_position_ = offset;
19       return 0;
20     case SEEK_CUR:
21       current_position_ += offset;
22       return 0;
23     case SEEK_END:
24       current_position_ = size_ + offset;
25       return 0;
26     default:
27       return -1;
28   }
29 }
30
31 int FileImpl::unlink(sg_host_t host)
32 {
33   simgrid::surf::StorageImpl* st = host->pimpl_->findStorageOnMountList(mount_point_.c_str());
34   /* Check if the file is on this storage */
35   if (st->content_->find(path_) == st->content_->end()) {
36     XBT_WARN("File %s is not on disk %s. Impossible to unlink", cname(), st->cname());
37     return -1;
38   } else {
39     XBT_DEBUG("UNLINK %s on disk '%s'", cname(), st->cname());
40     st->usedSize_ -= size_;
41
42     // Remove the file from storage
43     st->content_->erase(path_);
44
45     return 0;
46   }
47 }
48 }
49 }