mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
kernel: add section about /proc/version
Customize user, host and date
This commit is contained in:
20
README.adoc
20
README.adoc
@@ -5283,6 +5283,26 @@ Sources:
|
||||
|
||||
Bibliography: https://stackoverflow.com/questions/8516021/proc-create-example-for-kernel-module/18924359#18924359
|
||||
|
||||
===== /proc/version
|
||||
|
||||
Its data is shared with `uname()`, which is a POSIX C function and has a Linux syscall to back it up.
|
||||
|
||||
Where the data comes from and how to modify it:
|
||||
|
||||
* https://unix.stackexchange.com/questions/136959/where-does-uname-get-its-information-from/485962#485962
|
||||
* https://stackoverflow.com/questions/23424174/how-to-customize-or-remove-extra-linux-kernel-version-details-shown-at-boot
|
||||
|
||||
In this repo, leaking host information, and to make builds more reproducible, we are setting:
|
||||
|
||||
- user and date to dummy values
|
||||
- hostname to the kernel git commit
|
||||
|
||||
So the file contains something like:
|
||||
|
||||
....
|
||||
Linux version 4.19.0-dirty (lkmc@84df9525b0c27f3ebc2ebb1864fa62a97fdedb7d) (gcc version 6.4.0 (Buildroot 2018.05-00002-gbc60382b8f)) #1 SMP Thu Jan 1 00:00:00 UTC 1970
|
||||
....
|
||||
|
||||
==== sysfs
|
||||
|
||||
Sysfs is more restricted than <<procfs>>, as it does not take an arbitrary `file_operations`:
|
||||
|
||||
@@ -130,6 +130,12 @@ Configure the kernel, but don't build it.
|
||||
common_make_args +
|
||||
common.add_newlines(args.extra_make_args)
|
||||
),
|
||||
extra_env={
|
||||
'KBUILD_BUILD_VERSION': '1',
|
||||
'KBUILD_BUILD_TIMESTAMP': 'Thu Jan 1 00:00:00 UTC 1970',
|
||||
'KBUILD_BUILD_USER': 'lkmc',
|
||||
'KBUILD_BUILD_HOST': common.git_sha(common.linux_source_dir),
|
||||
},
|
||||
**common_args
|
||||
)
|
||||
common.run_cmd(
|
||||
|
||||
@@ -66,7 +66,9 @@ for key in common.arch_short_to_long_dict:
|
||||
arch_choices.append(common.arch_short_to_long_dict[key])
|
||||
default_arch = 'x86_64'
|
||||
gem5_cpt_prefix = '^cpt\.'
|
||||
sha = subprocess.check_output(['git', '-C', root_dir, 'log', '-1', '--format=%H']).decode().rstrip()
|
||||
def git_sha(repo_path):
|
||||
return subprocess.check_output(['git', '-C', repo_path, 'log', '-1', '--format=%H']).decode().rstrip()
|
||||
sha = common.git_sha(root_dir)
|
||||
release_dir = os.path.join(common.out_dir, 'release')
|
||||
release_zip_file = os.path.join(common.release_dir, 'lkmc-{}.zip'.format(common.sha))
|
||||
github_repo_id = 'cirosantilli/linux-kernel-module-cheat'
|
||||
|
||||
Reference in New Issue
Block a user