ctdb-daemon: Separate prototypes for system specific functions
authorAmitay Isaacs <amitay@gmail.com>
Fri, 23 Oct 2015 03:11:53 +0000 (14:11 +1100)
committerMartin Schwenke <martins@samba.org>
Fri, 30 Oct 2015 01:00:27 +0000 (02:00 +0100)
This groups function prototypes for system specific functions in
common/system.h and removes them from ctdb_private.h.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
34 files changed:
ctdb/client/ctdb_client.c
ctdb/common/ctdb_fork.c
ctdb/common/ctdb_io.c
ctdb/common/ctdb_util.c
ctdb/common/system.h [new file with mode: 0644]
ctdb/common/system_aix.c
ctdb/common/system_common.c
ctdb/common/system_freebsd.c
ctdb/common/system_gnu.c
ctdb/common/system_kfreebsd.c
ctdb/common/system_linux.c
ctdb/common/system_util.c
ctdb/include/ctdb_private.h
ctdb/server/ctdb_call.c
ctdb/server/ctdb_daemon.c
ctdb/server/ctdb_event_helper.c
ctdb/server/ctdb_lock.c
ctdb/server/ctdb_lock_helper.c
ctdb/server/ctdb_logging.c
ctdb/server/ctdb_logging_file.c
ctdb/server/ctdb_ltdb_server.c
ctdb/server/ctdb_monitor.c
ctdb/server/ctdb_recover.c
ctdb/server/ctdb_recoverd.c
ctdb/server/ctdb_takeover.c
ctdb/server/ctdb_traverse.c
ctdb/server/ctdb_update_record.c
ctdb/server/ctdb_vacuum.c
ctdb/server/ctdbd.c
ctdb/server/eventscript.c
ctdb/tcp/tcp_connect.c
ctdb/tests/src/ctdb_porting_tests.c
ctdb/tools/ctdb.c
ctdb/utils/pmda/pmda_ctdb.c

index b8e7e10418719cad4f5fbaedf057aba41e33825c..f0fbea40bc2293ff3031467318e710de9a8472d5 100644 (file)
@@ -29,6 +29,7 @@
 #include "../include/ctdb_private.h"
 #include "lib/util/dlinklist.h"
 #include "common/reqid.h"
+#include "common/system.h"
 
 /*
   allocate a packet for use in client<->daemon communication
index 8d38150de13ae2552daf2b4e4b8d997f10cf6787..336bc8ee1342ee0c69d7e435e0db6d41ae65060b 100644 (file)
@@ -22,6 +22,7 @@
 #include "../include/ctdb_client.h"
 #include "../include/ctdb_private.h"
 #include "../common/rb_tree.h"
+#include "common/system.h"
 
 void ctdb_set_child_info(TALLOC_CTX *mem_ctx, const char *child_name_fmt, ...)
 {
index 53486f43da63d568939c0c935ccac58e12ecf274..2318364439a7bbc25f19b5523bfe82c9afa19cee 100644 (file)
@@ -29,6 +29,8 @@
 #include "../include/ctdb_client.h"
 #include <stdarg.h>
 
+#include "common/system.h"
+
 #define QUEUE_BUFFER_SIZE      (16*1024)
 
 /* structures for packet queueing - see common/ctdb_io.c */
index 2864834a2530b95facba74ad8d4627a348065372..474ebfa9fafc1b0ccc4f35e8fb41d4fdfb2881f5 100644 (file)
@@ -24,6 +24,7 @@
 #include "system/wait.h"
 #include "../include/ctdb_private.h"
 #include "common/reqid.h"
