]> Zhao Yanbai Git Server - minix.git/commitdiff
Retire sysuname(2), synchronize sys/utsname.h 48/3248/2
authorDavid van Moolenbroek <david@minix3.org>
Fri, 9 Oct 2015 18:34:38 +0000 (18:34 +0000)
committerLionel Sambuc <lionel.sambuc@gmail.com>
Wed, 13 Jan 2016 19:32:46 +0000 (20:32 +0100)
Now that uname(3) uses sysctl(2), we no longer need sysuname(2).
Backward compatibility is retained for old statically linked
binaries for a short while.

Also remove the now-obsolete MINIX3-specific "arch" field from the
utsname structure.  While this is an ABI break at the libc level,
it should pose no problems in practice, because:

- statically linked programs (i.e., all of the base system) are not
  affected, as they will use headers synchronized with libc;
- the structure is getting smaller, thus, older dynamically linked
  programs (typically in pkgsrc) using the new libc will end up with
  garbage in the "arch" field, but it is unlikely they will use this
  field anyway, since it was specific to MINIX3;
- new dynamically linked programs using an old libc could end up with
  memory corruption, but this is not a scenario that is expected to
  occur in the first place - certainly not with programs from pkgsrc.

Change-Id: I29c76576f509feacc8f996f0bd353ca8961d4917

minix/commands/hostaddr/hostaddr.c
minix/include/minix/callnr.h
minix/lib/libc/sys/Makefile.inc
minix/lib/libc/sys/sysuname.c [deleted file]
minix/servers/pm/misc.c
minix/usr.bin/trace/service/pm.c
sys/sys/utsname.h

index 91d51f5ad742c2edd97155ee01d9f26c2bd004fb..0d75e422a643369e5349ac141f04557b66f2a762 100644 (file)
@@ -276,23 +276,6 @@ char *argv[];
        }
        if (do_hostname)
        {
-#if __minix_vmd
-               if (sysuname(_UTS_SET, _UTS_NODENAME,
-                                       nodename, strlen(nodename)+1) == -1)
-               {
-                       fprintf(stderr, "%s: Unable to set nodename: %s\n",
-                               prog_name, strerror(errno));
-                       exit(1);
-               }
-
-               if (sysuname(_UTS_SET, _UTS_HOSTNAME,
-                                       hostname, strlen(hostname)+1) == -1)
-               {
-                       fprintf(stderr, "%s: Unable to set hostname: %s\n",
-                               prog_name, strerror(errno));
-                       exit(1);
-               }
-#else
                FILE *fp;
 
                if ((fp= fopen("/etc/hostname.file", "w")) == NULL
@@ -303,7 +286,6 @@ char *argv[];
                                prog_name, strerror(errno));
                        exit(1);
                }
-#endif
        }
        if (!first_print) printf("\n");
        exit(0);
index 52ba9bc2753de1bf331fcbadb4c7f620b7d5b60e..7f5f36d26b9fb17276a8286347e7fc6ea8af83f0 100644 (file)
@@ -35,7 +35,7 @@
 #define PM_SIGPENDING          (PM_BASE + 22)
 #define PM_SIGPROCMASK         (PM_BASE + 23)
 #define PM_SIGRETURN           (PM_BASE + 24)
-#define PM_SYSUNAME            (PM_BASE + 25)
+#define PM_SYSUNAME            (PM_BASE + 25)          /* obsolete */
 #define PM_GETPRIORITY         (PM_BASE + 26)
 #define PM_SETPRIORITY         (PM_BASE + 27)
 #define PM_GETTIMEOFDAY                (PM_BASE + 28)
index a443dfc16d08d6fb7dffe2a5add4101d66b430a2..0ac027f657cd5a45fc88995ef7988cffd11c93ee 100644 (file)
@@ -19,7 +19,7 @@ SRCS+=        accept.c access.c adjtime.c bind.c brk.c sbrk.c m_closefrom.c getsid.c \
        vectorio.c shutdown.c sigaction.c sigpending.c sigreturn.c sigsuspend.c\
        sigprocmask.c socket.c socketpair.c stat.c statvfs.c svrctl.c \
        symlink.c \
-       sync.c syscall.c sysuname.c truncate.c umask.c unlink.c \
+       sync.c syscall.c truncate.c umask.c unlink.c \
        wait4.c write.c \
        utimensat.c utimes.c futimes.c lutimes.c futimens.c \
        _exit.c _ucontext.c environ.c __getcwd.c vfork.c sizeup.c init.c \
