<div dir="ltr"><div><div>&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).<br>
<br> Now I have a macro called push root which has the following purpose-<br>&quot;to push  root user and group to current context so to set current uid and gid to 0.&quot;<br><br> Now in kernel 3.8.3, I would do something like<br>
<br>struct cred *new1;<br>new1 =prepare_creds();<br>new1-&gt;uid = 0;   <br>new1-&gt;gid = 0;<br>commit_creds(new1);<br><br>So macro definition of push root, according to what I have proposed above, should be<br>#define push_root               \<br>
new1 =prepare_creds();      \<br>new1-&gt;uid = 0;                   \   <br>new1-&gt;gid = 0;                   \<br>commit_creds(new1)      <br><br>But I am getting errors like multiple declaration of new1 etc.<br><br>Even if I declare prepare_creds outside macro definition like<br>
<br>new1 =prepare_creds();    <br>#define push_root               \<br>new1-&gt;uid = 0;                   \   <br>new1-&gt;gid = 0;                   \<br>commit_creds(new1)       <br><br>I think I am  facing the issue that the macros are inlined during compilation, so when the compiler wants to replace them, it raises issues.<br>
<br>I could think of two ways to solve this issue-<br><br>1. define a new macro like #define prep_root() which defines the var once for all, and that I have to put it at the begin of each function needing push_root. This is not a very good method.<br>
<br>2. I should still try to go with inlined functions but how ?<br><br>Can someone suggest anything<br><br></div>Regards,<br></div>Saket Sinha<br></div>