develooper Front page | perl.perl5.porters | Postings from December 2008

Re: [perl #1154] [RESOLVED] -pi doesn't sanely handle write errors

From:
Morty Abzug
Date:
December 14, 2008 06:03
Subject:
Re: [perl #1154] [RESOLVED] -pi doesn't sanely handle write errors
Message ID:
20081214053016.GA29536@frakir.gsfc.nasa.gov
When I attempted to verify the fix using bleadperl, the bug still
seemed to be there.  I didn't get an error, and the return status was
0.  Am I missing something?

Methodology used to install bleadperl:

  mkdir ~/bleadperl ~/localperl &&
  cd ~/bleadperl &&
  rsync -avz rsync://public.activestate.com/perl-current/ . &&
  ./Configure -des -Dusedevel -Dprefix=$HOME/localperl &&
  make test &&
  make install; finished

Methodology used to test:

#!/bin/sh

# script to demo problem of perl not detecting write errors with -pi
# requires root on a linux system

IMG=/root/floppy.img
IMG_DIR=/root
IMG_SIZE=1440
BS=1024
SOURCE=/dev/zero
MOUNTPOINT=/mnt
MKFS_ARGS="-t ext2"
MOUNT_ARGS="-o loop"
FILE=bar
FILE_SIZE=900
#PERL=/usr/bin/perl
PERL=/home/morty/localperl/bin/perl5.11.0

echo Perl version:
$PERL -v

cd / &&
mkdir -p $IMG_DIR &&
dd if=$SOURCE of=$IMG bs=$BS count=$IMG_SIZE &&
mkfs $MKFS_ARGS $IMG </dev/null &&
mount $MOUNT_ARGS $IMG $MOUNTPOINT &&
cd $MOUNTPOINT &&
dd if=$SOURCE of=$FILE bs=$BS count=$FILE_SIZE &&
echo before running perl: && df -k . && ls -l bar* &&
echo Running perl. . . &&
$PERL -pi~ -e 1 $FILE

echo Done. Status is: $? && df -k . && ls -l bar*

# clean up regardless of status
cd /; umount $MOUNTPOINT; rm $IMG



Output of script above:


Perl version:

This is perl, v5.11.0 DEVEL35082 built for i686-linux
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-2008, Larry Wall

Perl may be copied only under the terms of either the Artistic License
or the
GNU General Public License, which may be found in the Perl 5 source
kit.

Complete documentation for Perl, including FAQ lists, should be found
on
this system using "man perl" or "perldoc perl".  If you have access to
the
Internet, point your browser at http://www.perl.org/, the Perl Home
Page.

1440+0 records in
1440+0 records out
1474560 bytes (1.5 MB) copied, 0.00894997 s, 165 MB/s
mke2fs 1.40.8 (13-Mar-2008)
/root/floppy.img is not a block special device.
Proceed anyway? (y,n) Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
184 inodes, 1440 blocks
72 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=1572864
1 block group
8192 blocks per group, 8192 fragments per group
184 inodes per group

Writing inode tables: done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
900+0 records in
900+0 records out
921600 bytes (922 kB) copied, 0.00389722 s, 236 MB/s
before running perl:
Filesystem           1K-blocks      Used Available Use% Mounted on
/root/floppy.img          1412       924       416  69% /mnt
-rw-r--r-- 1 root root 921600 2008-12-14 00:27 bar
Running perl. . .
Done. Status is: 0
Filesystem           1K-blocks      Used Available Use% Mounted on
/root/floppy.img          1412      1411         0 100% /mnt
-rw-r--r-- 1 root root 495616 2008-12-14 00:27 bar
-rw-r--r-- 1 root root 921600 2008-12-14 00:27 bar~


- Morty (remotely)



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About