you can likely just use click_random() if you need random data and you want it to work at both userlevel and in the kernel.
Otherwise, you can use stuff like #ifdef CLICK_LINUXMODULE and use get_random_bytes() from the linux kernel. You cannot do direct filesystem access from linux modules, and there is no (not-very-very-difficult) way around that Cliff On Sun, Aug 25, 2013 at 9:41 PM, ndritsos <ndrit...@gmail.com> wrote: > hello , > > iam trying to port code from openssl , especially > at this time i need the function Rand_poll() > https://github.com/openssl/openssl/blob/master/crypto/rand/rand_unix.c > lines 237 - 420 > > The function Rand_poll use > 1)getpid() > 2)close(..) > 3)open(...) > 4getuid() > > and all this functions are defined on unistd.h ! > > any idea someone how i can run this code on kernel level? > > > > On 08/26/2013 02:23 AM, Cliff Frey wrote: > > You cannot use unistd.h (or any other standard userlevel headers) in the > kernel. Whatever you are trying to do must be done in a different way. > Specifically you cannot use getpid(). > > What do you want/need getpid for? > > Cliff > > > On Sun, Aug 25, 2013 at 1:35 PM, ndritsos <ndrit...@gmail.com> wrote: > >> Hello everyone , >> >> i have created an element that uses the library unistd.h, and in the >> user level it works fine . >> Now i'm working in kernel level , and it doesn't work. >> >> in kernel level i have imported : >> >> #include <linux/unistd.h> >> >> and i have this compile time error: >> --- >> In file included from >> /home/dritsos/click/linuxmodule/../elements/local/ndritso.cc:23:0: >> /home/dritsos/click/include/click-linuxmodule/include2/linux/unistd.h:5:3: >> error: #error "missing #include <click/cxxprotect.h>" >> In file included from >> >> /home/dritsos/click/include/click-linuxmodule/include2/linux/unistd.h:12:0, >> from >> /home/dritsos/click/linuxmodule/../elements/local/ndritso.cc:23: >> /home/dritsos/click/include/click-linuxmodule/include0/asm/unistd.h:4:3: >> error: #error "missing #include <click/cxxprotect.h>" >> In file included from >> /home/dritsos/click/include/click-linuxmodule/include0/asm/unistd.h:8:0, >> from >> /home/dritsos/click/include/click-linuxmodule/include2/linux/unistd.h:12, >> from /home/dritsos/click/linuxmodule/../elements/local/ndritso.cc:23: >> >> /home/dritsos/click/include/click-linuxmodule/include0/asm/unistd_32.h:5:3: >> error: #error "missing #include <click/cxxprotect.h>" >> /home/dritsos/click/linuxmodule/../elements/local/ndritso.cc: In member >> function 'virtual int NdritsoElement::initialize(ErrorHandler*)': >> /home/dritsos/click/linuxmodule/../elements/local/ndritso.cc:59:8: >> error: 'getpid' was not declared in this scope >> make[3]: *** [/home/dritsos/click/linuxmodule/ndritso.o] Error 1 >> make[2]: *** [_module_/home/dritsos/click/linuxmodule] Error 2 >> make[2]: Leaving directory `/usr/src/linux-headers-3.0.0-12-generic' >> make[1]: *** [all] Error 2 >> make[1]: Leaving directory `/home/dritsos/click/linuxmodule' >> make: *** [install-linuxmodule] Error 2 >> >> >> --- >> >> >> Any idea how i can fix this error?? >> >> thanks in advance >> _______________________________________________ >> click mailing list >> click@amsterdam.lcs.mit.edu >> https://amsterdam.lcs.mit.edu/mailman/listinfo/click >> > > > _______________________________________________ click mailing list click@amsterdam.lcs.mit.edu https://amsterdam.lcs.mit.edu/mailman/listinfo/click