Clean up makefiles and a manpage.

OK'ed by:	phk
This commit is contained in:
Ruslan Ermilov 2008-04-10 14:02:00 +00:00
parent 9f82379c24
commit a1e0a00fd2
7 changed files with 106 additions and 115 deletions

View File

@ -1,10 +1,5 @@
# $FreeBSD$ # $FreeBSD$
VERSION_MAJOR = 1 SUBDIR= lib fifolog_create fifolog_writer fifolog_reader
VERSION_MINOR = 1
SUBDIR = lib fifolog_create fifolog_writer fifolog_reader
.include <bsd.subdir.mk> .include <bsd.subdir.mk>
test: _SUBDIR

View File

@ -1,13 +1,10 @@
# $FreeBSD$ # $FreeBSD$
LIBFIFOLOG = ${.OBJDIR}/../lib/libfifolog.a LIBFIFOLOG= ${.OBJDIR}/../lib/libfifolog.a
WARNS?= 6
WARNS ?= 6 #LINT= flint
#LINTFLAGS= ${.CURDIR}/../flint.lnt -I/usr/include
# CFLAGS += -O0 -g
# LINT = flint
# LINTFLAGS = ${.CURDIR}/../flint.lnt -I/usr/include
.include "../Makefile.inc" .include "../Makefile.inc"

View File

@ -1,22 +1,22 @@
# $FreeBSD$ # $FreeBSD$
PROG = fifolog_create PROG= fifolog_create
CFLAGS += -I${.CURDIR}/../lib CFLAGS+= -I${.CURDIR}/../lib
DPADD = ${LIBFIFOLOG} ${LIBUTIL} DPADD= ${LIBFIFOLOG} ${LIBUTIL}
LDADD = ${LIBFIFOLOG} -lutil LDADD= ${LIBFIFOLOG} -lutil
MAN = fifolog.1 MAN= fifolog.1
MLINKS += fifolog.1 fifolog_create.1 MLINKS= fifolog.1 fifolog_create.1 \
MLINKS += fifolog.1 fifolog_reader.1 fifolog.1 fifolog_reader.1 \
MLINKS += fifolog.1 fifolog_writer.1 fifolog.1 fifolog_writer.1
.include <bsd.prog.mk> regress:
test: ${PROG}
rm -f /tmp/fifolog.? rm -f /tmp/fifolog.?
./${PROG} /tmp/fifolog.0 ./${PROG} /tmp/fifolog.0
./${PROG} -s 10m /tmp/fifolog.1 ./${PROG} -s 10m /tmp/fifolog.1
./${PROG} -l 1k /tmp/fifolog.2 ./${PROG} -l 1k /tmp/fifolog.2
./${PROG} -r 1k /tmp/fifolog.3 ./${PROG} -r 1k /tmp/fifolog.3
.include <bsd.prog.mk>

View File

