1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-31 17:18:04 +03:00

ctdb-daemon: Separate prototypes for system specific functions

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>
This commit is contained in:
Amitay Isaacs 2015-10-23 14:11:53 +11:00 committed by Martin Schwenke
parent 4346fe6a02
commit b900adc55c
34 changed files with 102 additions and 36 deletions

View 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

View 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, ...)
{

View 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 */

View 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

66
ctdb/common/system.h Normal file
View File

@ -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__ */

View File

@ -31,6 +31,7 @@
#include <sys/kinfo.h>
#include <pcap.h>
#include "common/system.h"
#if 0

View File

@ -23,6 +23,8 @@
#include "ctdb_private.h"
#include "common/system.h"
/*
uint16 checksum for n bytes
*/

View File

@ -34,6 +34,7 @@
#include <net/if_arp.h>
#include <pcap.h>
#include "common/system.h"
#ifndef ETHERTYPE_IP6
#define ETHERTYPE_IP6 0x86dd

View File

@ -33,6 +33,7 @@
#include <net/if_arp.h>
#include <pcap.h>
#include "common/system.h"
#ifndef ETHERTYPE_IP6
#define ETHERTYPE_IP6 0x86dd

View File

@ -33,6 +33,7 @@
#include <net/if_arp.h>
#include <pcap.h>
#include "common/system.h"
#ifndef ETHERTYPE_IP6
#define ETHERTYPE_IP6 0x86dd

View 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

View File

@ -26,6 +26,8 @@
#include "ctdb_private.h"
#include "common/system.h"
#if HAVE_SCHED_H
#include <sched.h>
#endif

View 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

View 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;

View 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;

View File

@ -20,6 +20,7 @@
#include "includes.h"
#include "system/filesys.h"
#include "ctdb_private.h"
#include "common/system.h"
static char *progname = NULL;

View 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

View File

@ -21,6 +21,7 @@
#include "tdb.h"
#include "system/filesys.h"
#include "ctdb_private.h"
#include "common/system.h"
static char *progname = NULL;

View 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;

View 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"

View 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"

View 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;

View 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)

View 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 */

View 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)

View 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);

View 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;

View 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)

View 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;

View 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);

View 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"
/*

View File

@ -22,6 +22,7 @@
#include "system/filesys.h"
#include "popt.h"
#include "cmdline.h"
#include "common/system.h"
static struct {
const char *socketname;

View 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 */

View File

@ -26,6 +26,7 @@
#include "ctdb_private.h"
#include "ctdb_protocol.h"
#include "domain.h"
#include "common/system.h"
/*
* CTDB PMDA