On Thu, 29 Mar 2007 00:28:07 +0200 "Rafael J. Wysocki" <[EMAIL PROTECTED]> wrote:
> On Thursday, 29 March 2007 00:14, Tim Dijkstra wrote:
> > On Tue, 27 Mar 2007 23:11:41 +0200
> > "Rafael J. Wysocki" <[EMAIL PROTECTED]> wrote:
> >
> > > > diff -u -r1.70 suspend.c
> > > > --- suspend.c 16 Mar 2007 16:02:22 -0000 1.70
> > > > +++ suspend.c 27 Mar 2007 20:36:52 -0000
> > > > @@ -208,7 +208,7 @@
> > > > swap.offset = offset;
> > > > error = ioctl(dev, SNAPSHOT_SET_SWAP_AREA, &swap);
> > > > if (error && !offset)
> > > > - error = ioctl(dev, SNAPSHOT_SET_SWAP_FILE, blkdev);
> > > > + error = ioctl(dev, SNAPSHOT_SET_SWAP_FILE, (unsigned
> > > > long) blkdev);
> > >
> > > Heh, I wonder. :-)
> >
> >
> > Apparently it worked... IMHO this means the code in user.c should be
> > different. snapshot_ioctl expects an unsigned long, which isn't what
> > the user sends. Would it be useful to use copy_from_user()? (Disclaimer
> > I haven't written a single line of kernel code yet, this is just from
> > reading user.c)
>
> Well, maybe, but then we'd have to redefine the ioctl which I'd rather avoid.
> Besides, the kernel only needs the lower 32 bits anyway, so why should we
> complicate things to pass the remaining 32 zero bits to it for nothing?
>
> The problem is that in fact the kernel expects us to provide a _pointer_
> as arg to the ioctl and unsigned long just happens to be of the same size. So
> I think we can live with your hack in the userland just fine (but please add a
> comment explaining why its needed).
Would this comment suffice?
Index: suspend.c
===================================================================
RCS file: /cvsroot/suspend/suspend/suspend.c,v
retrieving revision 1.70
diff -u -r1.70 suspend.c
--- suspend.c 16 Mar 2007 16:02:22 -0000 1.70
+++ suspend.c 29 Mar 2007 19:42:43 -0000
@@ -207,8 +207,13 @@
swap.dev = blkdev;
swap.offset = offset;
error = ioctl(dev, SNAPSHOT_SET_SWAP_AREA, &swap);
+ /* We cast blkdev to `unsigned long' here because dev_t can be
+ * `unsinged long long' on some architectures. The kernel side expects
+ * a unsigned long however (32 bits is enough). Without the cast this
+ * goes OK on LE, on BE however we end up with the wrong bits...
+ */
if (error && !offset)
- error = ioctl(dev, SNAPSHOT_SET_SWAP_FILE, blkdev);
+ error = ioctl(dev, SNAPSHOT_SET_SWAP_FILE, (unsigned
long)(blkdev));
return error;
}
signature.asc
Description: PGP signature
------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________ Suspend-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/suspend-devel
