4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
22 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
23 /* All Rights Reserved */
26 #ident "%Z%%M% %I% %E% SMI" /* from SVR4 bnu:systat.c 2.7 */
30 #define STATNAME(f, n) ((void)sprintf(f, "%s/%s", STATDIR, n))
34 * make system status entry
36 * text -> text string to read
42 systat(name
, type
, text
, retry
)
49 char filename
[MAXFULLNAME
], line
[S_SIZE
];
55 (void) time(&prestime
);
57 STATNAME(filename
, name
);
59 fp
= fopen(filename
, "r");
61 if (fgets(line
, S_SIZE
, fp
) != NULL
)
62 if (getargs(line
, vec
, 4) == 4) {
64 presretry
= atol(vec
[3]);
72 /* if there is already a status file - don't change */
74 case SS_LOCKED_DEVICE
:
75 case SS_CANT_ACCESS_DEVICE
:
80 /* reset count on successful call */
83 case SS_CONVERSATION
: /* failure during conversation - contact ok */
88 /* Startup failure means protocol mismatch--some administrative
89 * action must be taken
95 default: /* increment count and set up retry time */
97 if (!retry
) { /* use exponential backoff */
98 if (presretry
< RETRYTIME
)
101 retry
= presretry
+ presretry
;
102 if (retry
> MAXRETRYTIME
)
103 retry
= MAXRETRYTIME
;
106 else { /* use specified time */
107 if (retry
< RETRYTIME
)
113 fp
= fopen(filename
, "w");
114 /* can't ASSERT since assert() calls systat() */
116 errent(Ct_OPEN
, filename
, errno
, __FILE__
, __LINE__
);
119 (void) chmod(filename
, PUB_FILEMODE
);
120 (void) fprintf(fp
, "%d %d %ld %ld %s %s\n",
121 type
, count
, prestime
, retry
, text
, name
);
127 * check system status for call
128 * name -> system to check
131 * >0 -> system status
141 char filename
[MAXFULLNAME
], line
[S_SIZE
];
142 time_t lasttime
, prestime
;
144 STATNAME(filename
, name
);
145 fp
= fopen(filename
, "r");
149 if (fgets(line
, S_SIZE
, fp
) == NULL
) {
153 (void) unlink(filename
);
158 (void) time(&prestime
);
159 sscanf(line
, "%d%d%ld%ld", &type
, &count
, &lasttime
, &retrytime
);
164 case SS_LOGIN_FAILED
:
168 case SS_CANT_ACCESS_DEVICE
:
173 case SS_UNKNOWN_RESPONSE
:
175 case SS_CALLBACK_LOOP
:
177 if (prestime
- lasttime
< retrytime
) {
178 logent("RETRY TIME NOT REACHED", "NO CALL");
179 CDEBUG(4, "RETRY TIME (%ld) NOT REACHED\n", retrytime
);