Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 5 Dec 2001 16:02:51 -0700
From:      Chad David <davidc@acns.ab.ca>
To:        Wayne Pascoe <freebsd@molemanarmy.com>
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: Repost - f_type value in statfs structure
Message-ID:  <20011205160251.A20136@colnta.acns.ab.ca>
In-Reply-To: <86wv01tijn.fsf@pan.home.penguinpowered.org.uk>; from freebsd@molemanarmy.com on Wed, Dec 05, 2001 at 10:21:16PM %2B0000
References:  <86wv01tijn.fsf@pan.home.penguinpowered.org.uk>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Dec 05, 2001 at 10:21:16PM +0000, Wayne Pascoe wrote:
> Hi all,
> 
> Sorry to repost this, but I'm still trying to nail this issue. Any
> assistance would be much appreciated.
> 
> I've written an application that uses getmntinfo which creates an
> array of statfs structs and stores information about mounted
> filesystems there.
> 
> The issue that I am having is detecting valid filesystems to do
> further checks on. I am only interested in checking local filesystems
> such as UFS. 

Check for the MNT_LOCAL flag in f_flags.

For example:

#include <sys/param.h>
#include <sys/ucred.h>
#include <sys/mount.h>
#include <stdio.h>

int
main() {
struct statfs *fs, *fsa;
int cnt;

	cnt = getmntinfo(&fsa, 0);

	if (!cnt) {
		fprintf(stderr, "getmntinfo() failed\n");
		exit(1);
	}

	for (fs = fsa; cnt != 0; fs++, cnt--)
		printf("%s %d\n", fs->f_fstypename, (fs->f_flags & MNT_LOCAL) == MNT_LOCAL);

	exit(0);
}

Hope that helps.

-- 
Chad David        davidc@acns.ab.ca
ACNS Inc.         Calgary, Alberta Canada

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011205160251.A20136>