wr_dumpset.c revision 38494
138494Sobrien/*
238494Sobrien * Copyright (c) 1997-1998 Erez Zadok
338494Sobrien * Copyright (c) 1989 Jan-Simon Pendry
438494Sobrien * Copyright (c) 1989 Imperial College of Science, Technology & Medicine
538494Sobrien * Copyright (c) 1989 The Regents of the University of California.
638494Sobrien * All rights reserved.
738494Sobrien *
838494Sobrien * This code is derived from software contributed to Berkeley by
938494Sobrien * Jan-Simon Pendry at Imperial College, London.
1038494Sobrien *
1138494Sobrien * Redistribution and use in source and binary forms, with or without
1238494Sobrien * modification, are permitted provided that the following conditions
1338494Sobrien * are met:
1438494Sobrien * 1. Redistributions of source code must retain the above copyright
1538494Sobrien *    notice, this list of conditions and the following disclaimer.
1638494Sobrien * 2. Redistributions in binary form must reproduce the above copyright
1738494Sobrien *    notice, this list of conditions and the following disclaimer in the
1838494Sobrien *    documentation and/or other materials provided with the distribution.
1938494Sobrien * 3. All advertising materials mentioning features or use of this software
2038494Sobrien *    must display the following acknowledgement:
2138494Sobrien *      This product includes software developed by the University of
2238494Sobrien *      California, Berkeley and its contributors.
2338494Sobrien * 4. Neither the name of the University nor the names of its contributors
2438494Sobrien *    may be used to endorse or promote products derived from this software
2538494Sobrien *    without specific prior written permission.
2638494Sobrien *
2738494Sobrien * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2838494Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2938494Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3038494Sobrien * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
3138494Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3238494Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3338494Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3438494Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3538494Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3638494Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3738494Sobrien * SUCH DAMAGE.
3838494Sobrien *
3938494Sobrien *      %W% (Berkeley) %G%
4038494Sobrien *
4138494Sobrien * $Id: wr_dumpset.c,v 5.2.2.1 1992/02/09 15:09:47 jsp beta $
4238494Sobrien *
4338494Sobrien */
4438494Sobrien
4538494Sobrien#ifdef HAVE_CONFIG_H
4638494Sobrien# include <config.h>
4738494Sobrien#endif /* HAVE_CONFIG_H */
4838494Sobrien#include <am_defs.h>
4938494Sobrien#include <fsi_data.h>
5038494Sobrien#include <fsinfo.h>
5138494Sobrien
5238494Sobrien
5338494Sobrienstatic int
5438494Sobrienwrite_dumpset_info(FILE *ef, qelem *q)
5538494Sobrien{
5638494Sobrien  int errors = 0;
5738494Sobrien  disk_fs *dp;
5838494Sobrien
5938494Sobrien  ITER(dp, disk_fs, q) {
6038494Sobrien    if (dp->d_dumpset) {
6138494Sobrien      fprintf(ef, "%s\t%s:%-30s\t# %s\n",
6238494Sobrien	      dp->d_dumpset,
6338494Sobrien	      dp->d_host->h_lochost ?
6438494Sobrien	      dp->d_host->h_lochost :
6538494Sobrien	      dp->d_host->h_hostname,
6638494Sobrien	      dp->d_mountpt,
6738494Sobrien	      dp->d_dev);
6838494Sobrien    }
6938494Sobrien  }
7038494Sobrien  return errors;
7138494Sobrien}
7238494Sobrien
7338494Sobrien
7438494Sobrienint
7538494Sobrienwrite_dumpset(qelem *q)
7638494Sobrien{
7738494Sobrien  int errors = 0;
7838494Sobrien
7938494Sobrien  if (dumpset_pref) {
8038494Sobrien    FILE *ef = pref_open(dumpset_pref, "dumpsets", info_hdr, "exabyte dumpset");
8138494Sobrien    if (ef) {
8238494Sobrien      host *hp;
8338494Sobrien
8438494Sobrien      ITER(hp, host, q) {
8538494Sobrien	if (hp->h_disk_fs) {
8638494Sobrien	  errors += write_dumpset_info(ef, hp->h_disk_fs);
8738494Sobrien	}
8838494Sobrien      }
8938494Sobrien      errors += pref_close(ef);
9038494Sobrien    } else {
9138494Sobrien      errors++;
9238494Sobrien    }
9338494Sobrien  }
9438494Sobrien
9538494Sobrien  return errors;
9638494Sobrien}
97