Re: Problem creating a new system call

Saurabh Desai (sdesai@ecs.fullerton.edu)
Sat, 11 Oct 1997 11:47:32 -0700 (PDT)


On Sat, 11 Oct 1997, Shyamalan Pather wrote:

> On Fri, 10 Oct 1997, Saurabh Desai wrote:
> > _syscall2 (int, bdflush, int, mode, int, nr_hints)

Actually, I also tried calling the 'sys_bdflush' system call from a
user level process using the above statement. Here is what happened.
I assume that you have read the code for sys_bdflush() which is in
"fs/buffer.c". Just a brief summary here.

asmlinkage int sys_bdflush(int func, long data)

where 'func' controls the behavior of bdflush. If func=1, bdflush
calls sync_old_buffers() to sync the dirty buffers. For any other
value (greater than 1), it either writes or reads the bdflush_param
structure in the kernel space. For an even value of func, the
appropriate parameter will be written from the data structure in the
kernel space to the user space. For an odd value of func, the param.
will be read from the user space to the kernel space.
When I execute the system call with func=1, it works and
returns 0 (which is right) and I suppose that sync_old buffers() is
called to sync the dirty buffers.
when func is > 1, and an odd number, the return value is again
1, which is right too. (hopefully the param value is written to the
kernel space)
but when func is an even number (that is I am trying to read
the parameter value into the user space), the return value is always
-1 (which I think corresponds to -EPERM). I run this process as a root
so I suppose I should have the privilege of using bdflush.
Any feedback on this ?
thanks.
saurabh desai.

>
> Hello,
>
> In the line above, why is the second argument to syscall2
> "bdflush" instead of "prefetch"? As I understand it, the second argument
> to the syscallX macros is the name of the function you want to call to
> invoke the system call -- in your case, this would be "prefetch".
>
> Hope this helps

I am sorry for the MISTYPE word. It is prefetch in the original code and
not bdflush. Thanks.