vrb_write(3)
π vrb_write(3) β writing data out of a VRB, bestie edition
okay so real talk, this one lives in the VRB Programmer's Manual and honestly it's kind of a vibe. You've got a virtual ring buffer stuffed with data, you've got an open file descriptor, and you want the first one to pour into the second one. That's the whole plot. Let's get into it π«Ά
π LIBRARY
Link against -lvrb and you're golden β¨
β¨ SYNOPSIS β¨
#include <vrb.h>
size_t vrb_write(vrb_p vrb, int fd, size_t size);
πΈ DESCRIPTION πΈ
vrb_write takes data and writes it out to an open file descriptor you specify, using write(2), pulling from the virtual ring buffer you point it at. It keeps going until one of these happens:
- the maximum length you asked for has been written π
- the buffer is full (nothing more to give) π
- an error gets returned β and yes, that includes
EAGAINorEWOULDBLOCKwhen you're dealing with a non-blocking descriptor, so keep that in mind ngl π
π ARGUMENTS π
vrb_p vrbβ which virtual ring buffer we're working with, like, the actual source of the data πint fdβ the open file descriptor to write to, the destination, the moment π¦size_t sizeβ the maximum length to write, OR pass~0for unlimited (which means all of the buffer, go off π)
β RETURN VALUE β
The type is size_t, and here's how it goes:
- if it works, you get back the actual length of data written out of the buffer β
- if there was literally no data available to write, you get
0β not an error, just an empty vibe check π - if
write(2)itself errors out, the return value is~0anderrnogets set bywrite(2)β so like, the error is coming from the write call, not from this function's own drama π
π ERRORS π
If an error comes back, errno is gonna be one of these:
0β an end-of-file has occurred. And lowkey pay attention here: this is a different way of returning an end-of-file condition thanwrite(2)uses. Not me warning you, that's just the docs fr fr πEINVALβ you handed over an invalid virtual ring buffer pointer. Rude, but fair πΈ
bestie fr fr double-check your pointer before you call this, EINVAL is literally sitting right there waiting
π§ SEE ALSO π§
vrb(3), vrb_capacity(3), vrb_data_len(3), vrb_data_ptr(3), vrb_destroy(3), vrb_get(3), vrb_get_min(3), vrb_give(3), vrb_init(3), vrb_init_opt(3), vrb_is_empty(3), vrb_is_full(3), vrb_is_not_empty(3), vrb_is_not_full(3), vrb_move(3), vrb_new(3), vrb_new_opt(3), vrb_put(3), vrb_put_all(3), vrb_read(3), vrb_read_min(3), vrb_resize(3), vrb_space_len(3), vrb_space_ptr(3), vrb_take(3), vrb_uninit(3), vrb_write_min(3), write(2)
and that's the whole page, periodt π this little icon dropped under the vrb name and it's dated 2002-09-30 β vintage, honestly iconic, no cap πβ¨
π¦ where this page comes from
- nixos 26.05: vrb 0.5.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms