Annotation of src/usr.bin/tcfs/tcfs_flags.c, Revision 1.2
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 <stdio.h>
14: #include <errno.h>
15: #include <fcntl.h>
16: #include <sys/types.h>
17: #include <ctype.h>
18: #include <pwd.h>
19: #include <unistd.h>
20: #include <sys/param.h>
21: #include <sys/mount.h>
22: #include <sys/wait.h>
23: #include <sys/stat.h>
24:
25: #include <miscfs/tcfs/tcfs.h>
26: #include <miscfs/tcfs/tcfs_fileinfo.h>
27: #include "tcfsdefines.h"
28:
29: #include <des.h>
30:
31: tcfs_flags
32: tcfs_getflags(int fd)
33: {
34: tcfs_flags r;
35: struct stat s;
36:
37: if (fstat(fd,&s) < 0) {
38: r.flag = -1;
39: } else
40: r.flag = s.st_flags;
41: return r;
42: }
43:
44:
45: tcfs_flags
46: tcfs_setflags(int fd, tcfs_flags x)
47: {
1.2 ! provos 48: tcfs_flags r, n;
1.1 provos 49: r = tcfs_getflags(fd);
50:
51: if (r.flag == -1) {
1.2 ! provos 52: r.flag = -1;
! 53: return r;
1.1 provos 54: }
55:
56: n = x;
1.2 ! provos 57: FI_SET_SP(&n, FI_SPURE(&r));
1.1 provos 58:
1.2 ! provos 59: if (fchflags(fd, n.flag)) {
! 60: perror("fchflags");
! 61: r.flag = -1;
! 62: }
1.1 provos 63:
64: return r;
65: }