summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorfenner <fenner@FreeBSD.org>2003-01-27 18:16:32 +0000
committerfenner <fenner@FreeBSD.org>2003-01-27 18:16:32 +0000
commitfd28d315c2756ca8360fdcadf6e7dad28022fffd (patch)
tree5781132d52c7bb17b50f3a39e59b3ea07cfc931d /usr.bin
parent54307fc302e0a65fb0a919d0202a3031d4e4d83d (diff)
downloadFreeBSD-src-fd28d315c2756ca8360fdcadf6e7dad28022fffd.zip
FreeBSD-src-fd28d315c2756ca8360fdcadf6e7dad28022fffd.tar.gz
Don't try to fseek before the beginning of the file; POSIX requires that
this return an error. This re-enables display of the first entry in /var/account/acct instead of the error "lastcomm: /var/account/acct: Invalid argument"
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/lastcomm/lastcomm.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/usr.bin/lastcomm/lastcomm.c b/usr.bin/lastcomm/lastcomm.c
index dc47eb1..ab67a2c 100644
--- a/usr.bin/lastcomm/lastcomm.c
+++ b/usr.bin/lastcomm/lastcomm.c
@@ -60,6 +60,8 @@ __FBSDID("$FreeBSD$");
#include <utmp.h>
#include "pathnames.h"
+/*XXX*/#include <inttypes.h>
+
time_t expand(u_int);
char *flagbits(int);
const char *getdev(dev_t);
@@ -156,13 +158,6 @@ main(int argc, char *argv[])
if (fread(&ab, sizeof(struct acct), 1, fp) != 1)
err(1, "%s", acctfile);
- if (fseek(fp, 2 * -(long)sizeof(struct acct), SEEK_CUR) == -1)
- err(1, "%s", acctfile);
-
- if (size == 0)
- break;
- size -= sizeof(struct acct);
-
if (ab.ac_comm[0] == '\0') {
ab.ac_comm[0] = '?';
ab.ac_comm[1] = '\0';
@@ -215,6 +210,12 @@ main(int argc, char *argv[])
(void)printf(" %.16s", ctime(&t));
}
printf("\n");
+
+ if (size == 0)
+ break;
+ size -= sizeof(struct acct);
+ if (fseek(fp, 2 * -(long)sizeof(struct acct), SEEK_CUR) == -1)
+ err(1, "%s", acctfile);
}
exit(0);
}
OpenPOWER on IntegriCloud