@ -24,18 +24,12 @@
.\" .\"
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd Feb 9, 2008 .Dd February 9, 2008
.Os FreeBSD 8.0 .Os
.Dt FIFOLOG 1 .Dt FIFOLOG 1
.Sh NAME .Sh NAME
.Nm fifolog_create .Nm fifolog_create , fifolog_write , fifolog_read
.Nd Initialize storage for fifolog .Nd "initialize, write, seek and extract data from a fifolog"
.br
.Nm fifolog_write
.Nd Write data to fifolog
.br
.Nm fifolog_read
.Nd Seek and extract data from fifolog
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm fifolog_create .Nm fifolog_create
.Op Fl l Ar record-size .Op Fl l Ar record-size
@ -70,34 +64,39 @@ timestamps before it is written to storage, such that it is possible
to seek out a particular time interval in the stored data, without to seek out a particular time interval in the stored data, without
having to decompress the entire logfile. having to decompress the entire logfile.
.Pp .Pp
.Nm Fifolog_create The
.Nm fifolog_create
utility
is used to initialize the first sector of a disk device is used to initialize the first sector of a disk device
or filesystem file to make it a fifolog and should be called only or file system file to make it a fifolog and should be called only
once. once.
.Pp .Pp
Running Running
.Nm .Nm fifolog_create
on an existing fifolog will reset it so that on an existing fifolog will reset it so that
.Nm fifolog_reader .Nm fifolog_reader
and and
.Nm fifolog_writer .Nm fifolog_writer
will not see the previous contents. will not see the previous contents.
(The previos contents is not physically erased, and with a bit (The previous contents are not physically erased, and with a bit
of hand-work, all but the first record can be easily recovered). of hand-work all but the first record can be easily recovered.)
.Pp .Pp
If the file does not already exist If the
.Ar file
does not already exist,
.Nm .Nm
will attempt to create and will attempt to create and
.Xr ftruncate 3 .Xr ftruncate 2
it to the specified size, defaulting to 86400 records of 512 bytes it to the specified size, defaulting to 86400 records of 512 bytes
if the if the
.Fl r , .Fl r , l
.Fl l
or or
.Fl s .Fl s
arguments do not specify otherwise. options do not specify otherwise.
.Pp .Pp
.Nm Fifolog_writer The
.Nm fifolog_writer
utility
will read standard input and write it to the end of the fifolog will read standard input and write it to the end of the fifolog
according to the parameters given. according to the parameters given.
.Pp .Pp
@ -106,7 +105,7 @@ data or when either of two timers expire, forcing a partially filled
buffer to be written. buffer to be written.
.Pp .Pp
The first and faster timer, The first and faster timer,
.Fl w write-rate , .Fl w Ar write-rate ,
forces available data to be written forces available data to be written
but does not flush and reset the compression dictionary. but does not flush and reset the compression dictionary.
This timer is intended to minimize the amount of logdata lost in RAM This timer is intended to minimize the amount of logdata lost in RAM
@ -114,7 +113,7 @@ in case of a crash and by default it fires 10 seconds after
the previous write. the previous write.
.Pp .Pp
The second and slower timer, The second and slower timer,
.Fl s sync-rate , .Fl s Ar sync-rate ,
forces a full flush and reset of the compression forces a full flush and reset of the compression
engine and causes the next record written to be a synchronization engine and causes the next record written to be a synchronization
point with an uncompressed timestamp, making it possible to start point with an uncompressed timestamp, making it possible to start
@ -122,14 +121,16 @@ reading the logfile from that record.
By default this timer fires a minute after the previous sync. By default this timer fires a minute after the previous sync.
.Pp .Pp
The The
.Fl z compression .Fl z Ar compression
argument controls the option controls the
.Xr zlib 3 .Xr zlib 3
compression level, legal values are zero to nine which is the default. compression level; legal values are zero to nine which is the default.
.Pp .Pp
.Nm Fifolog_reader The
.Nm fifolog_reader
utility
will retrieve records from the fifolog according to the specified will retrieve records from the fifolog according to the specified
parameters and write them either to stdout or the file specified parameters and write them either to standard output or the file specified
with with
.Fl o . .Fl o .
.Pp .Pp
@ -142,56 +143,60 @@ The lower-case variants
and and
.Fl e .Fl e
take a take a
.Xr time_t .Vt time_t
value, whereas the upper-case variants value, whereas the upper-case variants
.Fl B .Fl B
and and
.Fl E .Fl E
take human redable specifications such as "1 hour ago". take human-readable specifications such as
.Dq Li "1 hour ago" .
.Pp .Pp
The The
.Fl t .Fl t
argument forces timestamps to be formatted as "YYYYMMDDhhmmss" instead option forces timestamps to be formatted as
of as time_t, and .Dq Li "YYYYMMDDhhmmss"
instead of as
.Vt time_t ,
and
.Fl T .Fl T
allows the specification of a allows the specification of an
.Xr strftime 3 .Xr strftime 3
formatting string. formatting string.
.Pp .Pp
Finally, records can be filtered such that only records matching the Finally, records can be filtered such that only records matching the
(REG_BASIC) regular expression specified with .Pq Dv REG_BASIC
regular expression specified with
.Fl R .Fl R
is output. are output.
.Sh IMPLEMENTATION NOTES .Sh IMPLEMENTATION NOTES
The data stored in the fifolog consists of three layers, an outher The data stored in the fifolog consists of three layers, an outer
layer that allows searches to synchronization points based on timestamps layer that allows searches to synchronization points based on timestamps
without having to decompress and decode the actual contents, a without having to decompress and decode the actual contents, a
compression layer implemented with compression layer implemented with
.Xr zlib 3 .Xr zlib 3 ,
and an inner serialization and timestamping layer. and an inner serialization and timestamping layer.
.Pp .Pp
The exact encoding is described in the fifolog.h file. The exact encoding is described in the
.Pa fifolog.h
file.
.Pp .Pp
Fifolog is particularly well suited for use on Flash based media, where Fifolog is particularly well suited for use on Flash based media, where
it results in much lower write-wear, than a filesystem with regular it results in much lower write-wear, than a file system with regular
logfiles rotated with log files rotated with
.Xr newsyslog 8 .Xr newsyslog 8
etc. etc.
.Sh EXAMPLES .Sh EXAMPLES
Create a fifolog with 1024*1024 records of 512 bytes: Create a fifolog with 1024*1024 records of 512 bytes:
.Bd -literal .Pp
fifolog_create -r 10m /tmp/fifolog .Dl "fifolog_create -r 10m /tmp/fifolog"
.Ed
.Pp .Pp
Write a single record to this file: Write a single record to this file:
.Bd -literal .Pp
date | fifolog_writer /tmp/fifolog .Dl "date | fifolog_writer /tmp/fifolog"
.Ed
.Pp .Pp
Read it back with human readable timestamps: Read it back with human readable timestamps:
.Bd -literal .Pp
fifolog_reader -t /tmp/fifolog .Dl "fifolog_reader -t /tmp/fifolog"
.Ed
.Pp .Pp
One particular useful use of One particular useful use of
.Nm fifolog_writer .Nm fifolog_writer
@ -199,12 +204,15 @@ is with
.Xr syslogd 8 .Xr syslogd 8
using a line such as this in using a line such as this in
.Xr /etc/syslog.conf 5 : .Xr /etc/syslog.conf 5 :
.Bd -literal .Pp
*.* |fifolog_writer /var/log/syslog_fifolog .Dl "*.* |fifolog_writer /var/log/syslog_fifolog"
.Ed
.Sh HISTORY .Sh HISTORY
The fifolog tools have been liberated from an open source SCADA applications The fifolog tools have been liberated from an open source
called "measured", which monitors and controls remote radio navigation .Tn SCADA
applications called
.Dq measured ,
which monitors and controls remote radio navigation
transmitters for the Danish Air Traffic Control system. transmitters for the Danish Air Traffic Control system.
.Sh AUTHORS .Sh AUTHORS
The fifolog tools were written by Poul-Henning Kamp The fifolog tools were written by
.An Poul-Henning Kamp .

