Thomas Gleixner | 457c899 | 2019-05-19 13:08:55 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
| 3 | * linux/init/version.c |
| 4 | * |
| 5 | * Copyright (C) 1992 Theodore Ts'o |
| 6 | * |
| 7 | * May be freely distributed as part of Linux. |
| 8 | */ |
| 9 | |
Sam Ravnborg | 9204595 | 2009-10-18 00:36:47 +0200 | [diff] [blame] | 10 | #include <generated/compile.h> |
Laura Abbott | 9afb719 | 2018-07-05 17:49:37 -0700 | [diff] [blame] | 11 | #include <linux/build-salt.h> |
Yonghong Song | 1fdd743 | 2021-04-01 16:27:23 -0700 | [diff] [blame] | 12 | #include <linux/elfnote-lto.h> |
Masahiro Yamada | e4f02fd | 2017-11-17 15:29:10 -0800 | [diff] [blame] | 13 | #include <linux/export.h> |
Dan Moulding | 5a70462 | 2022-07-17 17:31:37 -0700 | [diff] [blame] | 14 | #include <linux/init.h> |
| 15 | #include <linux/printk.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <linux/uts.h> |
| 17 | #include <linux/utsname.h> |
David Howells | 0bb80f2 | 2013-04-12 01:50:06 +0100 | [diff] [blame] | 18 | #include <linux/proc_ns.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | |
Dan Moulding | 5a70462 | 2022-07-17 17:31:37 -0700 | [diff] [blame] | 20 | static int __init early_hostname(char *arg) |
| 21 | { |
| 22 | size_t bufsize = sizeof(init_uts_ns.name.nodename); |
| 23 | size_t maxlen = bufsize - 1; |
Azeem Shaikh | 8ebab15 | 2023-08-30 16:08:06 +0000 | [diff] [blame] | 24 | ssize_t arglen; |
Dan Moulding | 5a70462 | 2022-07-17 17:31:37 -0700 | [diff] [blame] | 25 | |
Azeem Shaikh | 8ebab15 | 2023-08-30 16:08:06 +0000 | [diff] [blame] | 26 | arglen = strscpy(init_uts_ns.name.nodename, arg, bufsize); |
| 27 | if (arglen < 0) { |
Dan Moulding | 5a70462 | 2022-07-17 17:31:37 -0700 | [diff] [blame] | 28 | pr_warn("hostname parameter exceeds %zd characters and will be truncated", |
| 29 | maxlen); |
| 30 | } |
| 31 | return 0; |
| 32 | } |
| 33 | early_param("hostname", early_hostname); |
| 34 | |
Roman Zippel | 3eb3c740 | 2007-01-10 14:45:28 +0100 | [diff] [blame] | 35 | const char linux_proc_banner[] = |
| 36 | "%s version %s" |
| 37 | " (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ")" |
| 38 | " (" LINUX_COMPILER ") %s\n"; |
Laura Abbott | 9afb719 | 2018-07-05 17:49:37 -0700 | [diff] [blame] | 39 | |
| 40 | BUILD_SALT; |
Yonghong Song | 1fdd743 | 2021-04-01 16:27:23 -0700 | [diff] [blame] | 41 | BUILD_LTO_INFO; |
Masahiro Yamada | 2df8220c | 2022-08-28 11:39:53 +0900 | [diff] [blame] | 42 | |
| 43 | /* |
| 44 | * init_uts_ns and linux_banner contain the build version and timestamp, |
| 45 | * which are really fixed at the very last step of build process. |
| 46 | * They are compiled with __weak first, and without __weak later. |
| 47 | */ |
| 48 | |
| 49 | struct uts_namespace init_uts_ns __weak; |
| 50 | const char linux_banner[] __weak; |
| 51 | |
| 52 | #include "version-timestamp.c" |
| 53 | |
| 54 | EXPORT_SYMBOL_GPL(init_uts_ns); |