2 * Metadata on-disk locking for processes serialization
4 * Copyright (C) 2016-2023 Red Hat, Inc. All rights reserved.
5 * Copyright (C) 2016-2023 Ondrej Kozina
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #ifndef _CRYPTSETUP_UTILS_LOCKING_H
23 #define _CRYPTSETUP_UTILS_LOCKING_H
28 struct crypt_lock_handle;
31 int device_locked_readonly(struct crypt_lock_handle *h);
32 int device_locked(struct crypt_lock_handle *h);
34 int device_read_lock_internal(struct crypt_device *cd, struct device *device);
35 int device_write_lock_internal(struct crypt_device *cd, struct device *device);
36 void device_unlock_internal(struct crypt_device *cd, struct device *device);
38 int device_locked_verify(struct crypt_device *cd, int fd, struct crypt_lock_handle *h);
40 int crypt_read_lock(struct crypt_device *cd, const char *name, bool blocking, struct crypt_lock_handle **lock);
41 int crypt_write_lock(struct crypt_device *cd, const char *name, bool blocking, struct crypt_lock_handle **lock);
42 void crypt_unlock_internal(struct crypt_device *cd, struct crypt_lock_handle *h);
45 /* Used only in device internal allocation */
46 void device_set_lock_handle(struct device *device, struct crypt_lock_handle *h);
47 struct crypt_lock_handle *device_get_lock_handle(struct device *device);