<div dir="ltr"><div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 15, 2013 at 6:03 PM, Saket Sinha <span dir="ltr"><<a href="mailto:saket.sinha89@gmail.com" target="_blank">saket.sinha89@gmail.com</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 dir="ltr">Mandeep:<div><br><div>Even this hasnt helped..though it was a btight idea. :(</div></div>
</div></blockquote><div><br>And what _exact_ error does the compiler give if you use the new (modified) macro?<br><br></div><div>The re-def error should not be there as the variable "new1" is within the local scope now.<br>
</div><div><br></div><div>-mandeep<br><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 dir="ltr"><div><div><br></div></div>
<div><br></div><div>P.S.-I can give my system on remote via Team Viewer, if you want to try.</div><div>
<br></div><div><div>Regards,</div><div>Saket Sinha</div></div></div><div class=""><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jul 15, 2013 at 5:39 PM, Mandeep Sandhu <span dir="ltr"><<a href="mailto:mandeepsandhu.chd@gmail.com" target="_blank">mandeepsandhu.chd@gmail.com</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 dir="ltr">How about:<br><pre><div><span>#define push_root() \</span></div><div><span>        recursive_mutex_lock(&context->id_lock);        \</span></div>
<div>
<span>        context->uid = current->fsuid;                        \</span></div><div><span>        context->gid = current->fsgid;                        \<br></span></div><div><span> <font>do { \<br>
<span style="font-family:courier new,monospace"> </span></font></span><font><span style="font-family:courier new,monospace"><span>struct cred *new1 = </span><span><span>prepare_creds();</span> \<br> </span><div>
//make changes to any member of this structure \<br></div>
<span>commit_creds(new1); \<br></span></span></font></div><div><span style="font-family:courier new,monospace"><span style="font-size:13px"><font> } while(0);</font><br>
</span></span></div><br></pre><pre>HTH,<br></pre><pre>-mandeep<br></pre><br></div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jul 15, 2013 at 5:27 PM, Saket Sinha <span dir="ltr"><<a href="mailto:saket.sinha89@gmail.com" target="_blank">saket.sinha89@gmail.com</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 dir="ltr">Here is the macro<div><a href="https://github.com/HeisSpiter/hepunion/blob/master/fs/hepunion/hepunion.h#L393" target="_blank">https://github.com/HeisSpiter/hepunion/blob/master/fs/hepunion/hepunion.h#L393</a><br>
</div><div>
<br></div><div>Now this driver is at 2.6.18 kernel. I have to upgrade it to 3.8.3.</div><div>As I have said</div><div><span style="font-family:arial,sans-serif;font-size:13px">"current" in kernel is a global macro, that always point to the "struct task_struct * " of the currently executing task (for details on task_struct, ref Robert Love, pg 24-27).</span><br>
</div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><a href="https://github.com/HeisSpiter/hepunion/blob/master/fs/hepunion/hepunion.h#L397" target="_blank">https://github.com/HeisSpiter/hepunion/blob/master/fs/hepunion/hepunion.h#L397</a><span style="font-family:arial,sans-serif;font-size:13px"><br>
</span></div><div><br></div><div>Now if you look at thse two lines-</div><div><div><br></div><div>current->fsuid = 0;<span style="white-space:pre-wrap">        </span>\</div><div>current->fsgid = 0</div></div><div><br>
</div><div>Now task struct does not contain fsuid and fsgid, instead you have </div><div>struct cred containing fsuid and fsgid.</div><div><a href="http://lxr.free-electrons.com/source/include/linux/cred.h#L102" target="_blank">http://lxr.free-electrons.com/source/include/linux/cred.h#L102</a><br>
</div><div><br></div><div>So normal method is </div><div><span style="font-family:arial,sans-serif;font-size:13px">struct cred *new1;</span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px">new1 =prepare_creds();</span><br style="font-family:arial,sans-serif;font-size:13px">
<font face="arial, sans-serif">//make changes to any member of this structure </font><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px">commit_creds(new1);</span><br>
</div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">Now this above action I need to perform through a macro, in order to bring minimal changes to the driver.</span></div>
<div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><font face="arial, sans-serif">Now, I have told everything. Can someone suggest something that might work.</font></div><div><font face="arial, sans-serif"><br>
</font></div><div><font face="arial, sans-serif">Regards,</font></div><div><font face="arial, sans-serif">Saket Sinha</font></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br>
</span></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jul 15, 2013 at 5:07 PM, Mandeep Sandhu <span dir="ltr"><<a href="mailto:mandeepsandhu.chd@gmail.com" target="_blank">mandeepsandhu.chd@gmail.com</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 dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote"><div>On Mon, Jul 15, 2013 at 4:50 PM, Saket Sinha <span dir="ltr"><<a href="mailto:saket.sinha89@gmail.com" target="_blank">saket.sinha89@gmail.com</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 dir="ltr"><div style="font-family:arial,sans-serif;font-size:13px">Mandip:</div><div style="font-family:arial,sans-serif;font-size:13px">
Error is expected error or declaration at the end of input</div></div></blockquote><div><br></div></div><div>Without looking at the code, it's difficult to comment further.<br><br></div><div>Can you attach a small compilable example which exhibits the error?<span><font color="#888888"><br>
<br></font></span></div><span><font color="#888888"><div>-mandeep<br><br></div></font></span><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 dir="ltr">
<div style="font-family:arial,sans-serif;font-size:13px">Anish:</div><div style="font-family:arial,sans-serif;font-size:13px">that '\' should not be there first of all and even if I put it same error</div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div></div>
</blockquote></div></div><br></div></div>
</blockquote></div><br></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div></div></div>