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

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: {
        !            48:        tcfs_flags r,n;
        !            49:        r = tcfs_getflags(fd);
        !            50:
        !            51:        if (r.flag == -1) {
        !            52:                 r.flag = -1;
        !            53:                 return r;
        !            54:        }
        !            55:
        !            56:        n = x;
        !            57:        FI_SET_SP(&n,FI_SPURE(&r));
        !            58:
        !            59:        if (fchflags(fd, n.flag))
        !            60:                 r.flag = -1;
        !            61:
        !            62:        return r;
        !            63: }