For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > October 2007 > Re: How to make system calls having 64-bit arguments using 'int 80h'









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: How to make system calls having 64-bit arguments using 'int 80h'
Spoon

2007-10-24, 8:08 am

Visa Inquirer wrote:

> If I need to make a system call with 6 arguments I can use the code:
> " push %esi\n"
> " push %edi\n"
> " push %ebx\n"
> " push %ebp\n"
> " movl 16+ 4(%esp),%eax\n" // syscall_num
> " movl 16+ 8(%esp),%ebx\n" // arg1
> " movl 16+12(%esp),%ecx\n" // arg2
> " movl 16+16(%esp),%edx\n" // arg3
> " movl 16+20(%esp),%esi\n" // arg4
> " movl 16+24(%esp),%edi\n" // arg5
> " movl 16+28(%esp),%ebp\n" // arg6
> " int $0x80\n"
> " popl %ebp\n"
> " popl %ebx\n"
> " popl %edi\n"
> " popl %esi\n"
> " ret\n"
>
> But what happens for system calls like 'mmap'?
> void *mmap(void *start, size_t length, int prot, int flags,
> int fd, off_t offset);
> Its last argument is off_t which is 64-bit.


Are you sure the offset really is 64-bits wide?
http://lxr.linux.no/source/arch/i38.../sys_i386.c#L43
asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
unsigned long prot, unsigned long flags,
unsigned long fd, unsigned long pgoff)

> Where should the high
> part of this offset fit in? There is not enough registers...
> Same for ls:
> off_t ls(int fildes, off_t offset, int whence);
> how will the high part of 'offset' argument be passed?


Are you sure the offset really is 64-bits wide?
asmlinkage off_t sys_ls(unsigned int fd, off_t offset,
unsigned int origin)
typedef __kernel_off_t off_t;
typedef long __kernel_off_t;

lls explicitly breaks a 64-bit argument into two 32-bit pieces:
http://lxr.linux.no/source/fs/read_write.c#L154
asmlinkage long sys_lls(unsigned int fd, unsigned long offset_high,
unsigned long offset_low, loff_t __user * result,
unsigned int origin)
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com