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

Annotation of src/usr.bin/tcfs/tcfsflag.c, Revision 1.1.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 <des.h>
                     24:
                     25: #include <miscfs/tcfs/tcfs.h>
                     26: #include <miscfs/tcfs/tcfs_fileinfo.h>
                     27: #include "tcfsdefines.h"
                     28:
                     29: tcfs_flags tcfs_getflags(int);
                     30: tcfs_flags tcfs_setflags(int,tcfs_flags);
                     31:
                     32: int
                     33: flags_main(int argc, char *argv[])
                     34: {
                     35:        int fd;
                     36:        tcfs_flags i;
                     37:
                     38:        if (argc < 3) {
                     39:                fprintf (stderr, "tcfsflags {r,x,g} file\n\n");
                     40:                exit(1);
                     41:        }
                     42:
                     43:        fd = open(argv[2],O_RDONLY);
                     44:        if (!fd) {
                     45:                fprintf(stderr, "open failed\n");
                     46:                exit(1);
                     47:        }
                     48:
                     49:        i = tcfs_getflags(fd);
                     50:        if (i.flag == -1) {
                     51:                fprintf(stderr,"getflags error\n");
                     52:                close(fd);
                     53:                exit(1);
                     54:        }
                     55:
                     56:        switch(*argv[1]) {
                     57:        case 'r':
                     58:                printf("%s x:%d g:%d\n",argv[2],
                     59:                       FI_CFLAG(&i),FI_GSHAR(&i));
                     60:                exit(0);
                     61:        case 'x':
                     62:                FI_SET_CF(&i,~(FI_CFLAG(&i)));
                     63:                break;
                     64:        case 'g':
                     65:                FI_SET_GS(&i,~(FI_GSHAR(&i)));
                     66:                break;
                     67:        }
                     68:
                     69:        i = tcfs_setflags(fd,i);
                     70:        if (i.flag == -1) {
                     71:                fprintf(stderr,"setflags error\n");
                     72:                exit(1);
                     73:        }
                     74:        close(fd);
                     75:
                     76:        exit(0);
                     77: }
                     78: