Eliot.Henry@samba.acs.unc.edu (BBS Account) (07/27/90)
I am trying to find a way to access the disk drives at the lowest level. I need to read and write to them at the bit level. I have tried pbread but am having trouble getting it to work. I am assuming that the driver for disks is open (but i did try calling open driver ".Sony" this caused another error saying the .sony was not recognized! Help anyone please!
anderson@Apple.COM (Clark Anderson) (07/27/90)
From: Eliot.Henry@samba.acs.unc.edu (BBS Account): >I am trying to find a way to access the disk drives at the lowest level. >I need to read and write to them at the bit level. I have tried pbread but am >having trouble getting it to work. I am assuming that the driver for disks >is open (but i did try calling open driver ".Sony" this caused another error >saying the .sony was not recognized! Help anyone please! The drivers for all mounted disks are already open, otherwise they couldn't be mounted. You only use the name of the driver when you're opening it, after that you use the ref number. The ref number for the Sony floppy driver is -5, the # for a SCSI device is -(SCSI ID+33) (ID0=-33, ID1=-34) Consult the disk driver chapter in IM Vol 2. (David Shayer, replying vicariously through Clark Anderson) --clark -- ----------------------------------------------------------- Clark Anderson InterNet: anderson@apple.com CPU Engineering AppleLink: C.ANDERSON Apple Computer, Inc BellNet: 408-974-4593 "I speak only for myself, much to my employer's relief..." -------------------------------------------------------------
stevec@Apple.COM (Steve Christensen) (07/28/90)
In article <640@beguine.UUCP> Eliot.Henry@samba.acs.unc.edu writes: >I am trying to find a way to access the disk drives at the lowest level. >I need to read and write to them at the bit level. I have tried pbread but am >having trouble getting it to work. I am assuming that the driver for disks >is open (but i did try calling open driver ".Sony" this caused another error >saying the .sony was not recognized! Help anyone please! If you just want to get the contents of the 512 byte blocks on floppies, you just need to do a PBRead(). The driver is already open so you don't need to open it again. Try something like this Pascal snippet: VAR pb : ParamBlockRec; theBuffer : PACKED ARRAY[1..512] OF SignedByte; ... BEGIN ... pb.ioRefNum:=-5; {-5 is .Sony driver's refNum} pb.ioVRefNum:=xxx; {drive number for floppies are 1,2[,3]} pb.ioBuffer:=@theBuffer; {where to put the data} pb.ioReqCount:=512; {how much to read} pb.ioPosMode:=FSFromStart; {position is relative to first block} pb.ioPosOffset:=xxx; {byte offset from start of disk} { = 512 * disk block number} IF PBRead(@pb, FALSE)=NoErr THEN BEGIN {do whatever processing on the data} END; To read more data at a time, just allocate a bigger buffer and increase the value in the ioReqCount field. Theses should be a multiple of 512 bytes. If you need to get at the disks at a lower level than the device manager, that's not recommended since you'll break on the IIfx if not on some future hardware as well... steve -- ____________________________________________________________________ Steve Christensen Internet: stevec@goofy.apple.com Apple Computer, Inc. AppleLink: STEVEC 20525 Mariani Ave, MS 81-CS CompuServe: 76174,1712 Cupertino, CA 95014 "You just contradicted me." "No I didn't." ____________________________________________________________________