Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* How to get the "filename" argument in kernel open() routine on Alpha/OSF1 v3.2?
@ 1997-09-22  4:00 Chung-min Hung
  0 siblings, 0 replies; only message in thread
From: Chung-min Hung @ 1997-09-22  4:00 UTC (permalink / 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);
}




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1997-09-22  4:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1997-09-22  4:00 How to get the "filename" argument in kernel open() routine on Alpha/OSF1 v3.2? Chung-min Hung

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