Deleted Added
full compact
usrdb.c (90878) usrdb.c (100107)
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

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

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 const char rcsid[] =
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

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

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 const char rcsid[] =
33 "$FreeBSD: head/usr.sbin/sa/usrdb.c 90878 2002-02-19 00:05:59Z imp $";
33 "$FreeBSD: head/usr.sbin/sa/usrdb.c 100107 2002-07-15 16:05:15Z des $";
34#endif /* not lint */
35
36#include <sys/param.h>
37#include <sys/types.h>
38#include <sys/acct.h>
39#include <err.h>
40#include <errno.h>
41#include <fcntl.h>
42#include <pwd.h>
34#endif /* not lint */
35
36#include <sys/param.h>
37#include <sys/types.h>
38#include <sys/acct.h>
39#include <err.h>
40#include <errno.h>
41#include <fcntl.h>
42#include <pwd.h>
43#include <stdint.h>
43#include <stdio.h>
44#include <stdlib.h>
45#include <string.h>
46#include "extern.h"
47#include "pathnames.h"
48
49static int uid_compare __P((const DBT *, const DBT *));
50

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

233
234 rv = DB_SEQ(usracct_db, &key, &data, R_FIRST);
235 if (rv < 0)
236 warn("retrieving user accounting stats");
237
238 while (rv == 0) {
239 memcpy(ui, data.data, sizeof(struct userinfo));
240
44#include <stdio.h>
45#include <stdlib.h>
46#include <string.h>
47#include "extern.h"
48#include "pathnames.h"
49
50static int uid_compare __P((const DBT *, const DBT *));
51

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

234
235 rv = DB_SEQ(usracct_db, &key, &data, R_FIRST);
236 if (rv < 0)
237 warn("retrieving user accounting stats");
238
239 while (rv == 0) {
240 memcpy(ui, data.data, sizeof(struct userinfo));
241
241 printf("%-*s %9qu ", MAXLOGNAME - 1,
242 user_from_uid(ui->ui_uid, 0), ui->ui_calls);
242 printf("%-*s %9ju ", MAXLOGNAME - 1,
243 user_from_uid(ui->ui_uid, 0), (uintmax_t)ui->ui_calls);
243
244 t = (double) (ui->ui_utime + ui->ui_stime) /
245 (double) AHZ;
246 if (t < 0.0001) /* kill divide by zero */
247 t = 0.0001;
248
249 printf("%12.2f%s ", t / 60.0, "cpu");
250
251 /* ui->ui_calls is always != 0 */
252 if (dflag)
244
245 t = (double) (ui->ui_utime + ui->ui_stime) /
246 (double) AHZ;
247 if (t < 0.0001) /* kill divide by zero */
248 t = 0.0001;
249
250 printf("%12.2f%s ", t / 60.0, "cpu");
251
252 /* ui->ui_calls is always != 0 */
253 if (dflag)
253 printf("%12qu%s", ui->ui_io / ui->ui_calls, "avio");
254 printf("%12ju%s",
255 (uintmax_t)(ui->ui_io / ui->ui_calls), "avio");
254 else
256 else
255 printf("%12qu%s", ui->ui_io, "tio");
257 printf("%12ju%s", (uintmax_t)ui->ui_io, "tio");
256
257 /* t is always >= 0.0001; see above */
258 if (kflag)
259 printf("%12.0f%s", ui->ui_mem / t, "k");
260 else
258
259 /* t is always >= 0.0001; see above */
260 if (kflag)
261 printf("%12.0f%s", ui->ui_mem / t, "k");
262 else
261 printf("%12qu%s", ui->ui_mem, "k*sec");
263 printf("%12ju%s", (uintmax_t)ui->ui_mem, "k*sec");
262
263 printf("\n");
264
265 rv = DB_SEQ(usracct_db, &key, &data, R_NEXT);
266 if (rv < 0)
267 warn("retrieving user accounting stats");
268 }
269}

--- 17 unchanged lines hidden ---
264
265 printf("\n");
266
267 rv = DB_SEQ(usracct_db, &key, &data, R_NEXT);
268 if (rv < 0)
269 warn("retrieving user accounting stats");
270 }
271}

--- 17 unchanged lines hidden ---