View File

@ -1,17 +1,15 @@
# $FreeBSD$ # $FreeBSD$
PROG = fifolog_reader PROG= fifolog_reader
CFLAGS += -I${.CURDIR}/../lib -I${.CURDIR} CFLAGS+= -I${.CURDIR}/../lib
NO_MAN = see ../fifolog_create/fifolog.1 NO_MAN= # see ../fifolog_create/fifolog.1
DPADD = ${LIBFIFOLOG} ${LIBUTIL} ${LIBZ} DPADD= ${LIBFIFOLOG} ${LIBUTIL} ${LIBZ}
LDADD = ${LIBFIFOLOG} -lutil -lz LDADD= ${LIBFIFOLOG} -lutil -lz
.include <bsd.prog.mk> regress:
test: ${PROG}
./${PROG} /tmp/fifolog.0 ./${PROG} /tmp/fifolog.0
./${PROG} -t /tmp/fifolog.0 ./${PROG} -t /tmp/fifolog.0
./${PROG} /tmp/fifolog.1 ./${PROG} /tmp/fifolog.1
@ -19,5 +17,4 @@ test: ${PROG}
./${PROG} -T "%y%m%d-%H%M%S" /tmp/fifolog.1 ./${PROG} -T "%y%m%d-%H%M%S" /tmp/fifolog.1
./${PROG} -T "" /tmp/fifolog.1 ./${PROG} -T "" /tmp/fifolog.1
t2: .include <bsd.prog.mk>
./${PROG} -t /critter/10.1.29.74.fifolog

View File

@ -1,16 +1,16 @@
# $FreeBSD$ # $FreeBSD$
PROG = fifolog_writer PROG= fifolog_writer
CFLAGS += -I${.CURDIR}/../lib CFLAGS+= -I${.CURDIR}/../lib
NO_MAN = see ../fifolog_create/fifolog.1 NO_MAN= # see ../fifolog_create/fifolog.1
DPADD = ${LIBFIFOLOG} ${LIBUTIL} ${LIBZ} DPADD= ${LIBFIFOLOG} ${LIBUTIL} ${LIBZ}
LDADD = ${LIBFIFOLOG} -lutil -lz LDADD= ${LIBFIFOLOG} -lutil -lz
.include <bsd.prog.mk> regress:
test: ${PROG}
date | ./${PROG} -z 0 /tmp/fifolog.0 date | ./${PROG} -z 0 /tmp/fifolog.0
lptest 65 | ./${PROG} -z 9 /tmp/fifolog.1 lptest 65 | ./${PROG} -z 9 /tmp/fifolog.1
.include <bsd.prog.mk>

View File

@ -1,17 +1,11 @@
# $FreeBSD$ # $FreeBSD$
LIB = fifolog LIB= fifolog
INTERNALLIB = API not published or supported. INTERNALLIB= # API not published or supported.
SRCS += fifolog_int.c SRCS= fifolog_int.c fifolog_create.c fifolog_write_poll.c fifolog_reader.c
SRCS += fifolog_create.c SRCS+= getdate.y
SRCS += fifolog_write_poll.c
SRCS += fifolog_reader.c
SRCS += getdate.y
CFLAGS += -I${.CURDIR} CFLAGS+= -I${.CURDIR}
.include <bsd.lib.mk> .include <bsd.lib.mk>
test:
echo ${HAS_EXPAND_NUMBER}