1*46439007SCharles.Forsyth# 2*46439007SCharles.Forsyth# adapted from /sys/include/disk.h on Plan 9: subject to the Lucent Public License 1.02 3*46439007SCharles.Forsyth# 4*46439007SCharles.ForsythDisks: module 5*46439007SCharles.Forsyth{ 6*46439007SCharles.Forsyth PATH: con "/dis/lib/disks.dis"; 7*46439007SCharles.Forsyth 8*46439007SCharles.Forsyth # disk partition interface 9*46439007SCharles.Forsyth Disk: adt { 10*46439007SCharles.Forsyth prefix: string; 11*46439007SCharles.Forsyth part: string; 12*46439007SCharles.Forsyth fd: ref Sys->FD; 13*46439007SCharles.Forsyth wfd: ref Sys->FD; 14*46439007SCharles.Forsyth ctlfd: ref Sys->FD; 15*46439007SCharles.Forsyth rdonly: int; 16*46439007SCharles.Forsyth dtype: string; # "file", "sd" or "floppy" 17*46439007SCharles.Forsyth 18*46439007SCharles.Forsyth secs: big; 19*46439007SCharles.Forsyth secsize: int; 20*46439007SCharles.Forsyth size: big; 21*46439007SCharles.Forsyth offset: big; # within larger disk, perhaps 22*46439007SCharles.Forsyth width: int; # of disk size in bytes as decimal string 23*46439007SCharles.Forsyth c: int; # geometry: cyl, head, sectors 24*46439007SCharles.Forsyth h: int; 25*46439007SCharles.Forsyth s: int; 26*46439007SCharles.Forsyth chssrc: string; # "part", "disk" or "guess" 27*46439007SCharles.Forsyth 28*46439007SCharles.Forsyth open: fn(f: string, mode: int, noctl: int): ref Disk; 29*46439007SCharles.Forsyth readn: fn(d: self ref Disk, buf: array of byte, n: int): int; 30*46439007SCharles.Forsyth }; 31*46439007SCharles.Forsyth 32*46439007SCharles.Forsyth init: fn(); 33*46439007SCharles.Forsyth 34*46439007SCharles.Forsyth # PC partition grot 35*46439007SCharles.Forsyth PCpart: adt { 36*46439007SCharles.Forsyth active: int; # Active or 0 37*46439007SCharles.Forsyth ptype: int; 38*46439007SCharles.Forsyth base: big; # base block address: 0 or first extended partition in chain 39*46439007SCharles.Forsyth offset: big; # block offset from base to partition 40*46439007SCharles.Forsyth size: big; # in sectors 41*46439007SCharles.Forsyth 42*46439007SCharles.Forsyth extract: fn(a: array of byte, d: ref Disk): PCpart; 43*46439007SCharles.Forsyth bytes: fn(p: self PCpart, d: ref Disk): array of byte; 44*46439007SCharles.Forsyth }; 45*46439007SCharles.Forsyth Toffset: con 446; # offset of partition table in sector 46*46439007SCharles.Forsyth TentrySize: con 2+2*3+4+4; # partition table entry size 47*46439007SCharles.Forsyth NTentry: con 4; # number of table entries 48*46439007SCharles.Forsyth Magic0: con 16r55; 49*46439007SCharles.Forsyth Magic1: con 16rAA; 50*46439007SCharles.Forsyth Active: con 16r80; # partition is active 51*46439007SCharles.Forsyth Type9: con 16r39; # partition type used by Plan 9 and Inferno 52*46439007SCharles.Forsyth 53*46439007SCharles.Forsyth chstext: fn(p: array of byte): string; 54*46439007SCharles.Forsyth}; 55