Date: Fri, 29 Jul 2016 16:22:55 +0300 From: Slawa Olhovchenkov <slw@zxy.spb.ru> To: Adam Starak <starak.adam@gmail.com> Cc: freebsd-hackers@freebsd.org Subject: Re: Modify user space from kernel. Message-ID: <20160729132254.GD46309@zxy.spb.ru> In-Reply-To: <CAAz%2B7vqLgd5GSBfFMdD-xsAsEoujgPh8ZdKY4xZ1LO0h30OmSQ@mail.gmail.com> References: <CAAz%2B7vqLgd5GSBfFMdD-xsAsEoujgPh8ZdKY4xZ1LO0h30OmSQ@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Jul 29, 2016 at 03:11:25PM +0200, Adam Starak wrote: > Hello! > > My name is Adam. I participate in Google Summer of Code this year. I came > up with a big problem, which doesn't allow me to go further in my project. > > I made a new syscall, which is going to retrieve sysctl data and put it > inside the nvlist. And here my problem is. I need to move somehow this data > (packed nvlist) into the user space. Is there any chance to pass data from > kernel to user space without knowing the size of it? > > Right now, the implementation of __sysctl() function requests void pointer > and size in order to get data. If allocated memory is too low, it returns > ENOMEM and you need to realloc the data. I wanted to avoid this situation. char *intrname; size_t inamlen; sysctlbyname("hw.intrnames", NULL, &inamlen, NULL, 0); intrname = malloc(inamlen); sysctlbyname("hw.intrnames", intrname, &inamlen, NULL, 0); NB: check error!
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20160729132254.GD46309>