Synopsis: 'swapctl -s [-k]' wrong output format
Category: system
Environment:
System : OpenBSD 4.8
Details : OpenBSD 4.8 (GENERIC) #2: Fri Feb 18 01:05:02 CET 2011
[email protected]:/usr/src/sys/arch/i386/compile/GENERIC
Architecture: OpenBSD.i386
Machine : i386
Description:
swapctl -s yields 1K blocks in spite of -k absence making up for the
same
output in either case moreover with an unfortunate unit suffix of 'k'
How-To-Repeat:
localhost p5 $ swapctl -l
Device 512-blocks Used Avail Capacity Priority
swap_device 2096656 0 2096656 0% 0
/dev/wd0l 4195296 0 4195296 0% 0
Total 6291952 0 6291952 0%
localhost p5 $
localhost p5 $ swapctl -lk
Device 1K-blocks Used Avail Capacity Priority
swap_device 1048328 0 1048328 0% 0
/dev/wd0l 2097648 0 2097648 0% 0
Total 3145976 0 3145976 0%
localhost p5 $
localhost p5 $ swapctl -s
total: 3145976k bytes allocated = 0k used, 3145976k available
localhost p5 $
localhost p5 $ swapctl -sk
total: 3145976k bytes allocated = 0k used, 3145976k available
localhost p5 $
Fix:
diff -u -p swaplist.c.orig swaplist.c
--- swaplist.c.orig Thu Jul 26 19:03:05 2007
+++ swaplist.c Mon May 16 22:43:38 2011
@@ -68,13 +68,13 @@ list_swap(int pri, int kflag, int pflag, int dolong)
rnswap, nswap);
pathmax = 11;
- if (dolong) {
- if (kflag) {
+ if (kflag) {
header = "1K-blocks";
blocksize = 1024;
hlen = strlen(header);
} else
header = getbsize(&hlen, &blocksize);
+ if (dolong) {
for (i = rnswap; i-- > 0; sep++)
if (pathmax < (l = strlen(sep->se_path)))
pathmax = l;
@@ -105,11 +105,12 @@ list_swap(int pri, int kflag, int pflag, int dolong)
}
}
if (dolong == 0)
- printf("total: %ldk bytes allocated = %ldk used, "
- "%ldk available\n",
- (long)(dbtoqb(totalsize) / 1024),
- (long)(dbtoqb(totalinuse) / 1024),
- (long)(dbtoqb(totalsize - totalinuse) / 1024));
+ printf("total: %ld %*s allocated, %ld used, "
+ "%ld available\n",
+ (long)(dbtoqb(totalsize) / blocksize),
+ hlen, header,
+ (long)(dbtoqb(totalinuse) / blocksize),
+ (long)(dbtoqb(totalsize - totalinuse) / blocksize));
else if (ncounted > 1)
(void)printf("%-*s %*ld %8ld %8ld %5.0f%%\n", pathmax, "Total",
hlen,
After fix:
localhost p5 $ ./swapctl -l
Device 512-blocks Used Avail Capacity Priority
swap_device 2096656 0 2096656 0% 0
/dev/wd0l 4195296 0 4195296 0% 0
Total 6291952 0 6291952 0%
localhost p5 $
localhost p5 $ ./swapctl -lk
Device 1K-blocks Used Avail Capacity Priority
swap_device 1048328 0 1048328 0% 0
/dev/wd0l 2097648 0 2097648 0% 0
Total 3145976 0 3145976 0%
localhost p5 $
localhost p5 $ ./swapctl -s
total: 6291952 512-blocks allocated, 0 used, 6291952 available
localhost p5 $
localhost p5 $ ./swapctl -sk
total: 3145976 1K-blocks allocated, 0 used, 3145976 available
localhost p5 $
dmesg:
OpenBSD 4.8 (GENERIC) #2: Fri Feb 18 01:05:02 CET 2011
[email protected]:/usr/src/sys/arch/i386/compile/GENERIC
cpu0: Intel(R) Celeron(R) CPU 2.00GHz ("GenuineIntel" 686-class) 2 GHz
cpu0:
FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,SBF,CNXT-ID,xTPR
real mem = 527949824 (503MB)
avail mem = 509353984 (485MB)
mainbus0 at root
bios0 at mainbus0: AT/286+ BIOS, date 12/30/02, BIOS32 rev. 0 @ 0xeba00,
SMBIOS rev. 2.3 @ 0xfb360 (46 entries)
bios0: vendor Compaq version "686O2 v2.20" date 12/30/2002
bios0: Compaq 07E4h
acpi0 at bios0: rev 0
acpi0: sleep states S0 S1 S3 S4 S5
acpi0: tables DSDT FACP SSDT SSDT SSDT SSDT SSDT SSDT SSDT SSDT SSDT
SSDT SSDT SSDT SSDT SSDT SSDT SSDT
acpi0: wakeup devices PCI0(S4) HUB_(S4) COM1(S4) COM2(S4) USB1(S3)
USB2(S3) USB3(S3) EUSB(S3) PBTN(S4)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpiprt0 at acpi0: bus 5 (HUB_)
acpiprt1 at acpi0: bus 0 (PCI0)
acpicpu0 at acpi0
acpibtn0 at acpi0: PBTN
bios0: ROM list: 0xc0000/0xac00! 0xcac00/0x1800 0xcc400/0x4800
0xeaa00/0x5600!
cpu0 at mainbus0: (uniprocessor)
pci0 at mainbus0 bus 0: configuration mode 1 (bios)
pchb0 at pci0 dev 0 function 0 "Intel 82845G Host" rev 0x01
vga1 at pci0 dev 2 function 0 "Intel 82845G Video" rev 0x01
wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
intagp0 at vga1
agp0 at intagp0: aperture at 0xf0000000, size 0x8000000
inteldrm0 at vga1: irq 10
drm0 at inteldrm0
uhci0 at pci0 dev 29 function 0 "Intel 82801DB USB" rev 0x01: irq 10
uhci1 at pci0 dev 29 function 1 "Intel 82801DB USB" rev 0x01: irq 11
ehci0 at pci0 dev 29 function 7 "Intel 82801DB USB" rev 0x01: irq 5
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 "Intel EHCI root hub" rev 2.00/1.00 addr 1
ppb0 at pci0 dev 30 function 0 "Intel 82801BA Hub-to-PCI" rev 0x81
pci1 at ppb0 bus 5
pciide0 at pci1 dev 4 function 0 "CMD Technology SiI3512 SATA" rev 0x01: DMA
pciide0: using irq 10 for native-PCI interrupt
pciide0: port 0: device present, speed: 1.5Gb/s
wd0 at pciide0 channel 0 drive 0: <ST3250310NS>
wd0: 16-sector PIO, LBA48, 238475MB, 488397168 sectors
wd0(pciide0:0:0): using BIOS timings, Ultra-DMA mode 6
fxp0 at pci1 dev 8 function 0 "Intel PRO/100 VM" rev 0x81, i82562: irq
5, address 00:0b:cd:a1:60:a8
inphy0 at fxp0 phy 1: i82562EM 10/100 PHY, rev. 0
ichpcib0 at pci0 dev 31 function 0 "Intel 82801DB LPC" rev 0x01
pciide1 at pci0 dev 31 function 1 "Intel 82801DB IDE" rev 0x01: DMA,
channel 0 configured to compatibility, channel 1 configured to compatibility
pciide1: channel 0 disabled (no drives)
atapiscsi0 at pciide1 channel 1 drive 0
scsibus0 at atapiscsi0: 2 targets
cd0 at scsibus0 targ 0 lun 0: <HL-DT-ST, DVD-ROM GDR8161B, 0037> ATAPI
5/cdrom removable
cd0(pciide1:1:0): using PIO mode 4, Ultra-DMA mode 3
auich0 at pci0 dev 31 function 5 "Intel 82801DB AC97" rev 0x01: irq 5,
ICH4 AC97
ac97: codec id 0x41445372 (Analog Devices AD1981A)
ac97: codec features headphone, 20 bit DAC, No 3D Stereo
audio0 at auich0
usb1 at uhci0: USB revision 1.0
uhub1 at usb1 "Intel UHCI root hub" rev 1.00/1.00 addr 1
usb2 at uhci1: USB revision 1.0
uhub2 at usb2 "Intel UHCI root hub" rev 1.00/1.00 addr 1
isa0 at ichpcib0
isadma0 at isa0
com0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo
com1 at isa0 port 0x2f8/8 irq 3: ns16550a, 16 byte fifo
pckbc0 at isa0 port 0x60/5
pckbd0 at pckbc0 (kbd slot)
pckbc0: using irq 1 for kbd slot
wskbd0 at pckbd0: console keyboard, using wsdisplay0
pmsi0 at pckbc0 (aux slot)
pckbc0: using irq 12 for aux slot
wsmouse0 at pmsi0 mux 0
pcppi0 at isa0 port 0x61
spkr0 at pcppi0
lpt0 at isa0 port 0x378/4 irq 7
npx0 at isa0 port 0xf0/16: reported by CPUID; using exception 16
fdc0 at isa0 port 0x3f0/6 irq 6 drq 2
fd0 at fdc0 drive 0: 1.44MB 80 cyl, 2 head, 18 sec
biomask ed65 netmask ed65 ttymask ffff
mtrr: Pentium Pro MTRR support
umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI Technologies
HUAWEI Mobile Modem" rev 1.10/0.00 addr 2
ucom0 at umsm0
umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI Technologies
HUAWEI Mobile Modem" rev 1.10/0.00 addr 2
ucom1 at umsm1
umass0 at uhub1 port 2 configuration 1 interface 2 "HUAWEI Technologies
HUAWEI Mobile Modem" rev 1.10/0.00 addr 2
umass0: using SCSI over Bulk-Only
scsibus1 at umass0: 2 targets, initiator 0
cd1 at scsibus1 targ 1 lun 0: <HUAWEI, Mass Storage, 2.31> SCSI2 5/cdrom
removable
softraid0 at root
root on wd0a swap on wd0b dump on wd0b
usbdevs:
Controller /dev/usb0:
addr 1: high speed, self powered, config 1, EHCI root hub(0x0000),
Intel(0x8086), rev 1.00
port 1 powered
port 2 powered
port 3 powered
port 4 powered
port 5 powered
port 6 powered
Controller /dev/usb1:
addr 1: full speed, self powered, config 1, UHCI root hub(0x0000),
Intel(0x8086), rev 1.00
port 1 powered
port 2 addr 2: full speed, power 500 mA, config 1, HUAWEI Mobile
Modem(0x1003), HUAWEI Technologies(0x12d1), rev 0.00
Controller /dev/usb2:
addr 1: full speed, self powered, config 1, UHCI root hub(0x0000),
Intel(0x8086), rev 1.00
port 1 powered
port 2 powered
/ty
----------------------------------------------------------------
Najtansze samochody w Polsce!
Odwiedz >> http://linkint.pl/f29ab