#include <signal.h>
#include <unistd.h>
#include <inttypes.h>
+#include <getopt.h>
#include "hal-common.h"
#include "hal-common-interface.h"
#define LSHAL_FLAG_MANIFEST_VERSION BIT(7)
#define LSHAL_FLAG_COMPATIBILITY BIT(8)
+#define DEFAULT_HAL_BACKEND_COMPATIBILITY_LOADED_PATH "/opt/etc/hal/.hal-backend-compatibility-loaded"
+
struct _hal_backend_module_data {
/**
* Each HAL module defines the different backend_module_data.
lshal_print_hal_backend_info(flags);
}
+static int show_help(void)
+{
+ printf(
+ "lshal - list platform hal and associated backend information\n"
+ "\n"
+ "USAGE\n"
+ "\tlshal [OPTION]...\n"
+ "\n"
+ "OPTION\n"
+ "\t-h, --help\n"
+ "\t\tShow this help.\n"
+ "\n"
+ "\t-r, --reset\n"
+ "\t\tClear hal information cache.\n"
+ );
+
+ return 0;
+}
+
+static int reset_cache(void)
+{
+ int ret;
+
+ ret = unlink(DEFAULT_HAL_BACKEND_COMPATIBILITY_LOADED_PATH);
+ if (ret < 0) {
+ printf("Failed to reset cache, %m\n");
+ return ret;
+ }
+
+ sync();
+
+ return 0;
+}
+
int main(int argc, char *argv[])
{
+ const struct option lshal_long_option[] = {
+ { "help", no_argument, NULL, 'h' },
+ { "reset", no_argument, NULL, 'r' },
+ { 0, },
+ };
+ int opt;
+
/* Register signal handler for freeing resources */
signal(SIGINT, lshal_handle_signal);
+ for (;;) {
+ opt = getopt_long(argc, argv, "hr", lshal_long_option, NULL);
+ if (opt == -1)
+ break;
+
+ switch (opt) {
+ case 'h':
+ return show_help();
+ case 'r':
+ return reset_cache();
+ default:
+ break;
+ }
+ }
+
lshal();
return 0;