diff --git a/tools/acrntrace/README.rst b/tools/acrntrace/README.rst index 2fb38c24c..433f161b0 100644 --- a/tools/acrntrace/README.rst +++ b/tools/acrntrace/README.rst @@ -13,7 +13,7 @@ Usage ***** The ``acrntrace`` tool runs on the Service OS (SOS) to capture trace data and -output to trace file under ``/tmp/acrntrace`` with raw (binary) data format. +output to trace file under ``./acrntrace`` with raw (binary) data format. Options: @@ -96,7 +96,7 @@ data to your linux system, and running the analysis tool. will exit automatically when the free storage space on the disk is less than reserved space. Reserved space on the disk is configurable through '-r'. - Trace files are created under ``/tmp/acrntrace/``, with a + Trace files are created under ``./acrntrace/``, with a date-time-based directory name such as ``20171115-101605`` #. When done, stop a running ``acrntrace``, with: @@ -120,7 +120,7 @@ data to your linux system, and running the analysis tool. .. code-block:: none - # scp -r /tmp/acrntrace/20171115-101605/ \ + # scp -r ./acrntrace/20171115-101605/ \ username@hostname:/home/username/trace_data Replace username and hostname with appropriate values. diff --git a/tools/acrntrace/acrntrace.c b/tools/acrntrace/acrntrace.c index 007103029..39fda35cf 100644 --- a/tools/acrntrace/acrntrace.c +++ b/tools/acrntrace/acrntrace.c @@ -22,9 +22,6 @@ #include "acrntrace.h" -/* default minimal amount free space (in MB) left on the disk */ -static uint64_t disk_reserved = 512; - #define TIMER_ID (128) static uint32_t timeout = 0; @@ -47,8 +44,6 @@ static void display_usage(void) "[Usage] acrntrace [-i] [period in msec] [-ch]\n\n" "[Options]\n" "\t-h: print this message\n" - "\t-r: minimal amount (in MB) of free space kept on the disk\n" - "\t before acrntrace stops\n" "\t-i: period_in_ms: specify polling interval [1-999]\n" "\t-t: max time to capture trace data (in second)\n" "\t-c: clear the buffered old data\n"); @@ -109,15 +104,6 @@ static int parse_opt(int argc, char *argv[]) period = ret * 1000; pr_dbg("Period is %lu\n", period); break; - case 'r': - ret = atoi(optarg); - if (ret <=0) { - pr_err("'-r' require integer greater than 0\n"); - return -EINVAL; - } - disk_reserved = ret; - pr_dbg("Keeping %dMB of space on the disk\n", ret); - break; case 't': ret = atoi(optarg); if (ret <= 0) { @@ -186,7 +172,6 @@ static int create_trace_file_dir(char *dir) pr_info("start tracing at %s\n", time_str); - /* Pre-condition: Make sure tmpfs is mounted on /tmp */ if (stat(TRACE_FILE_ROOT, &st)) { err = mkdir(TRACE_FILE_ROOT, 0644); if (err) { @@ -234,24 +219,6 @@ static void reader_fn(param_t * param) while (1) { do { - /* Check that filesystem has enough space */ - if (fstatvfs(fd, &stat)) { - printf("Fail to get vfs stat.\n"); - exiting = 1; - exit(EXIT_FAILURE); - } - - freespace = stat.f_frsize * (uint64_t)stat.f_bfree; - freespace >>= 20; /* Convert to MB */ - - if (freespace <= disk_reserved) { - printf("Disk space limit reached (free space:" - "%luMB, limit %luMB).\n", - freespace, disk_reserved); - exiting = 1; - exit(EXIT_FAILURE); - } - ret = sbuf_write(fd, sbuf); } while (ret > 0); diff --git a/tools/acrntrace/acrntrace.h b/tools/acrntrace/acrntrace.h index 2bae7b313..ea54f4d38 100644 --- a/tools/acrntrace/acrntrace.h +++ b/tools/acrntrace/acrntrace.h @@ -17,9 +17,9 @@ #define MMAP_SIZE ((TRACE_ELEMENT_SIZE * TRACE_ELEMENT_NUM \ + PAGE_SIZE - 1) & PAGE_MASK) */ -#define TRACE_FILE_NAME_LEN 36 -#define TRACE_FILE_DIR_LEN (TRACE_FILE_NAME_LEN - 2) -#define TRACE_FILE_ROOT "/tmp/acrntrace/" +#define TRACE_FILE_NAME_LEN 32 +#define TRACE_FILE_DIR_LEN (TRACE_FILE_NAME_LEN - 3) +#define TRACE_FILE_ROOT "acrntrace/" #define DEV_PATH_LEN 18 #define TIME_STR_LEN 16 #define CMD_MAX_LEN 48 diff --git a/tools/acrntrace/sbuf.c b/tools/acrntrace/sbuf.c index 871f28540..d293d2c4e 100644 --- a/tools/acrntrace/sbuf.c +++ b/tools/acrntrace/sbuf.c @@ -10,6 +10,7 @@ #include #include #include "sbuf.h" +#include static inline bool sbuf_is_empty(shared_buf_t *sbuf) { @@ -59,9 +60,9 @@ int sbuf_write(int fd, shared_buf_t *sbuf) start = (void *)sbuf + SBUF_HEAD_SIZE + sbuf->head; written = write(fd, start, sbuf->ele_size); - if ( written != sbuf->ele_size) { - printf("Failed to write. Expect written size %d, returned %d\n", - sbuf->ele_size, written); + if (written != sbuf->ele_size) { + printf("Failed to write: ret %d (ele_size %d), errno %d\n", + written, sbuf->ele_size, (written == -1) ? errno : 0); return -1; }