[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140320094238.14878.9756.stgit@localhost.localdomain>
Date: Thu, 20 Mar 2014 15:12:38 +0530
From: Janani Venkataraman <jananive@...ux.vnet.ibm.com>
To: linux-kernel@...r.kernel.org
Cc: amwang@...hat.com, procps@...elists.org, rdunlap@...otime.net,
james.hogan@...tec.com, aravinda@...ux.vnet.ibm.com, hch@....de,
mhiramat@...hat.com, jeremy.fitzhardinge@...rix.com,
xemul@...allels.com, d.hatayama@...fujitsu.com, coreutils@....org,
kosaki.motohiro@...fujitsu.com, adobriyan@...il.com,
util-linux@...r.kernel.org, tarundsk@...ux.vnet.ibm.com,
vapier@...too.org, roland@...k.frob.com, ananth@...ux.vnet.ibm.com,
gorcunov@...nvz.org, avagin@...nvz.org, oleg@...hat.com,
eparis@...hat.com, suzuki@...ux.vnet.ibm.com, andi@...stfloor.org,
tj@...nel.org, akpm@...ux-foundation.org,
torvalds@...ux-foundation.org
Subject: [PATCH 26/33] [libgencore] Setting up Connection
Creating a socket and setting up a connection with the server(daemon).
Signed-off-by: Janani Venkataraman <jananive@...ux.vnet.ibm.com>
---
src/Makefile.am | 4 +++
src/client.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 74 insertions(+)
create mode 100644 src/client.c
diff --git a/src/Makefile.am b/src/Makefile.am
index b9b2e9b..a1d57ca 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -3,6 +3,10 @@ HAVE_SYSTEMD_SOCKET_SUPPORT = 0
SOCKET_PATH = /var/run/gencored.socket
CFLAGS += -I. -DHAVE_SYSTEMD_SOCKET_SUPPORT='$(HAVE_SYSTEMD_SOCKET_SUPPORT)' -DSOCKET_PATH='"$(SOCKET_PATH)"'
+lib_LTLIBRARIES = libgencore.la
+libgencore_la_LDFLAGS = -fPIC
+libgencore_la_SOURCES = client.c
+
bin_PROGRAMS = gencore
gencore_SOURCES = coredump.c proc.c elf32.c elf64.c
diff --git a/src/client.c b/src/client.c
new file mode 100644
index 0000000..cddaf94
--- /dev/null
+++ b/src/client.c
@@ -0,0 +1,70 @@
+/*
+ * Client interface for selfdump.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright (C) IBM Corporation, 2013
+ *
+ * Authors:
+ * Janani Venkataraman <jananve@...ibm.com>
+ */
+
+#include <stdio.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+int setup_connection(void)
+{
+ int socket_fd;
+ struct sockaddr_un address;
+ socklen_t len = sizeof(struct sockaddr_un);
+
+ /* Creating the socket */
+ socket_fd = socket(PF_UNIX, SOCK_STREAM, 0);
+ if (socket_fd < 0)
+ return -1;
+
+ memset(&address, 0, len);
+
+ address.sun_family = PF_FILE;
+ strcpy(address.sun_path, SOCKET_PATH);
+
+ /* Connecting to the server */
+ if (connect(socket_fd, (struct sockaddr *) &address, len)) {
+ close(socket_fd);
+ return -1;
+ }
+
+ return socket_fd;
+}
+
+int gencore(char *corefile)
+{
+ int socket, ret;
+
+ /* Socket operation */
+ socket = setup_connection();
+ if (socket == -1) {
+ ret = errno;
+ goto cleanup;
+ }
+
+cleanup:
+
+ return ret;
+}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists