summaryrefslogtreecommitdiff
path: root/mount.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-01-23 01:52:57 +0100
committerLennart Poettering <lennart@poettering.net>2010-01-23 01:52:57 +0100
commit5cb5a6ffc33667c93e9bc3572534dcaa684046e3 (patch)
tree51e8b6260d56027c4d610ff6db5882737101a809 /mount.c
parentcd2dbd7df9f1b8c46386b2898523aec3dd4578fd (diff)
first attempt in implementinging execution logic
Diffstat (limited to 'mount.c')
-rw-r--r--mount.c86
1 files changed, 86 insertions, 0 deletions
diff --git a/mount.c b/mount.c
new file mode 100644
index 0000000000..fa92e5b7bb
--- /dev/null
+++ b/mount.c
@@ -0,0 +1,86 @@
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+#include <errno.h>
+
+#include "name.h"
+#include "mount.h"
+#include "load-fragment.h"
+#include "load-fstab.h"
+#include "load-dropin.h"
+
+static int mount_load(Name *n) {
+ int r;
+ Mount *m = MOUNT(n);
+
+ assert(m);
+
+ /* Load a .mount file */
+ if ((r = name_load_fragment(n)) < 0 && errno != -ENOENT)
+ return r;
+
+ /* Load entry from /etc/fstab */
+ if ((r = name_load_fstab(n)) < 0)
+ return r;
+
+ /* Load drop-in directory data */
+ if ((r = name_load_dropin(n)) < 0)
+ return r;
+
+ return r;
+}
+
+static void mount_dump(Name *n, FILE *f, const char *prefix) {
+
+ static const char* const state_table[_MOUNT_STATE_MAX] = {
+ [MOUNT_DEAD] = "dead",
+ [MOUNT_MOUNTING] = "mounting",
+ [MOUNT_MOUNTED] = "mounted",
+ [MOUNT_UNMOUNTING] = "unmounting",
+ [MOUNT_MAINTAINANCE] = "maintainance"
+ };
+
+ Mount *s = MOUNT(n);
+
+ assert(s);
+
+ fprintf(f,
+ "%sMount State: %s\n"
+ "%sPath: %s\n",
+ prefix, state_table[s->state],
+ prefix, s->path);
+}
+
+static NameActiveState mount_active_state(Name *n) {
+
+ static const NameActiveState table[_MOUNT_STATE_MAX] = {
+ [MOUNT_DEAD] = NAME_INACTIVE,
+ [MOUNT_MOUNTING] = NAME_ACTIVATING,
+ [MOUNT_MOUNTED] = NAME_ACTIVE,
+ [MOUNT_UNMOUNTING] = NAME_DEACTIVATING,
+ [MOUNT_MAINTAINANCE] = NAME_INACTIVE,
+ };
+
+ return table[MOUNT(n)->state];
+}
+
+static void mount_free_hook(Name *n) {
+ Mount *d = MOUNT(n);
+
+ assert(d);
+ free(d->path);
+}
+
+const NameVTable mount_vtable = {
+ .suffix = ".mount",
+
+ .load = mount_load,
+ .dump = mount_dump,
+
+ .start = NULL,
+ .stop = NULL,
+ .reload = NULL,
+
+ .active_state = mount_active_state,
+
+ .free_hook = mount_free_hook
+};