/*
 *  linux/ibcs/TESTS/sysfs.c
 *
 *  Copyright (C) 1994  Mike Jagdis (jaggy@purplet.demon.co.uk)
 *
 * $Id: sysfs.c,v 1.1.1.2 1994/02/23 17:23:03 mike Exp $
 * $Source: /var/CVS/ibcs/TESTS/sysfs.c,v $
 */

#include <sys/types.h>
#include <sys/fstyp.h>
#include <sys/fsid.h>
#include <stdio.h>


main(argc, argv)
	int argc;
	char *argv[];
{
	int n_fs, i;
	char buf[1024];

	if (argc == 1) {
		if ((n_fs = sysfs(GETNFSTYP)) < 0) {
			perror("sysfs: GETNFSTYP");
			exit(1);
		}
		printf("%d file system types\n", n_fs);
		for (i=1; i<=n_fs; i++) {
			if (sysfs(GETFSTYP, i, buf) < 0) {
				perror("\nsysfs: GETFSTYP");
			} else {
				printf("%d %s\n", i, buf);
			}
		}
	} else {
		for (n_fs=1; n_fs<argc; n_fs++) {
			if ((i = sysfs(GETFSIND, argv[n_fs])) < 0)
				perror("sysfs: GETFSIND");
			else
				printf("%s is index %d\n", argv[n_fs], i);
		}
	}
}
