DragonFly submit List (threaded) for 2007-06
DragonFly BSD
DragonFly submit List (threaded) for 2007-06
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: VKERNEL Pidfile patch


From: Chris Turner <c.turner@xxxxxxxxxxxxxxxxxxx>
Date: Sun, 17 Jun 2007 12:15:10 -0400

Sascha Wildner wrote:
> 
> Uh, can you use diff -u please?
> 
oops.. hadn't had my coffee yet :) See attached.

as mentioned in the first post, this is a manually edited patch as
I've got another one outstanding on the vkernel.7 file for the
vk-shutdown..

(which I'll check for same diff -u issue)

Perhaps I should submit them as one - but trying to keep the features
separate..

Thanks,

- Chris

Index: share/man/man7/vkernel.7
===================================================================
RCS file: /var/local/apps/dcvs/src/share/man/man7/vkernel.7,v
retrieving revision 1.18
diff -u -r1.18 vkernel.7
--- share/man/man7/vkernel.7	14 Jun 2007 21:11:29 -0000	1.18
+++ share/man/man7/vkernel.7	17 Jun 2007 04:05:58 -0000
@@ -51,6 +51,7 @@
 .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
@@ -149,6 +150,9 @@
 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
Index: sys/platform/vkernel/platform/init.c
===================================================================
RCS file: /var/local/apps/dcvs/src/sys/platform/vkernel/platform/init.c,v
retrieving revision 1.39
diff -u -r1.39 init.c
--- sys/platform/vkernel/platform/init.c	28 May 2007 05:26:29 -0000	1.39
+++ sys/platform/vkernel/platform/init.c	17 Jun 2007 14:00:15 -0000
@@ -107,6 +107,7 @@
 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(char *path);
 static void usage(const char *ctl);
 
 static int save_ac;
@@ -123,13 +124,14 @@
 	char *diskFile[VKDISK_MAX];
 	char *cdFile[VKDISK_MAX];
 	char *suffix;
+	char *pidfile = NULL;
 	int netifFileNum = 0;
 	int diskFileNum = 0;
 	int cdFileNum = 0;
 	int c;
 	int i;
 	int n;
-
+	
 	save_ac = ac;
 	save_av = av;
 
@@ -138,7 +140,7 @@
 	 */
 	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':
 			/*
@@ -200,12 +202,16 @@
 				}
 			}
 			break;
+		case 'p':
+			pidfile = optarg;	
+			break;
 		case 'U':
 			kernel_mem_readonly = 0;
 			break;
 		}
 	}
 
+	writepid(pidfile);
 	cpu_disable_intr();
 	init_sys_memory(memImageFile);
 	init_kern_memory();
@@ -1039,6 +1045,24 @@
 
 static
 void
+writepid(char *path)
+{
+	pid_t self = 0;
+	FILE *pidfile = NULL;
+
+	self = getpid();
+	pidfile = fopen(path, "w");
+	if (pidfile) {
+		fprintf(pidfile, "%ld\n", (long)self);
+		fclose(pidfile);
+	}
+	else {
+		perror("Warning: couldn't open pidfile");
+	}
+}
+
+static
+void
 usage(const char *ctl)
 {
 	


[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]