]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/shared/dissect-image.h
minor code beautifications
[thirdparty/systemd.git] / src / shared / dissect-image.h
CommitLineData
8c1be37e
LP
1#pragma once
2
3/***
4 This file is part of systemd.
5
6 Copyright 2016 Lennart Poettering
7
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
12
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
20***/
21
22#include <stdbool.h>
23
24#include "macro.h"
25
26typedef struct DissectedImage DissectedImage;
27typedef struct DissectedPartition DissectedPartition;
28
29struct DissectedPartition {
30 bool found:1;
31 bool rw:1;
32 int partno; /* -1 if there was no partition and the images contains a file system directly */
33 int architecture; /* Intended architecture: either native, secondary or unset (-1). */
34 char *fstype;
35 char *node;
36};
37
38enum {
39 PARTITION_ROOT,
40 PARTITION_ROOT_SECONDARY, /* Secondary architecture */
41 PARTITION_HOME,
42 PARTITION_SRV,
43 PARTITION_ESP,
44 PARTITION_SWAP,
45 _PARTITION_DESIGNATOR_MAX,
46 _PARTITION_DESIGNATOR_INVALID = -1
47};
48
49typedef enum DissectedImageMountFlags {
50 DISSECTED_IMAGE_READ_ONLY = 1,
51 DISSECTED_IMAGE_DISCARD_ON_LOOP = 2, /* Turn on "discard" if on loop device and file system supports it */
52} DissectedImageMountFlags;
53
54struct DissectedImage {
55 DissectedPartition partitions[_PARTITION_DESIGNATOR_MAX];
56};
57
58int dissect_image(int fd, DissectedImage **ret);
59
60DissectedImage* dissected_image_unref(DissectedImage *m);
61DEFINE_TRIVIAL_CLEANUP_FUNC(DissectedImage*, dissected_image_unref);
62
63int dissected_image_mount(DissectedImage *m, const char *dest, DissectedImageMountFlags flags);
64
65const char* partition_designator_to_string(int i) _const_;
66int partition_designator_from_string(const char *name) _pure_;