snapshot.c revision 44a6b1b68029833893f6e9cee35aa27a974038f6
/*-*- 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 "unit.h"
#include "snapshot.h"
#include "unit-name.h"
#include "dbus-snapshot.h"
#include "bus-errors.h"
};
static void snapshot_init(Unit *u) {
assert(s);
UNIT(s)->ignore_on_isolate = true;
UNIT(s)->ignore_on_snapshot = true;
}
assert(s);
log_debug("%s changed %s -> %s",
}
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 0;
}
static int snapshot_stop(Unit *u) {
assert(s);
return 0;
}
Iterator i;
assert(s);
assert(f);
return 0;
}
int r;
assert(u);
else
s->deserialized_state = state;
if ((r = parse_boolean(value)) < 0)
else
s->cleanup = r;
return r;
} else
return 0;
}
assert(u);
}
assert(u);
}
Iterator i;
char *n = NULL;
int r;
const char *k;
assert(m);
if (name) {
if (!unit_name_is_valid(name, false)) {
return -EINVAL;
}
return -EINVAL;
}
if (manager_get_unit(m, name)) {
return -EEXIST;
}
} else {
for (;;) {
return -ENOMEM;
if (!manager_get_unit(m, n))
break;
free(n);
}
name = n;
}
free(n);
if (r < 0)
goto fail;
SNAPSHOT(u)->by_snapshot_create = true;
if (other->ignore_on_snapshot)
continue;
continue;
continue;
continue;
goto fail;
}
u->allow_isolate = true;
return 0;
fail:
if (u)
return r;
}
void snapshot_remove(Snapshot *s) {
assert(s);
}
static const char* const snapshot_state_table[_SNAPSHOT_STATE_MAX] = {
[SNAPSHOT_DEAD] = "dead",
[SNAPSHOT_ACTIVE] = "active"
};
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,
.bus_interface = "org.freedesktop.systemd1.Snapshot",
};