1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-02-09 09:57:26 +03:00

shared: add a single definition of libmount cleanup functions

Use a trivial header file to share mnt_free_tablep and mnt_free_iterp.
It would be nicer put this in mount-util.h, but libmount.h is not in the
default include path, and the build system would have to be adjusted to pass
pkg-config include path in various places, and it's just not worth the trouble.
A separate header file works nicely.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2019-04-04 12:54:19 +02:00
parent 949082ac21
commit fb36b1339b
4 changed files with 13 additions and 11 deletions

View File

@ -5,8 +5,6 @@
#include <stdio.h> #include <stdio.h>
#include <sys/epoll.h> #include <sys/epoll.h>
#include <libmount.h>
#include "sd-messages.h" #include "sd-messages.h"
#include "alloc-util.h" #include "alloc-util.h"
@ -17,6 +15,7 @@
#include "exit-status.h" #include "exit-status.h"
#include "format-util.h" #include "format-util.h"
#include "fstab-util.h" #include "fstab-util.h"
#include "libmount-util.h"
#include "log.h" #include "log.h"
#include "manager.h" #include "manager.h"
#include "mkdir.h" #include "mkdir.h"
@ -36,9 +35,6 @@
#define RETRY_UMOUNT_MAX 32 #define RETRY_UMOUNT_MAX 32
DEFINE_TRIVIAL_CLEANUP_FUNC(struct libmnt_table*, mnt_free_table);
DEFINE_TRIVIAL_CLEANUP_FUNC(struct libmnt_iter*, mnt_free_iter);
static const UnitActiveState state_translation_table[_MOUNT_STATE_MAX] = { static const UnitActiveState state_translation_table[_MOUNT_STATE_MAX] = {
[MOUNT_DEAD] = UNIT_INACTIVE, [MOUNT_DEAD] = UNIT_INACTIVE,
[MOUNT_MOUNTING] = UNIT_ACTIVATING, [MOUNT_MOUNTING] = UNIT_ACTIVATING,

View File

@ -0,0 +1,10 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
/* This needs to be after sys/mount.h */
#include <libmount.h>
#include "macro.h"
DEFINE_TRIVIAL_CLEANUP_FUNC(struct libmnt_table*, mnt_free_table);
DEFINE_TRIVIAL_CLEANUP_FUNC(struct libmnt_iter*, mnt_free_iter);

View File

@ -95,6 +95,7 @@ shared_sources = files('''
json-internal.h json-internal.h
json.c json.c
json.h json.h
libmount-util.h
lockfile-util.c lockfile-util.c
lockfile-util.h lockfile-util.h
log-link.h log-link.h

View File

@ -13,9 +13,6 @@
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
/* This needs to be after sys/mount.h :( */
#include <libmount.h>
#include "sd-device.h" #include "sd-device.h"
#include "alloc-util.h" #include "alloc-util.h"
@ -25,6 +22,7 @@
#include "escape.h" #include "escape.h"
#include "fd-util.h" #include "fd-util.h"
#include "fstab-util.h" #include "fstab-util.h"
#include "libmount-util.h"
#include "linux-3.13/dm-ioctl.h" #include "linux-3.13/dm-ioctl.h"
#include "mount-setup.h" #include "mount-setup.h"
#include "mount-util.h" #include "mount-util.h"
@ -38,9 +36,6 @@
#include "util.h" #include "util.h"
#include "virt.h" #include "virt.h"
DEFINE_TRIVIAL_CLEANUP_FUNC(struct libmnt_table*, mnt_free_table);
DEFINE_TRIVIAL_CLEANUP_FUNC(struct libmnt_iter*, mnt_free_iter);
static void mount_point_free(MountPoint **head, MountPoint *m) { static void mount_point_free(MountPoint **head, MountPoint *m) {
assert(head); assert(head);
assert(m); assert(m);