The patch I sent was not correct because ofname and olname where mixed up when doing the flags work. I fixed this now, and I tried restoring my /usr/bin. It now created the hardlinks, but gave me errors that the owner and times of the hardlinks are not setable (because of the same thing)
How relevant is setting those two things anyway? Is it possible that a hard- link has other time stats or belongs other owner/groups as it's sourcefile? If those two atributs has to be considered for hardlinks too, a similar patch has to be applied to atrribs.c I'd say. W/o looking into it I'm not sure if there is olname defined? I'll continue testing tomorrow.... *yawn* --- src/findlib/create_file.c.orig Tue May 2 16:48:16 2006 +++ src/findlib/create_file.c Tue Dec 12 23:58:55 2006 @@ -304,9 +304,46 @@ Dmsg2(130, "Hard link %s => %s\n", attr->ofname, attr->olname); if (link(attr->olname, attr->ofname) != 0) { berrno be; - Jmsg3(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 + 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) { + Jmsg2(jcr, M_ERROR, 0, _("Could not restore file flags for file %s: ERR=%s\n"), + attr->olname, be.strerror()); + } +#endif /* HAVE_CHFLAGS */ + Jmsg3(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) { + Jmsg2(jcr, M_ERROR, 0, _("Could not restore file flags for file %s: ERR=%s\n"), + attr->olname, be.strerror()); + } + } else { + Jmsg2(jcr, M_ERROR, 0, _("Could not reset file flags for file %s: ERR=%s\n"), + attr->olname, be.strerror()); + } + } else { + Jmsg3(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 -- Oliver Lehmann http://www.pofo.de/ http://wishlist.ans-netz.de/ ------------------------------------------------------------------------- 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