 |
Linux Format forums Help, discussion, magazine feedback and more
|
| View previous topic :: View next topic |
| Author |
Message |
_cih_
Joined: Wed Sep 13, 2006 5:50 pm Posts: 10
|
Posted: Wed Sep 20, 2006 9:01 pm Post subject: Create directory using : _syscallX macro |
|
|
Please can anybody giv me any hints, how to create a directory using a :
_syscallX() , macro ? |
|
| Back to top |
|
 |
kunchok
Joined: Thu Sep 21, 2006 1:18 am Posts: 3
|
Posted: Thu Sep 21, 2006 2:28 am Post subject: |
|
|
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 |
|
 |
kunchok
Joined: Thu Sep 21, 2006 1:18 am Posts: 3
|
Posted: Thu Sep 21, 2006 3:25 am Post subject: |
|
|
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 previous topic :: View next topic |
|
|
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
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|