given inode and fs, determine if dir or not?

Doug Gwyn gwyn at smoke.BRL.MIL
Wed Nov 23 16:39:31 AEST 1988


In article <25943 at teknowledge-vaxc.ARPA> mkhaw at teknowledge-vaxc.ARPA (Mike Khaw) writes:
>If I have an inode (and fs root) on hand, how do I tell whether that
>inode is a directory or not?  The definition of struct inode suggests
>that it's possible, but I can't find a man entry that says how.

Assuming you have already figured out how to find the disk block
containing the start of the inode, the start of an inode on disk
normally consists of essentially the same information that would
be returned for stat(2) or fstat(2) and a handful of pointers to
the data blocks associated with the inode.  (Slightly
oversimplified.)  There is often a system header file <sys/inode.h>
that describes the on-disk inode structure; watch out, because it
typically includes descriptions of in-core (kernel) data structures,
of which the disk inode information is only a part.

Look in your System Administrator Reference Manual under FS(*)
(where * depends on the vendor) for information about the file
system.



More information about the Comp.unix.wizards mailing list