old-www/HOWTO/Implement-Sys-Call-Linux-2..../x127.html

203 lines
3.0 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML
><HEAD
><TITLE
>testmycall.h (new user space header file to be created)</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="Implementing a System Call on Linux 2.6 for i386"
HREF="index.html"><LINK
REL="PREVIOUS"
TITLE="New user space files, to be created, to test our system call"
HREF="x125.html"><LINK
REL="NEXT"
TITLE="testmycall.c (new user space source file to be created)"
HREF="x156.html"></HEAD
><BODY
CLASS="sect1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Implementing a System Call on Linux 2.6 for i386</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="x125.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="x156.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="sect1"
><H1
CLASS="sect1"
><A
NAME="AEN127"
></A
>14. testmycall.h (new user space header file to be created)</H1
><P
>testmycall.h</P
><P
></P
><P
></P
><OL
TYPE="1"
><LI
><P
>Create a header file called testmycall.h. This header file should be included by any program calling our system call.</P
></LI
><LI
><P
>Add three lines to it</P
></LI
></OL
><P
></P
><OL
TYPE="1"
><LI
><P
>Line 1: This is needed because we need the definition of _syscall1.</P
></LI
></OL
><P
>#include&#60;linux/unistd.h&#62;</P
><P
></P
><OL
TYPE="1"
><LI
><P
>Line 2: This is needed because we need the number of our system call.</P
></LI
></OL
><P
>#define __NR_mycall 317</P
><P
></P
><OL
TYPE="1"
><LI
><P
>Line 3: This is needed for system calls with 1 argument. It is explained in detail below.</P
></LI
></OL
><P
>_syscall1(long, mycall, int, i)</P
><P
></P
><P
>So, our user header file looks like:</P
><P
></P
><P
>/*---Start of header file------*/</P
><P
>#include&#60;linux/unistd.h&#62;</P
><P
>#define __NR_mycall 317</P
><P
>_syscall1(long, mycall, int, i)</P
><P
>/*---End of header file--------*/</P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="x125.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="x156.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>New user space files, to be created, to test our system call</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>testmycall.c (new user space source file to be created)</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>