Re: *oldlenp comes back with wrong value in helper sysctl_createv() function

2024-01-20 Thread Emile 'iMil' Heitor
case CTLTYPE_STRING: { unsigned char buf[1024], *tbuf; tbuf = buf; sz = sizeof(buf); rc = prog_sysctl([0], namelen, tbuf, , NULL, 0); The sysctl command first tries with a buffer of 1024 bytes and retries with the

Re: *oldlenp comes back with wrong value in helper sysctl_createv() function

2024-01-20 Thread Michael van Elst
On Sat, Jan 20, 2024 at 10:48:12AM +0100, Emile 'iMil' Heitor wrote: Hi, that's from sysctl.c: case CTLTYPE_STRING: { unsigned char buf[1024], *tbuf; tbuf = buf; sz = sizeof(buf); rc = prog_sysctl([0], namelen, tbuf, ,

Re: *oldlenp comes back with wrong value in helper sysctl_createv() function

2024-01-20 Thread Emile 'iMil' Heitor
The helper function produces the value that is returned in *oldlenp. If you happen to use CTL_DESCRIBE (e.g. running sysctl -d), it's not your helper function being called but the sysctl_describe helper that returns a value of 1024. Maybe you can show your helper routine and how you call sysctl

Re: *oldlenp comes back with wrong value in helper sysctl_createv() function

2024-01-20 Thread Michael van Elst
i...@home.imil.net (Emile 'iMil' Heitor) writes: >Except it does not, the first time it calls back the helper function, >*oldlenp value is 1024 no matter what I set it to before. >But if I return once again (either with ENOMEM or 0, doesn't matter), >the helper function will now be called with

*oldlenp comes back with wrong value in helper sysctl_createv() function

2024-01-19 Thread Emile 'iMil' Heitor
I am creating a sysctl entry for TSLOG https://man.freebsd.org/cgi/man.cgi?query=tslog=4=freebsd-release In every example I see in our source tree, I read that when oldp is NULL, *oldlenp should be set to desired size, return 0, and the sysctl_createv() helper function will be again called