On Mon, Jul 15, 2013 at 3:54 PM, Saket Sinha <saket.sinha89@xxxxxxxxx> wrote:
Dear Srinivas,If you are suggesting something like#define push_root \ {new1 =prepare_creds(); \
new1->uid = 0; \
new1->gid = 0; \
commit_creds(new1)}Sorry I am still getting a compiler error.
What errors is the compiler giving?
Last time you mentioned that it's saying new1 has multiple def's.
Last time you mentioned that it's saying new1 has multiple def's.
Is it possible your macro has a declaration of new1 in it. So if you use the macro in the same scope, you'll get re-def errors.
You can also try and look at the intermediate file for your source code, i.e after the pre-processing is done (*.i files).
I don't remember the exact gcc option. Try --save-temps and look at the <source file name>.i file.
I don't remember the exact gcc option. Try --save-temps and look at the <source file name>.i file.
HTH,
-mandeep
Regards,Saket SinhaOn Mon, Jul 15, 2013 at 2:25 PM, Srinivas Ganji <srinivasganji.kernel@xxxxxxxxx> wrote:
A small suggestion, use begin { and end } braces for declaring your macro. May be I am wrong, but you can try this. Then, the declaration become local to that block.
Regards,SrinivasOn Mon, Jul 15, 2013 at 1:03 AM, Saket Sinha <saket.sinha89@xxxxxxxxx> wrote:
_______________________________________________Saket Sinha"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).Regards,
Now I have a macro called push root which has the following purpose-
"to push root user and group to current context so to set current uid and gid to 0."
Now in kernel 3.8.3, I would do something like
struct cred *new1;
new1 =prepare_creds();
new1->uid = 0;
new1->gid = 0;
commit_creds(new1);
So macro definition of push root, according to what I have proposed above, should be
#define push_root \
new1 =prepare_creds(); \
new1->uid = 0; \
new1->gid = 0; \
commit_creds(new1)
But I am getting errors like multiple declaration of new1 etc.
Even if I declare prepare_creds outside macro definition like
new1 =prepare_creds();
#define push_root \
new1->uid = 0; \
new1->gid = 0; \
commit_creds(new1)
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.
I could think of two ways to solve this issue-
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.
2. I should still try to go with inlined functions but how ?
Can someone suggest anything
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies