From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,73449ad79f7b8565,start X-Google-Attributes: gidfee84,public From: Chung-min Hung Subject: How to get the "filename" argument in kernel open() routine on Alpha/OSF1 v3.2? Date: 1997/09/22 Message-ID: <34261C62.A5C9106B@cwb.gov.tw>#1/1 X-Deja-AN: 274566929 Organization: SEEDNET InterNetNews News System Newsgroups: comp.unix.osf.osf1 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 #include ..... 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); }