summaryrefslogtreecommitdiff
path: root/usr.bin/tcfs/tcfstat.c
blob: 39557ff6db60ea634063b71d0d6a2655671d0de8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
 *	Transparent Cryptographic File System (TCFS) for NetBSD 
 *	Author and mantainer: 	Luigi Catuogno [luicat@tcfs.unisa.it]
 *	
 *	references:		http://tcfs.dia.unisa.it
 *				tcfs-bsd@tcfs.unisa.it
 */

/*
 *	Base utility set v0.1
 */

#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/wait.h>
#include <des.h>

#include <miscfs/tcfs/tcfs.h>

char *stat_usage= "usage: tcfstat [-p mount-point | fs-label]";

int
stat_main(int argc, char *argv[], char *envp[])
{
	struct tcfs_status st;	
	int e,es,ok=0;
	char filesystem[MAXPATHLEN];
	
	if (argc==3 && !strcmp("-p",argv[1])) {
		strlcpy(filesystem, argv[2], sizeof(filesystem));
		ok=1;
	}

	if (argc == 2) {
		if (!(es = tcfs_getfspath(argv[1],filesystem))) {
			fprintf(stderr,"filesystem label not found!\n");
			exit(1);
		}
		ok = 1;
	}

	if (ok == 0 || argc < 2 || argc > 3) {
                fprintf(stderr, "%s\n", stat_usage);
                exit(1);
        }

	
	e = tcfs_getstatus(filesystem, &st);
	if (e == -1) {
		fprintf(stderr,"filesystem %s not mounted\n",filesystem);
		exit(1);
	}
	
	printf("Status: %d; user keys: %d, group keys: %d\n",st.status, st.n_ukey, st.n_gkey);
	printf("TCFS version: %d, Cipher: %s, keysize: %d, cipher version: %d\n",st.tcfs_version, st.cipher_desc, st.cipher_keysize, st.cipher_version);
			
	exit(0);
}