diff --git a/minix/lib/libc/sys/sysuname.c b/minix/lib/libc/sys/sysuname.c
deleted file mode 100644 (file)
index f8f08d0..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*     sysuname(2) - transfer uname(3) strings.        Author: Kees J. Bot
- *                                                             5 Dec 1992
- */
-
-#include <sys/cdefs.h>
-#include "namespace.h"
-#include <lib.h>
-#include <string.h>
-#include <sys/utsname.h>
-
-int sysuname(int req, int field, char *value, size_t len)
-{
-       message m;
-
-       memset(&m, 0, sizeof(m));
-       m.m_lc_pm_sysuname.req = req;
-       m.m_lc_pm_sysuname.field = field;
-       m.m_lc_pm_sysuname.len = len;
-       m.m_lc_pm_sysuname.value = (vir_bytes)value;
-
-       return _syscall(PM_PROC_NR, PM_SYSUNAME, &m);
-}
-
-/*
- * $PchId: _sysuname.c,v 1.4 1995/11/27 19:42:09 philip Exp $
- */
index 93f331e06d64980063feee05c8ec50879bf9ee20..c304b1ac38db9b4a040235a1cf4d33831c215e12 100644 (file)
@@ -28,6 +28,7 @@
 #include "mproc.h"
 #include "kernel/proc.h"
 
