1 From f0624f6cc656cb177b64e2664f2a806221bfab58 Mon Sep 17 00:00:00 2001
2 From: Christian Hesse <mail@eworm.de>
3 Date: Thu, 28 Jul 2016 08:49:20 +0200
4 Subject: [PATCH 1/1] make iproute2 fhs compliant
6 Signed-off-by: Christian Hesse <mail@eworm.de>
9 netem/Makefile | 4 ++--
11 tc/tc_util.c | 15 +++++++++++++++
13 5 files changed, 20 insertions(+), 4 deletions(-)
15 diff --git a/Makefile b/Makefile
16 index eb571a5..db0a04c 100644
19 @@ -14,7 +14,7 @@ DBM_INCLUDE:=$(DESTDIR)/usr/include
23 -DEFINES= -DRESOLVE_HOSTNAMES -DLIBDIR=\"$(LIBDIR)\"
24 +DEFINES= -DRESOLVE_HOSTNAMES -DLIBDIR=\"$(LIBDIR)\" -DDATADIR=\"$(DATADIR)\"
25 ifneq ($(SHARED_LIBS),y)
26 DEFINES+= -DNO_SHARED_LIBS
28 diff --git a/netem/Makefile b/netem/Makefile
29 index e52e125..5b4d283 100644
32 @@ -20,9 +20,9 @@ stats: stats.c
33 $(HOSTCC) $(CCOPTS) -I../include -o $@ $@.c -lm
36 - mkdir -p $(DESTDIR)$(LIBDIR)/tc
37 + mkdir -p $(DESTDIR)$(DATADIR)/tc
38 for i in $(DISTDATA); \
39 - do install -m 644 $$i $(DESTDIR)$(LIBDIR)/tc; \
40 + do install -m 644 $$i $(DESTDIR)$(DATADIR)/tc; \
44 diff --git a/tc/q_netem.c b/tc/q_netem.c
45 index 8fe2204..a15a5c7 100644
48 @@ -113,7 +113,7 @@ static int get_distribution(const char *type, __s16 *data, int maxdata)
52 - snprintf(name, sizeof(name), "%s/%s.dist", get_tc_lib(), type);
53 + snprintf(name, sizeof(name), "%s/%s.dist", get_tc_datadir(), type);
54 if ((f = fopen(name, "r")) == NULL) {
55 fprintf(stderr, "No distribution data for %s (%s: %s)\n",
56 type, name, strerror(errno));
57 diff --git a/tc/tc_util.c b/tc/tc_util.c
58 index afc4cf5..728b854 100644
62 #define LIBDIR "/usr/lib"
66 +#define DATADIR "/usr/share"
69 static struct db_names *cls_names;
71 #define NAMES_DB "/etc/iproute2/tc_cls"
72 @@ -73,6 +77,17 @@ const char *get_tc_lib(void)
76 +const char *get_tc_datadir(void)
78 + const char *data_dir;
80 + data_dir = getenv("TC_DATA_DIR");
82 + data_dir = DATADIR "/tc/";
87 int get_qdisc_handle(__u32 *h, const char *str)
90 diff --git a/tc/tc_util.h b/tc/tc_util.h
91 index 61e60b1..6d448de 100644
94 @@ -55,6 +55,7 @@ struct exec_util {
97 const char *get_tc_lib(void);
98 +const char *get_tc_datadir(void);
100 struct qdisc_util *get_qdisc_kind(const char *str);
101 struct filter_util *get_filter_kind(const char *str);