Commit f0125ac9 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner

transaction: Sync on certain journal steps

It would not be good if the files were not written, but the journal
would say that the step is complete. Therefore, sync the filesystem
before confirming the journal.
parent e2b5de0d
......@@ -156,7 +156,7 @@ All the results from the step are stored in the journal and also returned.
local function step(journal_type, fun, sync, ...)
local results = {fun(...)}
if flush then
-- TODO: sync the filesystem
sync()
end
journal.write(journal_type, unpack(results))
return unpack(results)
......
......@@ -518,6 +518,11 @@ static int lua_stat(lua_State *L) {
return 2;
}
static int lua_sync(lua_State *L __attribute__((unused))) {
sync();
return 0;
}
static int lua_setenv(lua_State *L) {
const char *name = luaL_checkstring(L, 1);
const char *value = luaL_checkstring(L, 2);
......@@ -544,6 +549,7 @@ static const struct injected_func injected_funcs[] = {
{ lua_move, "move" },
{ lua_ls, "ls" },
{ lua_stat, "stat" },
{ lua_sync, "sync" },
{ lua_setenv, "setenv" }
/*
* Note: watch_cancel is not provided, because it would be hell to
......
......@@ -118,6 +118,10 @@ stat(path)::
of `ls`). The second result is the permissions of the file, in the
imitation of shell's `ls -l`, like `rwxr-x---`.
sync()::
Writes everything to a permanent storage (equivalent to the shell's
`sync` command).
Journal manipulation
--------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment