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

1.4     ! aaron       1: /*     $OpenBSD: tcfs_flags.c,v 1.3 2000/06/19 20:35:47 fgsch 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: #include <des.h>
                     32:
                     33: tcfs_flags
                     34: tcfs_getflags(int fd)
                     35: {
                     36:        tcfs_flags r;
                     37:        struct stat s;
                     38:
1.4     ! aaron      39:        if (fstat(fd, &s) < 0) {
1.1       provos     40:                 r.flag = -1;
                     41:        } else
                     42:                 r.flag = s.st_flags;
1.4     ! aaron      43:
        !            44:        return (r);
1.1       provos     45: }
                     46:
                     47:
                     48: tcfs_flags
                     49: tcfs_setflags(int fd, tcfs_flags x)
                     50: {
1.2       provos     51:        tcfs_flags r, n;
1.4     ! aaron      52:
1.1       provos     53:        r = tcfs_getflags(fd);
                     54:
                     55:        if (r.flag == -1) {
1.2       provos     56:                r.flag = -1;
1.4     ! aaron      57:                return (r);
1.1       provos     58:        }
                     59:
                     60:        n = x;
1.2       provos     61:        FI_SET_SP(&n, FI_SPURE(&r));
1.1       provos     62:
1.2       provos     63:        if (fchflags(fd, n.flag)) {
                     64:                perror("fchflags");
                     65:                r.flag = -1;
                     66:        }
1.1       provos     67:
1.4     ! aaron      68:        return (r);
1.1       provos     69: }