Patch title: Release 94 bulk changes
Abstract:
File: /pliant/fullpliant/init.c
Key:
    Removed line
    Added line
// This is the 'init' script for the FullPliant system.
//
// Copyright  Hubert Tonneau  hubert.tonneau@pliant.cx
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License version 2
// as published by the Free Software Foundation.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// version 2 along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

/*
abstract
  text "An init executable for the FullPliant and PliantDebian distributions."
*/

#include "../language/os/linux_kernel.c"

#define false 0
#define true 1
#define null ((void *)0)

struct timespec {
  int tv_sec,tv_nsec; };

inline static _syscall2(int,clone,int,flags,void *,stack)
inline static _syscall3(int,execve,char *,filename,char **,argv,char **,env)
inline static _syscall3(int,waitpid,int,pid,int *,status,int,options)
inline static _syscall3(int,write,int,fd,const char *,buf,off_t,count)
inline static _syscall2(int,nanosleep,const struct timespec *,req,struct timespec *,rem)
inline static _syscall1(int,chroot,const char *,path)
inline static _syscall1(int,chdir,const char *,path)
inline static _syscall3(int,open,const char *,name,int,flags,int,rights)
inline static _syscall3(int,read,int,fd,char *,buf,off_t,count)
inline static _syscall3(int,write,int,fd,const char *,buf,off_t,count)
inline static _syscall3(int,ioctl,int,fd,int,request,int,param);
inline static _syscall1(int,close,int,fd)

char **process_args;
char **process_env;
char *env[]={"PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin",null};

char *args1[]={"/bin/pliant","module","/pliant/install/minimal.pli","module","/pliant/fullpliant/boot.pli",null};
char *args2[]={"/bin/pliant","module","/pliant/install/minimal.pli","module","/pliant/fullpliant/run.pli",null};
// char *args2[]={"/bin/pliant","precompile /binary/default.dump module /pliant/install/precompile.pli","module","/pliant/fullpliant/run.pli",null};


void startup() {
  int pid; int lap=0;
  int lap,pid;
  struct timespec ts;
  while(true) {
  for(lap=0;; lap++) {
    chroot("/");
    chdir("/");
    ioctl(0,0x4B3A,0); // KDSETMODE KD_TEXT
    // ioctl(0,0x5606,1); // VT_ACTIVATE
    pid=clone(0,null);
    if(pid>0) {
      while(waitpid(-1,null,0x40000000)!=pid);
    } else if(pid==0) {
      if(lap==0) {
        write(1,"\nLauching FullPliant boot script.\n",34);
        execve(args1[0],args1,env);
      } else {
        write(1,"\nLauching FullPliant run script.\n",33);
        execve(args2[0],args2,env); }
      write(1,"failed.\n",8);
      return; }
    ts.tv_sec=0;
    ts.tv_nsec=100000000;
    nanosleep(&ts,&ts);
    lap=lap+1; } }
    nanosleep(&ts,&ts); } }