Re: RLove's Linux Kernel Development, 2ed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2005-06-24 at 15:21, Aman Wardak wrote:
> On page 73, he has put down 2 lines of code that we can use to use
> the open system call without explicit library support.  The book reads
> "Placing this macro in an application is all that is required to use
> the open() system call".  I have used these 2 lines in my code as
> follows:
> 
> #define __NR_open 5
> _syscall3(long, open, const char *, filename, int, flags, int, mode)
> 
  _syscall3 is a macro defined in asm/unistd.h, included from
sys/syscall.h.  Add a '#include <sys/syscall.h>' at the top, and delete
the line that defines __NR_open (it is also defined when you include
sys/syscall.h).

> int main()
> {
>        long ret;
> 
>        ret = open("/root/tmp", 02, 00700);
> 
>        return ret;
> }
> 
> 
> However i get this when compiling:
> 
> # gcc syscall_open.c
> syscall_open.c:3: parse error before "open"
> syscall_open.c: In function `_syscall3':
> syscall_open.c:6: parse error before '{' token
> syscall_open.c:6: declaration for parameter `main' but no such parameter
> 
> 
> What am I doing wrong?
> 
> --
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive:       http://mail.nl.linux.org/kernelnewbies/
> FAQ:           http://kernelnewbies.org/faq/
> 
> 


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux