You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ma...@apache.org on 2020/07/30 01:33:22 UTC

[incubator-nuttx] 02/02: procfs: Get version info from uname instead

This is an automated email from the ASF dual-hosted git repository.

masayuki pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 338244dbac11a589c01949bb4ec77668e19142e6
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Tue Jul 28 22:26:04 2020 +0800

    procfs: Get version info from uname instead
    
    unify the version into one place
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
    Change-Id: I988fb40d3f460b0291114c60edb04db3aabb38f1
---
 fs/procfs/Make.defs          |  5 -----
 fs/procfs/fs_procfsversion.c | 15 +++++----------
 2 files changed, 5 insertions(+), 15 deletions(-)

diff --git a/fs/procfs/Make.defs b/fs/procfs/Make.defs
index 99ca2df..56607af 100644
--- a/fs/procfs/Make.defs
+++ b/fs/procfs/Make.defs
@@ -49,9 +49,4 @@ endif
 DEPPATH += --dep-path procfs
 VPATH += :procfs
 
-# To ensure version information is newest,
-# add fs_procfsversion to phony target for force rebuild
-
-.PHONY: fs_procfsversion$(OBJEXT)
-
 endif
diff --git a/fs/procfs/fs_procfsversion.c b/fs/procfs/fs_procfsversion.c
index fc2c55c..1a3e0c1 100644
--- a/fs/procfs/fs_procfsversion.c
+++ b/fs/procfs/fs_procfsversion.c
@@ -41,6 +41,7 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/utsname.h>
 
 #include <stdint.h>
 #include <stdbool.h>
@@ -206,6 +207,7 @@ static ssize_t version_read(FAR struct file *filep, FAR char *buffer,
                             size_t buflen)
 {
   FAR struct version_file_s *attr;
+  struct utsname name;
   size_t linesize;
   off_t offset;
   ssize_t ret;
@@ -219,16 +221,9 @@ static ssize_t version_read(FAR struct file *filep, FAR char *buffer,
 
   if (filep->f_pos == 0)
     {
-#if defined(__DATE__) && defined(__TIME__)
-      linesize = snprintf(attr->line, VERSION_LINELEN,
-                          "NuttX version %s %s %s %s\n",
-                          CONFIG_VERSION_STRING, CONFIG_VERSION_BUILD,
-                          __DATE__, __TIME__);
-#else
-      linesize = snprintf(attr->line, VERSION_LINELEN,
-                          "NuttX version %s %s\n",
-                          CONFIG_VERSION_STRING, CONFIG_VERSION_BUILD);
-#endif
+      uname(&name);
+      linesize = snprintf(attr->line, VERSION_LINELEN, "%s version %s %s\n",
+                          name.sysname, name.release, name.version);
 
       /* Save the linesize in case we are re-entered with f_pos > 0 */