X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=chiark-utils.git;a=blobdiff_plain;f=backup%2Fbackuplib.pl;h=26a8533d1150e85ee3e2fa7079f742ddf2df5647;hp=9acd7a0147c4072209d5181a75fb045350a9f31e;hb=460e29f1c9232dafbdc161bf67d3e956d23eeb6b;hpb=8e5f50513299d7d7f15d958579dc0b0751923ed1 diff --git a/backup/backuplib.pl b/backup/backuplib.pl index 9acd7a0..26a8533 100644 --- a/backup/backuplib.pl +++ b/backup/backuplib.pl @@ -1,6 +1,25 @@ +# backuplib.pl +# core common routines # - -# Assorted useful functions used by the backup scripts. +# This file is part of chiark backup, a system for backing up GNU/Linux and +# other UN*X-compatible machines, as used on chiark.greenend.org.uk. +# +# chiark backup is: +# Copyright (C) 1997-1998,2000-2001 Ian Jackson +# Copyright (C) 1999 Peter Maydell +# +# This is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2, or (at your option) any later version. +# +# This is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. sub printdate () { print scalar(localtime),"\n"; @@ -54,11 +73,14 @@ sub killprocesses { # Trailing whitespace is ignored. Lines of the form 'prefix foo bar' # are handled specially, as arex lines 'exclude regexp'; otherwise # we just shove the line into @fsys and let parsefsys deal with it. -sub readfsys ($) { - my ($fsnm) = @_; - open F, "$etc/fsys.$fsnm" or die "Filesystems $fsnm unknown ($!).\n"; + +sub readfsysfile ($) { + my ($fn) = @_; + my ($fh,$sfn); + $fh= new IO::File "$fn", "r" or die "cannot open fsys file $fn ($!).\n"; for (;;) { - $_= or die "unexpected EOF in $etc/fsys.$fsnm\n"; chomp; s/\s*$//; + $!=0; $_= <$fh> or die "unexpected EOF in $fn ($!)\n"; + chomp; s/\s*$//; last if m/^end$/; next unless m/\S/; next if m/^\#/; @@ -70,11 +92,23 @@ sub readfsys ($) { push @excldir,$1; } elsif (m/^exclude\s+(\S.*\S)$/) { push @excl,$1; + } elsif (m/^include\s+(\S.*\S)$/) { + $sfn =~ s/^\./fsys./; + $sfn = "$etc/$sfn" if $sfn !~ m,^/,; + readfsysfile($sfn); } else { push @fsys,$_; } } - close F or die $!; + close $fn or die $!; +} + +sub readfsys ($) { + my ($fsnm) = @_; + my ($fsf); + $fsf= "$etc/fsys.$fsnm"; + stat $fsf or die "Filesystems $fsnm unknown ($!).\n"; + readfsysfile($fsf); } # Parse a line from a filesystem definition file. We expect the line