Xref: utzoo news.admin:7728 news.software.b:3619 Path: utzoo!utstat!jarvis.csri.toronto.edu!mailrus!shadooby!samsung!cs.utexas.edu!uwm.edu!wuarchive!texbell!attctc! From: kcantrel@digi.UUCP (Keith Cantrell) Newsgroups: news.admin,news.software.b Subject: Changes to Bnews to allow multiple disk. Message-ID: <267@digi.UUCP> Date: 22 Nov 89 13:55:55 GMT Reply-To: kcantrel@digi.UUCP (Keith Cantrell) Followup-To: news.admin Organization: DSC Communications, Plano Tx. Lines: 153 ath: digi!kcantrel If anybody is interested in the changes that I made to allow Bnews-2.11 Patch level 17 to support multiple spool devices read on, otherwise type 'n' now. At first I thought it would be easy to just replace the 'link(source dist)' call with a 'system("cp source dist")' but as it turns out, when the link is made the article has not been fully created yet. So I had to do some digging and found that bnews by default keeps a list of all the links that it creates so that it can delete them if something goes wrong. Well all I did was add some code, after the article had been fully created, that used the list to create my 'system("cp source dist")' commands. Following is a patch file with the changes that I had to make: *** src/inews.c.org Thu Jul 13 19:23:18 1989 --- src/inews.c Thu Nov 16 09:18:32 1989 *************** *** 809,814 **** --- 815,823 ---- static char *artlinks[32]; static int linkcount; + #ifdef COPY_ON_EXDEV_ERROR + static int copy_file[32]; + #endif /* * Link ARTICLE into dir for ngname and update active file. */ *************** *** 825,830 **** --- 834,842 ---- lock(); (void) rewind(actfp); clearerr(actfp); + #ifdef COPY_ON_EXDEV_ERROR + copy_file[linkcount] = FALSE; + #endif for(;;) { fpos = ftell(actfp); if (fgets(afline, sizeof afline, actfp) == NULL) { *************** *** 863,868 **** --- 875,892 ---- #else /* !VMS */ if (link(ARTICLE, bfr) == 0) break; + #ifdef COPY_ON_EXDEV_ERROR + /* + * If the link failed, check to see if it was because it + * tried to link across devices. If it does, try to just copy + * it. + */ + if(errno == EXDEV) + { + copy_file[linkcount] = TRUE; + break; + } + #endif /* COPY_ON_EXDEV_ERROR */ #endif /* !VMS */ if (!exists(cp)) mknewsg(cp, ngname); *************** *** 875,880 **** --- 899,916 ---- #else /* !VMS */ if (link(ARTICLE, bfr) == 0) break; + #ifdef COPY_ON_EXDEV_ERROR + /* + * If the link failed, check to see if it was because it + * tried to link across devices. If it does try to just copy + * it. + */ + if(errno == EXDEV) + { + copy_file[linkcount] = TRUE; + break; + } + #endif /* COPY_ON_EXDEV_ERROR */ #endif /* !VMS */ e = errno; /* keep log from clobbering it */ log("Cannot install article as %s: %s", bfr, errmsg(errno)); *************** *** 1176,1182 **** --- 1212,1229 ---- else { for (c = 0; c < linkcount; c++) + { + #ifdef COPY_ON_EXDEV_ERROR + if(copy_file[c]) + { + char tmp[1024]; + sprintf(tmp, "/bin/cp %s %s", ARTICLE, artlinks[c]); + if(system(tmp) != 0) + logerr("Failed to copy temp article to spool area."); + } + #endif free(artlinks[c]); + } } (void) fclose(tfp); (void) fclose(infp); *** src/Makefile.dst.org Tue Sep 26 11:56:42 1989 --- src/Makefile.dst Wed Nov 15 11:55:47 1989 *************** *** 47,52 **** --- 47,53 ---- #NNTP INST = nntp #NFSCLIENT NFSCLIENT= -DNFSCLIENT + #COPY_ON_EXDEV_ERROR COPY_ON_EXDEV_ERROR= -DCOPY_ON_EXDEV_ERROR NFSSPOOLDIR = /nfsnews/$(SPOOLDIR) NFSLIBDIR = /nfsnews/$(LIBDIR) *************** *** 54,60 **** -DSPOOLDIR=\"$(DESTDIR)$(SPOOLDIR)\" \ -DBATCHDIR=\"$(DESTDIR)$(BATCHDIR)\" -DLIBDIR=\"$(DESTDIR)$(LIBDIR)\" \ -DBINDIR=\"$(DESTDIR)$(BINDIR)\" -DNEWSUSR=\"$(NEWSUSR)\" \ ! -DNEWSGRP=\"$(NEWSGRP)\" ${SERVER} ${NFSCLIENT} # Order is important here INSCOMPRESS= --- 55,61 ---- -DSPOOLDIR=\"$(DESTDIR)$(SPOOLDIR)\" \ -DBATCHDIR=\"$(DESTDIR)$(BATCHDIR)\" -DLIBDIR=\"$(DESTDIR)$(LIBDIR)\" \ -DBINDIR=\"$(DESTDIR)$(BINDIR)\" -DNEWSUSR=\"$(NEWSUSR)\" \ ! -DNEWSGRP=\"$(NEWSGRP)\" ${SERVER} ${NFSCLIENT} ${COPY_ON_EXDEV_ERROR} # Order is important here INSCOMPRESS= *** doc/install.mn.org Mon Oct 27 17:35:36 1986 --- doc/install.mn Wed Nov 15 12:14:45 1989 *************** *** 1024,1029 **** --- 1024,1040 ---- .pg If this is defined, sccs ids will be included in each file. If you are short on address space, don't define this. + .hn 3 + COPY_ON_EXDEV_ERROR + .pg + When an article is being created, it is first created in a temporary place + and then hard linked to all the appropriate places in the SPOOL area. + If you have your spool area spilt up over several devices, the hard link + will fail and an error will occur. If COPY_ON_EXDEV_ERROR is defined and + the hard link fails, an attempt will be made to copy, instead of hard linking, + the temporary article. The draw back of coping the file, is that if someone + cross posts to several groups, then there will actually be several copies of + the article instead of one copy and several links. .hn FILES .pg ******** End of patch file ***** ----------------------------------------------------------------------- Keith Cantrell Phones: hm: 214-492-1088 Apollo Computer wk: 214-519-2399 @ DSC A Subsidiary of Hewlett-Packard USMAIL: EMAIL: 2100 Sonata Ln cantrell@attctc.DALLAS.TX.US Carrollton TX 75007 or ...!attctc!digi!kcantrel -----------------------------------------------------------------------