RE: questions about sysctl

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



You're taking the size of s which is of type ( char * ) which is four
bytes in size. You probably need to to a strlen( s ) to get the size.

John

On Thu, 1 Nov 2001, Jonathan Khoo wrote:

> Hi guys,
>
> I tried a testing on sysctl. In my module, I defined the structure for
> ctl_table and everything works fine. I can see my variable when I do a
> sysctl -a.
> Next, I tried to call sysctl from a program but I can only get 4 bytes
> even though in the ctl_handler I tried to return a string with more than
> 4 bytes.
>
>
> in the module,
> static int handler(ctl_table *table, int *name, int nlen, void *oldval,
> size_t *oldlenp, void *newval, size_t newlen, void **context)
> {
>     char *s = "you called handler";
>     copy_to_user(oldval, s, sizeof(s));
>     return 0;
> }
>
>
> program output:
> you
>
> Does anyone knows where I did wrong?
>
> Many Thanks!
> Jon.
>
> -----Original Message-----
> From: owner-kernelnewbies@nl.linux.org
> [mailto:owner-kernelnewbies@nl.linux.org] On Behalf Of Jonathan Khoo
> Sent: Wednesday, October 31, 2001 1:27 PM
> To: kernelnewbies@nl.linux.org
> Subject: questions about sysctl
>
>
> Hi guys,
>
> Can anyone please explain to me the significance of proc_handler and
> ctl_handler in sysctl?
> Am I right to say that, if proc_handler is defined, the user will find
> an entry in /proc/sys for runtime manipulation. ctl_handler on the other
> hand is called upon, when the user calls sysctl(....) from a program.
> Another question I have is that can I used a user-defined structure
> (other than int) for the data to be used in proc_handler?
>
>
> Thanks for any advices!
> Jon.
>
>
>

-- 
John Tyner
jtyner@cs.ucr.edu

-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.kernelnewbies.org/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux