mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
g13: Implement --umount for dm-crypt.
* g13/g13.c (main): Implement command --umount. * g13/mount.c (g13_umount_container): use the syshelper if needed. * g13/backend.c (be_umount_container): New. * g13/be-dmcrypt.c (be_dmcrypt_umount_container): New. * g13/call-syshelp.c (call_syshelp_run_umount): New. * g13/sh-cmd.c (cmd_umount): New. (register_commands): Register UMOUNT. * g13/sh-dmcrypt.c (sh_dmcrypt_umount_container): New. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
c9a0bccc77
commit
b781113cf1
11 changed files with 245 additions and 23 deletions
60
g13/mount.c
60
g13/mount.c
|
@ -64,10 +64,7 @@ g13_mount_container (ctrl_t ctrl, const char *filename, const char *mountpoint)
|
|||
if (access (filename, F_OK))
|
||||
return gpg_error_from_syserror ();
|
||||
|
||||
/* Decide whether we need to use the g13-syshelp because we can't
|
||||
use lock files for them. This is most likely the case for device
|
||||
files; thus we test for this. FIXME: The correct solution would
|
||||
be to call g13-syshelp to match the file against the g13tab. */
|
||||
/* Decide whether we need to use the g13-syshelp. */
|
||||
err = call_syshelp_find_device (ctrl, filename, &blockdev_buffer);
|
||||
if (!err)
|
||||
{
|
||||
|
@ -217,27 +214,50 @@ gpg_error_t
|
|||
g13_umount_container (ctrl_t ctrl, const char *filename, const char *mountpoint)
|
||||
{
|
||||
gpg_error_t err;
|
||||
unsigned int rid;
|
||||
runner_t runner;
|
||||
|
||||
(void)ctrl;
|
||||
char *blockdev;
|
||||
|
||||
if (!filename && !mountpoint)
|
||||
return gpg_error (GPG_ERR_ENOENT);
|
||||
|
||||
err = mountinfo_find_mount (filename, mountpoint, &rid);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
runner = runner_find_by_rid (rid);
|
||||
if (!runner)
|
||||
/* Decide whether we need to use the g13-syshelp. */
|
||||
err = call_syshelp_find_device (ctrl, filename, &blockdev);
|
||||
if (!err)
|
||||
{
|
||||
log_error ("runner %u not found\n", rid);
|
||||
return gpg_error (GPG_ERR_NOT_FOUND);
|
||||
/* Need to employ the syshelper to umount the file system. */
|
||||
/* FIXME: We should get the CONTTYPE from the blockdev. */
|
||||
err = be_umount_container (ctrl, CONTTYPE_DM_CRYPT, blockdev);
|
||||
if (!err)
|
||||
{
|
||||
/* if (conttype == CONTTYPE_DM_CRYPT) */
|
||||
g13_request_shutdown ();
|
||||
}
|
||||
}
|
||||
else if (gpg_err_code (err) != GPG_ERR_NOT_FOUND)
|
||||
{
|
||||
log_error ("error finding device '%s': %s <%s>\n",
|
||||
filename, gpg_strerror (err), gpg_strsource (err));
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Not in g13tab - kill the runner process for this mount. */
|
||||
unsigned int rid;
|
||||
runner_t runner;
|
||||
|
||||
err = mountinfo_find_mount (filename, mountpoint, &rid);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
runner = runner_find_by_rid (rid);
|
||||
if (!runner)
|
||||
{
|
||||
log_error ("runner %u not found\n", rid);
|
||||
return gpg_error (GPG_ERR_NOT_FOUND);
|
||||
}
|
||||
|
||||
runner_cancel (runner);
|
||||
runner_release (runner);
|
||||
}
|
||||
|
||||
runner_cancel (runner);
|
||||
runner_release (runner);
|
||||
|
||||
return 0;
|
||||
xfree (blockdev);
|
||||
return err;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue