From 291f5240840cf46dfd0dc179c4e3b3baa2591aaa Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Thu, 4 Jul 2024 14:32:12 +0200 Subject: [PATCH] Use bfopen instead of fopen in various tools --- bacula/src/dird/malware.c | 2 +- bacula/src/filed/job.c | 2 +- bacula/src/lib/lex.c | 2 +- bacula/src/plugins/fd/fd_common.h | 10 +++++----- bacula/src/tools/bsnapshot.c | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/bacula/src/dird/malware.c b/bacula/src/dird/malware.c index d484c9e86..05e85fb15 100644 --- a/bacula/src/dird/malware.c +++ b/bacula/src/dird/malware.c @@ -69,7 +69,7 @@ static bool load_malware_db(JCR *jcr, BDB *db, int mode, const char *source, con Dmsg1(dbglvl, "Load malware database from %s\n", fname); /* We open the malware hash database */ - fp = fopen(fname, "r"); + fp = bfopen(fname, "r"); if (!fp) { berrno be; Mmsg(errmsg, _("[DE0053] Unable to open the Malware Database export %s ERR=%s\n"), diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index 751c192a3..943f471ac 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -1505,7 +1505,7 @@ int add_file_to_fileset(JCR *jcr, const char *fname, bool is_file) case '<': Dmsg1(100, "Doing < of '%s' include on client.\n", p + 1); p++; /* skip over < */ - if ((ffd = fopen(p, "rb")) == NULL) { + if ((ffd = bfopen(p, "rb")) == NULL) { berrno be; Jmsg(jcr, M_FATAL, 0, _("Cannot open FileSet input file: %s. ERR=%s\n"), diff --git a/bacula/src/lib/lex.c b/bacula/src/lib/lex.c index c7ff1914b..0792ab202 100644 --- a/bacula/src/lib/lex.c +++ b/bacula/src/lib/lex.c @@ -247,7 +247,7 @@ LEX *lex_open_file(LEX *lf, const char *filename, LEX_ERROR_HANDLER *scan_error) return NULL; } fd = bpipe->rfd; - } else if ((fd = fopen(fname, "rb")) == NULL) { + } else if ((fd = bfopen(fname, "rb")) == NULL) { free(fname); return NULL; } diff --git a/bacula/src/plugins/fd/fd_common.h b/bacula/src/plugins/fd/fd_common.h index da85457df..717538992 100644 --- a/bacula/src/plugins/fd/fd_common.h +++ b/bacula/src/plugins/fd/fd_common.h @@ -337,7 +337,7 @@ bool joblist::find_job(const char *name, POOLMEM **data) Mmsg(tmp, "%s/%s", working, base); P(joblist_mutex); - f = fopen(tmp, "r"); + f = bfopen(tmp, "r"); if (!f) { berrno be; Jmsg(ctx, M_ERROR, "Unable to open job database. ERR=%s\n", @@ -432,7 +432,7 @@ bool joblist::find_root_job() Mmsg(tmp, "%s/%s", working, base); P(joblist_mutex); - f = fopen(tmp, "r"); + f = bfopen(tmp, "r"); if (!f) { berrno be; Jmsg(ctx, M_ERROR, "Unable to prune previous jobs. ERR=%s\n", @@ -513,7 +513,7 @@ bool joblist::store_job(char *data) tmp = get_pool_memory(PM_FNAME); Mmsg(tmp, "%s/%s", working, base); - fp = fopen(tmp, "a+"); + fp = bfopen(tmp, "a+"); if (!fp) { berrno be; Jmsg(ctx, M_ERROR, "Unable to update the job history. ERR=%s\n", @@ -600,7 +600,7 @@ void joblist::prune_jobs(char *build_cmd(void *arg, const char *data, const char *curkey = *curjobname = *prevjob = *rootjob = *buf = *data = 0; P(joblist_mutex); - fout = fopen(tmpout, "w"); + fout = bfopen(tmpout, "w"); if (!fout) { berrno be; Jmsg(ctx, M_ERROR, "Unable to prune previous jobs. " @@ -609,7 +609,7 @@ void joblist::prune_jobs(char *build_cmd(void *arg, const char *data, const char goto bail_out; } - f = fopen(tmp, "r"); + f = bfopen(tmp, "r"); if (!f) { berrno be; Jmsg(ctx, M_ERROR, "Unable to prune previous jobs. ERR=%s\n", diff --git a/bacula/src/tools/bsnapshot.c b/bacula/src/tools/bsnapshot.c index 2bdd90b2a..6241fa69d 100644 --- a/bacula/src/tools/bsnapshot.c +++ b/bacula/src/tools/bsnapshot.c @@ -666,7 +666,7 @@ public: */ Mmsg(path, "%s/snapshotdb/%s", arg->working, arg->name); if (stat(path, &sp) == 0) { - FILE *fp = fopen(path, "r"); + FILE *fp = bfopen(path, "r"); if (!fp) { printf("status=0 error=\"Unable to get information about snapshot\n"); return 0; @@ -701,7 +701,7 @@ public: return 0; } - FILE *fp = fopen(path, "w"); + FILE *fp = bfopen(path, "w"); if (!fp) { berrno be; printf("status=0 error=\"Unable to store information about snapshot in %s errno=%s\"\n", path, be.bstrerror()); -- 2.47.3