From: Kern Sibbald Date: Wed, 20 Dec 2006 13:59:50 +0000 (+0000) Subject: kes Fix a couple of compiler warnings in wx-console X-Git-Tag: Release-7.0.0~7211 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=fe01c749d1326c3c17ca553cf6df822562c59a85;p=bacula%2Fbacula kes Fix a couple of compiler warnings in wx-console kes Apply the immutable patch for FreeBSD hardlinked files supplied by Olivier Lehmann. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3822 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/ChangeLog b/bacula/ChangeLog index 9ee1341f9a..fcc4b88c51 100644 --- a/bacula/ChangeLog +++ b/bacula/ChangeLog @@ -4,6 +4,9 @@ General: Version 1.39.32 released: 20Dec06 +kes Fix a couple of compiler warnings in wx-console +kes Apply the immutable patch for FreeBSD hardlinked files supplied + by Olivier Lehmann. kes Add Volume name to Forward spacing message. kes Update migration job start time (so it is not zero) to prevent immediate recycling of the job. This *should* fix bug #733. diff --git a/bacula/src/findlib/create_file.c b/bacula/src/findlib/create_file.c index 8b20ff4559..3d08fdcc84 100644 --- a/bacula/src/findlib/create_file.c +++ b/bacula/src/findlib/create_file.c @@ -289,9 +289,46 @@ int create_file(JCR *jcr, ATTR *attr, BFILE *bfd, int replace) Dmsg2(130, "Hard link %s => %s\n", attr->ofname, attr->olname); if (link(attr->olname, attr->ofname) != 0) { berrno be; +#ifdef HAVE_CHFLAGS + struct stat s; + + /* + * If using BSD user flags, maybe has a file flag + * preventing this. So attempt to disable, retry link, + * and reset flags. + * Note that BSD securelevel may prevent disabling flag. + */ + + if (stat(attr->olname, &s) == 0 && s.st_flags != 0) { + if (chflags(attr->olname, 0) == 0) { + if (link(attr->olname, attr->ofname) != 0) { + /* restore original file flags even when linking failed */ + if (chflags(attr->olname, s.st_flags) < 0) { + Qmsg2(jcr, M_ERROR, 0, _("Could not restore file flags for file %s: ERR=%s\n"), + attr->olname, be.strerror()); + } +#endif /* HAVE_CHFLAGS */ Qmsg3(jcr, M_ERROR, 0, _("Could not hard link %s -> %s: ERR=%s\n"), attr->ofname, attr->olname, be.strerror()); return CF_ERROR; +#ifdef HAVE_CHFLAGS + } + /* finally restore original file flags */ + if (chflags(attr->olname, s.st_flags) < 0) { + Qmsg2(jcr, M_ERROR, 0, _("Could not restore file flags for file %s: ERR=%s\n"), + attr->olname, be.strerror()); + } + } else { + Qmsg2(jcr, M_ERROR, 0, _("Could not reset file flags for file %s: ERR=%s\n"), + attr->olname, be.strerror()); + } + } else { + Qmsg3(jcr, M_ERROR, 0, _("Could not hard link %s -> %s: ERR=%s\n"), + attr->ofname, attr->olname, be.strerror()); + return CF_ERROR; + } +#endif /* HAVE_CHFLAGS */ + } return CF_CREATED; #endif diff --git a/bacula/technotes-1.39 b/bacula/technotes-1.39 index 7feb40bfe8..0c5bc046ee 100644 --- a/bacula/technotes-1.39 +++ b/bacula/technotes-1.39 @@ -3,6 +3,9 @@ General: Version 1.39.32 released: 20Dec06 +kes Fix a couple of compiler warnings in wx-console +kes Apply the immutable patch for FreeBSD hardlinked files supplied + by Olivier Lehmann. kes Add Volume name to Forward spacing message. kes Update migration job start time (so it is not zero) to prevent immediate recycling of the job. This *should* fix bug #733.