|
|
@@ -1516,12 +1516,86 @@ int sys_chmod(void)
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+static void dhcp_restart(void)
|
|
|
+{
|
|
|
+ int r;
|
|
|
+ char ipaddr[64],mask[64];
|
|
|
+ NetworkInfo_t net4,net6;
|
|
|
+
|
|
|
+ r = get_net(&net4, IP_V4);
|
|
|
+ if(r==0) {
|
|
|
+ r = get_ipaddr(AF_INET, DFLT_NIC, ipaddr, mask);
|
|
|
+ if(r && net4.mode==IP_DHCP) {
|
|
|
+ set_dhcp(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ r = get_net(&net6, IP_V6);
|
|
|
+ if(r==0) {
|
|
|
+ r = get_ipaddr(AF_INET6, DFLT_NIC, ipaddr, mask);
|
|
|
+ if(r && net6.mode==IP_DHCP) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
static void net_init(void)
|
|
|
{
|
|
|
nic_restart();
|
|
|
nic_set_mac();
|
|
|
}
|
|
|
|
|
|
+#include <dirent.h>
|
|
|
+#include <signal.h>
|
|
|
+#include <sys/wait.h>
|
|
|
+static int get_pid(char *proc)
|
|
|
+{
|
|
|
+ DIR *dir;
|
|
|
+ int pid=-1;
|
|
|
+ struct dirent *entry;
|
|
|
+
|
|
|
+ dir = opendir("/proc");
|
|
|
+ if (!dir) {
|
|
|
+ perror("opendir");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ while ((entry = readdir(dir))) {
|
|
|
+ if (entry->d_type != DT_DIR || !isdigit(entry->d_name[0])) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ char path[500];
|
|
|
+ snprintf(path, sizeof(path), "/proc/%s/cmdline", entry->d_name);
|
|
|
+ FILE *f = fopen(path, "r");
|
|
|
+ if (f) {
|
|
|
+ char cmd[64];
|
|
|
+ if (fgets(cmd, sizeof(cmd), f) && strstr(cmd, proc)) {
|
|
|
+ pid = atoi(entry->d_name);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ fclose(f);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ closedir(dir);
|
|
|
+ return pid;
|
|
|
+}
|
|
|
+int sys_kill(char *proc)
|
|
|
+{
|
|
|
+ int status;
|
|
|
+ int pid=get_pid(proc);
|
|
|
+ if(pid<0) {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ kill(pid, SIGKILL);
|
|
|
+ waitpid(pid, &status, 0);
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
|
|
|
#include "ui.h"
|
|
|
@@ -1535,7 +1609,7 @@ int sys_init(void)
|
|
|
init_hash_table();
|
|
|
|
|
|
ui_init();
|
|
|
- //net_init();
|
|
|
+ net_init();
|
|
|
thread_start(THREAD_ID_POLLING, polling_thread, NULL);
|
|
|
|
|
|
return 0;
|