+#include "common/system.h"
 
 /*
   return error string for last error
diff --git a/ctdb/common/system.h b/ctdb/common/system.h
new file mode 100644 (file)
index 0000000..8df87cd
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+   System specific code
+
+   Copyright (C) Amitay Isaacs  2015
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __CTDB_SYSTEM_H__
+#define __CTDB_SYSTEM_H__
+
+/* From system_common.c */
+
+uint32_t uint16_checksum(uint16_t *data, size_t n);
+bool ctdb_sys_have_ip(ctdb_sock_addr *_addr);
+char *ctdb_sys_find_ifname(ctdb_sock_addr *addr);
+
+/* From system_<os>.c */
+
+int ctdb_sys_send_arp(const ctdb_sock_addr *addr, const char *iface);
+int ctdb_sys_send_tcp(const ctdb_sock_addr *dest,
+                     const ctdb_sock_addr *src,
+                     uint32_t seq, uint32_t ack, int rst);
+int ctdb_sys_open_capture_socket(const char *iface, void **private_data);
+int ctdb_sys_close_capture_socket(void *private_data);
+int ctdb_sys_read_tcp_packet(int s, void *private_data,
+                       ctdb_sock_addr *src, ctdb_sock_addr *dst,
+                       uint32_t *ack_seq, uint32_t *seq);
+bool ctdb_sys_check_iface_exists(const char *iface);
+int ctdb_get_peer_pid(const int fd, pid_t *peer_pid);
+int ctdb_set_process_name(const char *name);
+
+/* From system_util.c */
+
+bool set_scheduler(void);
+void reset_scheduler(void);
+void set_nonblocking(int fd);
+void set_close_on_exec(int fd);
+
+bool parse_ipv4(const char *s, unsigned port, struct sockaddr_in *sin);
+bool parse_ip(const char *addr, const char *ifaces, unsigned port,
+             ctdb_sock_addr *saddr);
+bool parse_ip_mask(const char *str, const char *ifaces, ctdb_sock_addr *addr,
+                  unsigned *mask);
+bool parse_ip_port(const char *addr, ctdb_sock_addr *saddr);
+
+void lockdown_memory(bool valgrinding);
+
+int mkdir_p(const char *dir, int mode);
+void mkdir_p_or_die(const char *dir, int mode);
+
+ssize_t sys_read(int fd, void *buf, size_t count);
+ssize_t sys_write(int fd, const void *buf, size_t count);
+
+#endif /* __CTDB_SYSTEM_H__ */
index a98d38205679662ce0bf2f01c58e58be092fbdb3..59ee87185f609e4bd9df394a7191c4c8cfd928bc 100644 (file)
@@ -31,6 +31,7 @@
 #include <sys/kinfo.h>
 #include <pcap.h>
 
+#include "common/system.h"
 
 
 #if 0
index 899f3b56bebc6927089da675997c30362a4d1dc2..1e0a095ec8c4b40426c79e79994fd0901387c097 100644 (file)
@@ -23,6 +23,8 @@
 
 #include "ctdb_private.h"
 
+#include "common/system.h"
+
 /*
   uint16 checksum for n bytes
  */
index c5a816bf7af4533de01ce6224c909e8fcedb6bdb..e132e5ce4932e5f19e0af4f2c041958e992d646d 100644 (file)
@@ -34,6 +34,7 @@
 #include <net/if_arp.h>
 #include <pcap.h>
 
+#include "common/system.h"
 
 #ifndef ETHERTYPE_IP6
 #define ETHERTYPE_IP6 0x86dd
index bf8f43c4868d153592681471d8f730489b0f575f..7921655b5c7160f835fc9d6ef6796a084b332f04 100644 (file)
@@ -33,6 +33,7 @@
 #include <net/if_arp.h>
 #include <pcap.h>
 
+#include "common/system.h"
 
 #ifndef ETHERTYPE_IP6
 #define ETHERTYPE_IP6 0x86dd
index de7c8911c89e0893e398786abe31d60785645858..dd7f71a6af27e781bade2b2742db711c3f2cf292 100644 (file)
@@ -33,6 +33,7 @@
 #include <net/if_arp.h>
 #include <pcap.h>
 
+#include "common/system.h"
 
 #ifndef ETHERTYPE_IP6
 #define ETHERTYPE_IP6 0x86dd
index 79d1a83ff1023880b6f23fd9667210252d473082..bca928dc2f219af158770301fc22f23799f1c0d0 100644 (file)
@@ -30,6 +30,8 @@
 #include <netpacket/packet.h>
 #include <sys/prctl.h>
 
+#include "common/system.h"
+
 #ifndef ETHERTYPE_IP6
 #define ETHERTYPE_IP6 0x86dd
 #endif
index 663df6e6b579eabc7a5e254accc2130468157aac..088d86b449c05c989bad4b41586ef60a8f8fe9b6 100644 (file)
@@ -26,6 +26,8 @@
 
 #include "ctdb_private.h"
 
+#include "common/system.h"
+
 #if HAVE_SCHED_H
 #include <sched.h>
 #endif
index 74a155c8c1a0a341257dfe0b96674db5a8649c6a..18e9a556ca572586f5ee49a65f39b8bd7d249bef 100644 (file)
@@ -1010,8 +1010,6 @@ void ctdb_call_resend_all(struct ctdb_context *ctdb);
 void ctdb_node_dead(struct ctdb_node *node);
 void ctdb_node_connected(struct ctdb_node *node);
 bool ctdb_blocking_freeze(struct ctdb_context *ctdb);
-bool set_scheduler(void);
-void reset_scheduler(void);
 
 struct tevent_signal *ctdb_init_sigchld(struct ctdb_context *ctdb);
 void ctdb_track_child(struct ctdb_context *ctdb, pid_t pid);
@@ -1099,17 +1097,6 @@ int ctdb_ctrl_set_iface_link(struct ctdb_context *ctdb,
                             TALLOC_CTX *mem_ctx,
                             const struct ctdb_control_iface_info *info);
 
-/* from takeover/system.c */
-uint32_t uint16_checksum(uint16_t *data, size_t n);
-int ctdb_sys_send_arp(const ctdb_sock_addr *addr, const char *iface);
-bool ctdb_sys_have_ip(ctdb_sock_addr *addr);
-char *ctdb_sys_find_ifname(ctdb_sock_addr *addr);
-bool ctdb_sys_check_iface_exists(const char *iface);
-int ctdb_get_peer_pid(const int fd, pid_t *peer_pid);
-int ctdb_sys_send_tcp(const ctdb_sock_addr *dest, 
-                     const ctdb_sock_addr *src,
-                     uint32_t seq, uint32_t ack, int rst);
-
 /* Details of a byte range lock */
 struct ctdb_lock_info {
        ino_t inode;
@@ -1118,8 +1105,6 @@ struct ctdb_lock_info {
        bool read_only;
 };
 
-int ctdb_set_process_name(const char *name);
-
 typedef void (*client_async_callback)(struct ctdb_context *ctdb, uint32_t node_pnn, int32_t res, TDB_DATA outdata, void *callback_data);
 
 int ctdb_set_public_addresses(struct ctdb_context *ctdb, bool check_addresses);
@@ -1153,9 +1138,6 @@ int ctdb_event_script_callback(struct ctdb_context *ctdb,
                               const char *fmt, ...) PRINTF_ATTRIBUTE(6,7);
 void ctdb_release_all_ips(struct ctdb_context *ctdb);
 
-void set_nonblocking(int fd);
-void set_close_on_exec(int fd);
-
 bool ctdb_recovery_have_lock(struct ctdb_context *ctdb);
 bool ctdb_recovery_lock(struct ctdb_context *ctdb);
 void ctdb_recovery_unlock(struct ctdb_context *ctdb);
@@ -1182,16 +1164,6 @@ int ctdb_ctrl_get_all_tunables(struct ctdb_context *ctdb,
                               uint32_t destnode,
                               struct ctdb_tunable *tunables);
 
-bool parse_ip_mask(const char *s, const char *iface, ctdb_sock_addr *addr, unsigned *mask);
-bool parse_ip_port(const char *s, ctdb_sock_addr *addr);
-bool parse_ip(const char *s, const char *iface, unsigned port, ctdb_sock_addr *addr);
-bool parse_ipv4(const char *s, unsigned port, struct sockaddr_in *sin);
-
-int ctdb_sys_open_capture_socket(const char *iface, void **private_data);
-int ctdb_sys_close_capture_socket(void *private_data);
-int ctdb_sys_read_tcp_packet(int s, void *private_data, ctdb_sock_addr *src, ctdb_sock_addr *dst, uint32_t *ack_seq, uint32_t *seq);
-
 int ctdb_ctrl_killtcp(struct ctdb_context *ctdb, 
                      struct timeval timeout, 
                      uint32_t destnode,
@@ -1267,7 +1239,6 @@ int32_t ctdb_control_db_get_health(struct ctdb_context *ctdb,
 int32_t ctdb_monitoring_mode(struct ctdb_context *ctdb);
 bool ctdb_stopped_monitoring(struct ctdb_context *ctdb);
 int ctdb_set_child_logging(struct ctdb_context *ctdb);
-void lockdown_memory(bool valgrinding);
 
 struct client_async_data {
        enum ctdb_controls opcode;
@@ -1491,10 +1462,4 @@ struct lock_request *ctdb_lock_alldb(TALLOC_CTX *mem_ctx,
                                     void (*callback)(void *, bool),
                                     void *private_data);
 
-int mkdir_p(const char *dir, int mode);
-void mkdir_p_or_die(const char *dir, int mode);
-
-ssize_t sys_read(int fd, void *buf, size_t count);
-ssize_t sys_write(int fd, const void *buf, size_t count);
-
 #endif
index e767bf72c0ee28433184111959d5a5671e57ea31..cecdce294c48ad5d9d44204244922e457c7c42dd 100644 (file)
@@ -28,6 +28,7 @@
 #include "../include/ctdb_private.h"
 #include "../common/rb_tree.h"
 #include "common/reqid.h"
+#include "common/system.h"
 
 struct ctdb_sticky_record {
        struct ctdb_context *ctdb;
index 0287a67649bd23131028f91caab3b46137cbf15f..f7798671abef93fe84fe786a36e6abf9cc0db522 100644 (file)
@@ -30,6 +30,7 @@
 #include "../common/rb_tree.h"
 #include <sys/socket.h>
 #include "common/reqid.h"
+#include "common/system.h"
 
 struct ctdb_client_pid_list {
        struct ctdb_client_pid_list *next, *prev;
index a1b531882251d5a9e491f530fd61a378dabf9e64..7d24820d6df41814742bb3e7201490dcfd61c193 100644 (file)
@@ -20,6 +20,7 @@
 #include "includes.h"
 #include "system/filesys.h"
 #include "ctdb_private.h"
+#include "common/system.h"
 
 static char *progname = NULL;
 
index d8d4f5a6e3c030f2940acb923a3449d8dec6cc81..104ebcd97f46c3bd9a477e03499b34e9f0d6c8b7 100644 (file)
@@ -25,6 +25,7 @@
 #include "lib/tdb_wrap/tdb_wrap.h"
 #include "system/filesys.h"
 #include "lib/util/dlinklist.h"
+#include "common/system.h"
 
 /*
  * Non-blocking Locking API
index 7a09ecf3c70edc9777c066384496f97db6407dd1..c48a925bd955640a7f44fdc94eeb5c936f5aa374 100644 (file)
@@ -21,6 +21,7 @@
 #include "tdb.h"
 #include "system/filesys.h"
 #include "ctdb_private.h"
+#include "common/system.h"
 
 static char *progname = NULL;
 
index 129bdc9e7f65e333c739fb030cba96dcfef988ac..b2e8a6ec447299ffd51339c4601462a48fbc1101 100644 (file)
@@ -25,6 +25,7 @@
 #include "system/filesys.h"
 #include "lib/util/debug.h"
 #include "lib/util/dlinklist.h"
+#include "common/system.h"
 
 struct ctdb_log_backend {
        struct ctdb_log_backend *prev, *next;
index f931b4a8b83073ff80be3813ffd52c324d681320..24a4167f6ea018036756cdb4d80ad09c5b0d2903 100644 (file)
@@ -23,6 +23,7 @@
 #include "system/time.h"
 #include "system/filesys.h"
 #include "lib/util/time_basic.h"
+#include "common/system.h"
 
 #define CTDB_LOG_FILE_PREFIX "file"
 
index 3386bba2c3e482241fc12e66baa1ea05f4b672e2..5e4128bd3266c233fd3bab8e249b9fea246e0a42 100644 (file)
@@ -29,6 +29,7 @@
 #include "lib/util/dlinklist.h"
 #include <ctype.h>
 #include "common/reqid.h"
+#include "common/system.h"
 
 #define PERSISTENT_HEALTH_TDB "persistent_health.tdb"
 
index edaae48ff8ed0a0b186aa39ef3623b0aed7465a0..493e55a02aeca13cbf78d2d5832d6f70b37e7484 100644 (file)
@@ -22,6 +22,7 @@
 #include "system/filesys.h"
 #include "system/wait.h"
 #include "../include/ctdb_private.h"
+#include "common/system.h"
 
 struct ctdb_monitor_state {
        uint32_t monitoring_mode;
index b57aa8ef7c8b26ae3541534b615c73324f96332e..6ec66ded31f1fd9e0073a5a9c779f5b41dbb8820 100644 (file)
@@ -26,7 +26,7 @@
 #include "../include/ctdb_private.h"
 #include "lib/util/dlinklist.h"
 #include "lib/tdb_wrap/tdb_wrap.h"
-
+#include "common/system.h"
 
 int 
 ctdb_control_getvnnmap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata)
index e945d51f2eb435219b9a489c2ecfcecea69a4ba1..61658c633e4075972d6037a6a2bbc589cab8f66c 100644 (file)
@@ -28,6 +28,7 @@
 #include "../include/ctdb_private.h"
 #include "lib/tdb_wrap/tdb_wrap.h"
 #include "lib/util/dlinklist.h"
+#include "common/system.h"
 
 
 /* List of SRVID requests that need to be processed */
index 098cfe734f1421b95db77abc4710092710612736..d1330f1ff37e08ceaee02565770524bd5b085995 100644 (file)
@@ -27,6 +27,7 @@
 #include "../include/ctdb_private.h"
 #include "../common/rb_tree.h"
 #include "common/reqid.h"
+#include "common/system.h"
 
 
 #define TAKEOVER_TIMEOUT() timeval_current_ofs(ctdb->tunable.takeover_timeout,0)
index 88528c5267606e74e955a75ce1a8d424bcfac8b0..3b7eae80a6c573983c59f1b56da9de19341eb02c 100644 (file)
@@ -25,6 +25,7 @@
 #include "../include/ctdb_private.h"
 #include "lib/util/dlinklist.h"
 #include "common/reqid.h"
+#include "common/system.h"
 
 typedef void (*ctdb_traverse_fn_t)(void *private_data, TDB_DATA key, TDB_DATA data);
 
index 418bbb10e1c62b3ab118416277fc9b8eac32f4ed..3b5ea689730acac91ab10f51ebb36f052a153404 100644 (file)
@@ -22,6 +22,7 @@
 #include "lib/tdb_wrap/tdb_wrap.h"
 #include "tdb.h"
 #include "ctdb_private.h"
+#include "common/system.h"
 
 struct ctdb_persistent_write_state {
        struct ctdb_db_context *ctdb_db;
index d678ff98ab3b155dd6aa4392b169fdd14232801e..39eed0b74e5d7b1d69a5f7b2402ca745efe06e57 100644 (file)
@@ -29,6 +29,7 @@
 #include "lib/util/dlinklist.h"
 #include "../include/ctdb_private.h"
 #include "../common/rb_tree.h"
+#include "common/system.h"
 
 #define TIMELIMIT() timeval_current_ofs(10, 0)
 
index ac289c6f2d430d2f741e0610b9842bf65e9566ba..aebbc041ad12feb115ffb2fed434eb5344c424c0 100644 (file)
@@ -26,6 +26,7 @@
 #include "cmdline.h"
 #include "../include/ctdb_private.h"
 #include "common/reqid.h"
+#include "common/system.h"
 
 static struct {
        const char *nlist;
index 49619b27063d97e1394f8416076231c31d5274d3..b1b77cd1cddd94a66c16d2fcd7dc1ab3b3979575 100644 (file)
@@ -26,6 +26,7 @@
 #include "../include/ctdb_private.h"
 #include "../common/rb_tree.h"
 #include "lib/util/dlinklist.h"
+#include "common/system.h"
 
 static void ctdb_event_script_timeout(struct event_context *ev, struct timed_event *te, struct timeval t, void *p);
 
index 93049232d629ca3fe9557c45c3bad728c820704f..5935bf446655f8182e455f4a10459a11a05e8633 100644 (file)
@@ -23,6 +23,7 @@
 #include "system/network.h"
 #include "system/filesys.h"
 #include "../include/ctdb_private.h"
+#include "common/system.h"
 #include "ctdb_tcp.h"
 
 /*
index a4dda1930d04bf867cfdb8c9a5210b8e88e6ecc2..c8e268f58a1f43bd9e2fe6cd95c410ef2a6d94ef 100644 (file)
@@ -22,6 +22,7 @@
 #include "system/filesys.h"
 #include "popt.h"
 #include "cmdline.h"
+#include "common/system.h"
 
 static struct {
        const char *socketname;
index 013a484cc5fc77e751034f9d9ea5cd6f6a7eba01..5e676f721793c4bfc88165d40d272122914c6931 100644 (file)
@@ -31,6 +31,7 @@
 #include "../common/rb_tree.h"
 #include "lib/tdb_wrap/tdb_wrap.h"
 #include "lib/util/dlinklist.h"
+#include "common/system.h"
 
 #define ERR_TIMEOUT    20      /* timed out trying to reach node */
 #define ERR_NONODE     21      /* node does not exist */
index 114584423ae86c22077c2d7ecb1b06c84094c7d3..f1a90c48b86ccf189e81aef1b3db578e125e8471 100644 (file)
@@ -26,6 +26,7 @@
 #include "ctdb_private.h"
 #include "ctdb_protocol.h"
 #include "domain.h"
+#include "common/system.h"
 
 /*
  * CTDB PMDA