hercules-390 / hyperion

Hercules 390
Other
252 stars 70 forks source link

Bug in shadow file name construction #58

Closed ghost closed 9 years ago

ghost commented 9 years ago

According to the documentation:

The shadow file name should have spot where the shadow
file number will be set.  This is either the character preceding
the last period after the last slash or the last character if there
is no period.

For example:

    0100  3390  disks/linux1.dsk  sf=shadows/linux1_*.dsk

The existing code however does not behave this way. Instead, it places the shadow file number immediately before the first period found in the shadow file name, not the last period. For example, if I use the following configuration file statement:

0000  2305  a.b.c.cckd  ro  sf=a.b.c_Shadow_*.cckd

I get an error and my dasd image is not opened:

HHC00403I 0:0000 CKD file a.b.c.cckd: opening as r/o
HHC00414I 0:0000 CKD file a.b.c.cckd: cyls 48 heads 8 tracks 384 trklen 14336
HHC00301E 0:0000 CCKD file[1] 1.b.c_Shadow_*.cckd: error in function open(): Invalid argument

This is because the asterisk ('') character is an illegal file name character. The asterisk in the preceding shadow file name is where the shadow file number should have been placed, according to the documentation. As you can see, however, it instead replaced the character immediately before the first period, yielding an illegal file name of "1.b.cShadow.cckd".

If I instead replace the periods with underscores however (leaving the period and file extension intact):

0000  2305  a.b.c.cckd  ro  sf=a_b_c_Shadow_*.cckd

Then it works fine:

HHC00403I 0:0000 CKD file a.b.c.cckd: opening as r/o
HHC00414I 0:0000 CKD file a.b.c.cckd: cyls 48 heads 8 tracks 384 trklen 14336
HHC02198I Device 0000 type 2305 subchannel 0:0000 attached

Looking at the code, it appears the bug is being caused by ckddasd.c (and fbadasd.c) mistakenly doing a "strchr" to locate the first period instead of doing a "strrchr" to locate the last period.

(Note: this is not simply a documentation bug.)