ALQ API suggestions - from newbie ALQ user

Lonnie VanZandt lonnie.vanzandt at ngc.com
Fri Aug 5 20:40:44 GMT 2005


1. Although it is a rather obvious requirement, it would help newcomers to the 
ALQ service to note in the man 9 alq page that "options ALQ" has to be added 
to the kernel configuration in order to gain access to ALQ.

2. The alq_post and alq_write methods always write alq.aq_entlen bytes to the 
vnode. This is fine for record-oriented, fixed-size "protocols" where one is 
basically writing out a C struct on each write. But, if one wants to output 
arbitrarily-sized strings or binary sequences and does want the consumer to 
have to know that internally the output file was generated in fixed-sized 
chunks, then a method prototype like this would be very useful:

	int alq_write_bytes( struct alq * const, const void * const data, unsigned 
int maxByteCnt ); // returns byte count actually "written"

Here, the ALQ internal code would post an ALE with a data length equal to 
min( pAlq->aq_entlen, maxByteCnt ). The ALD then would write to the vnode not 
alq.aq_entlen bytes but ale.data_len bytes.

The alq_write caller could implement a "while bytes left" loop around the 
alq_write_bytes to write out sequences larger than the ALQ entry size.

The destination file then would be contiguous without padding at the end of 
the last partial entry.

The needed changes would be:

	a. add a data_len field to struct ale
	b. implement a new alq_write_bytes method in kern_alq.c
	c. set ale.data_len to alq.aq_entlen in alq_get() (to set the default size)
	d. modify alq_post() to write ale.data_len, not alq.ag_entlen bytes to the 
vnode

Lonnie.

PS: If there is some other kernel facility for doing just what I suggest, then 
my newbie ignorance has been revealed and I would appreciate being so 
informed.



More information about the freebsd-current mailing list