Hi Kern,
it is ok when you want me to deliver the patch in a defined format. I've no
problems with that. I must say that I didn't read the developer manual
before I sent the patch, but I hope the patch does now comply to the rules.
I've changed the indention from my former patch so you can see that
everything which changed/was added was done inside the ifdef preprocessor
directives.
This is a first step. The problems with the attribues can be "fixed" later.
With this patch at least the links are getting created which is better than
before.
Greetings, Oliver
Index: src/findlib/create_file.c
===================================================================
RCS file: /cvsroot/bacula/bacula/src/findlib/create_file.c,v
retrieving revision 1.56
diff -u -r1.56 create_file.c
--- src/findlib/create_file.c 21 Nov 2006 20:14:46 -0000 1.56
+++ src/findlib/create_file.c 13 Dec 2006 10:53:22 -0000
@@ -289,9 +289,46 @@
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
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users