Remove system namespace support again, the code has been merged into procd instead.
authorJo-Philipp Wich <jow@openwrt.org>
Tue, 4 Jun 2013 15:20:36 +0000 (17:20 +0200)
committerJo-Philipp Wich <jow@openwrt.org>
Tue, 4 Jun 2013 15:20:36 +0000 (17:20 +0200)
This reverts commit e5c9b0411d7ebc03a9edbdd3a7809f0e0bdb38dd.

CMakeLists.txt
main.c
system.c [deleted file]
system.h [deleted file]

index 6142e5cf01faba39210b3090da6d7593708df172..3c3470016c9498782d69f10795a1706d38dbe09e 100644 (file)
@@ -10,7 +10,7 @@ IF(APPLE)
   LINK_DIRECTORIES(/opt/local/lib)
 ENDIF()
 
-ADD_EXECUTABLE(luci-rpcd main.c session.c file.c uci.c iwinfo.c system.c)
+ADD_EXECUTABLE(luci-rpcd main.c session.c file.c uci.c iwinfo.c)
 TARGET_LINK_LIBRARIES(luci-rpcd ubox ubus uci iwinfo)
 
 SET(CMAKE_INSTALL_PREFIX /usr)
diff --git a/main.c b/main.c
index 71f5863afde3f9e9f9c9af2fb62ba387cc3f7008..ac5b8f817f8184381784dd09ac272777d3ac9c7c 100644 (file)
--- a/main.c
+++ b/main.c
@@ -27,7 +27,6 @@
 #include "file.h"
 #include "uci.h"
 #include "iwinfo.h"
-#include "system.h"
 
 static struct ubus_context *ctx;
 
@@ -65,7 +64,6 @@ int main(int argc, char **argv)
        rpc_file_api_init(ctx);
        rpc_uci_api_init(ctx);
        rpc_iwinfo_api_init(ctx);
-       rpc_system_api_init(ctx);
 
        uloop_run();
        ubus_free(ctx);
diff --git a/system.c b/system.c
deleted file mode 100644 (file)
index 2d28429..0000000
--- a/system.c
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * luci-rpcd - LuCI UBUS RPC server
- *
- *   Copyright (C) 2013 Jo-Philipp Wich <jow@openwrt.org>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <time.h>
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/sysinfo.h>
-#include <sys/utsname.h>
-
-#include "system.h"
-
-static struct blob_buf buf;
-
-static int
-rpc_system_board(struct ubus_context *ctx, struct ubus_object *obj,
-                 struct ubus_request_data *req, const char *method,
-                 struct blob_attr *msg)
-{
-       void *c;
-       char line[256];
-       char *key, *val;
-       struct utsname utsname;
-       FILE *f;
-
-       blob_buf_init(&buf, 0);
-
-       if (uname(&utsname) >= 0)
-       {
-               blobmsg_add_string(&buf, "kernel", utsname.release);
-               blobmsg_add_string(&buf, "hostname", utsname.nodename);
-       }
-
-       if ((f = fopen("/proc/cpuinfo", "r")) != NULL)
-       {
-               while(fgets(line, sizeof(line), f))
-               {
-                       key = strtok(line, "\t:");
-                       val = strtok(NULL, "\t\n");
-
-                       if (!key || !val)
-                               continue;
-
-                       if (!strcasecmp(key, "system type") ||
-                           !strcasecmp(key, "processor") ||
-                           !strcasecmp(key, "model name"))
-                       {
-                               blobmsg_add_string(&buf, "system", val + 2);
-                               break;
-                       }
-               }
-
-               fclose(f);
-       }
-
-       if ((f = fopen("/tmp/sysinfo/model", "r")) != NULL)
-       {
-               if (fgets(line, sizeof(line), f))
-               {
-                       val = strtok(line, "\t\n");
-
-                       if (val)
-                               blobmsg_add_string(&buf, "model", val);
-               }
-
-               fclose(f);
-       }
-       else if ((f = fopen("/proc/cpuinfo", "r")) != NULL)
-       {
-               while(fgets(line, sizeof(line), f))
-               {
-                       key = strtok(line, "\t:");
-                       val = strtok(NULL, "\t\n");
-
-                       if (!key || !val)
-                               continue;
-
-                       if (!strcasecmp(key, "machine") ||
-                           !strcasecmp(key, "hardware"))
-                       {
-                               blobmsg_add_string(&buf, "model", val + 2);
-                               break;
-                       }
-               }
-
-               fclose(f);
-       }
-
-       if ((f = fopen("/etc/openwrt_release", "r")) != NULL)
-       {
-               c = blobmsg_open_table(&buf, "release");
-
-               while (fgets(line, sizeof(line), f))
-               {
-                       key = strtok(line, "=\"");
-                       val = strtok(NULL, "\"\n");
-
-                       if (!key || !val)
-                               continue;
-
-                       if (!strcasecmp(key, "DISTRIB_ID"))
-                               blobmsg_add_string(&buf, "distribution", val);
-                       else if (!strcasecmp(key, "DISTRIB_RELEASE"))
-                               blobmsg_add_string(&buf, "version", val);
-                       else if (!strcasecmp(key, "DISTRIB_REVISION"))
-                               blobmsg_add_string(&buf, "revision", val);
-                       else if (!strcasecmp(key, "DISTRIB_CODENAME"))
-                               blobmsg_add_string(&buf, "codename", val);
-                       else if (!strcasecmp(key, "DISTRIB_TARGET"))
-                               blobmsg_add_string(&buf, "target", val);
-                       else if (!strcasecmp(key, "DISTRIB_DESCRIPTION"))
-                               blobmsg_add_string(&buf, "description", val);
-               }
-
-               blobmsg_close_array(&buf, c);
-
-               fclose(f);
-       }
-
-       ubus_send_reply(ctx, req, buf.head);
-
-       return UBUS_STATUS_OK;
-}
-
-static int
-rpc_system_info(struct ubus_context *ctx, struct ubus_object *obj,
-                struct ubus_request_data *req, const char *method,
-                struct blob_attr *msg)
-{
-       void *c;
-       time_t now;
-       struct tm *tm;
-       struct sysinfo info;
-
-       now = time(NULL);
-
-       if (!(tm = localtime(&now)))
-               return UBUS_STATUS_UNKNOWN_ERROR;
-
-       if (sysinfo(&info))
-               return UBUS_STATUS_UNKNOWN_ERROR;
-
-       blob_buf_init(&buf, 0);
-
-       blobmsg_add_u32(&buf, "uptime",    info.uptime);
-       blobmsg_add_u32(&buf, "localtime", mktime(tm));
-
-       c = blobmsg_open_array(&buf, "load");
-       blobmsg_add_u32(&buf, NULL, info.loads[0]);
-       blobmsg_add_u32(&buf, NULL, info.loads[1]);
-       blobmsg_add_u32(&buf, NULL, info.loads[2]);
-       blobmsg_close_array(&buf, c);
-
-       c = blobmsg_open_table(&buf, "memory");
-       blobmsg_add_u32(&buf, "total",    info.mem_unit * info.totalram);
-       blobmsg_add_u32(&buf, "free",     info.mem_unit * info.freeram);
-       blobmsg_add_u32(&buf, "shared",   info.mem_unit * info.sharedram);
-       blobmsg_add_u32(&buf, "buffered", info.mem_unit * info.bufferram);
-       blobmsg_close_table(&buf, c);
-
-       c = blobmsg_open_table(&buf, "swap");
-       blobmsg_add_u32(&buf, "total",    info.mem_unit * info.totalswap);
-       blobmsg_add_u32(&buf, "free",     info.mem_unit * info.freeswap);
-       blobmsg_close_table(&buf, c);
-
-       ubus_send_reply(ctx, req, buf.head);
-
-       return UBUS_STATUS_OK;
-}
-
-int rpc_system_api_init(struct ubus_context *ctx)
-{
-       static const struct ubus_method system_methods[] = {
-               UBUS_METHOD_NOARG("board", rpc_system_board),
-               UBUS_METHOD_NOARG("info",  rpc_system_info),
-       };
-
-       static struct ubus_object_type system_type =
-               UBUS_OBJECT_TYPE("luci-rpc-system", system_methods);
-
-       static struct ubus_object obj = {
-               .name = "system",
-               .type = &system_type,
-               .methods = system_methods,
-               .n_methods = ARRAY_SIZE(system_methods),
-       };
-
-       return ubus_add_object(ctx, &obj);
-}
diff --git a/system.h b/system.h
deleted file mode 100644 (file)
index 1771249..0000000
--- a/system.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * luci-rpcd - LuCI UBUS RPC server
- *
- *   Copyright (C) 2013 Jo-Philipp Wich <jow@openwrt.org>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef __RPC_SYSTEM_H
-#define __RPC_SYSTEM_H
-
-#include <libubus.h>
-#include <libubox/blobmsg.h>
-
-int rpc_system_api_init(struct ubus_context *ctx);
-
-#endif