shared/hash.c \
shared/hash.h \
shared/util.c \
- shared/util.h \
- libkmod/libkmod-util.c \
- libkmod/libkmod-util.h
+ shared/util.h
include_HEADERS = libkmod/libkmod.h
lib_LTLIBRARIES = libkmod/libkmod.la
CFILE_GLOB = $(top_srcdir)/libkmod/libkmod.c $(top_srcdir)/libkmod/libkmod-module.c $(top_srcdir)/libkmod/libkmod-list.c
IGNORE_HFILES = libkmod-internal.h \
- libkmod-util.h \
libkmod-index.h
content_files = version.xml
const char *algo, *hash_algo, *id_type;
};
bool kmod_module_signature_info(const struct kmod_file *file, struct kmod_signature_info *sig_info) _must_check_ __attribute__((nonnull(1, 2)));
-/* util functions */
-#include "libkmod-util.h"
+++ /dev/null
-/*
- * libkmod - interface to kernel module operations
- *
- * Copyright (C) 2011-2013 ProFUSION embedded systems
- * Copyright (C) 2012 Lucas De Marchi <lucas.de.marchi@gmail.com>
- * Copyright (C) 2013 Intel Corporation. All rights reserved.
- *
- * 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <ctype.h>
-#include <stdarg.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <shared/util.h>
-
-#include "libkmod.h"
-#include "libkmod-internal.h"
-
-static const struct kmod_ext {
- const char *ext;
- size_t len;
-} kmod_exts[] = {
- {KMOD_EXTENSION_UNCOMPRESSED, sizeof(KMOD_EXTENSION_UNCOMPRESSED) - 1},
-#ifdef ENABLE_ZLIB
- {".ko.gz", sizeof(".ko.gz") - 1},
-#endif
-#ifdef ENABLE_XZ
- {".ko.xz", sizeof(".ko.xz") - 1},
-#endif
- { }
-};
-
-inline char *modname_normalize(const char *modname, char buf[PATH_MAX],
- size_t *len)
-{
- size_t s;
-
- for (s = 0; s < PATH_MAX - 1; s++) {
- const char c = modname[s];
- if (c == '-')
- buf[s] = '_';
- else if (c == '\0' || c == '.')
- break;
- else
- buf[s] = c;
- }
-
- buf[s] = '\0';
-
- if (len)
- *len = s;
-
- return buf;
-}
-
-char *path_to_modname(const char *path, char buf[PATH_MAX], size_t *len)
-{
- char *modname;
-
- modname = basename(path);
- if (modname == NULL || modname[0] == '\0')
- return NULL;
-
- return modname_normalize(modname, buf, len);
-}
-
-bool path_ends_with_kmod_ext(const char *path, size_t len)
-{
- const struct kmod_ext *eitr;
-
- for (eitr = kmod_exts; eitr->ext != NULL; eitr++) {
- if (len <= eitr->len)
- continue;
- if (streq(path + len - eitr->len, eitr->ext))
- return true;
- }
-
- return false;
-}
+++ /dev/null
-#pragma once
-
-#include <limits.h>
-#include <stdbool.h>
-#include <stddef.h>
-
-#include <shared/macro.h>
-
-#define KMOD_EXTENSION_UNCOMPRESSED ".ko"
-
-char *modname_normalize(const char *modname, char buf[PATH_MAX], size_t *len) __attribute__((nonnull(1, 2)));
-char *path_to_modname(const char *path, char buf[PATH_MAX], size_t *len) __attribute__((nonnull(2)));
-bool path_ends_with_kmod_ext(const char *path, size_t len) __attribute__((nonnull(1)));
#define USEC_PER_SEC 1000000ULL
#define NSEC_PER_USEC 1000ULL
+static const struct kmod_ext {
+ const char *ext;
+ size_t len;
+} kmod_exts[] = {
+ {KMOD_EXTENSION_UNCOMPRESSED, sizeof(KMOD_EXTENSION_UNCOMPRESSED) - 1},
+#ifdef ENABLE_ZLIB
+ {".ko.gz", sizeof(".ko.gz") - 1},
+#endif
+#ifdef ENABLE_XZ
+ {".ko.xz", sizeof(".ko.xz") - 1},
+#endif
+ { }
+};
+
/* string handling functions and memory allocations */
/* ************************************************************************ */
return 0;
}
+char *modname_normalize(const char *modname, char buf[static PATH_MAX], size_t *len)
+{
+ size_t s;
+
+ for (s = 0; s < PATH_MAX - 1; s++) {
+ const char c = modname[s];
+ if (c == '-')
+ buf[s] = '_';
+ else if (c == '\0' || c == '.')
+ break;
+ else
+ buf[s] = c;
+ }
+
+ buf[s] = '\0';
+
+ if (len)
+ *len = s;
+
+ return buf;
+}
+
+char *path_to_modname(const char *path, char buf[static PATH_MAX], size_t *len)
+{
+ char *modname;
+
+ modname = basename(path);
+ if (modname == NULL || modname[0] == '\0')
+ return NULL;
+
+ return modname_normalize(modname, buf, len);
+}
+
+bool path_ends_with_kmod_ext(const char *path, size_t len)
+{
+ const struct kmod_ext *eitr;
+
+ for (eitr = kmod_exts; eitr->ext != NULL; eitr++) {
+ if (len <= eitr->len)
+ continue;
+ if (streq(path + len - eitr->len, eitr->ext))
+ return true;
+ }
+
+ return false;
+}
+
/* read-like and fread-like functions */
/* ************************************************************************ */
ssize_t read_str_safe(int fd, char *buf, size_t buflen)
/* module-related functions */
/* ************************************************************************ */
+#define KMOD_EXTENSION_UNCOMPRESSED ".ko"
+
int alias_normalize(const char *alias, char buf[static PATH_MAX], size_t *len) _must_check_ __attribute__((nonnull(1,2)));
+char *modname_normalize(const char *modname, char buf[static PATH_MAX], size_t *len) __attribute__((nonnull(1, 2)));
+char *path_to_modname(const char *path, char buf[static PATH_MAX], size_t *len) __attribute__((nonnull(2)));
+bool path_ends_with_kmod_ext(const char *path, size_t len) __attribute__((nonnull(1)));
/* read-like and fread-like functions */
/* ************************************************************************ */
#include <shared/util.h>
-#include <libkmod-util.h>
-
#include "testsuite.h"
static const char *ANSI_HIGHLIGHT_GREEN_ON = "\x1B[1;32m";
#include <shared/util.h>
#include <libkmod.h>
-#include <libkmod-util.h>
#include "kmod.h"
#include <sys/stat.h>
#include <sys/utsname.h>
+#include <shared/util.h>
+
#include <libkmod.h>
-#include <libkmod-util.h>
#include "kmod.h"