Bug #705 » vkpid.patch
share/man/man7/vkernel.7 17 Jun 2007 04:05:58 -0000 | ||
---|---|---|
.Op Fl i Ar file
|
||
.Op Fl I Ar interface Ns Op Ar :address1 Ns Oo Ar :address2 Oc Ns Oo Ar /netmask Oc
|
||
.Op Fl m Ar size
|
||
.Op Fl p Ar file
|
||
.Op Fl r Ar file
|
||
.Sh DESCRIPTION
|
||
The
|
||
... | ... | |
and
|
||
.Cm G
|
||
are allowed.
|
||
.It Fl p Ar file
|
||
Specify a file in which to store the process ID.
|
||
A warning is issued if this file cannot be opened for writing.
|
||
.It Fl r Ar file
|
||
Specify a R/W disk image
|
||
.Ar file
|
sys/platform/vkernel/platform/init.c 18 Jun 2007 00:33:30 -0000 | ||
---|---|---|
int DiskNum;
|
||
struct vknetif_info NetifInfo[VKNETIF_MAX];
|
||
int NetifNum;
|
||
char *pid_file = NULL;
|
||
vm_offset_t KvaStart;
|
||
vm_offset_t KvaEnd;
|
||
vm_offset_t KvaSize;
|
||
... | ... | |
static void init_vkernel(void);
|
||
static void init_disk(char *diskExp[], int diskFileNum, enum vkdisk_type type);
|
||
static void init_netif(char *netifExp[], int netifFileNum);
|
||
static void writepid( void );
|
||
static void cleanpid( void );
|
||
static void usage(const char *ctl);
|
||
static int save_ac;
|
||
... | ... | |
int c;
|
||
int i;
|
||
int n;
|
||
|
||
save_ac = ac;
|
||
save_av = av;
|
||
... | ... | |
*/
|
||
kernel_mem_readonly = 1;
|
||
while ((c = getopt(ac, av, "c:svm:r:e:i:I:U")) != -1) {
|
||
while ((c = getopt(ac, av, "c:svm:r:e:i:p:I:U")) != -1) {
|
||
switch(c) {
|
||
case 'e':
|
||
/*
|
||
... | ... | |
}
|
||
}
|
||
break;
|
||
case 'p':
|
||
pid_file = optarg;
|
||
break;
|
||
case 'U':
|
||
kernel_mem_readonly = 0;
|
||
break;
|
||
}
|
||
}
|
||
writepid();
|
||
cpu_disable_intr();
|
||
init_sys_memory(memImageFile);
|
||
init_kern_memory();
|
||
... | ... | |
static
|
||
void
|
||
writepid( void )
|
||
{
|
||
pid_t self = 0;
|
||
FILE *file = NULL;
|
||
if (pid_file == NULL)
|
||
return;
|
||
self = getpid();
|
||
file = fopen(pid_file, "w");
|
||
if (file != NULL) {
|
||
fprintf(file, "%ld\n", (long)self);
|
||
fclose(file);
|
||
}
|
||
else {
|
||
perror("Warning: couldn't open pidfile");
|
||
}
|
||
}
|
||
static
|
||
void
|
||
cleanpid( void )
|
||
{
|
||
if (pid_file == NULL)
|
||
return;
|
||
if ( unlink(pid_file) != 0 )
|
||
perror("Warning: couldn't remove pidfile");
|
||
}
|
||
static
|
||
void
|
||
usage(const char *ctl)
|
||
{
|
||
|
||
... | ... | |
{
|
||
kprintf("cpu reset, rebooting vkernel\n");
|
||
closefrom(3);
|
||
cleanpid();
|
||
execv(save_av[0], save_av);
|
||
}
|
||
... | ... | |
cpu_halt(void)
|
||
{
|
||
kprintf("cpu halt, exiting vkernel\n");
|
||
cleanpid();
|
||
exit(0);
|
||
}
|