how to know the file system type [programming]

Dan Nelson dnelson at allantgroup.com
Wed Aug 17 20:28:26 GMT 2005


In the last episode (Aug 17), Jorge Mario G. Mazo said:
>  --- jdyke <jdyke at azimainc.com> escribió:
> > Jorge Mario G. Mazo wrote:
> > > hi there
> > > I've been looking for a way to check the fs type
> > > I need to do something like this
> > > 
> > > if NTFS do this
> > > if msdis do that
> > > if ufs2  do that
> > > if ext2 do this other stuff
>
> it has to be pure C and parsing the fstab in C is not an option! also
> what about if the partition is not in fstab?

You didn't say anything about needing it in C :)  The answer is much
easier then; just call statfs() and look at the f_fstypename field. 
See the statfs manpage for more details.

-- 
	Dan Nelson
	dnelson at allantgroup.com


More information about the freebsd-questions mailing list