Deleted Added
full compact
usrdb.c (8857) usrdb.c (13558)
1/*
2 * Copyright (c) 1994 Christopher G. Demetriou
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 15 unchanged lines hidden (view full) ---

24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#ifndef LINT
1/*
2 * Copyright (c) 1994 Christopher G. Demetriou
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 15 unchanged lines hidden (view full) ---

24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#ifndef LINT
32static char rcsid[] = "$Id: usrdb.c,v 1.1.1.1 1994/09/26 21:22:57 davidg Exp $";
32static char rcsid[] = "$Id: usrdb.c,v 1.2 1995/05/30 03:51:42 rgrimes Exp $";
33#endif
34
35#include <sys/types.h>
36#include <sys/acct.h>
37#include <err.h>
38#include <errno.h>
39#include <fcntl.h>
33#endif
34
35#include <sys/types.h>
36#include <sys/acct.h>
37#include <err.h>
38#include <errno.h>
39#include <fcntl.h>
40#include <stdio.h>
41#include <string.h>
40#include "extern.h"
41#include "pathnames.h"
42
43static int uid_compare __P((const DBT *, const DBT *));
44
45static DB *usracct_db;
46
47int

--- 118 unchanged lines hidden (view full) ---

166}
167
168int
169usracct_update()
170{
171 DB *saved_usracct_db;
172 DBT key, data;
173 BTREEINFO bti;
42#include "extern.h"
43#include "pathnames.h"
44
45static int uid_compare __P((const DBT *, const DBT *));
46
47static DB *usracct_db;
48
49int

--- 118 unchanged lines hidden (view full) ---

168}
169
170int
171usracct_update()
172{
173 DB *saved_usracct_db;
174 DBT key, data;
175 BTREEINFO bti;
174 u_long uid;
175 int error, serr, nerr;
176
177 bzero(&bti, sizeof bti);
178 bti.compare = uid_compare;
179
180 saved_usracct_db = dbopen(_PATH_USRACCT, O_RDWR|O_CREAT|O_TRUNC, 0644,
181 DB_BTREE, &bti);
182 if (saved_usracct_db == NULL) {

--- 23 unchanged lines hidden (view full) ---

206 break;
207 }
208 }
209
210 if (DB_SYNC(saved_usracct_db, 0) < 0) {
211 warn("syncing process accounting summary");
212 error = -1;
213 }
176 int error, serr, nerr;
177
178 bzero(&bti, sizeof bti);
179 bti.compare = uid_compare;
180
181 saved_usracct_db = dbopen(_PATH_USRACCT, O_RDWR|O_CREAT|O_TRUNC, 0644,
182 DB_BTREE, &bti);
183 if (saved_usracct_db == NULL) {

--- 23 unchanged lines hidden (view full) ---

207 break;
208 }
209 }
210
211 if (DB_SYNC(saved_usracct_db, 0) < 0) {
212 warn("syncing process accounting summary");
213 error = -1;
214 }
214out:
215 if (DB_CLOSE(saved_usracct_db) < 0) {
216 warn("closing process accounting summary");
217 error = -1;
218 }
219 return error;
220}
221
222void

--- 14 unchanged lines hidden (view full) ---

237 printf("%-8s %9qu ",
238 user_from_uid(ui->ui_uid, 0), ui->ui_calls);
239
240 t = (double) (ui->ui_utime + ui->ui_stime) /
241 (double) AHZ;
242 if (t < 0.0001) /* kill divide by zero */
243 t = 0.0001;
244
215 if (DB_CLOSE(saved_usracct_db) < 0) {
216 warn("closing process accounting summary");
217 error = -1;
218 }
219 return error;
220}
221
222void

--- 14 unchanged lines hidden (view full) ---

237 printf("%-8s %9qu ",
238 user_from_uid(ui->ui_uid, 0), ui->ui_calls);
239
240 t = (double) (ui->ui_utime + ui->ui_stime) /
241 (double) AHZ;
242 if (t < 0.0001) /* kill divide by zero */
243 t = 0.0001;
244
245 printf("%12.2lf%s ", t / 60.0, "cpu");
245 printf("%12.2f%s ", t / 60.0, "cpu");
246
247 /* ui->ui_calls is always != 0 */
248 if (dflag)
249 printf("%12qu%s", ui->ui_io / ui->ui_calls, "avio");
250 else
251 printf("%12qu%s", ui->ui_io, "tio");
252
253 /* t is always >= 0.0001; see above */

--- 29 unchanged lines hidden ---
246
247 /* ui->ui_calls is always != 0 */
248 if (dflag)
249 printf("%12qu%s", ui->ui_io / ui->ui_calls, "avio");
250 else
251 printf("%12qu%s", ui->ui_io, "tio");
252
253 /* t is always >= 0.0001; see above */

--- 29 unchanged lines hidden ---