From: Eric Bollengier Date: Fri, 16 Feb 2024 17:14:20 +0000 (+0100) Subject: Fix org#2707 Check the NODUMP flag only on files and directories X-Git-Tag: Release-15.0.2~40 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=92e3c70f9b9fa52fbfad3597adda5b658bf99fb9;p=thirdparty%2Fbacula.git Fix org#2707 Check the NODUMP flag only on files and directories The current code was trying to get the flag from fifo, ending to block the backup procedure. Thanks to Martin. --- diff --git a/bacula/src/findlib/find_one.c b/bacula/src/findlib/find_one.c index 7c5089b1f..a9b019b20 100644 --- a/bacula/src/findlib/find_one.c +++ b/bacula/src/findlib/find_one.c @@ -230,29 +230,33 @@ static bool no_dump(JCR *jcr, FF_PKT *ff_pkt) bool ret = false; /* do backup */ int attr; int fd = -1; + if (ff_pkt->flags & FO_HONOR_NODUMP) { - fd = open(ff_pkt->fname, O_RDONLY|O_CLOEXEC); - if (fd < 0) { - Dmsg2(50, "Failed to open file: %s err: %d\n", - ff_pkt->fname, errno); - goto bail_out; + if (S_ISDIR(ff_pkt->statp.st_mode) || S_ISREG(ff_pkt->statp.st_mode)) { + /* lsattr and chattr in the e2fsprogs package only works for files and dirs */ + fd = open(ff_pkt->fname, O_RDONLY|O_CLOEXEC); + if (fd < 0) { + Dmsg2(50, "Failed to open file: %s err: %d\n", + ff_pkt->fname, errno); + goto bail_out; + } + + int ioctl_ret = ioctl(fd, FS_IOC_GETFLAGS, &attr); + if (ioctl_ret < 0) { + if (errno == ENOTTY) { + Dmsg2(50, "Failed to check for NODUMP flag for file: %s errno: %d, " + "probably because of wrong filesystem used.\n", + ff_pkt->fname, errno); + } else { + Dmsg2(50, "Failed to send Getflags IOCTL for: %s err: %d\n", + ff_pkt->fname, errno); + } + goto bail_out; + } + + /* Check if file has NODUMP flag set */ + ret = attr & FS_NODUMP_FL; } - - int ioctl_ret = ioctl(fd, FS_IOC_GETFLAGS, &attr); - if (ioctl_ret < 0) { - if (errno == ENOTTY) { - Dmsg2(50, "Failed to check for NODUMP flag for file: %s errno: %d, " - "probably because of wrong filesystem used.\n", - ff_pkt->fname, errno); - } else { - Dmsg2(50, "Failed to send Getflags IOCTL for: %s err: %d\n", - ff_pkt->fname, errno); - } - goto bail_out; - } - - /* Check if file has NODUMP flag set */ - ret = attr & FS_NODUMP_FL; } bail_out: