hemwire at yahoo.co.in
Fri Dec 24 05:00:36 EST 2010
Hi Dave & Nilesh,
Thanks for your support I fixed it,
--- On Fri, 24/12/10, Nilesh Tayade <nilesh.tayade at netscout.com> wrote:
> From: Nilesh Tayade <nilesh.tayade at netscout.com>
> Subject: Re: copy_to_user
> To: "Dave Hylands" <dhylands at gmail.com>
> Cc: "Srinivas G." <srinivasg at esntechnologies.co.in>, "Dexter Haslem" <dexter.haslem at gmail.com>, "Hemanth Kumar" <hemwire at yahoo.co.in>, "mukti jain" <muktijn at gmail.com>, Kernelnewbies at kernelnewbies.org
> Date: Friday, 24 December, 2010, 2:50 PM
> On Fri, 2010-12-24 at 01:00 -0800,
> Dave Hylands wrote:
> > Hi Nilesh.
> > On Thu, Dec 23, 2010 at 11:59 PM, Nilesh Tayade
> > <nilesh.tayade at netscout.com>
> > ...snip...
> > > I tried it, and it seems adding mutex_init()
> works as Mukti mentioned. I
> > > did get a kernel oops before (but no segfault).
> After adding
> > > mutex_init() there is no oops/segfault. The code,
> however, is reading
> > > the garbage, that needs to be fixed.
> > char n;
> > short a = *((short *)&n);
> > short b = *((short *)&n);
> > short c = *((short *)&n);
> > This sets a b and c to have essentially random
> > nbytes = read(
> fd, n, 40);
> > This causes the value of n to change. However, the
> values of a, b, and
> > c retain the same random values you assigned them
> > printf( "\r a =
> %d \n ", a);
> > printf("\r b =
> %d \n",b);
> > printf("\r c =
> %d \n",c);
> > This prints the random values of a, b, and c rather
> than printing thee
> > values of n that you read in.
> Thanks for the explanation Dave.
> I did not really bother to debug to avoid the garbage
> values, as the
> main concern was for segfault and kernel oops.
> > Dave Hylands
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
More information about the Kernelnewbies