void move(const char* fullpath);
/** Remove a file from disk */
- void unlink();
- void unlink(sg_host_t host);
+ int unlink();
+ int unlink(sg_host_t host);
/* FIXME: add these to the S4U API:
XBT_PUBLIC(const char *) MSG_file_get_name(msg_file_t file);
/** @brief Create a file writing action on the given host */
XBT_PUBLIC(surf_action_t) surf_host_write(sg_host_t host, surf_file_t fd, sg_size_t size);
-/**
- * @brief Unlink a file descriptor
- *
- * @param host The surf host
- * @param fd The file descriptor
- *
- * @return 0 if failed to unlink, 1 otherwise
- */
-XBT_PUBLIC(int) surf_host_unlink(sg_host_t host, surf_file_t fd);
-
/**
* @brief Move a file to another location on the *same mount point*.
* @details [long description]
*/
XBT_PUBLIC(int) surf_host_file_move(sg_host_t host, surf_file_t fd, const char* fullpath);
-/**
- * @brief Set the position indictator assiociated with the file descriptor to a new position
- * @details [long description]
- *
- * @param host The surf host
- * @param fd The file descriptor
- * @param offset The offset from the origin
- * @param origin Position used as a reference for the offset
- * - SEEK_SET: beginning of the file
- * - SEEK_CUR: current position indicator
- * - SEEK_END: end of the file
- * @return MSG_OK if successful, otherwise MSG_TASK_CANCELED
- */
-XBT_PUBLIC(int) surf_host_file_seek(sg_host_t host, surf_file_t fd, sg_offset_t offset, int origin);
-
/**
* @brief [brief description]
* @details [long description]
simcall_file_move(pimpl_,fullpath);
}
-void File::unlink()
+int File::unlink()
{
- simcall_file_unlink(pimpl_, Host::current());
+ return simgrid::simix::kernelImmediate([this] { return pimpl_->unlink(Host::current()); });
}
-void File::unlink(sg_host_t host)
+int File::unlink(sg_host_t host)
{
- simcall_file_unlink(pimpl_, host);
+ return simgrid::simix::kernelImmediate([this, host] { return pimpl_->unlink(host); });
}
}} // namespace simgrid::s4u
return simcall_BODY_file_close(fd, host);
}
-/**
- * \ingroup simix_file_management
- *
- */
-int simcall_file_unlink(surf_file_t fd, sg_host_t host)
-{
- return simcall_BODY_file_unlink(fd, host);
-}
-
-
/**
* \ingroup simix_file_management
* \brief Move a file to another location on the *same mount point*.
simgrid::simix::marshal<int>(simcall->result, result);
}
-static inline surf_file_t simcall_file_unlink__get__fd(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal<surf_file_t>(simcall->args[0]);
-}
-static inline surf_file_t simcall_file_unlink__getraw__fd(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal_raw<surf_file_t>(simcall->args[0]);
-}
-static inline void simcall_file_unlink__set__fd(smx_simcall_t simcall, surf_file_t arg)
-{
- simgrid::simix::marshal<surf_file_t>(simcall->args[0], arg);
-}
-static inline sg_host_t simcall_file_unlink__get__host(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal<sg_host_t>(simcall->args[1]);
-}
-static inline sg_host_t simcall_file_unlink__getraw__host(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal_raw<sg_host_t>(simcall->args[1]);
-}
-static inline void simcall_file_unlink__set__host(smx_simcall_t simcall, sg_host_t arg)
-{
- simgrid::simix::marshal<sg_host_t>(simcall->args[1], arg);
-}
-static inline int simcall_file_unlink__get__result(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal<int>(simcall->result);
-}
-static inline int simcall_file_unlink__getraw__result(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal_raw<int>(simcall->result);
-}
-static inline void simcall_file_unlink__set__result(smx_simcall_t simcall, int result){
- simgrid::simix::marshal<int>(simcall->result, result);
-}
-
static inline surf_file_t simcall_file_move__get__fd(smx_simcall_t simcall)
{
return simgrid::simix::unmarshal<surf_file_t>(simcall->args[0]);
return simcall<int, surf_file_t, sg_host_t>(SIMCALL_FILE_CLOSE, fd, host);
}
- inline static int simcall_BODY_file_unlink(surf_file_t fd, sg_host_t host)
- {
- /* Go to that function to follow the code flow through the simcall barrier */
- if (0) SIMIX_file_unlink(fd, host);
- return simcall<int, surf_file_t, sg_host_t>(SIMCALL_FILE_UNLINK, fd, host);
- }
-
inline static int simcall_BODY_file_move(surf_file_t fd, const char* fullpath)
{
/* Go to that function to follow the code flow through the simcall barrier */
SIMCALL_FILE_WRITE,
SIMCALL_FILE_OPEN,
SIMCALL_FILE_CLOSE,
- SIMCALL_FILE_UNLINK,
SIMCALL_FILE_MOVE,
SIMCALL_MC_RANDOM,
SIMCALL_SET_CATEGORY,
"SIMCALL_FILE_WRITE",
"SIMCALL_FILE_OPEN",
"SIMCALL_FILE_CLOSE",
- "SIMCALL_FILE_UNLINK",
"SIMCALL_FILE_MOVE",
"SIMCALL_MC_RANDOM",
"SIMCALL_SET_CATEGORY",
simgrid::simix::unmarshal<sg_host_t>(simcall->args[1]));
break;
-case SIMCALL_FILE_UNLINK:
- simgrid::simix::marshal<int>(simcall->result,
- SIMIX_file_unlink(simgrid::simix::unmarshal<surf_file_t>(simcall->args[0]),
- simgrid::simix::unmarshal<sg_host_t>(simcall->args[1])));
- SIMIX_simcall_answer(simcall);
- break;
-
case SIMCALL_FILE_MOVE:
simgrid::simix::marshal<int>(
simcall->result, simcall_HANDLER_file_move(simcall, simgrid::simix::unmarshal<surf_file_t>(simcall->args[0]),
sg_size_t file_write(surf_file_t fd, sg_size_t size, sg_host_t host) [[block]];
surf_file_t file_open(const char* mount, const char* path, sg_storage_t st) [[block]];
int file_close(surf_file_t fd, sg_host_t host) [[block]];
-int file_unlink(surf_file_t fd, sg_host_t host) [[nohandler]];
int file_move(surf_file_t fd, const char* fullpath);
int mc_random(int min, int max);
return synchro;
}
-//SIMIX FILE UNLINK
-int SIMIX_file_unlink(surf_file_t file, sg_host_t host)
-{
- if (host->isOff())
- THROWF(host_error, 0, "Host %s failed, you cannot call this function", host->cname());
-
- return surf_host_unlink(host, file);
-}
-
int simcall_HANDLER_file_move(smx_simcall_t simcall, surf_file_t file, const char* fullpath)
{
return SIMIX_file_move(simcall->issuer, file, fullpath);
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)
- {
- 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 seek(sg_offset_t offset, int origin);
+ int unlink(sg_host_t host);
private:
std::string path_;
return st->write(fd, size);
}
-int HostImpl::unlink(surf_file_t fd)
-{
- if (not fd) {
- XBT_WARN("No such file descriptor. Impossible to unlink");
- return -1;
- } else {
-
- simgrid::surf::StorageImpl* st = findStorageOnMountList(fd->mount());
- /* Check if the file is on this storage */
- if (st->content_->find(fd->cname()) == st->content_->end()) {
- XBT_WARN("File %s is not on disk %s. Impossible to unlink", fd->cname(), st->cname());
- return -1;
- } else {
- XBT_DEBUG("UNLINK %s on disk '%s'", fd->cname(), st->cname());
- st->usedSize_ -= fd->size();
-
- // Remove the file from storage
- st->content_->erase(fd->cname());
-
- return 0;
- }
- }
-}
-
int HostImpl::fileMove(surf_file_t fd, const char* fullpath)
{
/* Check if the new full path is on the same mount point */
*/
virtual Action* close(surf_file_t fd);
- /**
- * @brief Unlink a file
- * @details [long description]
- *
- * @param fd [description]
- * @return [description]
- */
- virtual int unlink(surf_file_t fd);
-
/**
* @brief Read a file
*
return host->pimpl_->close(fd);
}
-int surf_host_unlink(sg_host_t host, surf_file_t fd){
- return host->pimpl_->unlink(fd);
-}
-
surf_action_t surf_host_read(sg_host_t host, surf_file_t fd, sg_size_t size){
return host->pimpl_->read(fd, size);
}
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