fix: Add missing 'pselect6_time32' and 'ppoll_time32' syscall overrides
[lttng-modules.git] / src / wrapper / random.c
... / ...
CommitLineData
1/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
2 *
3 * wrapper/random.c
4 *
5 * wrapper around bootid read. Read the boot id through the /proc filesystem.
6 *
7 * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 */
9
10#include <linux/errno.h>
11
12/* boot_id depends on sysctl */
13#if defined(CONFIG_SYSCTL)
14
15#include <linux/fs.h>
16#include <linux/file.h>
17#include <linux/sched.h>
18#include <linux/uaccess.h>
19#include <wrapper/random.h>
20
21/*
22 * Returns string boot id.
23 */
24int wrapper_get_bootid(char *bootid)
25{
26 struct file *file;
27 int ret;
28 ssize_t len;
29
30 file = filp_open("/proc/sys/kernel/random/boot_id", O_RDONLY, 0);
31 if (IS_ERR(file))
32 return PTR_ERR(file);
33
34 len = kernel_read(file, bootid, BOOT_ID_LEN - 1, &file->f_pos);
35 if (len != BOOT_ID_LEN - 1) {
36 ret = -EINVAL;
37 goto end;
38 }
39
40 bootid[BOOT_ID_LEN - 1] = '\0';
41 ret = 0;
42end:
43 filp_close(file, current->files);
44 return ret;
45}
46EXPORT_SYMBOL_GPL(wrapper_get_bootid);
47
48#else
49
50int wrapper_get_bootid(char *bootid)
51{
52 return -ENOSYS;
53}
54EXPORT_SYMBOL_GPL(wrapper_get_bootid);
55
56#endif
This page took 0.022556 seconds and 4 git commands to generate.