File: cckdfix.c

package info (click to toggle)
hercules 3.07-2.2
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 14,536 kB
  • sloc: ansic: 162,921; sh: 8,522; makefile: 784; perl: 202; sed: 16
file content (117 lines) | stat: -rw-r--r-- 3,272 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// $Id: cckdfix.c 4102 2006-12-08 09:43:35Z jj $
//
// $Log$

#include "hercules.h"
int main ( int argc, char *argv[])
{
int             fd;
CKDDASD_DEVHDR  devhdr;
CCKDDASD_DEVHDR cdevhdr;
int             heads, cyls, devt;
char            pathname[MAX_PATH];

        hostpath(pathname, argv[1], sizeof(pathname));

        fd = open (pathname, O_RDWR|O_BINARY);
        if (fd < 0) return 1;

        read (fd, &devhdr, CKDDASD_DEVHDR_SIZE);
        read (fd, &cdevhdr, CCKDDASD_DEVHDR_SIZE);

        /* --------------------------------------- */
        /* Device header updates                   */
        /* --------------------------------------- */

        /* device identifier */

//      memcpy (devhdr.devid, "CKD_C370", 8);

        /* number of heads per cylinder
           must be in little-endian byte order */

//      devhdr.heads[3] = (heads >> 24) & 0xFF;
//      devhdr.heads[2] = (heads >> 16) & 0xFF;
//      devhdr.heads[1] = (heads >>  8) & 0xFF;
//      devhdr.heads[0] = heads & 0xFF;

        /* device type -- last two digits */

//      devhdr.devtype = devt;      /* eg 0x90 for 3390 */

        /* file sequence number; must be zero for
           compressed ckd dasd emulation */

//      devhdr.fileseq = 0;

        /* highest cylinder on this file; must be zero for
           compressed ckd dasd emulation */

//      devhdr.highcyl[0] = 0;
//      devhdr.highcyl[1] = 0;

//      memset (&devhdr.resv, 0, 492);


        /* --------------------------------------- */
        /* Compressed device header updates        */
        /* --------------------------------------- */

        /* version-release-modification level */

//      cdevhdr.vrm[0] = CCKD_VERSION;
//      cdevhdr.vrm[0] = CCKD_RELEASE;
//      cdevhdr.vrm[0] = CCKD_MODLVL;

        /* options byte */

//      cdevhdr.options = 0;
//      cdevhdr.options |= CCKD_NOFUDGE;
//      cdevhdr.options |= CCKD_BIGENDIAN;
//      cdevhdr.options |= CCKD_OPENED;

        /* lookup table sizes*/

//      cdevhdr.numl1tab = (cyls * heads) >> 8;
//      if ((cyls * heads) & 0xff != 0)
//         cdevhdr.numl1tab++;
//      cdevhdr.numl2tab = 256;

        /* free space header -- set to zeroes to force
           cckdcdsk to rebuild the free space */

//      cdevhdr.size = cdevhdr.used = cdevhdr.free =
//      cdevhdr.free_total = cdevhdr.free_largest =
//      cdevhdr.free_number = cdevhdr.free_imbed = 0;


        /* number of cylinders on the emulated device
           must be in little-endian byte order */

//      cdevhdr.cyls[3] = (cyls >> 24) & 0xFF;
//      cdevhdr.cyls[2] = (cyls >> 16) & 0xFF;
//      cdevhdr.cyls[1] = (cyls >>    8) & 0xFF;
//      cdevhdr.cyls[0] = cyls & 0xFF;

//      cdevhdr.resv1 = 0;

        /* compression algorithm and parameter */

//      cdevhdr.compress = CCKD_COMPRESS_NONE;
//      cdevhdr.compress_parm = 0;

//      cdevhdr.compress = CCKD_COMPRESS_ZLIB;
//      cdevhdr.compress_parm = Z_DEFAULT_COMPRESSION;

//      cdevhdr.compress = CCKD_COMPRESS_BZIP2;
//      cdevhdr.compress_parm = 5;

//      memset (&cdevhdr.resv2, 0, 464);

        lseek (fd, 0, SEEK_SET);
        write (fd, &devhdr, CKDDASD_DEVHDR_SIZE);
        write (fd, &cdevhdr, CCKDDASD_DEVHDR_SIZE);

        close (fd);
        return 0;
}