How do I read an inode?

Jonathan I. Kamens jik at athena.mit.edu
Fri Jul 27 11:05:49 AEST 1990


  (Note the Followup-To and cross-post on this; I don't really think
it's a wizard-level question.)

In article <114837 at linus.mitre.org>, oking at smiley.arpa (Osborne I King)
writes:
|> How do I read inode information associated with
|> a special file for example: a block special file.

  Your subject line says, "How do I read an inode?" and your message
says, "How do I read inode information associated with a special
file..." but I'm still not sure what you're asking.

  What "inode information" are you asking about?  Since you mention
special files in particular, my best guess is that you're talking about
the major and minor device numbers and the device type.  To obtain both
of these, you use the stat() system call, the same way you would to
obtain file information about any regular file.

  In particular, the st_mode field of the stat structure tells you
whether it's a character or block special device (S_IFCHR and S_IFBLK on
BSD, I don't know what it is on others), and the st_rdev field tells you
the major and minor device numbers (the first two bytes are the major
number, and the second two bytes are the minor number).

  If that isn't what you're talking about, please explain a little bit
more clearly what you *are* talking about, so we can help you :-).

Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik at Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8495			      Home: 617-782-0710



More information about the Comp.unix.questions mailing list