File: [local] / src / usr.bin / tcfs / Attic / tcfs_flags.c (download)
Revision 1.6, Tue Jun 20 07:58:57 2000 UTC (23 years, 11 months ago) by fgsch
Branch: MAIN
Changes since 1.5: +10 -10 lines
add openbsd tags. rearrange headers as per style(9) and indent.
replace some strcpy by strlcpy.
|
/* $OpenBSD: tcfs_flags.c,v 1.6 2000/06/20 07:58:57 fgsch Exp $ */
/*
* Transparent Cryptographic File System (TCFS) for NetBSD
* Author and mantainer: Luigi Catuogno [luicat@tcfs.unisa.it]
*
* references: http://tcfs.dia.unisa.it
* tcfs-bsd@tcfs.unisa.it
*/
/*
* Base utility set v0.1
*/
#include <sys/types.h>
#include <sys/mount.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <pwd.h>
#include <stdio.h>
#include <unistd.h>
#include <miscfs/tcfs/tcfs.h>
#include <miscfs/tcfs/tcfs_fileinfo.h>
#include "tcfsdefines.h"
tcfs_flags
tcfs_getflags(int fd)
{
tcfs_flags r;
struct stat s;
if (fstat(fd, &s) < 0)
r.flag = -1;
else
r.flag = s.st_flags;
return (r);
}
tcfs_flags
tcfs_setflags(int fd, tcfs_flags x)
{
tcfs_flags r, n;
r = tcfs_getflags(fd);
if (r.flag == -1) {
r.flag = -1;
return (r);
}
n = x;
FI_SET_SP(&n, FI_SPURE(&r));
if (fchflags(fd, n.flag)) {
perror("fchflags");
r.flag = -1;
}
return (r);
}