1 /*
2 * Kernel version printing routine.
3 *
4 * Copyright (c) 2018-2021 The strace developers.
5 * All rights reserved.
6 *
7 * SPDX-License-Identifier: LGPL-2.1-or-later
8 */
9
10 #include "defs.h"
11
12 void
13 print_kernel_version(const unsigned long version)
14 {
15 if (xlat_verbose(xlat_verbosity) != XLAT_STYLE_ABBREV)
16 PRINT_VAL_X(version);
17
18 if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_RAW)
19 return;
20
21 if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE)
22 tprint_comment_begin();
23
24 const unsigned long ver_major = version >> 16;
25 const unsigned long ver_minor = (version >> 8) & 0xFF;
26 const unsigned long ver_patch = version & 0xFF;
27
28 tprints_arg_begin("KERNEL_VERSION");
29
30 PRINT_VAL_U(ver_major);
31 tprint_arg_next();
32
33 PRINT_VAL_U(ver_minor);
34 tprint_arg_next();
35
36 PRINT_VAL_U(ver_patch);
37 tprint_arg_end();
38
39 if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE)
40 tprint_comment_end();
41 }