/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2004-2010 Pawel Jakub Dawidek <[email protected]>4* All rights reserved.5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions8* are met:9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11* 2. Redistributions in binary form must reproduce the above copyright12* notice, this list of conditions and the following disclaimer in the13* documentation and/or other materials provided with the distribution.14*15* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND16* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE17* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE18* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE19* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL20* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS21* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)22* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT23* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY24* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF25* SUCH DAMAGE.26*/2728#ifndef _SUBR_H_29#define _SUBR_H_30#include <stdint.h>3132unsigned int g_lcm(unsigned int a, unsigned int b);33uint32_t bitcount32(uint32_t x);34int g_parse_lba(const char *lbastr, unsigned int sectorsize, off_t *sectors);3536off_t g_get_mediasize(const char *name);37unsigned int g_get_sectorsize(const char *name);3839int g_metadata_read(const char *name, unsigned char *md, size_t size,40const char *magic);41int g_metadata_store(const char *name, const unsigned char *md, size_t size);42int g_metadata_clear(const char *name, const char *magic);4344void gctl_error(struct gctl_req *req, const char *error, ...) __printflike(2, 3);45int gctl_get_int(struct gctl_req *req, const char *pfmt, ...) __printflike(2, 3);46intmax_t gctl_get_intmax(struct gctl_req *req, const char *pfmt, ...) __printflike(2, 3);47const char *gctl_get_ascii(struct gctl_req *req, const char *pfmt, ...) __printflike(2, 3);48int gctl_change_param(struct gctl_req *req, const char *name, int len,49const void *value);50int gctl_delete_param(struct gctl_req *req, const char *name);51int gctl_has_param(struct gctl_req *req, const char *name);5253#endif /* !_SUBR_H_ */545556