diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2016-12-10 01:08:13 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-10 01:08:13 -0500 |
commit | 4a5567d5d6ab01974dd089eb8907fecd6aff4fcf (patch) | |
tree | 4f40cdd195f08022e2846d5c9757147ca436fede /src/shared/loop-util.h | |
parent | 2e1f244efd2dfc1a60d032bef3d88b9ba6e0444b (diff) | |
parent | 58abb66f4b9b0b3a16fe29211454d9936d35c35d (diff) |
Merge pull request #4795 from poettering/dissect
Generalize image dissection logic of nspawn, and make it useful for other tools.
Diffstat (limited to 'src/shared/loop-util.h')
-rw-r--r-- | src/shared/loop-util.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/shared/loop-util.h b/src/shared/loop-util.h new file mode 100644 index 0000000000..45fead5f18 --- /dev/null +++ b/src/shared/loop-util.h @@ -0,0 +1,41 @@ +#pragma once + +/*** + This file is part of systemd. + + Copyright 2016 Lennart Poettering + + systemd is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + systemd is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with systemd; If not, see <http://www.gnu.org/licenses/>. +***/ + +#include "macro.h" + +typedef struct LoopDevice LoopDevice; + +/* Some helpers for setting up loopback block devices */ + +struct LoopDevice { + int fd; + int nr; + char *node; + bool relinquished; +}; + +int loop_device_make(int fd, int open_flags, LoopDevice **ret); +int loop_device_make_by_path(const char *path, int open_flags, LoopDevice **ret); + +LoopDevice* loop_device_unref(LoopDevice *d); +DEFINE_TRIVIAL_CLEANUP_FUNC(LoopDevice*, loop_device_unref); + +void loop_device_relinquish(LoopDevice *d); |