From cf785d3f64fee180aa0bf7eba8014681207cdfcb Mon Sep 17 00:00:00 2001 From: Ahreum Jeong Date: Mon, 29 May 2017 15:39:52 +0900 Subject: [PATCH] Modify values read from procfs to match output formats Add or delete '\n' to values read from procfs --- os/fs/procfs/fs_procfsproc.c | 35 ++++++++++++----------------------- os/fs/procfs/fs_procfsuptime.c | 6 +++--- os/fs/procfs/fs_procfsversion.c | 8 ++++---- 3 files changed, 19 insertions(+), 30 deletions(-) diff --git a/os/fs/procfs/fs_procfsproc.c b/os/fs/procfs/fs_procfsproc.c index ea9fcdd..8bec75b 100644 --- a/os/fs/procfs/fs_procfsproc.c +++ b/os/fs/procfs/fs_procfsproc.c @@ -406,7 +406,7 @@ static ssize_t proc_status(FAR struct proc_file_s *procfile, FAR struct tcb_s *t /* Show the scheduler */ - linesize = snprintf(procfile->line, STATUS_LINELEN, "%-12s%s\n", "Scheduler:", tcb->flags & TCB_FLAG_ROUND_ROBIN ? "SCHED_RR" : "SCHED_FIFO"); + linesize = snprintf(procfile->line, STATUS_LINELEN, "%-12s%s", "Scheduler:", tcb->flags & TCB_FLAG_ROUND_ROBIN ? "SCHED_RR" : "SCHED_FIFO"); copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset); totalsize += copysize; @@ -420,12 +420,12 @@ static ssize_t proc_status(FAR struct proc_file_s *procfile, FAR struct tcb_s *t /* Show the signal mask */ #ifndef CONFIG_DISABLE_SIGNALS - linesize = snprintf(procfile->line, STATUS_LINELEN, "%-12s%08x\n", "SigMask:", tcb->sigprocmask); + + linesize = snprintf(procfile->line, STATUS_LINELEN, "\n%-12s%08x", "SigMask:", tcb->sigprocmask); copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset); totalsize += copysize; #endif - return totalsize; } @@ -470,7 +470,7 @@ static ssize_t proc_cmdline(FAR struct proc_file_s *procfile, FAR struct tcb_s * if ((tcb->flags & TCB_FLAG_TTYPE_MASK) == TCB_FLAG_TTYPE_PTHREAD) { FAR struct pthread_tcb_s *ptcb = (FAR struct pthread_tcb_s *)tcb; - linesize = snprintf(procfile->line, STATUS_LINELEN, " 0x%p\n", ptcb->arg); + linesize = snprintf(procfile->line, STATUS_LINELEN, " 0x%p", ptcb->arg); copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset); totalsize += copysize; @@ -498,10 +498,6 @@ static ssize_t proc_cmdline(FAR struct proc_file_s *procfile, FAR struct tcb_s * } } - linesize = snprintf(procfile->line, STATUS_LINELEN, "\n"); - copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset); - - totalsize += copysize; return totalsize; } @@ -576,7 +572,7 @@ static ssize_t proc_stack(FAR struct proc_file_s *procfile, FAR struct tcb_s *tc /* Show the stack size */ - linesize = snprintf(procfile->line, STATUS_LINELEN, "%-12s%ld\n", "StackSize:", (long)tcb->adj_stack_size); + linesize = snprintf(procfile->line, STATUS_LINELEN, "%-12s%ld", "StackSize:", (long)tcb->adj_stack_size); copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset); totalsize += copysize; @@ -590,7 +586,7 @@ static ssize_t proc_stack(FAR struct proc_file_s *procfile, FAR struct tcb_s *tc /* Show the stack size */ - linesize = snprintf(procfile->line, STATUS_LINELEN, "%-12s%ld\n", "StackUsed:", (long)up_check_tcbstack(tcb)); + linesize = snprintf(procfile->line, STATUS_LINELEN, "\n%-12s%ld", "StackUsed:", (long)up_check_tcbstack(tcb)); copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset); totalsize += copysize; @@ -671,7 +667,7 @@ static ssize_t proc_groupstatus(FAR struct proc_file_s *procfile, FAR struct tcb return totalsize; } - linesize = snprintf(procfile->line, STATUS_LINELEN, "%-12s%d\n", "Members:", group->tg_nmembers); + linesize = snprintf(procfile->line, STATUS_LINELEN, "%-12s%d", "Members:", group->tg_nmembers); copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset); totalsize += copysize; @@ -683,7 +679,7 @@ static ssize_t proc_groupstatus(FAR struct proc_file_s *procfile, FAR struct tcb return totalsize; } - linesize = snprintf(procfile->line, STATUS_LINELEN, "Member IDs:"); + linesize = snprintf(procfile->line, STATUS_LINELEN, "\nMember IDs:"); copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset); totalsize += copysize; @@ -706,13 +702,6 @@ static ssize_t proc_groupstatus(FAR struct proc_file_s *procfile, FAR struct tcb return totalsize; } } - - linesize = snprintf(procfile->line, STATUS_LINELEN, "\n"); - copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset); - - totalsize += copysize; - buffer += copysize; - remaining -= copysize; #endif return totalsize; @@ -743,7 +732,7 @@ static ssize_t proc_groupfd(FAR struct proc_file_s *procfile, FAR struct tcb_s * totalsize = 0; #if CONFIG_NFILE_DESCRIPTORS > 0 /* Guaranteed to be true */ - linesize = snprintf(procfile->line, STATUS_LINELEN, "\n%3-s %-8s %s\n", "FD", "POS", "OFLAGS"); + linesize = snprintf(procfile->line, STATUS_LINELEN, "%3-s %-8s %s", "FD", "POS", "OFLAGS"); copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset); totalsize += copysize; @@ -760,7 +749,7 @@ static ssize_t proc_groupfd(FAR struct proc_file_s *procfile, FAR struct tcb_s * /* Is there an inode associated with the file descriptor? */ if (file->f_inode) { - linesize = snprintf(procfile->line, STATUS_LINELEN, "%3d %8ld %04x\n", i, (long)file->f_pos, file->f_oflags); + linesize = snprintf(procfile->line, STATUS_LINELEN, "\n%3d %8ld %04x", i, (long)file->f_pos, file->f_oflags); copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset); totalsize += copysize; @@ -775,7 +764,7 @@ static ssize_t proc_groupfd(FAR struct proc_file_s *procfile, FAR struct tcb_s * #endif #if CONFIG_NSOCKET_DESCRIPTORS > 0 - linesize = snprintf(procfile->line, STATUS_LINELEN, "\n%3-s %-2s %-3s %s\n", "SD", "RF", "TYP", "FLAGS"); + linesize = snprintf(procfile->line, STATUS_LINELEN, "\n%3-s %-2s %-3s %s", "SD", "RF", "TYP", "FLAGS"); copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset); totalsize += copysize; @@ -792,7 +781,7 @@ static ssize_t proc_groupfd(FAR struct proc_file_s *procfile, FAR struct tcb_s * /* Is there an connection associated with the socket descriptor? */ if (socket->conn) { - linesize = snprintf(procfile->line, STATUS_LINELEN, "%3d %2d %3d %02x", i + CONFIG_NFILE_DESCRIPTORS, (long)socket->conn->state, socket->conn->type, socket->conn->flags); + linesize = snprintf(procfile->line, STATUS_LINELEN, "\n%3d %2d %3d %02x", i + CONFIG_NFILE_DESCRIPTORS, (long)socket->conn->state, socket->conn->type, socket->conn->flags); copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset); totalsize += copysize; diff --git a/os/fs/procfs/fs_procfsuptime.c b/os/fs/procfs/fs_procfsuptime.c index 02ca33b..db9561e 100644 --- a/os/fs/procfs/fs_procfsuptime.c +++ b/os/fs/procfs/fs_procfsuptime.c @@ -261,7 +261,7 @@ static ssize_t uptime_read(FAR struct file *filep, FAR char *buffer, size_t bufl /* Convert the system up time to a seconds + hundredths of seconds string */ now = (double)ticktime / (double)CLOCKS_PER_SEC; - linesize = snprintf(attr->line, UPTIME_LINELEN, "%10.2f\n", now); + linesize = snprintf(attr->line, UPTIME_LINELEN, "%10.2f", now); #else /* Convert the system up time to seconds + hundredths of seconds */ @@ -279,9 +279,9 @@ static ssize_t uptime_read(FAR struct file *filep, FAR char *buffer, size_t bufl /* Convert the seconds + hundredths of seconds to a string */ #ifdef CONFIG_SYSTEM_TIME64 - linesize = snprintf(attr->line, UPTIME_LINELEN, "%7llu.%02u\n", sec, csec); + linesize = snprintf(attr->line, UPTIME_LINELEN, "%7llu.%02u", sec, csec); #else - linesize = snprintf(attr->line, UPTIME_LINELEN, "%7lu.%02u\n", sec, csec); + linesize = snprintf(attr->line, UPTIME_LINELEN, "%7lu.%02u", sec, csec); #endif #endif diff --git a/os/fs/procfs/fs_procfsversion.c b/os/fs/procfs/fs_procfsversion.c index 68bc6b0..aa861cd 100644 --- a/os/fs/procfs/fs_procfsversion.c +++ b/os/fs/procfs/fs_procfsversion.c @@ -196,7 +196,7 @@ static ssize_t version_read(FAR struct file *filep, FAR char *buffer, size_t buf remaining = buflen; totalsize = 0; - linesize = snprintf(attr->line, VERSION_LINELEN, "\tVersion: %s\n", CONFIG_VERSION_STRING); + linesize = snprintf(attr->line, VERSION_LINELEN, "Version: %s\n", CONFIG_VERSION_STRING); copysize = procfs_memcpy(attr->line, linesize, buffer, remaining, &offset); totalsize += copysize; buffer += copysize; @@ -206,7 +206,7 @@ static ssize_t version_read(FAR struct file *filep, FAR char *buffer, size_t buf goto end; } - linesize = snprintf(attr->line, VERSION_LINELEN, "\tCommit Hash: %s\n", CONFIG_VERSION_BUILD); + linesize = snprintf(attr->line, VERSION_LINELEN, "Commit Hash: %s\n", CONFIG_VERSION_BUILD); copysize = procfs_memcpy(attr->line, linesize, buffer, remaining, &offset); totalsize += copysize; buffer += copysize; @@ -216,7 +216,7 @@ static ssize_t version_read(FAR struct file *filep, FAR char *buffer, size_t buf goto end; } - linesize = snprintf(attr->line, VERSION_LINELEN, "\tBuild User: %s\n", CONFIG_VERSION_BUILD_USER); + linesize = snprintf(attr->line, VERSION_LINELEN, "Build User: %s\n", CONFIG_VERSION_BUILD_USER); copysize = procfs_memcpy(attr->line, linesize, buffer, remaining, &offset); totalsize += copysize; buffer += copysize; @@ -226,7 +226,7 @@ static ssize_t version_read(FAR struct file *filep, FAR char *buffer, size_t buf goto end; } - linesize = snprintf(attr->line, VERSION_LINELEN, "\tBuild Time: %s", CONFIG_VERSION_BUILD_TIME); + linesize = snprintf(attr->line, VERSION_LINELEN, "Build Time: %s", CONFIG_VERSION_BUILD_TIME); copysize = procfs_memcpy(attr->line, linesize, buffer, remaining, &offset); totalsize += copysize; -- 2.7.4