chiark / gitweb /
doc: Extend dirmngr's --allow-version-check description
[gnupg2.git] / g13 / be-dmcrypt.c
1 /* be-dmcrypt.c - The DM-Crypt based backend
2  * Copyright (C) 2015 Werner Koch
3  *
4  * This file is part of GnuPG.
5  *
6  * GnuPG is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * GnuPG is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, see <https://www.gnu.org/licenses/>.
18  */
19
20 #include <config.h>
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <errno.h>
25 #include <unistd.h>
26
27 #include "g13.h"
28 #include "i18n.h"
29 #include "keyblob.h"
30 #include "call-syshelp.h"
31 #include "be-dmcrypt.h"
32
33
34 /* Create the container using the current device.
35  * information in TUPLES. */
36 gpg_error_t
37 be_dmcrypt_create_container (ctrl_t ctrl)
38 {
39   gpg_error_t err;
40
41   err = call_syshelp_run_create (ctrl, CONTTYPE_DM_CRYPT);
42
43   return err;
44 }
45
46
47 /* Mount the container described by the filename FNAME and the keyblob
48  * information in TUPLES.  On success the runner id is stored at R_ID. */
49 gpg_error_t
50 be_dmcrypt_mount_container (ctrl_t ctrl,
51                             const char *fname, const char *mountpoint,
52                             tupledesc_t tuples)
53 {
54   gpg_error_t err;
55
56   err = call_syshelp_set_device (ctrl, fname);
57   if (err)
58     goto leave;
59
60   err = call_syshelp_run_mount (ctrl, CONTTYPE_DM_CRYPT, mountpoint, tuples);
61
62  leave:
63   return err;
64 }
65
66
67 /* Unmount the container described by the filename FNAME.  */
68 gpg_error_t
69 be_dmcrypt_umount_container (ctrl_t ctrl, const char *fname)
70 {
71   gpg_error_t err;
72
73   err = call_syshelp_set_device (ctrl, fname);
74   if (err)
75     goto leave;
76
77   err = call_syshelp_run_umount (ctrl, CONTTYPE_DM_CRYPT);
78
79  leave:
80   return err;
81 }
82
83
84 /* Suspend the container described by the filename FNAME.  */
85 gpg_error_t
86 be_dmcrypt_suspend_container (ctrl_t ctrl, const char *fname)
87 {
88   gpg_error_t err;
89
90   err = call_syshelp_set_device (ctrl, fname);
91   if (err)
92     goto leave;
93
94   err = call_syshelp_run_suspend (ctrl, CONTTYPE_DM_CRYPT);
95
96  leave:
97   return err;
98 }
99
100
101 /* Resume the container described by the filename FNAME and the keyblob
102  * information in TUPLES.  */
103 gpg_error_t
104 be_dmcrypt_resume_container (ctrl_t ctrl, const char *fname, tupledesc_t tuples)
105 {
106   gpg_error_t err;
107
108   err = call_syshelp_set_device (ctrl, fname);
109   if (err)
110     goto leave;
111
112   err = call_syshelp_run_resume (ctrl, CONTTYPE_DM_CRYPT, tuples);
113
114  leave:
115   return err;
116 }