System Call Wrapper of 'open'


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users System Call Wrapper of 'open'
# 1  
Old 06-24-2009
System Call Wrapper of 'open'

When the programmer use 'open' function, the process is like below.
"open -> system call wrapper of open in Glibc -> syscall_open in kernel"

I found the wrapper of open, but there is no implementation like 'int $80'.
Code:
int
__open (file, oflag)
     const char *file;
     int oflag;
{
  int mode;

  if (file == NULL)
    {
      __set_errno (EINVAL);
      return -1;
    }

  if (oflag & O_CREAT)
    {
      va_list arg;
      va_start(arg, oflag);
      mode = va_arg(arg, int);
      va_end(arg);
    }

  __set_errno (ENOSYS);
  return -1;
}

Please let me know where the wrapper of open is.
# 2  
Old 06-25-2009
This looks to me like you found a stub that's intended for someone to fill in for a specific system, given that no matter what you do to call it, it will return -1 and set errno. That said, I'm not sure why they would do all the other stuff just to return -1.

You need to be looking in a different place, I think.
# 3  
Old 06-25-2009
Are you referring to syscall in Linux?

You need to read this page, then download the kernel source if you want.

http://tldp.org/HOWTO/Implement-Sys-...-i386/x50.html
# 4  
Old 06-25-2009
Perhaps the following will help you. Assuming you are using a 32-bit X86 2.6 Linux kernel .....

0x80 is the value of the software interrupt (INT) which performs the transfer to kernel mode via system_call(). See ../arch/x84/kernel/entry_32.S for the system_call() source.

The syscall interface for open() is defined in ../include/linux/syscalls.h
Code:
asmlinkage long sys_open(const char __user *filename, int flags, int mode);

The system call number for open is defined in ../arch/include/asm/unistd_32.h
Code:
#define __NR_open 5

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

open() system call in c++????

Hi friends, I am trying to use the open system call in c++ language. Please have a look at my code. vi Open.cpp 1 #include <stdio.h> 2 #include <iostream> 3 4 #define BUFSIZE 1 5 6 using namespace std; 7 8 int main() 9 { 10 ... (5 Replies)
Discussion started by: gabam
5 Replies

2. Shell Programming and Scripting

system call

Trying to figure out a load issue with a webserver. I have traced a php script and noticed the following connect(4, {sa_family=AF_INET, sin_port=htons(3306), sin_addr=inet_addr("XX.XX.XX.XX")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000035> poll(, 1, 2000) = 1 () <0.000120>... (5 Replies)
Discussion started by: rajan007
5 Replies

3. Programming

need help with system call

hi everyone i wrote a system call and compiled the kernel succesfully... my system call is in a file in the kernel folder named my_syscall1.c (kernel/my_syscall1.c) the header file for this system call i added it in the folder include like this include/my_syscall1/my_syscall1.h my problem is... (2 Replies)
Discussion started by: demis87
2 Replies

4. Programming

system call

I have a cgi script which is called after certain time interval, which has this: system ("ls -l /tmp/cgic* | grep -v \"cgicsave.env\" | awk '{print $5}'"); During the execution of this script,the output is 0 sometimes. But due to this the system call is not working at all and doesnt o/p... (2 Replies)
Discussion started by: xs2punit
2 Replies

5. Programming

Is there a system call other than 'open' for opening very large files?

Dear all, Inside a C program, I want to open a very big file (about 12 GB) in order to read its content. Here is the code: /* argv contains the path to the file. */ inputFileDescriptor = open(argv, O_RDONLY); if (inputFileDescriptor < 0) { ... (6 Replies)
Discussion started by: dariyoosh
6 Replies

6. Programming

C:system call

Hi I'm studing the system call. I've written a small program that return the time spent in doing some operations. Now I'd like to write one that return the time spent in user mode of a process. I'm reading that i should use the tms struct: clock_t times(struct tms *buf); struct tms {... (2 Replies)
Discussion started by: Dedalus
2 Replies

7. Shell Programming and Scripting

system call

Hi, How to write a system calls in a script ? > cd $HOME > ls -ltr thanks in advance.. (10 Replies)
Discussion started by: hegdeshashi
10 Replies

8. Programming

c system call

How the c compiler differentiates the system calls and function calls? (1 Reply)
Discussion started by: rangaswamy
1 Replies

9. UNIX for Advanced & Expert Users

how to differentiate system call from library call

Hi, Ho do I differentiate system call from library call? for example if I am using chmod , how do I find out if it is a system call or library call? Thanks Muru (2 Replies)
Discussion started by: muru
2 Replies
Login or Register to Ask a Question