Fwd: swapon and swapoff testcases on busybox

Riaz Rahaman rahaman.riaz at gmail.com
Tue Mar 13 07:39:30 UTC 2007


does you swapon call not give any errors?

I find that in the busybox swaponoff.c code..they check for for holes basing
on assumption that each block is of size 512bytes.

busybox code: swaponoff.c
*********************************************************************
     if (S_ISREG(st.st_mode))
               if (st.st_blocks * 512 < st.st_size)
                       bb_error_msg_and_die("swap file has holes");
*********************************************************************

/ # dd if=/dev/zero of=swappyfile bs=1 count=1 seek=500000
1+0 records in
1+0 records out
/ # ./stat_riaz   --> a small binary that does a stat on swappyfile and
prints the below values
stat_buf.st_blocks: 506
stat_buf.st_size: 500001
stat_buf.st_blksize: 512

based on the swaponoff.c code check                if (st.st_blocks * 512 <
st.st_size)

506 *512 < 500001 ----> 259072 < 500001 which is true and you get a message
that file has holes...

by the way I find that the swapon syscall is giving me error that the swap
file has holes....

I am using arm gcc 3.4.4 compiler and linux kernel 2.6.10.


Riaz



On 3/12/07, Bernhard Fischer <rep.dot.nop at gmail.com> wrote:
>
> On Mon, Mar 12, 2007 at 01:50:55PM +0100, Bernhard Fischer wrote:
> >On Mon, Mar 12, 2007 at 04:37:04PM +0530, Riaz Rahaman wrote:
> >>In case this might be related to swapon functionality of busybox
> >
> >swapon/off works for me. mkswap is foobared, though:
>
> scratch that, mkswap from svn works fine in contrast to the old, stale
> version i had lying around.
>
> What version are you using, what compiler, libc, arch?
>
> Make sure to run mkswap before trying to swapon.
>
> $ ./busybox dd if=/dev/zero bs=1 seek=500000 count=1 of=swapfile01
> $ ./busybox mkswap swapfile01                                Setting up
> swapspace version 1, size = 495906 bytes
> # ./busybox swapon ./swapfile01
> # ./busybox swapoff ./swapfile01
>
> thanks,
> Bernhard
>
> >>---------- Forwarded message ----------
> >>From: Riaz Rahaman <rahaman.riaz at gmail.com>
> >>Date: Mar 12, 2007 4:36 PM
> >>Subject: swapon and swapoff testcases on busybox
> >>To: ltp-list at lists.sourceforge.net
> >>
> >>Hi,
> >>
> >>I am trying to run swapon and swapoff function on busybox....
> >>
> >>I get this error
> >>
> >>swapon: swapfile01 has holes
> >>swapon: ./swapfile01: Invalid argument
> >>
> >>when trying to enable swap file, did anyone face similar problem?
> >>
> >>I ever tried by creating a swapfile on a different machine and got it to
> >>this machine and ran the testcase....but got the same error...not sure
> if
> >>there is a problem with the swapon function of the busybox or something
> >>passed wrongly in the testcase.
> >>
> >>
> >>--
> >>Regards,
> >>Riaz Ur Rahaman
> >>
> >>--
> >>Regards,
> >>Riaz Ur Rahaman
> >
> >>_______________________________________________
> >>busybox mailing list
> >>busybox at busybox.net
> >>http://busybox.net/cgi-bin/mailman/listinfo/busybox
> >_______________________________________________
> >busybox mailing list
> >busybox at busybox.net
> >http://busybox.net/cgi-bin/mailman/listinfo/busybox
> >
>



-- 
Regards,
Riaz Ur Rahaman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.busybox.net/pipermail/busybox/attachments/20070313/6fd3055b/attachment.htm 


More information about the busybox mailing list