From: Marco van Wieringen Date: Sun, 6 Sep 2009 18:50:10 +0000 (+0200) Subject: Remove some #ifdef-ed code and make it just as the acl and xattr code use a const... X-Git-Tag: Release-5.0.0~318^2~1 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=62ab7eb59806bfa741d98624d4f5fbf037b1821f;p=bacula%2Fbacula Remove some #ifdef-ed code and make it just as the acl and xattr code use a const bool to enable the code. Signed-off-by: Kern Sibbald --- diff --git a/bacula/src/filed/backup.c b/bacula/src/filed/backup.c index 820f03087b..38d889b090 100644 --- a/bacula/src/filed/backup.c +++ b/bacula/src/filed/backup.c @@ -38,6 +38,12 @@ #include "bacula.h" #include "filed.h" +#ifdef HAVE_DARWIN_OS +const bool have_darwin_os = true; +#else +const bool have_darwin_os = false; +#endif + #if defined(HAVE_ACL) const bool have_acl = true; #else @@ -562,54 +568,54 @@ int save_file(JCR *jcr, FF_PKT *ff_pkt, bool top_level) } } -#ifdef HAVE_DARWIN_OS - /* Regular files can have resource forks and Finder Info */ - if (ff_pkt->type != FT_LNKSAVED && (S_ISREG(ff_pkt->statp.st_mode) && - ff_pkt->flags & FO_HFSPLUS)) { - if (ff_pkt->hfsinfo.rsrclength > 0) { - int flags; - int rsrc_stream; - if (!bopen_rsrc(&ff_pkt->bfd, ff_pkt->fname, O_RDONLY | O_BINARY, 0) < 0) { - ff_pkt->ff_errno = errno; - berrno be; - Jmsg(jcr, M_NOTSAVED, -1, _(" Cannot open resource fork for \"%s\": ERR=%s.\n"), - ff_pkt->fname, be.bstrerror()); - jcr->JobErrors++; - if (is_bopen(&ff_pkt->bfd)) { - bclose(&ff_pkt->bfd); + if (have_darwin_os) { + /* Regular files can have resource forks and Finder Info */ + if (ff_pkt->type != FT_LNKSAVED && (S_ISREG(ff_pkt->statp.st_mode) && + ff_pkt->flags & FO_HFSPLUS)) { + if (ff_pkt->hfsinfo.rsrclength > 0) { + int flags; + int rsrc_stream; + if (!bopen_rsrc(&ff_pkt->bfd, ff_pkt->fname, O_RDONLY | O_BINARY, 0) < 0) { + ff_pkt->ff_errno = errno; + berrno be; + Jmsg(jcr, M_NOTSAVED, -1, _(" Cannot open resource fork for \"%s\": ERR=%s.\n"), + ff_pkt->fname, be.bstrerror()); + jcr->JobErrors++; + if (is_bopen(&ff_pkt->bfd)) { + bclose(&ff_pkt->bfd); + } + goto good_rtn; + } + flags = ff_pkt->flags; + ff_pkt->flags &= ~(FO_GZIP|FO_SPARSE); + if (flags & FO_ENCRYPT) { + rsrc_stream = STREAM_ENCRYPTED_MACOS_FORK_DATA; + } else { + rsrc_stream = STREAM_MACOS_FORK_DATA; + } + stat = send_data(jcr, rsrc_stream, ff_pkt, digest, signing_digest); + ff_pkt->flags = flags; + bclose(&ff_pkt->bfd); + if (!stat) { + goto bail_out; } - goto good_rtn; } - flags = ff_pkt->flags; - ff_pkt->flags &= ~(FO_GZIP|FO_SPARSE); - if (flags & FO_ENCRYPT) { - rsrc_stream = STREAM_ENCRYPTED_MACOS_FORK_DATA; - } else { - rsrc_stream = STREAM_MACOS_FORK_DATA; + + Dmsg1(300, "Saving Finder Info for \"%s\"\n", ff_pkt->fname); + sd->fsend("%ld %d 0", jcr->JobFiles, STREAM_HFSPLUS_ATTRIBUTES); + Dmsg1(300, "bfiled>stored:header %s\n", sd->msg); + pm_memcpy(sd->msg, ff_pkt->hfsinfo.fndrinfo, 32); + sd->msglen = 32; + if (digest) { + crypto_digest_update(digest, (uint8_t *)sd->msg, sd->msglen); } - stat = send_data(jcr, rsrc_stream, ff_pkt, digest, signing_digest); - ff_pkt->flags = flags; - bclose(&ff_pkt->bfd); - if (!stat) { - goto bail_out; + if (signing_digest) { + crypto_digest_update(signing_digest, (uint8_t *)sd->msg, sd->msglen); } + sd->send(); + sd->signal(BNET_EOD); } - - Dmsg1(300, "Saving Finder Info for \"%s\"\n", ff_pkt->fname); - sd->fsend("%ld %d 0", jcr->JobFiles, STREAM_HFSPLUS_ATTRIBUTES); - Dmsg1(300, "bfiled>stored:header %s\n", sd->msg); - pm_memcpy(sd->msg, ff_pkt->hfsinfo.fndrinfo, 32); - sd->msglen = 32; - if (digest) { - crypto_digest_update(digest, (uint8_t *)sd->msg, sd->msglen); - } - if (signing_digest) { - crypto_digest_update(signing_digest, (uint8_t *)sd->msg, sd->msglen); - } - sd->send(); - sd->signal(BNET_EOD); } -#endif /* * Save ACLs when requested and available for anything not being a symlink and not being a plugin. diff --git a/bacula/src/filed/verify.c b/bacula/src/filed/verify.c index f4da34b666..2bf98afa7c 100644 --- a/bacula/src/filed/verify.c +++ b/bacula/src/filed/verify.c @@ -37,6 +37,12 @@ #include "bacula.h" #include "filed.h" +#ifdef HAVE_DARWIN_OS +const bool have_darwin_os = true; +#else +const bool have_darwin_os = false; +#endif + static int verify_file(JCR *jcr, FF_PKT *ff_pkt, bool); static int read_digest(BFILE *bfd, DIGEST *digest, JCR *jcr); @@ -288,8 +294,9 @@ int digest_file(JCR *jcr, FF_PKT *ff_pkt, DIGEST *digest) Dmsg0(50, "=== digest_file\n"); binit(&bfd); - if (ff_pkt->statp.st_size > 0 || ff_pkt->type == FT_RAW - || ff_pkt->type == FT_FIFO) { + if (ff_pkt->statp.st_size > 0 || + ff_pkt->type == FT_RAW || + ff_pkt->type == FT_FIFO) { int noatime = ff_pkt->flags & FO_NOATIME ? O_NOATIME : 0; if ((bopen(&bfd, ff_pkt->fname, O_RDONLY | O_BINARY | noatime, 0)) < 0) { ff_pkt->ff_errno = errno; @@ -304,29 +311,29 @@ int digest_file(JCR *jcr, FF_PKT *ff_pkt, DIGEST *digest) bclose(&bfd); } -#ifdef HAVE_DARWIN_OS + if (have_darwin_os) { /* Open resource fork if necessary */ - if (ff_pkt->flags & FO_HFSPLUS && ff_pkt->hfsinfo.rsrclength > 0) { - if (bopen_rsrc(&bfd, ff_pkt->fname, O_RDONLY | O_BINARY, 0) < 0) { - ff_pkt->ff_errno = errno; - berrno be; - Jmsg(jcr, M_ERROR, -1, _(" Cannot open resource fork for %s: ERR=%s.\n"), - ff_pkt->fname, be.bstrerror()); - if (is_bopen(&ff_pkt->bfd)) { - bclose(&ff_pkt->bfd); + if (ff_pkt->flags & FO_HFSPLUS && ff_pkt->hfsinfo.rsrclength > 0) { + if (bopen_rsrc(&bfd, ff_pkt->fname, O_RDONLY | O_BINARY, 0) < 0) { + ff_pkt->ff_errno = errno; + berrno be; + Jmsg(jcr, M_ERROR, -1, _(" Cannot open resource fork for %s: ERR=%s.\n"), + ff_pkt->fname, be.bstrerror()); + if (is_bopen(&ff_pkt->bfd)) { + bclose(&ff_pkt->bfd); + } + return 1; } - return 1; + read_digest(&bfd, digest, jcr); + bclose(&bfd); } - read_digest(&bfd, digest, jcr); - bclose(&bfd); - } - if (digest && ff_pkt->flags & FO_HFSPLUS) { - crypto_digest_update(digest, (uint8_t *)ff_pkt->hfsinfo.fndrinfo, 32); - } -#endif + if (digest && ff_pkt->flags & FO_HFSPLUS) { + crypto_digest_update(digest, (uint8_t *)ff_pkt->hfsinfo.fndrinfo, 32); + } - return 0; + return 0; + } } /* diff --git a/bacula/src/findlib/bfile.c b/bacula/src/findlib/bfile.c index 20999d935a..7ba1fca330 100644 --- a/bacula/src/findlib/bfile.c +++ b/bacula/src/findlib/bfile.c @@ -950,6 +950,11 @@ int bopen_rsrc(BFILE *bfd, const char *fname, int flags, mode_t mode) free_pool_memory(rsrc_fname); return bfd->fid; } +#else +int bopen_rsrc(BFILE *bfd, const char *fname, int flags, mode_t mode) +{ + return -1; +} #endif diff --git a/bacula/src/findlib/bfile.h b/bacula/src/findlib/bfile.h index 6355217743..b22d50cc4e 100644 --- a/bacula/src/findlib/bfile.h +++ b/bacula/src/findlib/bfile.h @@ -129,9 +129,7 @@ bool is_restore_stream_supported(int stream); bool is_win32_stream(int stream); char *xberror(BFILE *bfd); /* DO NOT USE -- use berrno class */ int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode); -#ifdef HAVE_DARWIN_OS int bopen_rsrc(BFILE *bfd, const char *fname, int flags, mode_t mode); -#endif int bclose(BFILE *bfd); ssize_t bread(BFILE *bfd, void *buf, size_t count); ssize_t bwrite(BFILE *bfd, void *buf, size_t count); diff --git a/bacula/src/findlib/find.h b/bacula/src/findlib/find.h index 035102cd17..030aa3f392 100644 --- a/bacula/src/findlib/find.h +++ b/bacula/src/findlib/find.h @@ -174,13 +174,11 @@ struct findFILESET { alist exclude_list; }; -#ifdef HAVE_DARWIN_OS struct HFSPLUS_INFO { unsigned long length; /* Mandatory field */ char fndrinfo[32]; /* Finder Info */ off_t rsrclength; /* Size of resource fork */ }; -#endif /* * Definition of the find_files packet passed as the @@ -229,9 +227,7 @@ struct FF_PKT { * To avoid clutter, we always include rsrc_bfd and volhas_attrlist */ BFILE rsrc_bfd; /* fd for resource forks */ bool volhas_attrlist; /* Volume supports getattrlist() */ -#ifdef HAVE_DARWIN_OS struct HFSPLUS_INFO hfsinfo; /* Finder Info and resource fork size */ -#endif };