]> git.ipfire.org Git - thirdparty/kmod.git/blame - libkmod/libkmod-index.h
libkmod: fix return error when opening index
[thirdparty/kmod.git] / libkmod / libkmod-index.h
CommitLineData
8f923be6
LDM
1/*
2 * libkmod - interface to kernel module operations
3 *
e6b0e49b 4 * Copyright (C) 2011-2013 ProFUSION embedded systems
8f923be6
LDM
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
cb451f35
LDM
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
8f923be6
LDM
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
dea2dfee 17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
8f923be6 18 */
e8847fd2 19
e8fd8fec 20#pragma once
e8847fd2 21
b18979b7 22#include <inttypes.h>
e8847fd2 23
e8847fd2
LDM
24struct index_value {
25 struct index_value *next;
26 unsigned int priority;
1433ba9e 27 unsigned int len;
e8847fd2
LDM
28 char value[0];
29};
30
31/* In-memory index (depmod only) */
e8847fd2 32struct index_file;
e8847fd2 33struct index_file *index_file_open(const char *filename);
4a4876d6
LDM
34void index_file_close(struct index_file *idx);
35char *index_search(struct index_file *idx, const char *key);
758428a7 36void index_dump(struct index_file *in, int fd, const char *prefix);
4a4876d6 37struct index_value *index_searchwild(struct index_file *idx, const char *key);
e8847fd2
LDM
38
39void index_values_free(struct index_value *values);
40
b471a6b4
LDM
41/* Implementation using mmap */
42struct index_mm;
3bd7187f
LDM
43int index_mm_open(const struct kmod_ctx *ctx, const char *filename,
44 unsigned long long *stamp, struct index_mm **pidx);
b471a6b4 45void index_mm_close(struct index_mm *index);
b797b791 46char *index_mm_search(struct index_mm *idx, const char *key);
bf89f70c 47struct index_value *index_mm_searchwild(struct index_mm *idx, const char *key);
758428a7 48void index_mm_dump(struct index_mm *idx, int fd, const char *prefix);