lkml.org 
[lkml]   [1999]   [Nov]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subject;( wrapped source-code, try this[Re: pseudo function-call from kernel to a user-process]
see the attachment
--
Marcel Lanz <marcel.lanz@ds9.ch>

PGP-Key fingerprint = 71 BE AC 43 04 53 F9 2D 4F B7 B1 47 E5 9B 91 72
-------------- syscall dkmctl -------
#define DKM_MAP_REQ 1
#define DKM_CSD_REG 2
#define DKM_CSD_DEREG 3
#define DKM_DOSIG 4
#define DKM_MAP_RESP 5
pid_t dkm_csd_pid;
/*spinlock_t dkm_map_lock = SPIN_LOCK_UNLOCKED;*/
struct semaphore dkm_map_sema = MUTEX;
dkm_csd_pid = -1;

asmlinkage int sys_dkmctl(int cmd, void *arg, void *resp)
{
char* node_name;
node_name = (char*) kmalloc(64, GFP_KERNEL);
switch(cmd) {
case DKM_MAP_REQ: /*spin_lock_irqsave(&dkm_map_lock, flags);*/
down(&dkm_map_sema);
copy_to_user((char*)arg, "filename", 9);
break;
case DKM_MAP_RESP: strncpy_from_user(node_name, arg, strlen_user(arg));
printk("node to name is: %s\n", node_name);
/*spin_unlock_irq(&dkm_map_lock);*/
up(&dkm_map_sema);
break;
case DKM_CSD_REG: dkm_csd_pid = *(int*)arg;
break;

case DKM_CSD_DEREG: dkm_csd_pid = -1;
break;

case DKM_DOSIG: if(dkm_csd_pid > 0)
force_sig(SIGUSR2, find_task_by_pid(dkm_csd_pid));
break;
default: break;
} /* switch */
printk("csd_pid is: %d, current->pid is: %d\n", dkm_csd_pid, current->pid);
kfree(node_name);

return 0;
}
------------------------------
signal-handler:
void on_sigusr2(int signal)
{
char* node_name;
char* buff;
node_name = (char*) malloc(64);
buff = (char*) malloc(64);

printf("sigusr2 from kernel reveived\n");
dkmctl(DKM_MAP_REQ, buff, NULL);
printf("buff is: %s\n", buff);
strcpy(node_name, "orinoco");
dkmctl(DKM_MAP_RESP, node_name);

free(node_name);
free(buff);
}
\
 
 \ /
  Last update: 2005-03-22 13:54    [from the cache]
©2003-2011 Jasper Spaans