1 # Generate dl-tunable-list.h from dl-tunables.list
6 min_of
["INT_32"]=
"INT32_MIN"
7 max_of
["INT_32"]=
"INT32_MAX"
9 max_of
["UINT_64"]=
"UINT64_MAX"
11 max_of
["SIZE_T"]=
"SIZE_MAX"
19 # Skip over blank lines and comments.
28 # Beginning of either a top namespace, tunable namespace or a tunable, decided
29 # on the current value of TUNABLE, NS or TOP_NS.
37 else if (tunable ==
"") {
41 printf ("Unexpected occurrence of '{': %s:%d\n", FILENAME, FNR)
48 # End of either a top namespace, tunable namespace or a tunable.
51 # Tunables definition ended, now fill in default attributes.
52 if (!types
[top_ns
,ns
,tunable
]) {
53 types
[top_ns
,ns
,tunable
] =
"STRING"
55 if (!minvals
[top_ns
,ns
,tunable
]) {
56 minvals
[top_ns
,ns
,tunable
] = min_of
[types
[top_ns
,ns
,tunable
]]
58 if (!maxvals
[top_ns
,ns
,tunable
]) {
59 maxvals
[top_ns
,ns
,tunable
] = max_of
[types
[top_ns
,ns
,tunable
]]
61 if (!env_alias
[top_ns
,ns
,tunable
]) {
62 env_alias
[top_ns
,ns
,tunable
] =
"{0}"
64 if (!security_level
[top_ns
,ns
,tunable
]) {
65 security_level
[top_ns
,ns
,tunable
] =
"SXID_ERASE"
67 len =
length(top_ns
"."ns
"."tunable
)
68 if (len
> max_name_len
)
76 else if (top_ns
!= "") {
80 printf ("syntax error: extra }: %s:%d\n", FILENAME, FNR)
86 # Everything else, which could either be a tunable without any attributes or a
90 printf("Line %d: Invalid tunable outside a namespace: %s\n", NR, $
0)
95 # We encountered a tunable without any attributes, so note it with a
97 types
[top_ns
,ns
,$
1] =
"STRING"
101 # Otherwise, we have encountered a tunable attribute.
103 attr = gensub
(/^
[ \t]+|[ \t]+$
/, "", "g", arr
[1])
104 val = gensub
(/^
[ \t]+|[ \t]+$
/, "", "g", arr
[2])
106 if (attr ==
"type") {
107 types
[top_ns
,ns
,tunable
] = val
109 else if (attr ==
"minval") {
110 minvals
[top_ns
,ns
,tunable
] = val
112 else if (attr ==
"maxval") {
113 maxvals
[top_ns
,ns
,tunable
] = val
115 else if (attr ==
"env_alias") {
116 env_alias
[top_ns
,ns
,tunable
] =
sprintf("\"%s\"", val
)
118 if (len
> max_alias_len
)
121 else if (attr ==
"security_level") {
122 if (val ==
"SXID_ERASE" || val ==
"SXID_IGNORE" || val ==
"NONE") {
123 security_level
[top_ns
,ns
,tunable
] = val
126 printf("Line %d: Invalid value (%s) for security_level: %s, ", NR, val
,
128 print("Allowed values are 'SXID_ERASE', 'SXID_IGNORE', or 'NONE'")
132 else if (attr ==
"default") {
133 if (types
[top_ns
,ns
,tunable
] ==
"STRING") {
134 default_val
[top_ns
,ns
,tunable
] =
sprintf(".strval = \"%s\"", val
);
137 default_val
[top_ns
,ns
,tunable
] =
sprintf(".numval = %s", val
)
144 print "Unterminated namespace. Is a closing brace missing?"
148 print "/* AUTOGENERATED by gen-tunables.awk. */"
149 print "#ifndef _TUNABLES_H_"
150 print "# error \"Do not include this file directly.\""
151 print "# error \"Include tunables.h instead.\""
153 print "#include <dl-procinfo.h>\n"
155 # Now, the enum names
156 print "\ntypedef enum"
159 split (tnm
, indices
, SUBSEP
);
163 printf (" TUNABLE_ENUM_NAME(%s, %s, %s),\n", t
, n
, m
);
165 print "} tunable_id_t;\n"
167 print "\n#ifdef TUNABLES_INTERNAL"
168 # Internal definitions.
169 print "# define TUNABLE_NAME_MAX " (max_name_len
+ 1)
170 print "# define TUNABLE_ALIAS_MAX " (max_alias_len
+ 1)
171 print "# include \"dl-tunable-types.h\""
172 # Finally, the tunable list.
173 print "static tunable_t tunable_list[] attribute_relro = {"
175 split (tnm
, indices
, SUBSEP
);
179 printf (" {TUNABLE_NAME_S(%s, %s, %s)", t
, n
, m
)
180 printf (", {TUNABLE_TYPE_%s, %s, %s}, {%s}, NULL, TUNABLE_SECLEVEL_%s, %s},\n",
181 types
[t
,n
,m
], minvals
[t
,n
,m
], maxvals
[t
,n
,m
],
182 default_val
[t
,n
,m
], security_level
[t
,n
,m
], env_alias
[t
,n
,m
]);