From 7ef83239c9245c1cb66d86af67fbab0103e2cf6a Mon Sep 17 00:00:00 2001 From: Marco van Wieringen Date: Thu, 13 Aug 2009 09:33:01 +0200 Subject: [PATCH] Loose void pointer and use C++ supported declaration elsewhere defined structure. --- bacula/src/filed/xattr.c | 45 +++++++++++++++++++--------------------- bacula/src/jcr.h | 3 ++- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/bacula/src/filed/xattr.c b/bacula/src/filed/xattr.c index d3f97e241f..5790f423d7 100644 --- a/bacula/src/filed/xattr.c +++ b/bacula/src/filed/xattr.c @@ -654,9 +654,8 @@ static int os_default_xattr_streams[1] = { STREAM_XATTR_SOLARIS }; static xattr_link_cache_entry_t *find_xattr_link_cache_entry(JCR *jcr, ino_t inum) { xattr_link_cache_entry_t *ptr; - xattr_private_data_t *xpd = (xattr_private_data_t *)jcr->xattr_private_data; - foreach_alist(ptr, xpd->xattr_link_cache) { + foreach_alist(ptr, jcr->xpd->xattr_link_cache) { if (ptr && ptr->inum == inum) { return ptr; } @@ -667,13 +666,12 @@ static xattr_link_cache_entry_t *find_xattr_link_cache_entry(JCR *jcr, ino_t inu static void add_xattr_link_cache_entry(JCR *jcr, ino_t inum, char *target) { xattr_link_cache_entry_t *ptr; - xattr_private_data_t *xpd = (xattr_private_data_t *)jcr->xattr_private_data; ptr = (xattr_link_cache_entry_t *)malloc(sizeof(xattr_link_cache_entry_t)); memset((caddr_t)ptr, 0, sizeof(xattr_link_cache_entry_t)); ptr->inum = inum; bstrncpy(ptr->target, target, sizeof(ptr->target)); - xpd->xattr_link_cache->append(ptr); + jcr->xpd->xattr_link_cache->append(ptr); } #if defined(HAVE_SYS_NVPAIR_H) && defined(_PC_SATTR_ENABLED) @@ -912,7 +910,6 @@ static bxattr_exit_code solaris_save_xattr(JCR *jcr, int fd, const char *xattr_n char *acl_text = NULL; char attribs[MAXSTRING]; char buffer[BUFSIZ]; - xattr_private_data_t *xpd = (xattr_private_data_t *)jcr->xattr_private_data; bxattr_exit_code retval = bxattr_exit_error; berrno be; @@ -975,11 +972,11 @@ static bxattr_exit_code solaris_save_xattr(JCR *jcr, int fd, const char *xattr_n * Encode the stat struct into an ASCII representation and jump out of the function. */ encode_stat(attribs, &st, 0, stream); - xpd->toplevel_hidden_dir_xattr_data_len = bsnprintf(xpd->toplevel_hidden_dir_xattr_data, - sizeof(xpd->toplevel_hidden_dir_xattr_data), - "%s%c%s%c%s%c", - target_attrname, 0, attribs, 0, - (acl_text) ? acl_text : "", 0); + jcr->xpd->toplevel_hidden_dir_xattr_data_len = bsnprintf(jcr->xpd->toplevel_hidden_dir_xattr_data, + sizeof(jcr->xpd->toplevel_hidden_dir_xattr_data), + "%s%c%s%c%s%c", + target_attrname, 0, attribs, 0, + (acl_text) ? acl_text : "", 0); goto bail_out; } else { /* @@ -1098,11 +1095,13 @@ static bxattr_exit_code solaris_save_xattr(JCR *jcr, int fd, const char *xattr_n } /* - * See if this is the first real xattr being saved. If it is save the toplevel_hidden_dir attributes first. + * See if this is the first real xattr being saved. + * If it is save the toplevel_hidden_dir attributes first. */ - if (xpd->nr_xattr_saved == 0) { - pm_memcpy(jcr->xattr_data, xpd->toplevel_hidden_dir_xattr_data, xpd->toplevel_hidden_dir_xattr_data_len); - jcr->xattr_data_len = xpd->toplevel_hidden_dir_xattr_data_len; + if (jcr->xpd->nr_xattr_saved == 0) { + pm_memcpy(jcr->xattr_data, jcr->xpd->toplevel_hidden_dir_xattr_data, + jcr->xpd->toplevel_hidden_dir_xattr_data_len); + jcr->xattr_data_len = jcr->xpd->toplevel_hidden_dir_xattr_data_len; retval = send_xattr_stream(jcr, STREAM_XATTR_SOLARIS); } @@ -1146,7 +1145,7 @@ static bxattr_exit_code solaris_save_xattr(JCR *jcr, int fd, const char *xattr_n if (retval) { retval = send_xattr_stream(jcr, stream); - xpd->nr_xattr_saved++; + jcr->xpd->nr_xattr_saved++; } /* @@ -1766,7 +1765,6 @@ bail_out: static bxattr_exit_code solaris_build_xattr_streams(JCR *jcr, FF_PKT *ff_pkt) { char cwd[PATH_MAX]; - xattr_private_data_t *xpd; bxattr_exit_code retval = bxattr_exit_ok; /* @@ -1774,10 +1772,9 @@ static bxattr_exit_code solaris_build_xattr_streams(JCR *jcr, FF_PKT *ff_pkt) * If not just pretend things went ok. */ if (pathconf(jcr->last_fname, _PC_XATTR_EXISTS) > 0) { - xpd = (xattr_private_data_t *)malloc(sizeof(xattr_private_data_t)); - memset((caddr_t)xpd, 0, sizeof(xattr_private_data_t)); - xpd->xattr_link_cache = New(alist(10, not_owned_by_alist)); - jcr->xattr_private_data = (void *)xpd; + jcr->xpd = (xattr_private_data_t *)malloc(sizeof(xattr_private_data_t)); + memset((caddr_t)jcr->xpd, 0, sizeof(xattr_private_data_t)); + jcr->xpd->xattr_link_cache = New(alist(10, not_owned_by_alist)); /* * As we change the cwd in the save function save the current cwd @@ -1786,10 +1783,10 @@ static bxattr_exit_code solaris_build_xattr_streams(JCR *jcr, FF_PKT *ff_pkt) getcwd(cwd, sizeof(cwd)); retval = solaris_save_xattrs(jcr, NULL, NULL); chdir(cwd); - delete xpd->xattr_link_cache; - xpd->xattr_link_cache = NULL; - free(xpd); - jcr->xattr_private_data = NULL; + delete jcr->xpd->xattr_link_cache; + jcr->xpd->xattr_link_cache = NULL; + free(jcr->xpd); + jcr->xpd = NULL; } return retval; } diff --git a/bacula/src/jcr.h b/bacula/src/jcr.h index eebd37a1cf..fb6e1bd8c2 100644 --- a/bacula/src/jcr.h +++ b/bacula/src/jcr.h @@ -148,6 +148,7 @@ struct ATTR_DBR; struct Plugin; struct save_pkt; struct bpContext; +struct xattr_private_data_t; #ifdef FILE_DAEMON class htable; @@ -350,7 +351,7 @@ public: POOLMEM *acl_data; /* data with ACLs for backup/restore */ uint32_t acl_data_len; /* length of acl data buffer */ uint32_t total_acl_errors; /* numbers of errors encountered for acl backup/restore */ - void *xattr_private_data; /* private data for xattr saving */ + xattr_private_data_t *xpd; /* private data for xattr saving */ POOLMEM *xattr_data; /* data with Extended Attributes for backup/restore */ uint32_t xattr_data_len; /* length of xattr_data buffer */ uint32_t total_xattr_errors; /* numbers of errors encountered for xattr backup/restore */ -- 2.39.5