* $Id: fsi_util.c,v 5.2.1.2 90/12/21 16:41:57 jsp Alpha $
* Copyright (c) 1989 Jan-Simon Pendry
* Copyright (c) 1989 Imperial College of Science, Technology & Medicine
* Copyright (c) 1989 The Regents of the University of California.
* Redistribution and use in source and binary forms are permitted provided
* that: (1) source distributions retain this entire copyright notice and
* comment, and (2) distributions including binaries display the following
* acknowledgement: ``This product includes software developed by the
* University of California, Berkeley and its contributors'' in the
* documentation or other materials provided with the distribution and in
* all advertising materials mentioning features or use of this software.
* Neither the name of the University nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
* @(#)fsi_util.c 5.1 (Berkeley) %G%
#include "../fsinfo/fsinfo.h"
* Lots of ways of reporting errors...
void error(s
, s1
, s2
, s3
, s4
)
char *s
, *s1
, *s2
, *s3
, *s4
;
fprintf(stderr
, "%s: Error, ", progname
);
fprintf(stderr
, s
, s1
, s2
, s3
, s4
);
void lerror(l
, s
, s1
, s2
, s3
, s4
)
char *s
, *s1
, *s2
, *s3
, *s4
;
fprintf(stderr
, "%s:%d: ", l
->i_file
, l
->i_line
);
fprintf(stderr
, s
, s1
, s2
, s3
, s4
);
void lwarning(l
, s
, s1
, s2
, s3
, s4
)
char *s
, *s1
, *s2
, *s3
, *s4
;
fprintf(stderr
, "%s:%d: ", l
->i_file
, l
->i_line
);
fprintf(stderr
, s
, s1
, s2
, s3
, s4
);
void fatal(s
, s1
, s2
, s3
, s4
)
char *s
, *s1
, *s2
, *s3
, *s4
;
fprintf(stderr
, "%s: Fatal, ", progname
);
fprintf(stderr
, s
, s1
, s2
, s3
, s4
);
char *sp
= (char *) xmalloc(len
+1);
void log(s
, s1
, s2
, s3
, s4
)
char *s
, *s1
, *s2
, *s3
, *s4
;
fprintf(stdout
, "%s: ", progname
);
fprintf(stdout
, s
, s1
, s2
, s3
, s4
);
fprintf(ef
, "# *** NOTE: This file contains %s info\n", info
);
fprintf(ef
, "# *** NOTE: Only for use on %s\n", hn
);
static void make_banner(fp
)
time_t t
= time((time_t*) 0);
char *ctime(), *cp
= ctime(&t
);
# *** This file was automatically generated -- DO NOT EDIT HERE ***\n\
# \"%s\" run by %s@%s on %s\
progname
, username
, hostname
, cp
);
static int show_range
= 10;
static int total_shown
= 0;
static int total_mmm
= 8;
static int col_output(len
)
if (total_mmm
!= -show_range
+1) {
sprintf(n
, "%d", total_shown
);
fputs(n
, stdout
); fflush(stdout
);
if (total_mmm
> show_range
) {
} else if (total_mmm
== 0) {
fputc('*', stdout
); fflush(stdout
);
void show_area_being_processed(area
, n
)
static char *last_area
= 0;
if (!last_area
|| strcmp(area
, last_area
) != 0) {
total_mmm
= show_range
+1;
(void) col_output(strlen(area
)+2);
fprintf(stdout
, "[%s", area
);
* Open a file with the given prefix and name
FILE *pref_open(pref
, hn
, hdr
, arg
)
sprintf(p
, "%s%s", pref
, hn
);
log("Writing %s info for %s to %s", pref
, hn
, p
);
error("can't open %s for writing", p
);
* Determine where Amd would automount the host/volname pair
void compute_automount_point(buf
, hp
, vn
)
sprintf(buf
, "%s/%s%s", autodir
, hp
->h_hostpath
, vn
);
sprintf(buf
, "%s/%s%s", autodir
, hp
->h_lochost
, vn
);
char *p
= (char *) calloc(i
, (unsigned) s
);
char *p
= (char *) malloc(i
);
automount
*new_automount(name
)
automount
*ap
= ALLOC(automount
);
ap
->a_ioloc
= current_location();
auto_tree
*new_auto_tree(def
, ap
)
auto_tree
*tp
= ALLOC(auto_tree
);
tp
->t_ioloc
= current_location();
hp
->h_ioloc
= current_location();
yyerror("host field \"%s\" already set", host_strings
[k
]);
dict_ent
*de
= dict_locate(dict_of_hosts
, v
);
yyerror("duplicate host %s!", v
);
dict_add(dict_of_hosts
, v
, (char *) hp
);
domain_strip(p
, hostname
);
q
= hp
->h_config
= new_que();
q
= hp
->h_ether
= new_que();
case HF_ARCH
: hp
->h_arch
= v
; break;
case HF_OS
: hp
->h_os
= v
; break;
case HF_CLUSTER
: hp
->h_cluster
= v
; break;
ether_if
*ep
= ALLOC(ether_if
);
ep
->e_ioloc
= current_location();
void set_ether_if(ep
,k
, v
)
yyerror("netif field \"%s\" already set", ether_if_strings
[k
]);
extern u_long
inet_addr();
ep
->e_inaddr
.s_addr
= inet_addr(v
);
if (ep
->e_inaddr
.s_addr
== (u_long
) -1)
yyerror("malformed IP dotted quad: %s", v
);
if ((sscanf(v
, "0x%lx", &nm
) == 1 || sscanf(v
, "%lx", &nm
) == 1) && nm
!= 0)
ep
->e_netmask
= htonl(nm
);
yyerror("malformed netmask: %s", v
);
void set_disk_fs(dp
, k
, v
)
yyerror("fs field \"%s\" already set", disk_fs_strings
[k
]);
case DF_FSTYPE
: dp
->d_fstype
= v
; break;
case DF_OPTS
: dp
->d_opts
= v
; break;
case DF_DUMPSET
: dp
->d_dumpset
= v
; break;
case DF_LOG
: dp
->d_log
= v
; break;
case DF_PASSNO
: dp
->d_passno
= atoi(v
); free(v
); break;
case DF_FREQ
: dp
->d_freq
= atoi(v
); free(v
); break;
case DF_MOUNT
: dp
->d_mount
= &((mount
*) v
)->m_q
; break;
disk_fs
*dp
= ALLOC(disk_fs
);
dp
->d_ioloc
= current_location();
yyerror("mount tree field \"%s\" already set", mount_strings
[k
]);
dict_add(dict_of_volnames
, v
, (char *) mp
);
mount
*fp
= ALLOC(mount
);
fp
->m_ioloc
= current_location();
void set_fsmount(fp
, k
, v
)
yyerror("mount field \"%s\" already set", fsmount_strings
[k
]);
case FM_LOCALNAME
: fp
->f_localname
= v
; break;
case FM_VOLNAME
: fp
->f_volname
= v
; break;
case FM_FSTYPE
: fp
->f_fstype
= v
; break;
case FM_OPTS
: fp
->f_opts
= v
; break;
case FM_FROM
: fp
->f_from
= v
; break;
fsmount
*fp
= ALLOC(fsmount
);
fp
->f_ioloc
= current_location();
q
->q_forw
= q
->q_back
= q
;