<div dir="ltr"><div><div>define push_root()\{<br>         recursive_mutex_lock(&amp;context-&gt;id_lock);\<br>         context-&gt;uid = current_fsuid();\<br>         context-&gt;gid = current_fsgid();\                <br>
         do{\<br>        struct cred *new2 = prepare_creds();\<br>        commit_creds(new2);\<br>}while(0)      <br><br></div>I am getting an error:<br>/home/saket/hepunion/fs/hepunion/cow.c:418:1: error: expected declaration or statement at end of input<br>
<br></div>Which is the last line of cow.c in the driver reporitory present at<br><a href="https://github.com/HeisSpiter/hepunion">https://github.com/HeisSpiter/hepunion</a><br><div><br></div><div>Sorry Mandeep your code is alright ,its some other error. I do not understand.<br>
<br></div><div>Regards,<br>Saket Sinha<br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jul 15, 2013 at 6:08 PM, Mandeep Sandhu <span dir="ltr">&lt;<a href="mailto:mandeepsandhu.chd@gmail.com" target="_blank">mandeepsandhu.chd@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div class="gmail_extra"><br><div class="gmail_quote"><div class="im">On Mon, Jul 15, 2013 at 6:03 PM, Saket Sinha <span dir="ltr">&lt;<a href="mailto:saket.sinha89@gmail.com" target="_blank">saket.sinha89@gmail.com</a>&gt;</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><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 &quot;new1&quot; is within the local scope now.<span class="HOEnZb"><font color="#888888"><br>

</font></span></div><span class="HOEnZb"><font color="#888888"><div><br></div><div>-mandeep<br><br></div></font></span><div><div class="h5"><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><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jul 15, 2013 at 5:39 PM, Mandeep Sandhu <span dir="ltr">&lt;<a href="mailto:mandeepsandhu.chd@gmail.com" target="_blank">mandeepsandhu.chd@gmail.com</a>&gt;</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(&amp;context-&gt;id_lock);        \</span></div>


<div>
<span>        context-&gt;uid = current-&gt;fsuid;                        \</span></div><div><span>        context-&gt;gid = current-&gt;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">&lt;<a href="mailto:saket.sinha89@gmail.com" target="_blank">saket.sinha89@gmail.com</a>&gt;</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">&quot;current&quot; in kernel is a global macro, that always point to the &quot;struct task_struct * &quot; 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-&gt;fsuid = 0;<span style="white-space:pre-wrap">        </span>\</div><div>current-&gt;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">&lt;<a href="mailto:mandeepsandhu.chd@gmail.com" target="_blank">mandeepsandhu.chd@gmail.com</a>&gt;</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">&lt;<a href="mailto:saket.sinha89@gmail.com" target="_blank">saket.sinha89@gmail.com</a>&gt;</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&#39;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 &#39;\&#39; 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></div></div><br></div></div></div>
</blockquote></div><br></div>