From dbd54342fd66fd372f5c2edd1597019814f41c9c Mon Sep 17 00:00:00 2001 From: Ori Bernstein Date: Sun, 1 Nov 2020 11:42:54 -0800 Subject: [PATCH] libbio: add aux pointer to bio This allows us to attach additional context to the biobuf so can read from some sort of data structure without a global variable. --- sys/include/bio.h | 1 + sys/man/2/bio | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/sys/include/bio.h b/sys/include/bio.h index 2a874de31..2c5cdc8cf 100644 --- a/sys/include/bio.h +++ b/sys/include/bio.h @@ -34,6 +34,7 @@ struct Biobufhdr uchar* gbuf; /* pointer to good data in buf */ void (*errorf)(char *); /* called on error if not nil */ int (*iof)(Biobufhdr*, void *, long); /* called to do i/o */ + void *aux; /* user data */ }; struct Biobuf diff --git a/sys/man/2/bio b/sys/man/2/bio index b62a5877d..8c63870cb 100644 --- a/sys/man/2/bio +++ b/sys/man/2/bio @@ -1,6 +1,6 @@ .TH BIO 2 .SH NAME -Bopen, Bfdopen, Binit, Binits, Brdline, Brdstr, Bgetc, Bgetrune, Bgetd, Bungetc, Bungetrune, Bread, Bseek, Boffset, Bfildes, Blinelen, Bputc, Bputrune, Bprint, Bvprint, Bwrite, Bflush, Bterm, Bbuffered, Blethal \- buffered input/output +Bopen, Bfdopen, Binit, Binits, Brdline, Brdstr, Bgetc, Bgetrune, Bgetd, Bungetc, Bungetrune, Bread, Bseek, Boffset, Bfildes, Blinelen, Bputc, Bputrune, Bprint, Bvprint, Bwrite, Bflush, Bterm, Bbuffered, Blethal, Biofn \- buffered input/output .SH SYNOPSIS .ta \w'Biobuf* 'u .B #include @@ -9,6 +9,16 @@ Bopen, Bfdopen, Binit, Binits, Brdline, Brdstr, Bgetc, Bgetrune, Bgetd, Bungetc, .br .B #include .PP +.ft L +.nf +.ta \w' 'u +\w' 'u +\w' 'u +\w' 'u +\w' 'u +typedef struct Biobufhdr Biobufhdr; +struct Biobufhdr { + void *aux; /* user data */ + ... /* internals */ +}; +.fi +.PP .B Biobuf* Bopen(char *file, int mode) .PP