Page MenuHomeFreeBSD

libsbuf: add an sbuf_prepend() API
Needs ReviewPublic

Authored by kevans on Mon, Apr 21, 7:01 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, May 5, 7:16 PM
Unknown Object (File)
Mon, Apr 28, 12:26 PM
Unknown Object (File)
Wed, Apr 23, 4:07 AM
Unknown Object (File)
Mon, Apr 21, 11:34 PM
Unknown Object (File)
Mon, Apr 21, 11:31 PM
Unknown Object (File)
Mon, Apr 21, 11:08 PM
Unknown Object (File)
Mon, Apr 21, 11:04 PM
Unknown Object (File)
Mon, Apr 21, 10:48 PM
Subscribers

Details

Reviewers
imp
des
kib
Summary

I'd like to consider this for my proposed devctl_notifyf in D34504,
which needs to tap out the data portion of the devctl notification to
netlink. The new model would expand the format string into the sbuf,
tap it out to netlink, then prepend the !system= subsystem= type=
afterwards to form the message we enqueue for devctl.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 63617
Build 60501: arc lint + arc unit

Event Timeline

On second thought, I'm not so sure this will work anyways... I'd need to finish the sbuf in order to tap out a copy for netlink, since sbuf_data() is only guaranteed to work on a finished sbuf.

sys/kern/subr_sbuf.c
436
476

So suppose we have sbuf="X", then prepend(sbuf, "A"), then prepend(sbuf, "B"). What should be the result, "ABX" or "BAX"?

sys/kern/subr_sbuf.c
476

BAX -- action is always immediate, only weird state is if you ENOMEM in the middle of constructing the string since we may prepend whole str in smaller chunks than the full size of the string

sys/kern/subr_sbuf.c
476

Might be, give a hint in the man page?

sys/kern/subr_sbuf.c
471

so why won't this expand this to the whole size all at once? The loop concerns me.

sys/kern/subr_sbuf.c
471

I kept the loop because of what the comment above it describes- sbuf_extend takes an int, so I wanted to account for the perhaps unlikely possibility that we get a string > INT_MAX in size