[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.6

1.6     ! fgsch       1: /*     $OpenBSD: tcfs_flags.c,v 1.5 2000/06/20 01:29:14 provos 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:
1.6     ! fgsch      15: #include <sys/types.h>
        !            16: #include <sys/mount.h>
        !            17: #include <sys/param.h>
        !            18: #include <sys/stat.h>
        !            19: #include <sys/wait.h>
        !            20: #include <ctype.h>
1.1       provos     21: #include <errno.h>
                     22: #include <fcntl.h>
                     23: #include <pwd.h>
1.6     ! fgsch      24: #include <stdio.h>
1.1       provos     25: #include <unistd.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.6     ! fgsch      37:        if (fstat(fd, &s) < 0)
1.1       provos     38:                 r.flag = -1;
1.6     ! fgsch      39:        else
1.1       provos     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: }