1 /* CCKDFIX.C    (c) Copyright Greg Smith, 2000-2009                  */
2 /*              Correct compressed CKD file.                         */
3 
4 #include "hercules.h"
main(int argc,char * argv[])5 int main ( int argc, char *argv[])
6 {
7 int             fd;
8 CKDDASD_DEVHDR  devhdr;
9 CCKDDASD_DEVHDR cdevhdr;
10 int             heads, cyls, devt;
11 char            pathname[MAX_PATH];
12 
13         hostpath(pathname, argv[1], sizeof(pathname));
14 
15         fd = hopen(pathname, O_RDWR|O_BINARY);
16         if (fd < 0) return 1;
17 
18         read (fd, &devhdr, CKDDASD_DEVHDR_SIZE);
19         read (fd, &cdevhdr, CCKDDASD_DEVHDR_SIZE);
20 
21         /* --------------------------------------- */
22         /* Device header updates                   */
23         /* --------------------------------------- */
24 
25         /* device identifier */
26 
27 //      memcpy (devhdr.devid, "CKD_C370", 8);
28 
29         /* number of heads per cylinder
30            must be in little-endian byte order */
31 
32 //      devhdr.heads[3] = (heads >> 24) & 0xFF;
33 //      devhdr.heads[2] = (heads >> 16) & 0xFF;
34 //      devhdr.heads[1] = (heads >>  8) & 0xFF;
35 //      devhdr.heads[0] = heads & 0xFF;
36 
37         /* device type -- last two digits */
38 
39 //      devhdr.devtype = devt;      /* eg 0x90 for 3390 */
40 
41         /* file sequence number; must be zero for
42            compressed ckd dasd emulation */
43 
44 //      devhdr.fileseq = 0;
45 
46         /* highest cylinder on this file; must be zero for
47            compressed ckd dasd emulation */
48 
49 //      devhdr.highcyl[0] = 0;
50 //      devhdr.highcyl[1] = 0;
51 
52 //      memset (&devhdr.resv, 0, 492);
53 
54 
55         /* --------------------------------------- */
56         /* Compressed device header updates        */
57         /* --------------------------------------- */
58 
59         /* version-release-modification level */
60 
61 //      cdevhdr.vrm[0] = CCKD_VERSION;
62 //      cdevhdr.vrm[0] = CCKD_RELEASE;
63 //      cdevhdr.vrm[0] = CCKD_MODLVL;
64 
65         /* options byte */
66 
67 //      cdevhdr.options = 0;
68 //      cdevhdr.options |= CCKD_NOFUDGE;
69 //      cdevhdr.options |= CCKD_BIGENDIAN;
70 //      cdevhdr.options |= CCKD_OPENED;
71 
72         /* lookup table sizes*/
73 
74 //      cdevhdr.numl1tab = (cyls * heads) >> 8;
75 //      if ((cyls * heads) & 0xff != 0)
76 //         cdevhdr.numl1tab++;
77 //      cdevhdr.numl2tab = 256;
78 
79         /* free space header -- set to zeroes to force
80            cckdcdsk to rebuild the free space */
81 
82 //      cdevhdr.size = cdevhdr.used = cdevhdr.free =
83 //      cdevhdr.free_total = cdevhdr.free_largest =
84 //      cdevhdr.free_number = cdevhdr.free_imbed = 0;
85 
86 
87         /* number of cylinders on the emulated device
88            must be in little-endian byte order */
89 
90 //      cdevhdr.cyls[3] = (cyls >> 24) & 0xFF;
91 //      cdevhdr.cyls[2] = (cyls >> 16) & 0xFF;
92 //      cdevhdr.cyls[1] = (cyls >>    8) & 0xFF;
93 //      cdevhdr.cyls[0] = cyls & 0xFF;
94 
95 //      cdevhdr.resv1 = 0;
96 
97         /* compression algorithm and parameter */
98 
99 //      cdevhdr.compress = CCKD_COMPRESS_NONE;
100 //      cdevhdr.compress_parm = 0;
101 
102 //      cdevhdr.compress = CCKD_COMPRESS_ZLIB;
103 //      cdevhdr.compress_parm = Z_DEFAULT_COMPRESSION;
104 
105 //      cdevhdr.compress = CCKD_COMPRESS_BZIP2;
106 //      cdevhdr.compress_parm = 5;
107 
108 //      memset (&cdevhdr.resv2, 0, 464);
109 
110         lseek (fd, 0, SEEK_SET);
111         write (fd, &devhdr, CKDDASD_DEVHDR_SIZE);
112         write (fd, &cdevhdr, CCKDDASD_DEVHDR_SIZE);
113 
114         close (fd);
115         return 0;
116 }
117