[luau] kernel module, /proc filesystem, and mmap

Jimen Ching jching at flex.com
Sun Oct 20 08:54:01 PDT 2002


On Sun, 20 Oct 2002, Ray Strode wrote:
>>	mode = ...; /* read/write for all... */
>>	entry = create_proc_entry("jimen", mode, NULL);
>>	entry->proc_fops = my_fops;
>My guess is that you probably need to set entry->read_proc and
>entry->write_proc also. (I don't know if you've seen
>linux/Documentation/DocBook/procfs_example.c or not, but it seems like a
>pretty easy example to follow).

Hmm, it seems if proc_fops is set, these two have no effect.  That's not a
big deal, since I only care about mmap'ing a variable.  Even if I did
create these functions, they would be empty stubs.

I'll take a look at the example...

>>		if (remap_page_range(vma->vm_start, (unsigned long)&var,
>offtopic, but that cast doesn't sit well with me (because whose to say
>sizeof(int *) == sizeof(long) ?) For instance on sparc i think that long
>is 32-bit and pointers are 64-bit, so a cast like that would cut off half
>the address's bits.
>That said... I think it must be right because the kernel developers are a
>lot smarter than me :-) and they've prototyped the function that way.

Kernel developers or not, they're still humans, I think.  ;-)

Anyway, I cast the pointer because gcc gave a warning due to the prototype
and argument type mismatch.  You know, the one about implicit cast between
pointer and integer.

>>  But without it, I'm not even getting a valid pointer.
>You mean you are getting a valid pointer, but the value the pointer
>points to doesn't change?

Yes, that's what I meant.  Though I question whether the pointer is
actually valid, since the content never changes, even when I try to modify
it from the application.

>If you sent me your code, I wouldn't mind playing around with it.  I've
>always kinda wanted to learn kernel programming.

I'll send you the code tomorrow via private email.  I need to clean it up
first.  Thanks.

--jc
-- 
Jimen Ching (WH6BRR)      jching at flex.com     wh6brr at uhm.ampr.org




More information about the LUAU mailing list