blob: 52370c8f0ef263a8142f70578854903cf45f7e59 [file] [log] [blame]
Lucas De Marchi51e873d2011-12-31 19:29:13 -02001#include <stdio.h>
2#include <stdlib.h>
3#include <stddef.h>
4#include <errno.h>
5#include <unistd.h>
6#include <inttypes.h>
7#include <string.h>
8#include <libkmod.h>
9
10static const char *config[] = {
11 NULL,
12 NULL,
13};
14
15int main(int argc, char *argv[])
16{
17 struct kmod_ctx *ctx;
18 int r;
19 char cmd[4096];
20
21 if (argc < 2) {
22 fprintf(stderr, "Provide a path to config\n");
23 return EXIT_FAILURE;
24 }
25
26 config[0] = argv[1];
27
28 ctx = kmod_new(NULL, config);
29 if (ctx == NULL)
30 exit(EXIT_FAILURE);
31
32 r = kmod_validate_resources(ctx);
33 if (r != KMOD_RESOURCES_OK) {
34 fprintf(stderr, "ERR: return should be 'resources ok'\n");
35 return EXIT_FAILURE;
36 }
37
38 snprintf(cmd, sizeof(cmd), "touch %s", config[0]);
39 system(cmd);
40 r = kmod_validate_resources(ctx);
41 if (r != KMOD_RESOURCES_MUST_RECREATE) {
42 fprintf(stderr, "ERR: return should be 'must recreate'\n");
43 return EXIT_FAILURE;
44 }
45
46 kmod_unref(ctx);
47
48 return EXIT_SUCCESS;
49}