Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Oct 2007 12:28:42 -0700
From:      Yuri <yuri@rawbw.com>
To:        Derek Ragona <derek@computinginnovations.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Calling syscalls through int 0x80 documentation?
Message-ID:  <1192735722.4717b3ea8273a@webmail.rawbw.com>
In-Reply-To: <6.0.0.22.2.20071018141850.02482e78@mail.computinginnovations.com>
References:  <1192731161.4717a21980065@webmail.rawbw.com> <6.0.0.22.2.20071018132410.02311ad8@mail.computinginnovations.com> <1192733243.4717aa3b1843f@webmail.rawbw.com> <6.0.0.22.2.20071018141850.02482e78@mail.computinginnovations.com>

next in thread | previous in thread | raw e-mail | index | archive | help

> I guess I'd ask why you want to use syscall at all to just open a file?  I 
> thought you wanted to access some hardware and had no other way to do that.

Derek,

Opening a file is just an example. I want to be able to make any system call
this way since my program for whatever reasons has to be compiled with such gcc
options that prevent being linked to system calls in the traditional way. No
hardware issues for me.

Btw I submitted the wrong assembly code with my previous message.
The right one (still not working) is below.

Lack of documentation causes me to ask this kind of question here.

Yuri

---- code ---
#include <fcntl.h>

extern int mysyscall (
          int syscall_no,
          int a1, int a2, int a3,
          int a4, int a5, int a6);
asm(
".text\n"
"mysyscall:\n"
"       movl    %esp,%ebx\n"
"       push    28(%ebx)\n"
"       push    24(%ebx)\n"
"       push    20(%ebx)\n"
"       push    16(%ebx)\n"
"       push    12(%ebx)\n"
"       push    8(%ebx)\n"
"       push    4(%ebx)\n"
"       int     $0x80\n"
"       pop     %ecx\n"
"       pop     %ecx\n"
"       pop     %ecx\n"
"       pop     %ecx\n"
"       pop     %ecx\n"
"       pop     %ecx\n"
"       pop     %ecx\n"
"       ret\n"
".previous\n"
);

main() {
  char *fname = "myxxxfile";
  //int fd = open(fname, O_WRONLY|O_CREAT);
  int fd = mysyscall(5, (int)fname,O_WRONLY|O_CREAT,0,0,0,0); // open
  printf("fd=%i\n",fd);
}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1192735722.4717b3ea8273a>