Annotation of src/usr.bin/tcfs/tcfstat.c, Revision 1.5
1.1 provos 1: /*
2: * Transparent Cryptographic File System (TCFS) for NetBSD
3: * Author and mantainer: Luigi Catuogno [luicat@tcfs.unisa.it]
4: *
5: * references: http://tcfs.dia.unisa.it
6: * tcfs-bsd@tcfs.unisa.it
7: */
8:
9: /*
10: * Base utility set v0.1
11: */
12:
13: #include <sys/types.h>
14: #include <sys/param.h>
15: #include <sys/mount.h>
16: #include <sys/wait.h>
1.2 fgsch 17: #include <stdio.h>
18: #include <string.h>
19: #include <unistd.h>
1.1 provos 20:
21: #include <miscfs/tcfs/tcfs.h>
1.2 fgsch 22: #include "tcfslib.h"
1.1 provos 23:
24: char *stat_usage= "usage: tcfstat [-p mount-point | fs-label]";
25:
26: int
27: stat_main(int argc, char *argv[], char *envp[])
28: {
29: struct tcfs_status st;
1.4 aaron 30: int e, es, ok = 0;
1.1 provos 31: char filesystem[MAXPATHLEN];
32:
1.3 aaron 33: if (argc == 3 && !strcmp("-p", argv[1])) {
1.1 provos 34: strlcpy(filesystem, argv[2], sizeof(filesystem));
1.3 aaron 35: ok = 1;
1.1 provos 36: }
37:
38: if (argc == 2) {
1.3 aaron 39: if (!(es = tcfs_getfspath(argv[1], filesystem))) {
40: fprintf(stderr, "filesystem label not found!\n");
1.1 provos 41: exit(1);
42: }
43: ok = 1;
44: }
45:
46: if (ok == 0 || argc < 2 || argc > 3) {
47: fprintf(stderr, "%s\n", stat_usage);
48: exit(1);
49: }
50:
51:
52: e = tcfs_getstatus(filesystem, &st);
53: if (e == -1) {
1.3 aaron 54: fprintf(stderr, "filesystem %s not mounted\n", filesystem);
1.1 provos 55: exit(1);
56: }
57:
1.3 aaron 58: printf("Status: %d; user keys: %d, group keys: %d\n", st.status, st.n_ukey, st.n_gkey);
59: printf("TCFS version: %d, Cipher: %s, keysize: %d, cipher version: %d\n", st.tcfs_version, st.cipher_desc, st.cipher_keysize, st.cipher_version);
1.1 provos 60:
61: exit(0);
62: }
63: