snapshot.c revision 96aad8d15a324d0e956a4e5653a11a67b209b41a
/*-*- 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-common-errors.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);
"%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);
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;
}
free(n);
n = NULL;
}
}
if (r < 0)
goto fail;
u->transient = true;
if (other->ignore_on_snapshot ||
continue;
continue;
continue;
continue;
if (r < 0)
goto fail;
}
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",
};