diff options
author | Fernando ApesteguĂa <fernape@FreeBSD.org> | 2022-03-08 14:19:53 +0000 |
---|---|---|
committer | Dmitry Chagin <dchagin@FreeBSD.org> | 2022-06-17 19:33:50 +0000 |
commit | c43c6efaee52465c1076de3f2ba2d3aef56c5bb7 (patch) | |
tree | cc3ee0e6dacefc255023c3a04d4c5e93f8263a2f /sys/compat/linprocfs/linprocfs.c | |
parent | d6e320830168835e400bc305b169089d7cb1df1f (diff) |
[linprocfs] add sys/kernel/random/boot_id
This file holds a UUID that is invariant for every boot. In our case, it is
invariant per mount.
PR: 262369
Reported by: sodynet1@gmail.com
Approved by: dchagin@
Differential Revision: https://reviews.freebsd.org/D34860
(cherry picked from commit 0f2041a5b03259a8a7b20ffc98e34884cc5590b3)
Diffstat (limited to 'sys/compat/linprocfs/linprocfs.c')
-rw-r--r-- | sys/compat/linprocfs/linprocfs.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c index 97ae357a229e..e1cc3289ce99 100644 --- a/sys/compat/linprocfs/linprocfs.c +++ b/sys/compat/linprocfs/linprocfs.c @@ -1888,6 +1888,24 @@ linprocfs_douuid(PFS_FILL_ARGS) } /* + * Filler function for proc/sys/kernel/random/boot_id + */ +static int +linprocfs_doboot_id(PFS_FILL_ARGS) +{ + static bool firstboot = 1; + static struct uuid uuid; + + if (firstboot) { + kern_uuidgen(&uuid, 1); + firstboot = 0; + } + sbuf_printf_uuid(sb, &uuid); + sbuf_printf(sb, "\n"); + return(0); +} + +/* * Filler function for proc/pid/auxv */ static int @@ -2097,6 +2115,8 @@ linprocfs_init(PFS_INIT_ARGS) dir = pfs_create_dir(dir, "random", NULL, NULL, NULL, 0); pfs_create_file(dir, "uuid", &linprocfs_douuid, NULL, NULL, NULL, PFS_RD); + pfs_create_file(dir, "boot_id", &linprocfs_doboot_id, + NULL, NULL, NULL, PFS_RD); /* /proc/sys/vm/.... */ dir = pfs_create_dir(sys, "vm", NULL, NULL, NULL, 0); |