All of lore.kernel.org
 help / color / mirror / Atom feed
* OT: calling kernel syscall manually
@ 2006-09-12 12:05 guest01
  2006-09-12 13:34 ` David Woodhouse
  0 siblings, 1 reply; 13+ messages in thread
From: guest01 @ 2006-09-12 12:05 UTC (permalink / raw)
  To: linux-kernel

Hi

Sorry guys, this question is a little bit off topic, but maybe someone
has an answer, I am sure that there is a simple one. :-)

Ok, I have to find 3 possibilities to create a directory with 3 small c
programs:
1 -> using libc: mkdir(dir,mode)
2 -> using libcsyscall:  syscall(__NR_mkdir, "mkdirLibcSyscall", 0777);
3 -> using kernel directly

Ok, the third one is a little bit tricky, at least for me. I found an
example for lseek, but I don't know how to convert that for mkdir. I
don't know the necessary arguments, ..

> #include <linux/unistd.h>
> 
> _syscall5(int, _llseek, unsigned int, fd,
>           unsigned long, offset_high, unsigned long, offset_low,
>           long long *, result, unsigned int, origin)
> 
> long long
> my_llseek(unsigned int fd, unsigned long long offset, unsigned int origin) {
>           long long result;
>           int retval;
> 
>           retval = _llseek (fd, offset >> 32, offset & 0xffffffff,
>                             &result, origin);
>           return (retval == -1) ? -1 : result;
> }

Any help would be much appreciated. Thxs

regards
peda

^ permalink raw reply	[flat|nested] 13+ messages in thread
* Re: OT: calling kernel syscall manually
@ 2006-09-13  5:35 Albert Cahalan
  2006-09-13  6:55 ` David Woodhouse
  0 siblings, 1 reply; 13+ messages in thread
From: Albert Cahalan @ 2006-09-13  5:35 UTC (permalink / raw)
  To: dwmw2, guest01, linux-kernel

David Woodhouse writes:
> On Tue, 2006-09-12 at 14:05 +0200, guest01 wrote:

>> 3 -> using kernel directly
>>
>> Ok, the third one is a little bit tricky, at least for me.
>> I found an example for lseek, but I don't know how to convert
>> that for mkdir. I don't know the necessary arguments, ..
>
> The third one has always been broken on i386 for PIC code

No, I was just using it today in PIC i386 code.
The %ebx register gets pushed, the needed value
gets moved into %ebx, the int 0x80 is done, and
the %ebx register gets popped. Only a few odd
calls like clone() need something different.

(not that this should be needed: gcc is broken
if it can't save/restore the needed registers)

> and was pointless anyway, since glibc provides this
> functionality. The kernel method has been removed from
> userspace visibility all architectures, and we plan to
> remove it entirely in 2.6.19 since it's not at all useful.

It's damn useful. Hint: Linux does not require glibc.

I could hack up my own assembly. I did that for clone(),
but I didn't enjoy that waste of my time.

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2006-09-13 17:53 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-12 12:05 OT: calling kernel syscall manually guest01
2006-09-12 13:34 ` David Woodhouse
2006-09-12 14:31   ` guest01
2006-09-12 14:37     ` David Woodhouse
2006-09-12 20:25   ` Phillip Susi
2006-09-12 20:46     ` Miguel Ojeda
2006-09-12 22:03     ` Arnd Bergmann
2006-09-12 22:43     ` David Woodhouse
2006-09-13 16:52       ` guest01
2006-09-13 17:52         ` David Woodhouse
  -- strict thread matches above, loose matches on Subject: below --
2006-09-13  5:35 Albert Cahalan
2006-09-13  6:55 ` David Woodhouse
2006-09-13 15:52   ` Albert Cahalan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.