From 98db583e9b2e7aa8e095a75a6bb5f42b0d65ae79 Mon Sep 17 00:00:00 2001 From: Csaba Henk Date: Tue, 9 May 2017 19:23:18 +0200 Subject: libglusterfs: extract some functionality to functions - code in run.c to close all file descriptors, except for specified ones is extracted to int close_fds_except (int *fdv, size_t count); - tokenizing and editing a string that consists of comma-separated tokens (as done eg. in mount_param_to_flag() of contrib/fuse/mount.c is abstacted into the following API: char *token_iter_init (char *str, char sep, token_iter_t *tit); gf_boolean_t next_token (char **tokenp, token_iter_t *tit); void drop_token (char *token, token_iter_t *tit); Updates #153 Change-Id: I7cb5bda38f680f08882e2a7ef84f9142ffaa54eb Signed-off-by: Csaba Henk Reviewed-on: https://review.gluster.org/17229 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Amar Tumballi --- libglusterfs/src/common-utils.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'libglusterfs/src/common-utils.h') diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h index 6243732b522..6bd24179592 100644 --- a/libglusterfs/src/common-utils.h +++ b/libglusterfs/src/common-utils.h @@ -774,6 +774,14 @@ void skip_word (char **str); /* returns a new string with nth word of given string. n>=1 */ char *get_nth_word (const char *str, int n); +typedef struct token_iter { + char *end; + char sep; +} token_iter_t; +char *token_iter_init (char *str, char sep, token_iter_t *tit); +gf_boolean_t next_token (char **tokenp, token_iter_t *tit); +void drop_token (char *token, token_iter_t *tit); + gf_boolean_t mask_match (const uint32_t a, const uint32_t b, const uint32_t m); gf_boolean_t gf_is_ip_in_net (const char *network, const char *ip_str); char valid_host_name (char *address, int length); @@ -903,4 +911,6 @@ gf_fop_string (glusterfs_fop_t fop); char * get_ip_from_addrinfo (struct addrinfo *addr, char **ip); +int +close_fds_except (int *fdv, size_t count); #endif /* _COMMON_UTILS_H */ -- cgit