summarylogtreecommitdiffstats
path: root/0001-make-iproute2-fhs-compliant.patch
blob: ef6a07761de4049dd738fc3f879c0f60971498f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
From f0624f6cc656cb177b64e2664f2a806221bfab58 Mon Sep 17 00:00:00 2001
From: Christian Hesse <mail@eworm.de>
Date: Thu, 28 Jul 2016 08:49:20 +0200
Subject: [PATCH 1/1] make iproute2 fhs compliant

Signed-off-by: Christian Hesse <mail@eworm.de>
---
 Makefile       |  2 +-
 netem/Makefile |  4 ++--
 tc/q_netem.c   |  2 +-
 tc/tc_util.c   | 15 +++++++++++++++
 tc/tc_util.h   |  1 +
 5 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index eb571a5..db0a04c 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@ DBM_INCLUDE:=$(DESTDIR)/usr/include
 
 SHARED_LIBS = y
 
-DEFINES= -DRESOLVE_HOSTNAMES -DLIBDIR=\"$(LIBDIR)\"
+DEFINES= -DRESOLVE_HOSTNAMES -DLIBDIR=\"$(LIBDIR)\" -DDATADIR=\"$(DATADIR)\"
 ifneq ($(SHARED_LIBS),y)
 DEFINES+= -DNO_SHARED_LIBS
 endif
diff --git a/netem/Makefile b/netem/Makefile
index e52e125..5b4d283 100644
--- a/netem/Makefile
+++ b/netem/Makefile
@@ -20,9 +20,9 @@ stats: stats.c
 	$(HOSTCC) $(CCOPTS) -I../include -o $@ $@.c -lm
 
 install: all
-	mkdir -p $(DESTDIR)$(LIBDIR)/tc
+	mkdir -p $(DESTDIR)$(DATADIR)/tc
 	for i in $(DISTDATA); \
-	do install -m 644 $$i $(DESTDIR)$(LIBDIR)/tc; \
+	do install -m 644 $$i $(DESTDIR)$(DATADIR)/tc; \
 	done
 
 clean:
diff --git a/tc/q_netem.c b/tc/q_netem.c
index 8fe2204..a15a5c7 100644
--- a/tc/q_netem.c
+++ b/tc/q_netem.c
@@ -113,7 +113,7 @@ static int get_distribution(const char *type, __s16 *data, int maxdata)
 	char *line = NULL;
 	char name[128];
 
-	snprintf(name, sizeof(name), "%s/%s.dist", get_tc_lib(), type);
+	snprintf(name, sizeof(name), "%s/%s.dist", get_tc_datadir(), type);
 	if ((f = fopen(name, "r")) == NULL) {
 		fprintf(stderr, "No distribution data for %s (%s: %s)\n",
 			type, name, strerror(errno));
diff --git a/tc/tc_util.c b/tc/tc_util.c
index afc4cf5..728b854 100644
--- a/tc/tc_util.c
+++ b/tc/tc_util.c
@@ -32,6 +32,10 @@
 #define LIBDIR "/usr/lib"
 #endif
 
+#ifndef DATADIR
+#define DATADIR "/usr/share"
+#endif
+
 static struct db_names *cls_names;
 
 #define NAMES_DB "/etc/iproute2/tc_cls"
@@ -73,6 +77,17 @@ const char *get_tc_lib(void)
 	return lib_dir;
 }
 
+const char *get_tc_datadir(void)
+{
+	const char *data_dir;
+
+	data_dir = getenv("TC_DATA_DIR");
+	if (!data_dir)
+		data_dir = DATADIR "/tc/";
+
+	return data_dir;
+}
+
 int get_qdisc_handle(__u32 *h, const char *str)
 {
 	__u32 maj;
diff --git a/tc/tc_util.h b/tc/tc_util.h
index 61e60b1..6d448de 100644
--- a/tc/tc_util.h
+++ b/tc/tc_util.h
@@ -55,6 +55,7 @@ struct exec_util {
 };
 
 const char *get_tc_lib(void);
+const char *get_tc_datadir(void);
 
 struct qdisc_util *get_qdisc_kind(const char *str);
 struct filter_util *get_filter_kind(const char *str);