Mark Post writes:
> >>> On 5/18/2016 at 04:27 PM, Malcolm Beattie <[email protected]> wrote:
> -snip-
> > So an ad hoc and quick and dirty way to write a couple of tracks
> > of a lone R0 that'll be treated by Linux as "n/f" is (starting
> > with DASD device 777 offline):
>
> Cool, it does indeed work.  So I wrapped a script around that and uploaded it 
> to http://wiki.linuxvm.org/wiki/Projects_and_Software/Scripts for anyone 
> that's interested in it.
>
> Bug reports are welcome, but don't expect rapid turnaround.  :)

Having the following "llunformat" as the low-level script that does
the unformatting (invoke as "llunformat devno") may be preferable in
terms of keeping people's lunch down compared to the Perl one-liner:

#!/usr/bin/perl
# Copyright 2016 IBM United Kingdom Ltd
# Author: Malcolm Beattie, IBM
# Last update: 19 May 2016
# Sample code - NO WARRANTY
#
use strict;

sub ckd {
    my ($c, $h, $r, $key, $data) = @_;
    my $count = pack("nnCCn", $c, $h, $r, length($key), length($data));
    return $count . $key . $data;
}

sub track {
    my ($data) = @_;
    return $data . ("\xff" x 8) . ("\0" x (65536 - 8 - length($data)));
}

my $devno = shift @ARGV or die "Usage: llunformat devno\n";
my $dev = sprintf("/dev/disk/by-path/ccw-0.0.%04s", $devno);
my @cmd = (qw(dd bs=65536 oflag=direct), "of=$dev");
open(DD, "|-", @cmd) or die "dd: $!\n";

for (my $h = 0; $h < 2; $h++) {
    print DD track(ckd(0, $h, 0, "", "\0" x 8));
}

--Malcolm

--
Malcolm Beattie
Linux and System z Technical Consultant, zChampion
IBM UK Systems and Technology Group

----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390
----------------------------------------------------------------------
For more information on Linux on System z, visit
http://wiki.linuxvm.org/

Reply via email to