Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Jan 2001 12:54:34 +0100
From:      Poul-Henning Kamp <phk@critter.freebsd.dk>
To:        "Soumen Biswas" <soumen.biswas@gte.net>
Cc:        hackers@FreeBSD.ORG
Subject:   Re: how to write custom init 
Message-ID:  <14561.979300474@critter>
In-Reply-To: Your message of "Fri, 12 Jan 2001 03:46:08 PST." <001201c07c8d$4276f8a0$1e813b3f@netscaler.com> 

next in thread | previous in thread | raw e-mail | index | archive | help

You may want to check out sysinstalls initialization, it is used to
run as /sbin/init when you boot from installation media

Poul-Henning

In message <001201c07c8d$4276f8a0$1e813b3f@netscaler.com>, "Soumen Biswas" writ
es:
>Hi , 
>
>What are the points to be observed while writing custom init 
> 
>I am currently doing something like :  
>/* 
>  1.  never exit 
>   2. open fd 0,1 & 2 
>   3. link statically  */
>
>int main( int argc, char **argv )
>{
>int fd ;
>char cmd[128] = {0};
>
>fd = open( "/dev/console", O_RDWR );
>dup(fd);
>dup(fd);
>
> while( 1 ) {
> printf( "comm>" ); fflush( stdout );
> fgets( cmd, sizeof(cmd ), stdin );
>
> if( memcmp( "init", cmd , 4 ) == 0 ) 
>   { close(0); close(1);close(2); execv("/init/sbin", argv ); }
>
> if( memcmp( "quit", cmd, 4) == 0 ) reboot( RB_AUTOBOOT );
> } /* while */
>
>/* should not reach here */
>return 0 ;
>}
>
>
>Am I missing something ?
>
>Thanx & Regards 
>soumen
>
>
>
>
>
>To Unsubscribe: send mail to majordomo@FreeBSD.org
>with "unsubscribe freebsd-hackers" in the body of the message
>

--
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk@FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?14561.979300474>