<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 3, 2013 at 10:38 PM, ajay saini <span dir="ltr"><<a href="mailto:ajay_saini1006@yahoo.co.in" target="_blank">ajay_saini1006@yahoo.co.in</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="font-size:12pt;font-family:times new roman,new york,times,serif"><div style="font-family:'times new roman','new york',times,serif;font-size:12pt">
Hi,</div><div style="font-family:'times new roman','new york',times,serif;font-size:12pt"><br></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:'times new roman','new york',times,serif">
I had some confusion/doubts regarding Linux kernel / OS and I <span style="background-color:transparent">want to be completely sure that my understanding is right for below, and need your inputs (would be really glad for your help):</span></div>
<div style="font-style:normal;font-size:16px;background-color:transparent;font-family:'times new roman','new york',times,serif"><span style="background-color:transparent"><br></span></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:'times new roman','new york',times,serif">
<span style="background-color:transparent">- There are functions defined in linux kernel. Some of these functions have a line "EXPORT_SYMBOL(<function_name>);" after them.</span><br></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:'times new roman','new york',times,serif">
<span style="background-color:transparent"> These are the functions which are exported, so they can be directly called from a linux kernel module - right ? (we just need to include header files which define</span></div>
<div style="font-style:normal;font-size:16px;background-color:transparent;font-family:'times new roman','new york',times,serif"><span style="background-color:transparent">
them</span><span style="background-color:transparent"> in</span><span style="background-color:transparent"> our kernel module)</span></div></div></div></blockquote><div><br></div><div>Yes. They are used during dynamic loading of modules. More here: <a href="http://stackoverflow.com/questions/6670589/use-of-export-symbol">http://stackoverflow.com/questions/6670589/use-of-export-symbol</a><br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="font-size:12pt;font-family:times new roman,new york,times,serif">
<div style="font-style:normal;font-size:16px;background-color:transparent;font-family:'times new roman','new york',times,serif"><span style="background-color:transparent"><br></span></div><div style="background-color:transparent">
<span style="font-style:normal;font-size:16px;background-color:transparent;font-family:'times new roman','new york',times,serif">- There are some functions </span><span style="font-family:'times new roman','new york',times,serif;font-size:16px">defined in linux kernel</span><span style="background-color:transparent;font-family:'times new roman','new york',times,serif;font-size:16px">, which are not static and are not exported, like "</span><span style="background-color:transparent"><font face="times new roman, new york, times, serif">migrate_pages" in migrate.c and it is mentioned in</font></span></div>
<div style="font-style:normal;font-size:16px;background-color:transparent;font-family:'times new roman','new york',times,serif"><span style="background-color:transparent"><font face="times new roman, new york, times, serif"> include/linux/migrate.h file.</font></span><span style="background-color:transparent"> </span></div>
<div style="font-style:normal;font-size:16px;background-color:transparent;font-family:'times new roman','new york',times,serif"><span style="background-color:transparent"> Is there a way to call these functions, directly from kernel module ?? (even if I include the header file) ??</span></div>
<div style="font-style:normal;font-size:16px;background-color:transparent;font-family:'times new roman','new york',times,serif"><span style="background-color:transparent"> If no, </span><span style="background-color:transparent">What is the technique used there, which prevents the module from calling this function (even though I have included the header file)??</span></div>
</div></div></blockquote><div><br>The compiler? :)<br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="font-size:12pt;font-family:times new roman,new york,times,serif">
<div style="font-style:normal;font-size:16px;background-color:transparent;font-family:'times new roman','new york',times,serif"><span style="background-color:transparent"><br></span></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:'times new roman','new york',times,serif">
<span style="background-color:transparent">- We have kernel header files defined in include/linux/ and there are user space header files (the C libraries).</span></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:'times new roman','new york',times,serif">
<span style="background-color:transparent"> Can a user space program include kernel header file and call a kernel function directly?? No , right ??</span></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:'times new roman','new york',times,serif">
<span style="background-color:transparent"> Again, what is there which prevents a user space program from doing so?? How this technique is implemented ??</span></div></div></div></blockquote><div><br></div><div>Kernel fxn's can't be called directly, you'll have to use either the syscal interface or one of the many (indirect) userspace-kernel communication mechanisms.<br>
<br></div><div>Again, the "technique" here is that you compiler will barf if you try and use kernel functions directly as it won't find the definitions of those functions during linking. CMIIW.<br></div><div>
<br></div><div>HTH,<br></div><div>-mandeep<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="font-size:12pt;font-family:times new roman,new york,times,serif">
<div style="font-style:normal;font-size:16px;background-color:transparent;font-family:'times new roman','new york',times,serif"><span style="background-color:transparent"><font face="times new roman, new york, times, serif"> </font></span></div>
<div style="font-style:normal;font-size:16px;background-color:transparent;font-family:'times new roman','new york',times,serif"><span style="background-color:transparent"><font face="times new roman, new york, times, serif">- I understand that, a struct page exists for each physical page in RAM. And this linked list of struct pages are stored together at the beginning of a zone. After this</font></span></div>
<div style="font-style:normal;font-size:16px;background-color:transparent;font-family:'times new roman','new york',times,serif"><span style="background-color:transparent"><font face="times new roman, new york, times, serif"> storage, does the real data (content) of pages is stored.</font></span></div>
<div style="font-style:normal;font-size:16px;background-color:transparent;font-family:'times new roman','new york',times,serif"><span style="background-color:transparent"><font face="times new roman, new york, times, serif"> Now each
of these pages must be pointing to the data area/page which they define ? Which is this field in the struct page, which points to this data area, a physical</font></span></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:'times new roman','new york',times,serif">
<span style="background-color:transparent"><font face="times new roman, new york, times, serif"> address + length of the page ?</font></span></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:'times new roman','new york',times,serif">
<span style="background-color:transparent"><font face="times new roman, new york, times, serif"> </font></span></div><div style="font-family:'times new roman','new york',times,serif;font-size:12pt"><span style="background-color:transparent;font-size:12pt">Thanks,</span></div>
<div style="font-family:'times new roman','new york',times,serif;font-size:12pt"><span style="background-color:transparent;font-size:12pt">Ajay</span></div></div></div><br>_______________________________________________<br>
Kernelnewbies mailing list<br>
<a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
<a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
<br></blockquote></div><br></div></div>