mirror of
https://github.com/AuxXxilium/kmod.git
synced 2024-11-23 23:10:53 +07:00
3bd7187ff5
When calling kmod_load_resources() we could end up getting a bogus return value -ENOMEM due to several other reasons, like the index not existing. Change index_mm_open() to propagate the failure reason so we can take actions on it or return to the caller.
49 lines
1.7 KiB
C
49 lines
1.7 KiB
C
/*
|
|
* libkmod - interface to kernel module operations
|
|
*
|
|
* Copyright (C) 2011-2013 ProFUSION embedded systems
|
|
*
|
|
* This library 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.
|
|
*
|
|
* This library 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 this library; if not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <inttypes.h>
|
|
|
|
struct index_value {
|
|
struct index_value *next;
|
|
unsigned int priority;
|
|
unsigned int len;
|
|
char value[0];
|
|
};
|
|
|
|
/* In-memory index (depmod only) */
|
|
struct index_file;
|
|
struct index_file *index_file_open(const char *filename);
|
|
void index_file_close(struct index_file *idx);
|
|
char *index_search(struct index_file *idx, const char *key);
|
|
void index_dump(struct index_file *in, int fd, const char *prefix);
|
|
struct index_value *index_searchwild(struct index_file *idx, const char *key);
|
|
|
|
void index_values_free(struct index_value *values);
|
|
|
|
/* Implementation using mmap */
|
|
struct index_mm;
|
|
int index_mm_open(const struct kmod_ctx *ctx, const char *filename,
|
|
unsigned long long *stamp, struct index_mm **pidx);
|
|
void index_mm_close(struct index_mm *index);
|
|
char *index_mm_search(struct index_mm *idx, const char *key);
|
|
struct index_value *index_mm_searchwild(struct index_mm *idx, const char *key);
|
|
void index_mm_dump(struct index_mm *idx, int fd, const char *prefix);
|