chiark / gitweb /
Fix check_loopback()
[elogind.git] / src / machine / image.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 #pragma once
4
5 /***
6   This file is part of systemd.
7
8   Copyright 2014 Lennart Poettering
9
10   systemd is free software; you can redistribute it and/or modify it
11   under the terms of the GNU Lesser General Public License as published by
12   the Free Software Foundation; either version 2.1 of the License, or
13   (at your option) any later version.
14
15   systemd is distributed in the hope that it will be useful, but
16   WITHOUT ANY WARRANTY; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18   Lesser General Public License for more details.
19
20   You should have received a copy of the GNU Lesser General Public License
21   along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 ***/
23
24 #include "time-util.h"
25 #include "hashmap.h"
26 #include "machined.h"
27
28 typedef enum ImageType {
29         IMAGE_DIRECTORY,
30         IMAGE_SUBVOLUME,
31         IMAGE_GPT,
32         _IMAGE_TYPE_MAX,
33         _IMAGE_TYPE_INVALID = -1
34 } ImageType;
35
36 typedef struct Image {
37         ImageType type;
38         char *name;
39         char *path;
40         bool read_only;
41
42         usec_t crtime;
43         usec_t mtime;
44 } Image;
45
46 Image *image_unref(Image *i);
47 void image_hashmap_free(Hashmap *map);
48
49 DEFINE_TRIVIAL_CLEANUP_FUNC(Image*, image_unref);
50 DEFINE_TRIVIAL_CLEANUP_FUNC(Hashmap*, image_hashmap_free);
51
52 int image_find(const char *name, Image **ret);
53 int image_discover(Hashmap *map);
54
55 extern const sd_bus_vtable image_vtable[];
56
57 char *image_bus_path(const char *name);
58
59 int image_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error);
60 int image_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error);
61
62 const char* image_type_to_string(ImageType t) _const_;
63 ImageType image_type_from_string(const char *s) _pure_;