nps: poci/nws_poci.c - editing init scripts is a "Very Bad Idea", ...
baggins
baggins at pld-linux.org
Mon Sep 12 16:44:05 CEST 2005
Author: baggins Date: Mon Sep 12 14:44:04 2005 GMT
Module: nps Tag: HEAD
---- Log message:
- editing init scripts is a "Very Bad Idea", instead create
/etc/newisys/ip_{sp,platform} files
---- Files affected:
nps/poci:
nws_poci.c (1.5 -> 1.6)
---- Diffs:
================================================================
Index: nps/poci/nws_poci.c
diff -u nps/poci/nws_poci.c:1.5 nps/poci/nws_poci.c:1.6
--- nps/poci/nws_poci.c:1.5 Sat Sep 10 01:16:12 2005
+++ nps/poci/nws_poci.c Mon Sep 12 16:43:59 2005
@@ -67,7 +67,13 @@
#include "swinventory.h"
#include "dimm_map.h"
-
+#ifndef PLATFORM_IP_CONFIG
+#define PLATFORM_IP_CONFIG "/etc/newisys/ip_platform"
+#endif
+
+#ifndef SP_IP_CONFIG
+#define SP_IP_CONFIG "/etc/newisys/ip_sp"
+#endif
/**********************************************
Function: main
@@ -1653,7 +1659,7 @@
unsigned char *platIp, *spIp;
char command[BUFSIZE], errMsg[BUFSIZE];
int jnetChanged = FALSE;
- int fd;
+ int fd, fd1;
uint32_t pip;
struct in_addr inp;
int pref;
@@ -1698,17 +1704,21 @@
jnetChanged = TRUE;
//Step 1
- snprintf(command,BUFSIZE,
- "/bin/sed 's/^.*ifconfig jnet0 [0-9].*$/ifconfig jnet0 %s/'"
- " /etc/init.d/poci > .poci; /bin/cp .poci /etc/init.d/poci;"
- "/bin/rm .poci;",platIp);
- if( system(command) != 0) {
+ fd = open(PLATFORM_IP_CONFIG, O_RDWR|O_CREAT, 0644);
+ fd1 = open(SP_IP_CONFIG, O_RDWR|O_CREAT, 0644);
+ if ((fd == -1) || (fd1 == -1)) {
syslog(LOG_CRIT, "Jnet set ip failed\n");
//Even though the change may have failed, we will return
//that it succeeded so the parent loop will re-establish
//the listening socket
return jnetChanged;
- }
+ }
+ snprintf(command,BUFSIZE, "%s", platIp);
+ write(fd, command, strlen(command));
+ close(fd);
+ snprintf(command,BUFSIZE, "%s", spIp);
+ write(fd1, command, strlen(command));
+ close(fd1);
//now bring restart the network at this new address.
pref = calc_minimal_prefix(inet_network(spIp), inet_network(platIp));
================================================================
---- CVS-web:
http://cvs.pld-linux.org/nps/poci/nws_poci.c?r1=1.5&r2=1.6&f=u
More information about the pld-cvs-commit
mailing list