Xref: utzoo comp.sys.att:5498 unix-pc.general:2210 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ukma!rutgers!bpa!manta!brant From: brant@manta.pha.pa.us (Brant Cheikes) Newsgroups: comp.sys.att,unix-pc.general Subject: Re: From blocks to files (on a UNIXpc) Summary: Close, but no cigar. Message-ID: <463@manta.pha.pa.us> Date: 10 Feb 89 05:05:23 GMT References: <462@manta.pha.pa.us> <1392@mtunb.ATT.COM> Reply-To: brant@manta.pha.pa.us (Brant Cheikes) Organization: Soul of the Gnu Machine, Philadelphia Lines: 60 In article <462@manta.pha.pa.us> I asked: >Given a block number, how can I find out (a) if it's part of a file, >and (b) what file it's part of? In article <1392@mtunb.ATT.COM> jcm@mtunb.UUCP (was-John McMillan) replied: > [...] I > will simply PRESUME you are referring to: > A LOGICAL BLOCK # on an identified FILE-SYSTEM. This is nearly correct. I meant a 512-byte block #, numbered from zero, with block 0 referring to the boot block. I'm starting from a HDERR message like this: HDERR ST:51 EF:10 CL:FF45 CH:FF01 SN:FF00 SC:FF02 SDH:FF24 DMACNT:FFFF DCRREG:94 MCRREG:9D00 Wed Feb 8 10:00:58 1989 Given CH, CL, SN, and SDH, and knowing my disk stats, I can compute the logical block number. In the above case, for a disk with 8 heads and 16 blocks (sectors) per track, the computation is: cyl # = 0x145 = 325 (decimal), sector 0, head 4. there are 8 heads * 16 blocks/track = 128 blocks/cyl logical block of error = (cylinder# * blocks/cyl) + (head * blocks/track) + sector = (325*128)+(16*4)+0 = 41664. (NB: cylinder, head, and sector are all numbered from zero) Now, knowing that the error occurred in the 41664'th 512-byte block on the disk, I want to determine if that block is in the free list or if it's part of a file. If the latter, I want to know which file it's allocated to. (BTW, I can verify the block is not an inode block as follows: My disk has a 64 LOGICAL (1024-byte) block partition 0, an 8000 LOGICAL block partition 1, and an 114944 512-byte block partition 0. df -t shows a total of 14368 inodes. There are 8 inodes/block (see INOPB for 512-byte FS), so the inodes take up 14368/8 = 1796 512-byte blocks. So data blocks begin at block # (64*2)+(8000*2)+1796=17924. Since 41664 > 17924, the error isn't in an inode block.) John suggested the following approach, given a LOGICAL block #: > As root, run: > /etc/ncheck -i #### -a /dev/rfp### This is not the right answer. The argument to -i is supposed to be an inode number, not a block number (logical or otherwise). So my question remains. But thanks for trying! [NB: if I have said anything incorrect here, I trust that someone will swiftly correct me.] -- Brant Cheikes University of Pennsylvania, Department of Computer and Information Science brant@manta.pha.pa.us, brant@linc.cis.upenn.edu, bpa!manta!brant