Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: Chung-min Hung <hjm@cwb.gov.tw>
Subject: How to get the "filename" argument in kernel open() routine on Alpha/OSF1 v3.2?
Date: 1997/09/22	[thread overview]
Message-ID: <34261C62.A5C9106B@cwb.gov.tw> (raw)


Hi !

  On Alpha/OSF1 v3.2, I write a kernel module to replace some
system-call routines by changing the entries of the "sysent" table.

  The following program segment is part of the kernel module I write.
The xxInit() is called to change the "SYS_open" entry of he "sysent"
table.
When user program calls the open(), the newOpen() will be invoked. But
there seems to be something wrong:
1.The copyin() statement works but the "filename" was incorrect. What's
  wrong  with it and how to use the arguments to get "filename" from
user-
  space ?
2.Is the synopsis of kennel open() system call correct ? If not, what
  is the correct synopsis ?

  Could you tell me how to solve these problems ? Thanks.

 hjm@cwb.gov.tw

-----------------------------------------------------------------------

#include <sys/syscall.h>
#include <sys/systm.h>
.....
char filename[32];
int (*sysOpen)() = 0; /* save pointer to original open system call */

xxInit()
{
    /*-----------------------------------------------------------------
     * save the entry pronits of the original system calls
     * the the entry pronits of system calls is save in sysent array
     * (defined in /usr/include/sys/systm.h)
     *----------------------------------------------------------------*/

    sysOpen   = sysent[SYS_open ].sy_call;
    .....

    /*-----------------------------------------------------------------
     * replace entry points of system call by that of new system calls
     *----------------------------------------------------------------*/

    sysent[SYS_open ].sy_call = mssOpen;
    .....
}

int newOpen(a1, a2, a3)
char*a1;
int a2, a3;
{
    int ret;

    /* get the "filename" from user space */
    if ((ret = copyin(a1, filename, 32)) < 0) {
        printf("get filename error = %d\n", ret);
        return(ret);
    }
    filename[32] = 0;
    printf("filename is : %s\n", filename);

    /* call the original open system call */
    ret = sysOpen(a1, a2, a3);
    return(ret);
}




                 reply	other threads:[~1997-09-22  4:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox