My kernel module loads "modprobe -v my_module --allow-unsupported -o some-data" and I retrieve the "some data" parameter. The following code gave me the entire command line, and here is how I analyzed the parameter of interest:
struct mm_struct *mm; unsigned char x, cmdlen; mm = get_task_mm(current); down_read(&mm->mmap_sem); cmdlen = mm->arg_end - mm->arg_start; for(x=0; x<cmdlen; x++) { if(*(unsigned char *)(mm->arg_start + x) == '-' && *(unsigned char *)(mm->arg_start + (x+1)) == 'o') { break; } } up_read(&mm->mmap_sem); if(x == cmdlen) { printk(KERN_ERR "inject: ERROR - no target specified\n"); return -EINVAL; } strcpy(target,(unsigned char *)(mm->arg_start + (x+3)));
"target" contains the line after the -o option. You can compress this somewhat - the caller (in this case modprobe) will be the first line in mm-> arg_start - according to your needs.
source share