[BACK]Return to tcfs_flags.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / tcfs

Annotation of src/usr.bin/tcfs/tcfs_flags.c, Revision 1.5

1.5     ! provos      1: /*     $OpenBSD: tcfs_flags.c,v 1.4 2000/06/19 22:42:28 aaron Exp $    */
1.3       fgsch       2:
1.1       provos      3: /*
                      4:  *     Transparent Cryptographic File System (TCFS) for NetBSD
                      5:  *     Author and mantainer:   Luigi Catuogno [luicat@tcfs.unisa.it]
                      6:  *
                      7:  *     references:             http://tcfs.dia.unisa.it
                      8:  *                             tcfs-bsd@tcfs.unisa.it
                      9:  */
                     10:
                     11: /*
                     12:  *     Base utility set v0.1
                     13:  */
                     14:
                     15: #include <stdio.h>
                     16: #include <errno.h>
                     17: #include <fcntl.h>
                     18: #include <sys/types.h>
                     19: #include <ctype.h>
                     20: #include <pwd.h>
                     21: #include <unistd.h>
                     22: #include <sys/param.h>
                     23: #include <sys/mount.h>
                     24: #include <sys/wait.h>
                     25: #include <sys/stat.h>
                     26:
                     27: #include <miscfs/tcfs/tcfs.h>
                     28: #include <miscfs/tcfs/tcfs_fileinfo.h>
                     29: #include "tcfsdefines.h"
                     30:
                     31: tcfs_flags
                     32: tcfs_getflags(int fd)
                     33: {
                     34:        tcfs_flags r;
                     35:        struct stat s;
                     36:
1.4       aaron      37:        if (fstat(fd, &s) < 0) {
1.1       provos     38:                 r.flag = -1;
                     39:        } else
                     40:                 r.flag = s.st_flags;
1.4       aaron      41:
                     42:        return (r);
1.1       provos     43: }
                     44:
                     45:
                     46: tcfs_flags
                     47: tcfs_setflags(int fd, tcfs_flags x)
                     48: {
1.2       provos     49:        tcfs_flags r, n;
1.4       aaron      50:
1.1       provos     51:        r = tcfs_getflags(fd);
                     52:
                     53:        if (r.flag == -1) {
1.2       provos     54:                r.flag = -1;
1.4       aaron      55:                return (r);
1.1       provos     56:        }
                     57:
                     58:        n = x;
1.2       provos     59:        FI_SET_SP(&n, FI_SPURE(&r));
1.1       provos     60:
1.2       provos     61:        if (fchflags(fd, n.flag)) {
                     62:                perror("fchflags");
                     63:                r.flag = -1;
                     64:        }
1.1       provos     65:
1.4       aaron      66:        return (r);
1.1       provos     67: }