From f2d9a5ded5225d107a96f11af136f4a12f56b0cd Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Wed, 20 Mar 2013 17:19:06 +0000 Subject: Add a patch to make the optional shmlog mechanism works on FreeBSD. This allows users to use i3-dump-log to gets logs out of i3 is it was run with the shmlog-size parameter set to something greater than 0 --- x11-wm/i3/Makefile | 1 + x11-wm/i3/files/patch-src__log.c | 68 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 x11-wm/i3/files/patch-src__log.c (limited to 'x11-wm') diff --git a/x11-wm/i3/Makefile b/x11-wm/i3/Makefile index 1be60e1b52dc..4eda2f3cb8f2 100644 --- a/x11-wm/i3/Makefile +++ b/x11-wm/i3/Makefile @@ -3,6 +3,7 @@ PORTNAME= i3 DISTVERSION= 4.5.1 +PORTREVISION= 1 CATEGORIES= x11-wm MASTER_SITES= http://i3wm.org/downloads/ \ ${MASTER_SITE_LOCAL} diff --git a/x11-wm/i3/files/patch-src__log.c b/x11-wm/i3/files/patch-src__log.c new file mode 100644 index 000000000000..5c50252eeb57 --- /dev/null +++ b/x11-wm/i3/files/patch-src__log.c @@ -0,0 +1,68 @@ +--- ./src/log.c.orig 2013-03-20 15:28:14.746383400 +0100 ++++ ./src/log.c 2013-03-20 18:27:56.885378021 +0100 +@@ -81,11 +81,11 @@ + void init_logging(void) { + if (!errorfilename) { + if (!(errorfilename = get_process_filename("errorlog"))) +- ELOG("Could not initialize errorlog\n"); ++ fprintf(stderr, "Could not initialize errorlog\n"); + else { + errorfile = fopen(errorfilename, "w"); + if (fcntl(fileno(errorfile), F_SETFD, FD_CLOEXEC)) { +- ELOG("Could not set close-on-exec flag\n"); ++ fprintf(stderr, "Could not set close-on-exec flag\n"); + } + } + } +@@ -107,25 +107,28 @@ + sysconf(_SC_PAGESIZE); + #endif + logbuffer_size = min(physical_mem_bytes * 0.01, shmlog_size); +- sasprintf(&shmlogname, "/i3-log-%d", getpid()); ++#if defined(__FreeBSD__) ++ asprintf(&shmlogname, "/tmp/i3-log-%d", getpid()); ++#else ++ asprintf(&shmlogname, "/i3-log-%d", getpid()); ++#endif + logbuffer_shm = shm_open(shmlogname, O_RDWR | O_CREAT, S_IREAD | S_IWRITE); + if (logbuffer_shm == -1) { +- ELOG("Could not shm_open SHM segment for the i3 log: %s\n", strerror(errno)); ++ fprintf(stderr, "Could not shm_open SHM segment for the i3 log: %s\n", strerror(errno)); + return; + } +- + if (ftruncate(logbuffer_shm, logbuffer_size) == -1) { + close(logbuffer_shm); +- shm_unlink("/i3-log-"); +- ELOG("Could not ftruncate SHM segment for the i3 log: %s\n", strerror(errno)); ++ shm_unlink(shmlogname); ++ fprintf(stderr, "Could not ftruncate SHM segment for the i3 log: %s\n", strerror(errno)); + return; + } + + logbuffer = mmap(NULL, logbuffer_size, PROT_READ | PROT_WRITE, MAP_SHARED, logbuffer_shm, 0); + if (logbuffer == MAP_FAILED) { + close(logbuffer_shm); +- shm_unlink("/i3-log-"); +- ELOG("Could not mmap SHM segment for the i3 log: %s\n", strerror(errno)); ++ shm_unlink(shmlogname); ++ fprintf(stderr, "Could not mmap SHM segment for the i3 log: %s\n", strerror(errno)); + logbuffer = NULL; + return; + } +@@ -138,13 +141,14 @@ + pthread_condattr_t cond_attr; + pthread_condattr_init(&cond_attr); + if (pthread_condattr_setpshared(&cond_attr, PTHREAD_PROCESS_SHARED) != 0) +- ELOG("pthread_condattr_setpshared() failed, i3-dump-log -f will not work!\n"); ++ fprintf(stderr, "pthread_condattr_setpshared() failed, i3-dump-log -f will not work!\n"); + pthread_cond_init(&(header->condvar), &cond_attr); + + logwalk = logbuffer + sizeof(i3_shmlog_header); + loglastwrap = logbuffer + logbuffer_size; + store_log_markers(); + } ++ + atexit(purge_zerobyte_logfile); + } + -- cgit v1.2.3