Inline Macro issue

Saket Sinha saket.sinha89 at gmail.com
Mon Jul 15 08:57:42 EDT 2013


define push_root()\{
         recursive_mutex_lock(&context->id_lock);\
         context->uid = current_fsuid();\
         context->gid = current_fsgid();\
         do{\
        struct cred *new2 = prepare_creds();\
        commit_creds(new2);\
}while(0)

I am getting an error:
/home/saket/hepunion/fs/hepunion/cow.c:418:1: error: expected declaration
or statement at end of input

Which is the last line of cow.c in the driver reporitory present at
https://github.com/HeisSpiter/hepunion

Sorry Mandeep your code is alright ,its some other error. I do not
understand.

Regards,
Saket Sinha


On Mon, Jul 15, 2013 at 6:08 PM, Mandeep Sandhu <mandeepsandhu.chd at gmail.com
> wrote:

>
> On Mon, Jul 15, 2013 at 6:03 PM, Saket Sinha <saket.sinha89 at gmail.com>wrote:
>
>> Mandeep:
>>
>> Even this hasnt helped..though it was a btight idea. :(
>>
>
> And what _exact_ error does the compiler give if you use the new
> (modified) macro?
>
> The re-def error should not be there as the variable "new1" is within the
> local scope now.
>
> -mandeep
>
>
>
>>
>>
>> P.S.-I can give my system on remote via Team Viewer, if you want to try.
>>
>> Regards,
>> Saket Sinha
>>
>>
>> On Mon, Jul 15, 2013 at 5:39 PM, Mandeep Sandhu <
>> mandeepsandhu.chd at gmail.com> wrote:
>>
>>> How about:
>>>
>>> #define push_root() \
>>> 	recursive_mutex_lock(&context->id_lock);	\
>>>
>>> 	context->uid = current->fsuid;			\
>>> 	context->gid = current->fsgid;			\
>>>         do {                                            \
>>>             struct cred *new1 = prepare_creds();           \
>>>
>>>
>>> //make changes to any member of this structure \
>>>
>>>             commit_creds(new1);                            \
>>>         } while(0);
>>>
>>> HTH,
>>>
>>> -mandeep
>>>
>>>
>>>
>>>
>>> On Mon, Jul 15, 2013 at 5:27 PM, Saket Sinha <saket.sinha89 at gmail.com>wrote:
>>>
>>>> Here is the macro
>>>>
>>>> https://github.com/HeisSpiter/hepunion/blob/master/fs/hepunion/hepunion.h#L393
>>>>
>>>> Now this driver is at 2.6.18 kernel. I have to upgrade it to 3.8.3.
>>>> As I have said
>>>> "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).
>>>>
>>>>
>>>> https://github.com/HeisSpiter/hepunion/blob/master/fs/hepunion/hepunion.h#L397
>>>>
>>>> Now if you look at thse two lines-
>>>>
>>>> current->fsuid = 0; \
>>>> current->fsgid = 0
>>>>
>>>> Now task struct does not contain fsuid and fsgid, instead you have
>>>> struct cred containing fsuid and fsgid.
>>>> http://lxr.free-electrons.com/source/include/linux/cred.h#L102
>>>>
>>>> So normal method is
>>>> struct cred *new1;
>>>> new1 =prepare_creds();
>>>> //make changes to any member of this structure
>>>> commit_creds(new1);
>>>>
>>>> Now this above action I need to perform through a macro, in order to
>>>> bring minimal changes to the driver.
>>>>
>>>> Now, I have told everything. Can someone suggest something that might
>>>> work.
>>>>
>>>> Regards,
>>>> Saket Sinha
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On Mon, Jul 15, 2013 at 5:07 PM, Mandeep Sandhu <
>>>> mandeepsandhu.chd at gmail.com> wrote:
>>>>
>>>>>
>>>>> On Mon, Jul 15, 2013 at 4:50 PM, Saket Sinha <saket.sinha89 at gmail.com>wrote:
>>>>>
>>>>>> Mandip:
>>>>>> Error is expected error or declaration at the end of input
>>>>>>
>>>>>
>>>>> Without looking at the code, it's difficult to comment further.
>>>>>
>>>>> Can you attach a small compilable example which exhibits the error?
>>>>>
>>>>> -mandeep
>>>>>
>>>>>
>>>>>
>>>>>>  Anish:
>>>>>> that '\' should not be there first of all and even if I put it same
>>>>>> error
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130715/a68aa5e2/attachment.html 


More information about the Kernelnewbies mailing list