Masanobu Yasui authored on 2010/03/31 14:15:05
Showing 4 changed files
... ...
@@ -281,6 +281,7 @@ typedef struct
281 281
   int sendsize;
282 282
   int sendready;
283 283
   int sendrate;
284
+  struct utsname uts;  
284 285
   struct sockaddr_in maddr;
285 286
   struct sockaddr_in laddr;
286 287
   struct sockaddr_un uaddr;
... ...
@@ -381,8 +381,13 @@ int mexec_send(mcomm *c, int n, int sync)
381 381
     argv[i] = c->parse[n][i];
382 382
   }
383 383
   argv[i] = NULL;
384
-  optind  = 0;
385
-  opterr  = 1;
384
+  
385
+  if(!strcmp("SunOS", moption.uts.sysname)){
386
+    optind = 1; /* solaris */
387
+  }else{
388
+    optind = 0; /* other */
389
+  }
390
+  opterr = 1;
386 391
 #ifdef HAVE_GETOPT_OPTRESET
387 392
   optreset = 1;
388 393
 #endif
... ...
@@ -564,8 +569,12 @@ int mexec_check(mcomm *c, int n)
564 564
   for(i=0;i<c->argc[n];i++)
565 565
     argv[i] = c->parse[n][i];
566 566
   argv[i] = NULL;
567
-  optind  = 0;
568
-  opterr  = 1;
567
+  if(!strcmp("SunOS", moption.uts.sysname)){
568
+    optind = 1; /* solaris */
569
+  }else{
570
+    optind = 0; /* other */
571
+  }
572
+  opterr = 1;
569 573
 #ifdef HAVE_GETOPT_OPTRESET
570 574
   optreset = 1;
571 575
 #endif
... ...
@@ -671,8 +680,12 @@ int mexec_dsync(mcomm *c, int n)
671 671
   for(i=0;i<c->argc[n];i++)
672 672
     argv[i] = c->parse[n][i];
673 673
   argv[i] = NULL;
674
-  optind  = 0;
675
-  opterr  = 1;
674
+  if(!strcmp("SunOS", moption.uts.sysname)){
675
+    optind = 1; /* solaris */
676
+  }else{
677
+    optind = 0; /* other */
678
+  }
679
+  opterr = 1;
676 680
 #ifdef HAVE_GETOPT_OPTRESET
677 681
   optreset = 1;
678 682
 #endif
... ...
@@ -6,13 +6,9 @@
6 6
 
7 7
 static void chexit()
8 8
 {
9
-  struct utsname uts;
10 9
   char cwd[PATH_MAX];
11 10
   if(moption.chroot){
12
-    if(uname(&uts) == -1){
13
-      return;
14
-    }
15
-    if(strcmp("Linux", uts.sysname)){
11
+    if(strcmp("Linux", moption.uts.sysname)){
16 12
       return;
17 13
     }
18 14
     /*----- chroot exit(linux only) -----*/
... ...
@@ -97,6 +97,7 @@ static void minit_option_setdefault()
97 97
     moption.comm[i].fd[0] = -1;
98 98
     moption.comm[i].fd[1] = -1;
99 99
   }
100
+  uname(&moption.uts);
100 101
 }
101 102
 
102 103
 static int minit_option_setuid(char *name)
... ...
@@ -644,6 +645,7 @@ static void minit_bootlog()
644 644
   int i;
645 645
 
646 646
   lprintf(0, "makuosan version %s\n", PACKAGE_VERSION);
647
+  lprintf(0, "sysname   : %s\n", moption.uts.sysname);
647 648
   lprintf(0, "loglevel  : %d\n", moption.loglevel);
648 649
   if(moption.chroot){
649 650
     lprintf(0, "chroot    : %s\n", moption.real_dir);
... ...
@@ -705,3 +707,4 @@ void minit(int argc, char *argv[])
705 705
   minit_bootlog();           /* ブートメッセージを出力する         */
706 706
   minit_daemonize();         /*                                    */
707 707
 }
708
+