snapshot.c revision b5efdb8af40ea759a1ea584c1bc44ecc81dd00ce
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2010 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include "alloc-util.h"
#include "bus-common-errors.h"
#include "dbus-snapshot.h"
#include "parse-util.h"
#include "parse-util.h"
#include "snapshot.h"
#include "string-util.h"
#include "unit-name.h"
#include "unit.h"
};
static void snapshot_init(Unit *u) {
assert(s);
UNIT(s)->ignore_on_isolate = true;
UNIT(s)->ignore_on_snapshot = true;
UNIT(s)->allow_isolate = true;
}
assert(s);
log_unit_debug(UNIT(s), "Changed %s -> %s", snapshot_state_to_string(old_state), snapshot_state_to_string(state));
}
static int snapshot_load(Unit *u) {
assert(u);
/* Make sure that only snapshots created via snapshot_create()
* can be loaded */
return -ENOENT;
u->load_state = UNIT_LOADED;
return 0;
}
static int snapshot_coldplug(Unit *u) {
assert(s);
if (s->deserialized_state != s->state)
snapshot_set_state(s, s->deserialized_state);
return 0;
}
assert(s);
assert(f);
fprintf(f,
"%sSnapshot State: %s\n"
"%sClean Up: %s\n",
}
static int snapshot_start(Unit *u) {
assert(s);
if (s->cleanup)
return 1;
}
static int snapshot_stop(Unit *u) {
assert(s);
return 1;
}
Iterator i;
assert(s);
assert(f);
return 0;
}
int r;
assert(u);
if (state < 0)
else
s->deserialized_state = state;
r = parse_boolean(value);
if (r < 0)
else
s->cleanup = r;
if (r < 0)
return r;
} else
return 0;
}
assert(u);
}
assert(u);
}
_cleanup_free_ char *n = NULL;
Iterator i;
int r;
const char *k;
assert(m);
if (name) {
return sd_bus_error_setf(e, SD_BUS_ERROR_INVALID_ARGS, "Unit name %s lacks snapshot suffix.", name);
if (manager_get_unit(m, name))
} else {
for (;;) {
return -ENOMEM;
if (!manager_get_unit(m, n)) {
name = n;
break;
}
n = mfree(n);
}
}
if (r < 0)
goto fail;
u->transient = true;
if (other->ignore_on_snapshot ||
continue;
continue;
continue;
continue;
if (r < 0)
goto fail;
}
log_unit_info(u, "Created snapshot.");
return 0;
fail:
if (u)
return r;
}
void snapshot_remove(Snapshot *s) {
assert(s);
}
const UnitVTable snapshot_vtable = {
.object_size = sizeof(Snapshot),
.no_alias = true,
.no_instances = true,
.no_gc = true,
.init = snapshot_init,
.load = snapshot_load,
.dump = snapshot_dump,
.start = snapshot_start,
.stop = snapshot_stop,
};