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