move away from syscall counts towards operation counts
[trinity.git] / ioctls / logger.c
blobf23cbcdbf847b0970bb2aa6a8855fbc01a4a20bc
1 #include <inttypes.h>
2 #include <stdlib.h>
4 /* drivers/staging/android/logger.h */
6 /* include/linux/logger.h
8 * Copyright (C) 2007-2008 Google, Inc.
9 * Author: Robert Love <rlove@android.com>
11 * This software is licensed under the terms of the GNU General Public
12 * License version 2, as published by the Free Software Foundation, and
13 * may be copied, distributed, and modified under those terms.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
22 #include <linux/types.h>
23 #include <linux/ioctl.h>
25 /**
26 * struct logger_entry - defines a single entry that is given to a logger
27 * @len: The length of the payload
28 * @__pad: Two bytes of padding that appear to be required
29 * @pid: The generating process' process ID
30 * @tid: The generating process' thread ID
31 * @sec: The number of seconds that have elapsed since the Epoch
32 * @nsec: The number of nanoseconds that have elapsed since @sec
33 * @msg: The message that is to be logged
35 struct logger_entry {
36 __u16 len;
37 __u16 __pad;
38 __s32 pid;
39 __s32 tid;
40 __s32 sec;
41 __s32 nsec;
42 char msg[0];
45 #define LOGGER_LOG_RADIO "log_radio" /* radio-related messages */
46 #define LOGGER_LOG_EVENTS "log_events" /* system/hardware events */
47 #define LOGGER_LOG_SYSTEM "log_system" /* system/framework messages */
48 #define LOGGER_LOG_MAIN "log_main" /* everything else */
50 #define LOGGER_ENTRY_MAX_LEN (4*1024)
51 #define LOGGER_ENTRY_MAX_PAYLOAD \
52 (LOGGER_ENTRY_MAX_LEN - sizeof(struct logger_entry))
54 #define __LOGGERIO 0xAE
56 #define LOGGER_GET_LOG_BUF_SIZE _IO(__LOGGERIO, 1) /* size of log */
57 #define LOGGER_GET_LOG_LEN _IO(__LOGGERIO, 2) /* used log len */
58 #define LOGGER_GET_NEXT_ENTRY_LEN _IO(__LOGGERIO, 3) /* next entry len */
59 #define LOGGER_FLUSH_LOG _IO(__LOGGERIO, 4) /* flush log */
61 #include "shm.h"
62 #include "utils.h"
63 #include "ioctls.h"
65 static const struct ioctl logger_ioctls[] = {
66 IOCTL(LOGGER_GET_LOG_BUF_SIZE),
67 IOCTL(LOGGER_GET_LOG_LEN),
68 IOCTL(LOGGER_GET_NEXT_ENTRY_LEN),
69 IOCTL(LOGGER_FLUSH_LOG),
72 static const char *const logger_miscdevs[] = {
73 LOGGER_LOG_RADIO,
74 LOGGER_LOG_EVENTS,
75 LOGGER_LOG_SYSTEM,
76 LOGGER_LOG_MAIN,
79 static const struct ioctl_group logger_grp = {
80 .devtype = DEV_MISC,
81 .devs = logger_miscdevs,
82 .devs_cnt = ARRAY_SIZE(logger_miscdevs),
83 .sanitise = pick_random_ioctl,
84 .ioctls = logger_ioctls,
85 .ioctls_cnt = ARRAY_SIZE(logger_ioctls),
88 REG_IOCTL_GROUP(logger_grp)