+/* START OF COMPATIBILITY BLOCK */
 struct utsname uts_val = {
   OS_NAME,             /* system name */
   "noname",            /* node/network name */
@@ -35,17 +36,19 @@ struct utsname uts_val = {
   OS_VERSION,          /* O.S. version (e.g. Minix 3.3.0 (GENERIC)) */
 #if defined(__i386__)
   "i386",              /* machine (cpu) type */
-  "i386",              /* architecture */
 #elif defined(__arm__)
-  "earm",              /* machine (cpu) type */
-  "earm",              /* architecture */
+  "evbarm",            /* machine (cpu) type */
 #else
 #error                 /* oops, no 'uname -mk' */
 #endif
 };
 
 static char *uts_tbl[] = {
-  uts_val.arch,
+#if defined(__i386__)
+  "i386",              /* architecture */
+#elif defined(__arm__)
+  "evbarm",            /* architecture */
+#endif
   NULL,                        /* No kernel architecture */
   uts_val.machine,
   NULL,                        /* No hostname */
@@ -55,11 +58,13 @@ static char *uts_tbl[] = {
   uts_val.sysname,
   NULL,                        /* No bus */                    /* No bus */
 };
+/* END OF COMPATIBILITY BLOCK */
 
 #if ENABLE_SYSCALL_STATS
 unsigned long calls_stats[NR_PM_CALLS];
 #endif
 
+/* START OF COMPATIBILITY BLOCK */
 /*===========================================================================*
  *                             do_sysuname                                  *
  *===========================================================================*/
@@ -69,28 +74,15 @@ int do_sysuname()
   int r;
   size_t n;
   char *string;
-#if 0 /* for updates */
-  char tmp[sizeof(uts_val.nodename)];
-  static short sizes[] = {
-       0,      /* arch, (0 = read-only) */
-       0,      /* kernel */
-       0,      /* machine */
-       0,      /* sizeof(uts_val.hostname), */
-       sizeof(uts_val.nodename),
-       0,      /* release */
-       0,      /* version */
-       0,      /* sysname */
-  };
-#endif
 
-  if (m_in.m_lc_pm_sysuname.field >= _UTS_MAX) return(EINVAL);
+  if (m_in.m_lc_pm_sysuname.field >= __arraycount(uts_tbl)) return(EINVAL);
 
   string = uts_tbl[m_in.m_lc_pm_sysuname.field];
   if (string == NULL)
        return EINVAL;  /* Unsupported field */
 
   switch (m_in.m_lc_pm_sysuname.req) {
-  case _UTS_GET:
+  case 0:
        /* Copy an uname string to the user. */
        n = strlen(string) + 1;
        if (n > m_in.m_lc_pm_sysuname.len) n = m_in.m_lc_pm_sysuname.len;
@@ -99,27 +91,13 @@ int do_sysuname()
        if (r < 0) return(r);
        break;
 
-#if 0  /* no updates yet */
-  case _UTS_SET:
-       /* Set an uname string, needs root power. */
-       len = sizes[m_in.m_lc_pm_sysuname.field];
-       if (mp->mp_effuid != 0 || len == 0) return(EPERM);
-       n = len < m_in.m_lc_pm_sysuname.len ? len : m_in.m_lc_pm_sysuname.len;
-       if (n <= 0) return(EINVAL);
-       r = sys_datacopy(mp->mp_endpoint, m_in.m_lc_pm_sysuname.value, SELF,
-               (phys_bytes)tmp, (phys_bytes)n);
-       if (r < 0) return(r);
-       tmp[n-1] = 0;
-       strcpy(string, tmp);
-       break;
-#endif
-
   default:
        return(EINVAL);
   }
   /* Return the number of bytes moved. */
   return(n);
 }
+/* END OF COMPATIBILITY BLOCK */
 
 
 /*===========================================================================*
index 77303fa88897fca0f910268e129d25cb76d94ab4..1bbef8896f2512dc3675bf3e255a6b873a2e9a21 100644 (file)
@@ -953,66 +953,6 @@ pm_sigreturn_in(struct trace_proc * proc, const message * __unused m_out,
        }
 }
 
-static void
-put_sysuname_field(struct trace_proc * proc, const char * name, int field)
-{
-       const char *text = NULL;
-
-       if (!valuesonly) {
-               switch (field) {
-               TEXT(_UTS_ARCH);
-               TEXT(_UTS_KERNEL);
-               TEXT(_UTS_MACHINE);
-               TEXT(_UTS_HOSTNAME);
-               TEXT(_UTS_NODENAME);
-               TEXT(_UTS_RELEASE);
-               TEXT(_UTS_VERSION);
-               TEXT(_UTS_SYSNAME);
-               TEXT(_UTS_BUS);
-               }
-       }
-
-       if (text != NULL)
-               put_field(proc, name, text);
-       else
-               put_value(proc, name, "%d", field);
-}
-
-static int
-pm_sysuname_out(struct trace_proc * proc, const message * m_out)
-{
-
-       if (!valuesonly && m_out->m_lc_pm_sysuname.req == _UTS_GET)
-               put_field(proc, "req", "_UTS_GET");
-       else if (!valuesonly && m_out->m_lc_pm_sysuname.req == _UTS_SET)
-               put_field(proc, "req", "_UTS_SET");
-       else
-               put_value(proc, "req", "%d", m_out->m_lc_pm_sysuname.req);
-       put_sysuname_field(proc, "field", m_out->m_lc_pm_sysuname.field);
-
-       if (m_out->m_lc_pm_sysuname.req == _UTS_GET)
-               return CT_NOTDONE;
-
-       put_buf(proc, "value", PF_STRING, m_out->m_lc_pm_sysuname.value,
-           m_out->m_lc_pm_sysuname.len);
-       put_value(proc, "len", "%zu", m_out->m_lc_pm_sysuname.len);
-       return CT_DONE;
-}
-
-static void
-pm_sysuname_in(struct trace_proc * proc, const message * m_out,
-       const message * m_in, int failed)
-{
-
-       if (m_out->m_lc_pm_sysuname.req == _UTS_GET) {
-               put_buf(proc, "value", failed | PF_STRING,
-                   m_out->m_lc_pm_sysuname.value, m_in->m_type);
-               put_value(proc, "len", "%zu", m_out->m_lc_pm_sysuname.len);
-               put_equals(proc);
-       }
-       put_result(proc);
-}
-
 static void
 put_priority_which(struct trace_proc * proc, const char * name, int which)
 {
@@ -1374,8 +1314,6 @@ static const struct call_handler pm_map[] = {
            pm_sigprocmask_in),
        PM_CALL(SIGRETURN) = HANDLER("sigreturn", pm_sigreturn_out,
            pm_sigreturn_in),
-       PM_CALL(SYSUNAME) = HANDLER("sysuname", pm_sysuname_out,
-           pm_sysuname_in),
        PM_CALL(GETPRIORITY) = HANDLER("getpriority", pm_getpriority_out,
            pm_getpriority_in),
        PM_CALL(SETPRIORITY) = HANDLER("setpriority", pm_setpriority_out,
index d24d7ef94c82c898c3fc91582ce3c899c8cea8d5..2daaa3c328e9d353734d04cd9de3465e53b041f4 100644 (file)
@@ -51,37 +51,12 @@ struct utsname {
        char    release[_SYS_NMLN];     /* Release level. */
        char    version[_SYS_NMLN];     /* Version level. */
        char    machine[_SYS_NMLN];     /* Hardware type. */
-#if defined(__minix)
-       char    arch[_SYS_NMLN];
-#endif /* defined(__minix) */
 };
 
 #include <sys/cdefs.h>
 
 __BEGIN_DECLS
 int    uname(struct utsname *);
-#if defined(__minix)
-#include <sys/types.h>
-int    sysuname(int _req, int _field, char *_value, size_t _len);
-#endif /* defined(__minix) */
 __END_DECLS
 
-#if defined(__minix)
-/* req: Get or set a string. */
-#define _UTS_GET       0
-#define _UTS_SET       1
-
-/* field: What field to get or set.  These values can't be changed lightly. */
-#define _UTS_ARCH      0
-#define _UTS_KERNEL    1
-#define _UTS_MACHINE   2
-#define _UTS_HOSTNAME  3
-#define _UTS_NODENAME  4
-#define _UTS_RELEASE   5
-#define _UTS_VERSION   6
-#define _UTS_SYSNAME   7
-#define _UTS_BUS       8
-#define _UTS_MAX       9       /* Number of strings. */
-#endif /* defined(__minix) */
-
 #endif /* !_SYS_UTSNAME_H_ */