Skip to content

Commit

Permalink
move output() and friends to trinity.h
Browse files Browse the repository at this point in the history
step 1 of killing off log.h

This is used pretty much everywhere, so it makes sense to put it in
the 'everything' header.
  • Loading branch information
kernelslacker committed Feb 22, 2017
1 parent 1570804 commit 4b9e9c5
Show file tree
Hide file tree
Showing 52 changed files with 24 additions and 63 deletions.
2 changes: 1 addition & 1 deletion arg-decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ static unsigned int render_syscall_postfix(struct syscallrecord *rec, char *buff
}

/* These next two functions are always called from child_random_syscalls() by a fuzzing child.
* They render the buffer, and output it (to both stdout and logs).
* They render the buffer, and output it to stdout.
* Other contexts (like post-mortem) directly use the buffers.
*/
void output_syscall_prefix(struct syscallrecord *rec)
Expand Down
1 change: 0 additions & 1 deletion child.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "arch.h"
#include "child.h"
#include "list.h"
#include "log.h"
#include "maps.h"
#include "params.h"
#include "pids.h"
Expand Down
1 change: 1 addition & 0 deletions childops/thrash-pid-files.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "pathnames.h"
#include "pids.h"
#include "random.h"
#include "shm.h"

static void read_pid_files(pid_t pid, char *buffer)
{
Expand Down
2 changes: 1 addition & 1 deletion debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#include <stdio.h>
#include <stdarg.h>
#include <syslog.h>
#include <unistd.h>
#include "child.h"
#include "debug.h"
#include "log.h"
#include "params.h"
#include "pids.h"
#include "shm.h"
Expand Down
2 changes: 1 addition & 1 deletion devices.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include <sys/types.h>
#include <linux/kdev_t.h>
#include "files.h"
#include "trinity.h"

#include "log.h"

static struct {
int major;
Expand Down
1 change: 0 additions & 1 deletion fds/bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include "bpf.h"
#include "fd.h"
#include "log.h"
#include "objects.h"
#include "random.h"
#include "sanitise.h"
Expand Down
1 change: 0 additions & 1 deletion fds/drm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "config.h"
#include "fd.h"
#include "log.h"
#include "memfd.h"
#include "objects.h"
#include "random.h"
Expand Down
1 change: 0 additions & 1 deletion fds/epoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <sys/epoll.h>

#include "fd.h"
#include "log.h"
#include "objects.h"
#include "random.h"
#include "sanitise.h"
Expand Down
1 change: 0 additions & 1 deletion fds/eventfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#include "fd.h"
#include "files.h"
#include "log.h"
#include "objects.h"
#include "random.h"
#include "sanitise.h"
Expand Down
1 change: 0 additions & 1 deletion fds/fanotify_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <unistd.h>

#include "fd.h"
#include "log.h"
#include "fanotify.h"
#include "objects.h"
#include "random.h"
Expand Down
1 change: 0 additions & 1 deletion fds/fds.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <unistd.h>

#include "fd.h"
#include "log.h"
#include "list.h"
#include "net.h"
#include "params.h"
Expand Down
1 change: 0 additions & 1 deletion fds/files.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "exit.h"
#include "fd.h"
#include "files.h"
#include "log.h"
#include "objects.h"
#include "pathnames.h"
#include "random.h"
Expand Down
1 change: 0 additions & 1 deletion fds/inotify.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <sys/inotify.h>

#include "fd.h"
#include "log.h"
#include "objects.h"
#include "random.h"
#include "sanitise.h"
Expand Down
1 change: 0 additions & 1 deletion fds/memfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <unistd.h>

#include "fd.h"
#include "log.h"
#include "memfd.h"
#include "objects.h"
#include "random.h"
Expand Down
1 change: 0 additions & 1 deletion fds/perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "objects.h"
#include "perf.h"
#include "shm.h"
#include "log.h"
#include "sanitise.h"

#define MAX_PERF_FDS 10
Expand Down
1 change: 0 additions & 1 deletion fds/pipes.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#include "fd.h"
#include "files.h"
#include "log.h"
#include "objects.h"
#include "pipes.h"
#include "random.h"
Expand Down
1 change: 0 additions & 1 deletion fds/sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#include "debug.h"
#include "domains.h"
#include "log.h"
#include "net.h"
#include "objects.h"
#include "params.h" // verbose, do_specific_domain
Expand Down
1 change: 0 additions & 1 deletion fds/testfiles.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#include "fd.h"
#include "files.h"
#include "log.h"
#include "objects.h"
#include "random.h"
#include "sanitise.h"
Expand Down
1 change: 0 additions & 1 deletion fds/timerfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#include "fd.h"
#include "files.h"
#include "log.h"
#include "objects.h"
#include "random.h"
#include "sanitise.h"
Expand Down
1 change: 0 additions & 1 deletion fds/userfaultfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <unistd.h>

#include "fd.h"
#include "log.h"
#include "userfaultfd.h"
#include "objects.h"
#include "random.h"
Expand Down
2 changes: 1 addition & 1 deletion ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <stdlib.h>

#include "ftrace.h"
#include "log.h"
#include "trinity.h"

static int trace_fd = -1;

Expand Down
1 change: 0 additions & 1 deletion generate-args.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "arch.h"
#include "debug.h"
#include "files.h"
#include "log.h"
#include "maps.h"
#include "net.h"
#include "pathnames.h"
Expand Down
16 changes: 1 addition & 15 deletions include/log.h
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
#pragma once

#include <unistd.h>
#include "child.h"
#include "config.h"
#include "exit.h"
#include "shm.h"
#include "syscall.h"
#include "types.h"
#include "utils.h"

#define MAX_LOGLEVEL 3

void output(unsigned char level, const char *fmt, ...);
void outputerr(const char *fmt, ...);
void outputstd(const char *fmt, ...);
void output_rendered_buffer(char *buffer);
void output_syscall_prefix(struct syscallrecord *rec);
void output_syscall_postfix(struct syscallrecord *rec);
void output_rendered_buffer(char *buffer);

void debugf(const char *fmt, ...);
7 changes: 7 additions & 0 deletions include/trinity.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,10 @@ void panic(int reason);

#define FAIL 0
#define SUCCESS 1

// output stuff that's used pretty much everywhere, so may as well be here.
#define MAX_LOGLEVEL 3
void output(unsigned char level, const char *fmt, ...);
void outputerr(const char *fmt, ...);
void outputstd(const char *fmt, ...);
void debugf(const char *fmt, ...);
1 change: 0 additions & 1 deletion ioctls/ioctls.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#include "files.h"
#include "ioctls.h"
#include "log.h"
#include "random.h"
#include "sanitise.h"
#include "shm.h"
Expand Down
3 changes: 2 additions & 1 deletion locks.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
#include <sys/types.h>
#include <unistd.h>
#include "debug.h"
#include "exit.h"
#include "locks.h"
#include "log.h"
#include "pids.h"
#include "shm.h"
#include "trinity.h"
#include "utils.h"

Expand Down
1 change: 1 addition & 0 deletions log.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <errno.h>
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
#include "log.h"
#include "pids.h"
#include "params.h" // quiet_level
Expand Down
1 change: 0 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "child.h"
#include "debug.h"
#include "ftrace.h"
#include "log.h"
#include "params.h"
#include "pids.h"
#include "post-mortem.h"
Expand Down
1 change: 0 additions & 1 deletion mm/maps-initial.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <sys/mman.h>
#include "arch.h"
#include "list.h"
#include "log.h"
#include "maps.h"
#include "random.h"
#include "utils.h"
Expand Down
1 change: 0 additions & 1 deletion net/bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "bpf.h"
#include "config.h"
#include "debug.h"
#include "log.h"
#include "net.h"
#include "random.h"
#include "syscall.h"
Expand Down
1 change: 0 additions & 1 deletion net/domains.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <unistd.h>

#include "debug.h"
#include "log.h"
#include "net.h"
#include "domains.h"
#include "params.h"
Expand Down
1 change: 0 additions & 1 deletion objects.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "list.h"
#include "log.h"
#include "objects.h"
#include "random.h"
#include "shm.h"
Expand Down
1 change: 0 additions & 1 deletion params.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "bdevs.h"
#include "child.h"
#include "ftrace.h"
#include "log.h"
#include "net.h"
#include "params.h"
#include "domains.h"
Expand Down
1 change: 0 additions & 1 deletion pathnames.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <sys/stat.h>

#include "exit.h"
#include "log.h"
#include "params.h"
#include "pathnames.h"
#include "random.h"
Expand Down
2 changes: 1 addition & 1 deletion pids.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <stdio.h>
#include <sys/types.h>
#include <signal.h>
#include "log.h"
#include <unistd.h>
#include "params.h" // dangerous
#include "pids.h"
#include "random.h"
Expand Down
1 change: 0 additions & 1 deletion post-mortem.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <fcntl.h>
#include <string.h>
#include <syslog.h>
#include "log.h"
#include "pids.h"
#include "shm.h"
#include "taint.h"
Expand Down
1 change: 0 additions & 1 deletion rand/random-address.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <sys/mman.h> // mprotect

#include "arch.h" // KERNEL_ADDR etc
#include "log.h"
#include "random.h"
#include "sanitise.h"
#include "maps.h"
Expand Down
1 change: 0 additions & 1 deletion rand/seed.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "shm.h"
#include "params.h" // 'user_set_seed'
#include "pids.h"
#include "log.h"
#include "random.h"
#include "utils.h"

Expand Down
1 change: 0 additions & 1 deletion shm.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <sys/mman.h>
#include "arch.h"
#include "child.h"
#include "log.h"
#include "params.h"
#include "pids.h"
#include "random.h"
Expand Down
2 changes: 1 addition & 1 deletion stats.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <errno.h>
#include "log.h"
#include "arch.h"
#include "stats.h"
#include "syscall.h"
#include "tables.h"
Expand Down
3 changes: 2 additions & 1 deletion syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <errno.h>
#include <string.h>
#include <signal.h>
#include <unistd.h>
#include <sys/prctl.h>
#include <sys/syscall.h>
#include <sys/types.h>
Expand All @@ -20,9 +21,9 @@
#include "sanitise.h"
#include "shm.h"
#include "syscall.h"
#include "log.h"
#include "tables.h"
#include "taint.h"
#include "trinity.h"
#include "uid.h"
#include "utils.h"

Expand Down
1 change: 0 additions & 1 deletion syscalls/bind.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* On error, -1 is returned, and errno is set appropriately.
*/
#include <sys/socket.h>
#include "log.h"
#include "sanitise.h"
#include "shm.h"

Expand Down
1 change: 0 additions & 1 deletion syscalls/futex.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "sanitise.h"
#include "maps.h"
#include "futex.h"
#include "log.h"

#define FUTEX_UNLOCKED (0)
#define FUTEX_LOCKED (!FUTEX_UNLOCKED)
Expand Down
1 change: 0 additions & 1 deletion syscalls/perf_event_open.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <sys/types.h>
#include <dirent.h>
#include <errno.h>
#include "log.h"
#include "maps.h"
#include "perf.h"
#include "perf_event.h"
Expand Down
1 change: 0 additions & 1 deletion syscalls/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <sys/socket.h>
#include "config.h"
#include "debug.h"
#include "log.h"
#include "net.h"
#include "params.h"
#include "domains.h"
Expand Down
Loading

0 comments on commit 4b9e9c5

Please sign in to comment.