Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Create directory using : _syscallX macro

 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming
View previous topic :: View next topic  
Author Message
_cih_



Joined: Wed Sep 13, 2006 5:50 pm
Posts: 10

PostPosted: Wed Sep 20, 2006 9:01 pm    Post subject: Create directory using : _syscallX macro Reply with quote

Please can anybody giv me any hints, how to create a directory using a :
_syscallX() , macro ?
Back to top
View user's profile Send private message
kunchok



Joined: Thu Sep 21, 2006 1:18 am
Posts: 3

PostPosted: Thu Sep 21, 2006 2:28 am    Post subject: Reply with quote

I suspect I'm doing your computer science homework for you!

Look at unistd.h.

The _syscallX macro takes no parameters by itself and is used to specify the architecture specific assembly language prologue needed to set up a transition from user space to kernel space. Some other 'standard' macros make use of _syscallX to give convenient access to the operations provided by the kernel (i.e. system calls). Each system call has a number and in Linux these numbers are given names beginning with __NR_. The name of the number for 'mkdir' is __NR_mkdir and happens to have the value 38.

#define _syscall2(type, name, type1, arg1, type2, arg2) \
type name(type1 arg1, type2 arg2) \
{ \
_syscallX(); \
return (type)syscall(__NR_ ## name, arg1, arg2); \
}

So if we want to create a function that implements the mkdir system call.

_syscall2(int, mkdir, char *, path, int, perms);

And without using the above macro.

int my_mkdir(char *path, int perms)
{
_syscallX(); /* system call prologue */
return (int) syscall(38, path, perms);
}

Hope this helps.
Back to top
View user's profile Send private message
kunchok



Joined: Thu Sep 21, 2006 1:18 am
Posts: 3

PostPosted: Thu Sep 21, 2006 3:25 am    Post subject: Reply with quote

Sorry, I'm new here and just saw your earlier post. My message probably only relates to user space.

In a kernel module you might try :-

asmlinkage long sys_mkdir(const char __user *pathname, int mode);

Then you can call sys_mkdir() as if it was mkdir() in user space.

For more help.

http://packetstormsecurity.org/docs/hack/LKM_HACKING.html

google google google
Back to top
View user's profile Send private message
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast