summaryrefslogtreecommitdiff
path: root/sys/miscfs
diff options
context:
space:
mode:
authorNiels Provos <provos@cvs.openbsd.org>2000-06-17 20:25:56 +0000
committerNiels Provos <provos@cvs.openbsd.org>2000-06-17 20:25:56 +0000
commit4101354f3e6be5b49e2d61825c2c7cb7901bec22 (patch)
tree8612e39906950509465ad13ef54daa62b57c09a3 /sys/miscfs
parentb12347c7401e730593586ffb0a6fcae647c52f93 (diff)
some KNF
Diffstat (limited to 'sys/miscfs')
-rw-r--r--sys/miscfs/tcfs/tcfs.h12
-rw-r--r--sys/miscfs/tcfs/tcfs_attr.c107
-rw-r--r--sys/miscfs/tcfs/tcfs_cipher.h35
-rw-r--r--sys/miscfs/tcfs/tcfs_cipher_BLOWFISH.c12
-rw-r--r--sys/miscfs/tcfs/tcfs_cipher_TDES.c88
-rw-r--r--sys/miscfs/tcfs/tcfs_cipher_conf.c37
-rw-r--r--sys/miscfs/tcfs/tcfs_cipher_none.c16
-rw-r--r--sys/miscfs/tcfs/tcfs_cmd.c241
-rw-r--r--sys/miscfs/tcfs/tcfs_crypto.c39
-rw-r--r--sys/miscfs/tcfs/tcfs_dir.c127
-rw-r--r--sys/miscfs/tcfs/tcfs_fileinfo.c62
-rw-r--r--sys/miscfs/tcfs/tcfs_fileinfo.h13
-rw-r--r--sys/miscfs/tcfs/tcfs_interp.c90
-rw-r--r--sys/miscfs/tcfs/tcfs_keytab.c491
-rw-r--r--sys/miscfs/tcfs/tcfs_keytab.h86
-rw-r--r--sys/miscfs/tcfs/tcfs_mount.h32
-rw-r--r--sys/miscfs/tcfs/tcfs_rw.c747
-rw-r--r--sys/miscfs/tcfs/tcfs_rw.h32
-rw-r--r--sys/miscfs/tcfs/tcfs_subr.c5
-rw-r--r--sys/miscfs/tcfs/tcfs_version.h6
-rw-r--r--sys/miscfs/tcfs/tcfs_vfsops.c14
-rw-r--r--sys/miscfs/tcfs/tcfs_vnops.c9
22 files changed, 1117 insertions, 1184 deletions
diff --git a/sys/miscfs/tcfs/tcfs.h b/sys/miscfs/tcfs/tcfs.h
index f5f0aae5bdb..e45202db18d 100644
--- a/sys/miscfs/tcfs/tcfs.h
+++ b/sys/miscfs/tcfs/tcfs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcfs.h,v 1.2 2000/06/17 17:32:26 provos Exp $ */
+/* $OpenBSD: tcfs.h,v 1.3 2000/06/17 20:25:54 provos Exp $ */
/*
* Copyright 2000 The TCFS Project at http://tcfs.dia.unisa.it/
* All rights reserved.
@@ -25,9 +25,10 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef _TCFS_MOUNT_H_
-#include "tcfs_mount.h"
-#endif
+#ifndef _TCFS_H_
+#define _TCFS_H_
+
+#include <miscfs/tcfs/tcfs_mount.h>
#ifdef _KERNEL
/*
@@ -112,5 +113,4 @@ int tcfs_set_status(struct tcfs_mount *, struct tcfs_args *, int);
tcfs_checkgkey((c),(p),(v)) )
#endif /* _KERNEL */
-
-
+#endif /* _TCFS_H_ */
diff --git a/sys/miscfs/tcfs/tcfs_attr.c b/sys/miscfs/tcfs/tcfs_attr.c
index 7a5c5e9bb72..fcaa9468a27 100644
--- a/sys/miscfs/tcfs/tcfs_attr.c
+++ b/sys/miscfs/tcfs/tcfs_attr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcfs_attr.c,v 1.2 2000/06/17 17:32:26 provos Exp $ */
+/* $OpenBSD: tcfs_attr.c,v 1.3 2000/06/17 20:25:54 provos Exp $ */
/*
* Copyright 2000 The TCFS Project at http://tcfs.dia.unisa.it/
* All rights reserved.
@@ -35,8 +35,9 @@
#include <sys/namei.h>
#include <sys/malloc.h>
#include <sys/buf.h>
+
#include <miscfs/tcfs/tcfs.h>
-#include "tcfs_rw.h"
+#include <miscfs/tcfs/tcfs_rw.h>
int
tcfs_getattr(v)
@@ -59,98 +60,78 @@ tcfs_getattr(v)
int
tcfs_setattr(v)
-void *v;
+ void *v;
{
struct vop_setattr_args *a = v;
struct vattr *ap;
- u_quad_t size=0;
- tcfs_fileinfo i,n;
- int error,sp=0;
-
+ u_quad_t size = 0;
+ tcfs_fileinfo i, n;
+ int error, sp = 0;
- i=tcfs_xgetflags(a->a_vp,a->a_p,a->a_cred);
- ap=a->a_vap;
+ i = tcfs_xgetflags(a->a_vp,a->a_p,a->a_cred);
+ ap = a->a_vap;
- if(FI_GSHAR(&i))
- {
- if(!tcfs_getgkey(a->a_cred,a->a_p,a->a_vp))
- {
+ if (FI_GSHAR(&i)) {
+ if(!tcfs_getgkey(a->a_cred,a->a_p,a->a_vp))
return EACCES;
- }
- }
- else
- {
- if (!tcfs_getpkey(a->a_cred,a->a_p,a->a_vp))
- if (!tcfs_getukey(a->a_cred,a->a_p,a->a_vp))
- {
+ } else {
+ if (!tcfs_getpkey(a->a_cred, a->a_p,a->a_vp))
+ if (!tcfs_getukey(a->a_cred, a->a_p,a->a_vp))
return EACCES;
- }
- }
-
- if ((ap->va_flags)!=VNOVAL)
- {
-
+ }
- n.flag=ap->va_flags;
- n.end_of_file=i.end_of_file;
+ if ((ap->va_flags) != VNOVAL) {
+ n.flag = ap->va_flags;
+ n.end_of_file = i.end_of_file;
- if((FI_CFLAG(&n)&&FI_GSHAR(&i))||(FI_GSHAR(&n)&&FI_CFLAG(&i)))
- {
+ if ((FI_CFLAG(&n) && FI_GSHAR(&i)) ||
+ (FI_GSHAR(&n) && FI_CFLAG(&i)))
return EACCES;
- }
- if(FI_SPURE(&n)!=FI_SPURE(&i))
- {
+ if (FI_SPURE(&n) != FI_SPURE(&i)) {
/* le spure no (le settano solo write e trunc) */
return EACCES;
- }
+ }
- if(FI_CFLAG(&n)&&(!FI_CFLAG(&i)))
- {
- sp=tcfs_ed(a->a_vp, a->a_p, a->a_cred, &n);
- FI_SET_SP(&n,sp);
+ if (FI_CFLAG(&n) && (!FI_CFLAG(&i))) {
+ sp = tcfs_ed(a->a_vp, a->a_p, a->a_cred, &n);
+ FI_SET_SP(&n, sp);
}
- if((!FI_CFLAG(&n))&&FI_CFLAG(&i))
- {
- sp=tcfs_ed(a->a_vp, a->a_p, a->a_cred, &n);
- FI_SET_SP(&n,0);
+ if ((!FI_CFLAG(&n)) && FI_CFLAG(&i)) {
+ sp = tcfs_ed(a->a_vp, a->a_p, a->a_cred, &n);
+ FI_SET_SP(&n, 0);
}
- if(FI_GSHAR(&n)&&(!FI_GSHAR(&i)))
- {
- sp=tcfs_ed(a->a_vp, a->a_p, a->a_cred, &n);
+ if (FI_GSHAR(&n) && (!FI_GSHAR(&i))) {
+ sp = tcfs_ed(a->a_vp, a->a_p, a->a_cred, &n);
FI_SET_SP(&n,sp);
}
- if((!FI_GSHAR(&n))&&FI_GSHAR(&i))
- {
- sp=tcfs_ed(a->a_vp, a->a_p, a->a_cred, &n);
+ if ((!FI_GSHAR(&n)) && FI_GSHAR(&i)) {
+ sp = tcfs_ed(a->a_vp, a->a_p, a->a_cred, &n);
FI_SET_SP(&n,0);
}
- ap->va_flags=i.flag=n.flag;
- if(a->a_vp->v_type==VREG)
- {
- ap->va_size=FI_ENDOF(&i)+sp;
- error=tcfs_xsetflags(a->a_vp, a->a_p,a->a_cred,&i);
+ ap->va_flags = i.flag = n.flag;
+ if (a->a_vp->v_type == VREG) {
+ ap->va_size = FI_ENDOF(&i) + sp;
+ error = tcfs_xsetflags(a->a_vp, a->a_p, a->a_cred,&i);
}
- return tcfs_bypass((void*)v);
+ return tcfs_bypass((void *)v);
}
- if ((ap->va_size)!=VNOVAL)
- {
-
- if(ap->va_size == 0)
- size=0;
+ if ((ap->va_size) != VNOVAL) {
+ if (ap->va_size == 0)
+ size = 0;
else
- size=(u_quad_t)(D_PFOFF(ap->va_size)+1);
+ size = (u_quad_t)(D_PFOFF(ap->va_size) + 1);
FI_SET_SP(&i,(size-ap->va_size));
- ap->va_size=size;
- error=tcfs_xsetflags(a->a_vp, a->a_p,a->a_cred,&i);
+ ap->va_size = size;
+ error = tcfs_xsetflags(a->a_vp, a->a_p,a->a_cred, &i);
}
- return tcfs_bypass((void*)v);
+ return tcfs_bypass((void *)v);
}
diff --git a/sys/miscfs/tcfs/tcfs_cipher.h b/sys/miscfs/tcfs/tcfs_cipher.h
index f1a97e856f8..62a14ecab1f 100644
--- a/sys/miscfs/tcfs/tcfs_cipher.h
+++ b/sys/miscfs/tcfs/tcfs_cipher.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcfs_cipher.h,v 1.2 2000/06/17 17:32:26 provos Exp $ */
+/* $OpenBSD: tcfs_cipher.h,v 1.3 2000/06/17 20:25:54 provos Exp $ */
/*
* Copyright 2000 The TCFS Project at http://tcfs.dia.unisa.it/
* All rights reserved.
@@ -25,28 +25,24 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef _TCFS_MOUNT_H_
-#include "tcfs_mount.h"
-#endif
+#ifndef _TCFS_CIPHER_H_
+#define _TCFS_CIPHER_H_
+
+#include <miscfs/tcfs/tcfs_mount.h>
#define _TCFS_CIPHER_H_
#define MaxNumOfCipher 8
#define MaxCipherNameLen 8
-enum {
- C_TDES=0,C_BLOW=2
- } ;
-
-struct tcfs_cipher
- {
- char cipher_desc[MaxCipherNameLen];
- int cipher_version;
- int cipher_keysize;
- void *(*init_key)(char*);
- void (*cleanup_key)(void*);
- void (*encrypt)(char*, int, void*);
- void (*decrypt)(char*, int, void*);
- };
+struct tcfs_cipher {
+ char cipher_desc[MaxCipherNameLen];
+ int cipher_version;
+ int cipher_keysize;
+ void *(*init_key)(char*);
+ void (*cleanup_key)(void*);
+ void (*encrypt)(char*, int, void*);
+ void (*decrypt)(char*, int, void*);
+};
extern struct tcfs_cipher tcfs_cipher_vect[MaxNumOfCipher];
@@ -89,7 +85,7 @@ static __inline void TCFS_DECRYPT(struct tcfs_mount *mp,char *blk,int len,void
void mkencrypt (struct tcfs_mount *, char *, int, void*);
void mkdecrypt (struct tcfs_mount *, char *, int, void*);
-/* prototipi funzioni */
+/* function prototypes */
void *cnone_init_key(char *);
void cnone_cleanup_key(void*);
@@ -109,3 +105,4 @@ void BLOWFISH_encrypt(char *, int , void*);
void BLOWFISH_decrypt(char *, int , void*);
#define BLOWFISH_KEYSIZE 8
+#endif /* _TCFS_CIPHER_H_ */
diff --git a/sys/miscfs/tcfs/tcfs_cipher_BLOWFISH.c b/sys/miscfs/tcfs/tcfs_cipher_BLOWFISH.c
index 719712a6441..5420c7523a2 100644
--- a/sys/miscfs/tcfs/tcfs_cipher_BLOWFISH.c
+++ b/sys/miscfs/tcfs/tcfs_cipher_BLOWFISH.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcfs_cipher_BLOWFISH.c,v 1.2 2000/06/17 17:32:26 provos Exp $ */
+/* $OpenBSD: tcfs_cipher_BLOWFISH.c,v 1.3 2000/06/17 20:25:54 provos Exp $ */
/*
* Copyright 2000 The TCFS Project at http://tcfs.dia.unisa.it/
* All rights reserved.
@@ -28,16 +28,18 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/malloc.h>
-#include "tcfs_cipher.h"
-#include "crypto/blf.h"
+
+#include <miscfs/tcfs/tcfs_cipher.h>
+
+#include <crypto/blf.h>
void *
BLOWFISH_init_key (char *key)
{
- blf_ctx *ks=NULL;
+ blf_ctx *ks = NULL;
- ks=(blf_ctx *)malloc (sizeof (blf_ctx), M_FREE, M_NOWAIT);
+ ks = (blf_ctx *)malloc (sizeof (blf_ctx), M_FREE, M_NOWAIT);
if (!ks)
return NULL;
diff --git a/sys/miscfs/tcfs/tcfs_cipher_TDES.c b/sys/miscfs/tcfs/tcfs_cipher_TDES.c
index c6448b2182a..f90d697336d 100644
--- a/sys/miscfs/tcfs/tcfs_cipher_TDES.c
+++ b/sys/miscfs/tcfs/tcfs_cipher_TDES.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcfs_cipher_TDES.c,v 1.2 2000/06/17 17:32:26 provos Exp $ */
+/* $OpenBSD: tcfs_cipher_TDES.c,v 1.3 2000/06/17 20:25:54 provos Exp $ */
/*
* Copyright 2000 The TCFS Project at http://tcfs.dia.unisa.it/
* All rights reserved.
@@ -28,73 +28,83 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/malloc.h>
-#include "tcfs_cipher.h"
+
+#include <miscfs/tcfs/tcfs_cipher.h>
+
#include <crypto/des_locl.h>
#include <crypto/des.h>
-void *TDES_init_key (char *key)
+void *
+TDES_init_key (char *key)
{
des_key_schedule *ks;
- ks=(des_key_schedule *)malloc (2*sizeof (des_key_schedule), M_FREE,M_NOWAIT);
+ ks = (des_key_schedule *)malloc (2 * sizeof (des_key_schedule),
+ M_FREE, M_NOWAIT);
if (!ks)
return NULL;
des_set_key ((des_cblock *)key, ks[0]);
- des_set_key ((des_cblock *)(key+8), ks[1]);
+ des_set_key ((des_cblock *)(key + 8), ks[1]);
return (void *)ks;
}
-void TDES_cleanup_key(void *k)
+void
+TDES_cleanup_key(void *k)
{
/* tcfs_keytab_dispnode does it
free((des_key_schedule*)k,M_FREE);
*/
}
-void TDES_encrypt(char *block, int nb, void *key)
+void
+TDES_encrypt(char *block, int nb, void *key)
{
- unsigned long * xi;
+ u_int32_t * xi;
int i;
char *tmp;
- des_key_schedule *ks=(des_key_schedule *)key;
- xi=(long *)block;
- tmp=block;
- des_ecb3_encrypt((des_cblock *)tmp,(des_cblock *)tmp,ks[0],ks[1],ks[0],DES_ENCRYPT);
- tmp+=8;
- for (i=1;i<nb/8;i++) {
- *(xi+2)^=*xi;
- *(xi+3)^=*(xi+1);
- des_ecb3_encrypt((des_cblock *)tmp,(des_cblock *)tmp,ks[0],ks[1],ks[0],DES_ENCRYPT);
- tmp+=8;
- xi+=2;
+ des_key_schedule *ks = (des_key_schedule *)key;
+
+ xi = (u_int32_t *)block;
+ tmp = block;
+ des_ecb3_encrypt((des_cblock *)tmp, (des_cblock *)tmp,
+ ks[0],ks[1],ks[0],DES_ENCRYPT);
+ tmp += 8;
+ for (i = 1;i < nb/8;i++) {
+ *(xi+2) ^= *xi;
+ *(xi+3) ^= *(xi + 1);
+ des_ecb3_encrypt((des_cblock *)tmp, (des_cblock *)tmp,
+ ks[0], ks[1], ks[0], DES_ENCRYPT);
+ tmp += 8;
+ xi += 2;
}
}
-void TDES_decrypt(char *block, int nb, void *key)
+void
+TDES_decrypt(char *block, int nb, void *key)
{
- unsigned long * xi,xo[2],xa[2];
+ u_int32_t * xi, xo[2], xa[2];
int i;
char *tmp;
- des_key_schedule *ks=(des_key_schedule *)key;
+ des_key_schedule *ks = (des_key_schedule *)key;
- xi=(long *)block;
- tmp=block;
- xo[0]=*xi; xo[1]=*(xi+1);
- des_ecb3_encrypt((des_cblock *)tmp,(des_cblock *)tmp,ks[0],ks[1],ks[0],DES_DECRYPT);
- tmp+=8;
- xi=(long *)tmp;
- for (i=1;i<nb/8;i++) {
- xa[0]=*xi; xa[1]=*(xi+1);
- des_ecb3_encrypt((des_cblock *)tmp,(des_cblock *)tmp,ks[0],ks[1],ks[0],DES_DECRYPT);
- *(xi)^=xo[0];
- *(xi+1)^=xo[1];
- xo[0]=xa[0];
- xo[1]=xa[1];
- tmp+=8;
- xi+=2;
+ xi = (u_int32_t *)block;
+ tmp = block;
+ xo[0] = *xi; xo[1] = *(xi+1);
+ des_ecb3_encrypt((des_cblock *)tmp, (des_cblock *)tmp,
+ ks[0], ks[1], ks[0], DES_DECRYPT);
+ tmp += 8;
+ xi = (u_int32_t *)tmp;
+ for (i = 1;i < nb/8; i++) {
+ xa[0] = *xi; xa[1] = *(xi+1);
+ des_ecb3_encrypt((des_cblock *)tmp, (des_cblock *)tmp,
+ ks[0], ks[1], ks[0], DES_DECRYPT);
+ *(xi) ^= xo[0];
+ *(xi+1)^= xo[1];
+ xo[0] = xa[0];
+ xo[1] = xa[1];
+ tmp += 8;
+ xi += 2;
}
}
-
-
diff --git a/sys/miscfs/tcfs/tcfs_cipher_conf.c b/sys/miscfs/tcfs/tcfs_cipher_conf.c
index 3bdb75bdc9b..e4897bbe1e2 100644
--- a/sys/miscfs/tcfs/tcfs_cipher_conf.c
+++ b/sys/miscfs/tcfs/tcfs_cipher_conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcfs_cipher_conf.c,v 1.2 2000/06/17 17:32:26 provos Exp $ */
+/* $OpenBSD: tcfs_cipher_conf.c,v 1.3 2000/06/17 20:25:54 provos Exp $ */
/*
* Copyright 2000 The TCFS Project at http://tcfs.dia.unisa.it/
* All rights reserved.
@@ -25,24 +25,23 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "tcfs_cipher.h"
+#include <miscfs/tcfs/tcfs_cipher.h>
struct tcfs_cipher tcfs_cipher_vect[]={
- {"3des",0,TDES_KEYSIZE,TDES_init_key,TDES_cleanup_key,
- TDES_encrypt,TDES_decrypt},
- {"none",0,0,cnone_init_key,cnone_cleanup_key,
- cnone_encrypt,cnone_decrypt},
- {"bfish",0,BLOWFISH_KEYSIZE,BLOWFISH_init_key,BLOWFISH_cleanup_key,
- BLOWFISH_encrypt,BLOWFISH_decrypt},
- {"none",0,0,cnone_init_key,cnone_cleanup_key,
- cnone_encrypt,cnone_decrypt},
- {"none",0,0,cnone_init_key,cnone_cleanup_key,
- cnone_encrypt,cnone_decrypt},
- {"none",0,0,cnone_init_key,cnone_cleanup_key,
- cnone_encrypt,cnone_decrypt},
- {"none",0,0,cnone_init_key,cnone_cleanup_key,
- cnone_encrypt,cnone_decrypt},
- {"none",0,0,cnone_init_key,cnone_cleanup_key,
- cnone_encrypt,cnone_decrypt},
+ {"3des", 0, TDES_KEYSIZE, TDES_init_key, TDES_cleanup_key,
+ TDES_encrypt, TDES_decrypt},
+ {"none", 0, 0, cnone_init_key, cnone_cleanup_key,
+ cnone_encrypt, cnone_decrypt},
+ {"bfish", 0, BLOWFISH_KEYSIZE, BLOWFISH_init_key, BLOWFISH_cleanup_key,
+ BLOWFISH_encrypt, BLOWFISH_decrypt},
+ {"none", 0, 0, cnone_init_key, cnone_cleanup_key,
+ cnone_encrypt, cnone_decrypt},
+ {"none", 0, 0, cnone_init_key, cnone_cleanup_key,
+ cnone_encrypt, cnone_decrypt},
+ {"none", 0, 0, cnone_init_key, cnone_cleanup_key,
+ cnone_encrypt, cnone_decrypt},
+ {"none", 0, 0, cnone_init_key, cnone_cleanup_key,
+ cnone_encrypt, cnone_decrypt},
+ {"none", 0, 0, cnone_init_key, cnone_cleanup_key,
+ cnone_encrypt, cnone_decrypt},
};
-
diff --git a/sys/miscfs/tcfs/tcfs_cipher_none.c b/sys/miscfs/tcfs/tcfs_cipher_none.c
index d148228c2e7..5a7c9bbc8ec 100644
--- a/sys/miscfs/tcfs/tcfs_cipher_none.c
+++ b/sys/miscfs/tcfs/tcfs_cipher_none.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcfs_cipher_none.c,v 1.2 2000/06/17 17:32:26 provos Exp $ */
+/* $OpenBSD: tcfs_cipher_none.c,v 1.3 2000/06/17 20:25:54 provos Exp $ */
/*
* Copyright 2000 The TCFS Project at http://tcfs.dia.unisa.it/
* All rights reserved.
@@ -25,21 +25,25 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "tcfs_cipher.h"
+#include <miscfs/tcfs/tcfs_cipher.h>
-void *cnone_init_key (char *key)
+void *
+cnone_init_key (char *key)
{
return (void *)key;
}
-void cnone_cleanup_key(void *k)
+void
+cnone_cleanup_key(void *k)
{
}
-void cnone_encrypt(char *block, int nb, void *key)
+void
+cnone_encrypt(char *block, int nb, void *key)
{
}
-void cnone_decrypt(char *block, int nb, void *key)
+void
+cnone_decrypt(char *block, int nb, void *key)
{
}
diff --git a/sys/miscfs/tcfs/tcfs_cmd.c b/sys/miscfs/tcfs/tcfs_cmd.c
index 410ee024bca..8234595e8fe 100644
--- a/sys/miscfs/tcfs/tcfs_cmd.c
+++ b/sys/miscfs/tcfs/tcfs_cmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcfs_cmd.c,v 1.2 2000/06/17 17:32:26 provos Exp $ */
+/* $OpenBSD: tcfs_cmd.c,v 1.3 2000/06/17 20:25:54 provos Exp $ */
/*
* Copyright 2000 The TCFS Project at http://tcfs.dia.unisa.it/
* All rights reserved.
@@ -36,42 +36,33 @@
#include <sys/malloc.h>
#include <sys/buf.h>
#include <miscfs/tcfs/tcfs.h>
-#include "tcfs_rw.h"
-#ifndef _TCFS_KEYTAB_H_
-#include "tcfs_keytab.h"
-#endif
-#include "tcfs_cmd.h"
-#include "tcfs_cipher.h"
-
-int tcfs_init_mp(struct tcfs_mount *mp, struct tcfs_args *req)
-{
- int result=0;
- int status=0;
+#include <miscfs/tcfs/tcfs_rw.h>
+#include <miscfs/tcfs/tcfs_keytab.h>
+#include <miscfs/tcfs/tcfs_cmd.h>
+#include <miscfs/tcfs/tcfs_cipher.h>
- if (!(mp->tcfs_uid_kt=tcfs_keytab_init()))
- {
- result= ENOMEM;
- status= ALLOCATION_FAILED;
- }
- else
- {
- if (!(mp->tcfs_gid_kt=tcfs_keytab_init()))
- {
+int
+tcfs_init_mp(struct tcfs_mount *mp, struct tcfs_args *req)
+{
+ int result = 0;
+ int status = 0;
+
+ if (!(mp->tcfs_uid_kt = tcfs_keytab_init())) {
+ result = ENOMEM;
+ status = ALLOCATION_FAILED;
+ } else {
+ if (!(mp->tcfs_gid_kt = tcfs_keytab_init())) {
tcfs_keytab_dispose(mp->tcfs_uid_kt);
- status= ALLOCATION_FAILED;
- result= ENOMEM;
- }
- else
- {
- if ((req->cipher_num>=MaxNumOfCipher)||
- (tcfs_cipher_vect[req->cipher_num].cipher_keysize==0))
- {
- result=EINVAL;
- status=BAD_CIPHER_NUMBER;
+ status = ALLOCATION_FAILED;
+ result = ENOMEM;
+ } else {
+ if ((req->cipher_num >= MaxNumOfCipher)||
+ (tcfs_cipher_vect[req->cipher_num].cipher_keysize == 0)) {
+ result = EINVAL;
+ status = BAD_CIPHER_NUMBER;
tcfs_keytab_dispose(mp->tcfs_uid_kt);
tcfs_keytab_dispose(mp->tcfs_gid_kt);
- }
- else
+ } else
mp->tcfs_cipher_num=req->cipher_num;
}
}
@@ -80,151 +71,159 @@ int tcfs_init_mp(struct tcfs_mount *mp, struct tcfs_args *req)
return result;
}
-int tcfs_exec_cmd(struct tcfs_mount *mp, struct tcfs_args *req)
+int
+tcfs_exec_cmd(struct tcfs_mount *mp, struct tcfs_args *req)
{
void *ks;
- int result=0;
- int status=0;
+ int result = 0;
+ int status = 0;
- switch (req->cmd)
- {
- case TCFS_PUT_UIDKEY:
- ks=TCFS_INIT_KEY(mp,req->tcfs_key);
- if(!ks)
- {
- result= ENOMEM;
- status= ALLOCATION_FAILED;
- break;
- }
- result=tcfs_keytab_push_uid(mp->tcfs_uid_kt,req->user,ks);
- if(result)
- {
- TCFS_CLEANUP_KEY(mp,ks);
- status=PUSHKEY_ERROR;
- }
- break;
-
- case TCFS_RM_UIDKEY:
- result = tcfs_keytab_rm_uid(mp->tcfs_uid_kt,req->user);
- status=(result?RMKEY_ERROR:TCFS_OK);
+ switch (req->cmd) {
+ case TCFS_PUT_UIDKEY:
+ ks=TCFS_INIT_KEY(mp, req->tcfs_key);
+ if (!ks) {
+ result = ENOMEM;
+ status = ALLOCATION_FAILED;
break;
-
- case TCFS_PUT_PIDKEY:
- ks=TCFS_INIT_KEY(mp,req->tcfs_key);
- if(!ks)
- {
- result= ENOMEM;
- status= ALLOCATION_FAILED;
- break;
- }
- result=tcfs_keytab_push_pid(mp->tcfs_uid_kt,req->user,req->proc,ks);
- if(result)
- {
- TCFS_CLEANUP_KEY(mp,ks);
- status=PUSHKEY_ERROR;
- }
- break;
-
- case TCFS_RM_PIDKEY:
- result=tcfs_keytab_rm_pid(mp->tcfs_uid_kt,req->user,req->proc);
- status=(result?RMKEY_ERROR:TCFS_OK);
+ }
+ result = tcfs_keytab_push_uid(mp->tcfs_uid_kt, req->user,ks);
+ if(result) {
+ TCFS_CLEANUP_KEY(mp,ks);
+ status = PUSHKEY_ERROR;
+ }
+ break;
+
+ case TCFS_RM_UIDKEY:
+ result = tcfs_keytab_rm_uid(mp->tcfs_uid_kt, req->user);
+ status = (result ? RMKEY_ERROR : TCFS_OK);
+ break;
+
+ case TCFS_PUT_PIDKEY:
+ ks = TCFS_INIT_KEY(mp, req->tcfs_key);
+ if(!ks) {
+ result = ENOMEM;
+ status = ALLOCATION_FAILED;
break;
-
- case TCFS_PUT_GIDKEY:
- result=tcfs_keytab_push_gid(mp,mp->tcfs_gid_kt,req->user,req->group,req->treshold,req->tcfs_key);
+ }
+ result = tcfs_keytab_push_pid(mp->tcfs_uid_kt, req->user,
+ req->proc, ks);
+ if(result) {
+ TCFS_CLEANUP_KEY(mp,ks);
+ status = PUSHKEY_ERROR;
+ }
+ break;
+
+ case TCFS_RM_PIDKEY:
+ result = tcfs_keytab_rm_pid(mp->tcfs_uid_kt,
+ req->user, req->proc);
+ status = (result ? RMKEY_ERROR : TCFS_OK);
+ break;
+
+ case TCFS_PUT_GIDKEY:
+ result = tcfs_keytab_push_gid(mp, mp->tcfs_gid_kt, req->user,
+ req->group, req->treshold,
+ req->tcfs_key);
- status=(result?PUSHKEY_ERROR:TCFS_OK);
- break;
+ status = (result ? PUSHKEY_ERROR : TCFS_OK);
+ break;
- case TCFS_RM_GIDKEY:
- result= tcfs_keytab_rm_gid(mp->tcfs_gid_kt,req->user,req->group);
- status=(result?RMKEY_ERROR:TCFS_OK);
- break;
+ case TCFS_RM_GIDKEY:
+ result = tcfs_keytab_rm_gid(mp->tcfs_gid_kt, req->user,
+ req->group);
+ status = (result ? RMKEY_ERROR : TCFS_OK);
+ break;
- case TCFS_GET_STATUS:
- return tcfs_set_status(mp,req,TCFS_OK);
+ case TCFS_GET_STATUS:
+ return tcfs_set_status(mp, req, TCFS_OK);
}
- (void)tcfs_set_status(mp,req,status);
+ (void)tcfs_set_status(mp, req, status);
return result;
}
-int tcfs_set_status(struct tcfs_mount *mp, struct tcfs_args *req, int error)
+int
+tcfs_set_status(struct tcfs_mount *mp, struct tcfs_args *req, int error)
{
- req->st.status=error;
- req->st.tcfs_version=TCFS_VERSION_NUM;
+ req->st.status = error;
+ req->st.tcfs_version = TCFS_VERSION_NUM;
- if(error!=TCFS_OK)
+ if(error != TCFS_OK)
return error;
- req->st.n_ukey=mp->tcfs_uid_kt->cnt;
- req->st.n_gkey=mp->tcfs_gid_kt->cnt;
- strncpy(req->st.cipher_desc,TCFS_CIPHER_DESC(mp),MaxCipherNameLen);
- req->st.cipher_keysize=TCFS_CIPHER_KEYSIZE(mp);
- req->st.cipher_version=TCFS_CIPHER_VERSION(mp);
+ req->st.n_ukey = mp->tcfs_uid_kt->cnt;
+ req->st.n_gkey = mp->tcfs_gid_kt->cnt;
+ strncpy(req->st.cipher_desc, TCFS_CIPHER_DESC(mp), MaxCipherNameLen);
+ req->st.cipher_keysize = TCFS_CIPHER_KEYSIZE(mp);
+ req->st.cipher_version = TCFS_CIPHER_VERSION(mp);
return error;
}
-int tcfs_checkukey(struct ucred *c, struct proc *p, struct vnode *vp)
+int
+tcfs_checkukey(struct ucred *c, struct proc *p, struct vnode *vp)
{
- return tcfs_keytab_check_uid(TCFS_VP2UKT(vp),c->cr_uid);
+ return tcfs_keytab_check_uid(TCFS_VP2UKT(vp), c->cr_uid);
}
-void *tcfs_getukey(struct ucred *c, struct proc *p, struct vnode *vp)
+void *
+tcfs_getukey(struct ucred *c, struct proc *p, struct vnode *vp)
{
tcfs_keytab_node *n;
- n=tcfs_keytab_fetch_uid(TCFS_VP2UKT(vp),c->cr_uid);
+ n = tcfs_keytab_fetch_uid(TCFS_VP2UKT(vp),c->cr_uid);
- if(n)
+ if (n)
return n->kn_key;
else
- {
return (void*)NULL;
- }
}
-int tcfs_checkpkey(struct ucred *c, struct proc *p, struct vnode *vp)
+
+int
+tcfs_checkpkey(struct ucred *c, struct proc *p, struct vnode *vp)
{
struct proc *cp;
- if(!p)
- cp=curproc;
+
+ if (!p)
+ cp = curproc;
else
- cp=p;
+ cp = p;
- return tcfs_keytab_check_pid(TCFS_VP2UKT(vp),c->cr_uid,cp->p_pid);
+ return tcfs_keytab_check_pid(TCFS_VP2UKT(vp), c->cr_uid, cp->p_pid);
}
-void *tcfs_getpkey(struct ucred *c, struct proc *p, struct vnode *vp)
+void *
+tcfs_getpkey(struct ucred *c, struct proc *p, struct vnode *vp)
{
tcfs_keytab_node *n;
struct proc *cp;
- if(!p)
- cp=curproc;
+ if (!p)
+ cp = curproc;
else
- cp=p;
+ cp = p;
- n=tcfs_keytab_fetch_pid(TCFS_VP2UKT(vp),c->cr_uid,cp->p_pid);
+ n = tcfs_keytab_fetch_pid(TCFS_VP2UKT(vp), c->cr_uid, cp->p_pid);
- if(n)
+ if (n)
return n->kn_key;
else
return (void*)NULL;
}
-int tcfs_checkgkey(struct ucred *c, struct proc *p, struct vnode *vp)
+int
+tcfs_checkgkey(struct ucred *c, struct proc *p, struct vnode *vp)
{
- return tcfs_keytab_check_uid(TCFS_VP2GKT(vp),c->cr_gid);
+ return tcfs_keytab_check_uid(TCFS_VP2GKT(vp), c->cr_gid);
}
-void *tcfs_getgkey(struct ucred *c, struct proc *p, struct vnode *vp)
+void *
+tcfs_getgkey(struct ucred *c, struct proc *p, struct vnode *vp)
{
tcfs_keytab_node *n;
- n=tcfs_keytab_fetch_gid(TCFS_VP2GKT(vp),c->cr_gid);
+ n = tcfs_keytab_fetch_gid(TCFS_VP2GKT(vp), c->cr_gid);
- if(n)
+ if (n)
return n->kn_key;
else
return (void*)NULL;
diff --git a/sys/miscfs/tcfs/tcfs_crypto.c b/sys/miscfs/tcfs/tcfs_crypto.c
index 7d49d302545..c29857f243c 100644
--- a/sys/miscfs/tcfs/tcfs_crypto.c
+++ b/sys/miscfs/tcfs/tcfs_crypto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcfs_crypto.c,v 1.2 2000/06/17 17:32:26 provos Exp $ */
+/* $OpenBSD: tcfs_crypto.c,v 1.3 2000/06/17 20:25:54 provos Exp $ */
/*
* Copyright 2000 The TCFS Project at http://tcfs.dia.unisa.it/
* All rights reserved.
@@ -25,41 +25,42 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "tcfs_cipher.h"
+#include <sys/param.h>
+
+#include <miscfs/tcfs/tcfs_cipher.h>
#define BLOCKSIZE 1024
#define SBLOCKSIZE 8
-#define MIN(a,b) ((a)<(b)?(a):(b))
#define D_NOBLK(o) ((o)/BLOCKSIZE+(o%BLOCKSIZE?1:0))
-void mkencrypt(struct tcfs_mount *mp,char *block,int nb, void* ks)
+void
+mkencrypt(struct tcfs_mount *mp, char *block, int nb, void *ks)
{
int i,r;
char *tmp;
- tmp=block;
- r=nb;
- for(i=0;i<D_NOBLK(nb)&&r>0;i++)
- {
- TCFS_ENCRYPT(mp,tmp,MIN(BLOCKSIZE,r),ks);
- tmp+=BLOCKSIZE;
- r-=BLOCKSIZE;
+ tmp = block;
+ r = nb;
+ for(i = 0; i < D_NOBLK(nb) && r > 0; i++) {
+ TCFS_ENCRYPT(mp, tmp, MIN(BLOCKSIZE, r), ks);
+ tmp += BLOCKSIZE;
+ r -= BLOCKSIZE;
}
}
-void mkdecrypt(struct tcfs_mount *mp,char *block,int nb,void* ks)
+void
+mkdecrypt(struct tcfs_mount *mp, char *block, int nb, void *ks)
{
int i,r;
char *tmp;
- tmp=block;
- r=nb;
- for(i=0;i<D_NOBLK(nb)&&r>0;i++)
- {
- TCFS_DECRYPT(mp, tmp,MIN(BLOCKSIZE,r),ks);
- tmp+=BLOCKSIZE;
- r-=BLOCKSIZE;
+ tmp = block;
+ r = nb;
+ for(i = 0; i < D_NOBLK(nb) && r > 0; i++) {
+ TCFS_DECRYPT(mp, tmp, MIN(BLOCKSIZE, r), ks);
+ tmp += BLOCKSIZE;
+ r -= BLOCKSIZE;
}
}
diff --git a/sys/miscfs/tcfs/tcfs_dir.c b/sys/miscfs/tcfs/tcfs_dir.c
index 4b3aa91e917..f5a061daa5a 100644
--- a/sys/miscfs/tcfs/tcfs_dir.c
+++ b/sys/miscfs/tcfs/tcfs_dir.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcfs_dir.c,v 1.2 2000/06/17 17:32:26 provos Exp $ */
+/* $OpenBSD: tcfs_dir.c,v 1.3 2000/06/17 20:25:54 provos Exp $ */
/*
* Copyright 2000 The TCFS Project at http://tcfs.dia.unisa.it/
* All rights reserved.
@@ -36,137 +36,143 @@
#include <sys/malloc.h>
#include <sys/buf.h>
#include <sys/dirent.h>
+
#include <miscfs/tcfs/tcfs.h>
-#include "tcfs_rw.h"
+#include <miscfs/tcfs/tcfs_rw.h>
-int tcfs_new_direntry (void *, tcfs_fileinfo *);
+int tcfs_new_direntry __P((void *, tcfs_fileinfo *));
-int tcfs_new_direntry(void *v , tcfs_fileinfo *i)
+int
+tcfs_new_direntry(void *v, tcfs_fileinfo *i)
{
struct vop_create_args *x;
struct ucred *cr;
struct proc *pr;
int err;
- x=(struct vop_create_args *)v;
- cr=x->a_cnp->cn_cred;
- pr=x->a_cnp->cn_proc;
+ x = (struct vop_create_args *)v;
+ cr = x->a_cnp->cn_cred;
+ pr = x->a_cnp->cn_proc;
- if(!TCFS_CHECK_AKEY(cr,pr,x->a_dvp))
+ if (!TCFS_CHECK_AKEY(cr, pr, x->a_dvp))
return tcfs_bypass(v);
/* Per i file speciali e per i link, niente flags (per ora)*/
- if((x->a_desc==VDESC(vop_mknod))||
- (x->a_desc==VDESC(vop_symlink))||
- (x->a_desc==VDESC(vop_link)))
- {
+ if((x->a_desc == VDESC(vop_mknod)) ||
+ (x->a_desc == VDESC(vop_symlink)) ||
+ (x->a_desc == VDESC(vop_link))) {
err=tcfs_bypass(v);
return err;
}
- if(!(err=tcfs_bypass(v)))
- err=tcfs_xsetflags(*(x->a_vpp),pr,cr,i);
+ if (!(err=tcfs_bypass(v)))
+ err = tcfs_xsetflags(*(x->a_vpp),pr,cr,i);
return err;
}
-int tcfs_create(v)
-void *v;
+int
+tcfs_create(v)
+ void *v;
{
struct vop_create_args *x;
struct ucred *cr;
struct proc *pr;
tcfs_fileinfo i;
- x=(struct vop_create_args *)v;
- cr=x->a_cnp->cn_cred;
- pr=x->a_cnp->cn_proc;
- i=tcfs_xgetflags(x->a_dvp,pr,cr);
+ x = (struct vop_create_args *)v;
+ cr = x->a_cnp->cn_cred;
+ pr = x->a_cnp->cn_proc;
+ i = tcfs_xgetflags(x->a_dvp, pr, cr);
- if(FI_CFLAG(&i)||FI_GSHAR(&i))
- return tcfs_new_direntry(v,&i);
+ if (FI_CFLAG(&i)||FI_GSHAR(&i))
+ return tcfs_new_direntry(v, &i);
else
return tcfs_bypass(v);
}
-int tcfs_mknod(v)
-void *v;
+int
+tcfs_mknod(v)
+ void *v;
{
struct vop_mknod_args *x;
struct ucred *cr;
struct proc *pr;
tcfs_fileinfo i;
- x=(struct vop_mknod_args *)v;
- cr=x->a_cnp->cn_cred;
- pr=x->a_cnp->cn_proc;
- i=tcfs_xgetflags(x->a_dvp,pr,cr);
+ x = (struct vop_mknod_args *)v;
+ cr = x->a_cnp->cn_cred;
+ pr = x->a_cnp->cn_proc;
+ i = tcfs_xgetflags(x->a_dvp, pr, cr);
- if(FI_CFLAG(&i)||FI_GSHAR(&i))
- return tcfs_new_direntry(v,&i);
+ if (FI_CFLAG(&i) || FI_GSHAR(&i))
+ return tcfs_new_direntry(v, &i);
else
- return tcfs_bypass(v);
+ return tcfs_bypass(v);
}
-int tcfs_mkdir(v)
-void *v;
+int
+tcfs_mkdir(v)
+ void *v;
{
struct vop_mkdir_args *x;
struct ucred *cr;
struct proc *pr;
tcfs_fileinfo i;
- x=(struct vop_mkdir_args *)v;
- cr=x->a_cnp->cn_cred;
- pr=x->a_cnp->cn_proc;
- i=tcfs_xgetflags(x->a_dvp,pr,cr);
+ x = (struct vop_mkdir_args *)v;
+ cr = x->a_cnp->cn_cred;
+ pr = x->a_cnp->cn_proc;
+ i = tcfs_xgetflags(x->a_dvp,pr,cr);
- if(FI_CFLAG(&i)||FI_GSHAR(&i))
- return tcfs_new_direntry(v,&i);
+ if (FI_CFLAG(&i) || FI_GSHAR(&i))
+ return tcfs_new_direntry(v, &i);
else
- return tcfs_bypass(v);
+ return tcfs_bypass(v);
}
int tcfs_link(v)
-void *v;
+ void *v;
{
struct vop_link_args *x;
struct ucred *cr;
struct proc *pr;
tcfs_fileinfo i;
- x=(struct vop_link_args *)v;
- cr=x->a_cnp->cn_cred;
- pr=x->a_cnp->cn_proc;
- i=tcfs_xgetflags(x->a_dvp,pr,cr);
+ x = (struct vop_link_args *)v;
+ cr = x->a_cnp->cn_cred;
+ pr = x->a_cnp->cn_proc;
+ i = tcfs_xgetflags(x->a_dvp, pr, cr);
- if(FI_CFLAG(&i)||FI_GSHAR(&i))
- return tcfs_new_direntry(v,&i);
+ if (FI_CFLAG(&i) || FI_GSHAR(&i))
+ return tcfs_new_direntry(v, &i);
else
- return tcfs_bypass(v);
+ return tcfs_bypass(v);
}
-int tcfs_symlink(v)
-void *v;
+int
+tcfs_symlink(v)
+ void *v;
{
struct vop_symlink_args *x;
struct ucred *cr;
struct proc *pr;
tcfs_fileinfo i;
- x=(struct vop_symlink_args *)v;
- cr=x->a_cnp->cn_cred;
- pr=x->a_cnp->cn_proc;
- i=tcfs_xgetflags(x->a_dvp,pr,cr);
+ x = (struct vop_symlink_args *)v;
+ cr = x->a_cnp->cn_cred;
+ pr = x->a_cnp->cn_proc;
+ i = tcfs_xgetflags(x->a_dvp,pr,cr);
- if(FI_CFLAG(&i)||FI_GSHAR(&i))
- return tcfs_new_direntry(v,&i);
+ if (FI_CFLAG(&i) || FI_GSHAR(&i))
+ return tcfs_new_direntry(v, &i);
else
return tcfs_bypass(v);
}
-int tcfs_readdir(v)
-void *v;
+int
+tcfs_readdir(v)
+ void *v;
{
/*
tcfs_fileinfo i;
@@ -208,8 +214,9 @@ void *v;
return tcfs_bypass(v);
}
-int tcfs_rename(v)
-void *v;
+int
+tcfs_rename(v)
+ void *v;
{
return tcfs_bypass(v);
}
diff --git a/sys/miscfs/tcfs/tcfs_fileinfo.c b/sys/miscfs/tcfs/tcfs_fileinfo.c
index e2c7c3b6757..37cbd938435 100644
--- a/sys/miscfs/tcfs/tcfs_fileinfo.c
+++ b/sys/miscfs/tcfs/tcfs_fileinfo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcfs_fileinfo.c,v 1.2 2000/06/17 17:32:27 provos Exp $ */
+/* $OpenBSD: tcfs_fileinfo.c,v 1.3 2000/06/17 20:25:54 provos Exp $ */
/*
* Copyright 2000 The TCFS Project at http://tcfs.dia.unisa.it/
* All rights reserved.
@@ -36,67 +36,73 @@
#include <sys/malloc.h>
#include <sys/buf.h>
#include <sys/stat.h>
+
#include <miscfs/tcfs/tcfs.h>
-#include "tcfs_rw.h"
+#include <miscfs/tcfs/tcfs_rw.h>
-tcfs_fileinfo tcfs_xgetflags(struct vnode *v, struct proc *p, struct ucred *c)
+tcfs_fileinfo
+tcfs_xgetflags(struct vnode *v, struct proc *p, struct ucred *c)
{
tcfs_fileinfo r;
struct vop_getattr_args x;
struct vattr att;
int retval;
- att=va_null;
- x.a_desc=VDESC(vop_getattr);
- x.a_vp=v;
- x.a_vap=&att;
- x.a_cred=c;
- x.a_p=p;
+ att = va_null;
+ x.a_desc = VDESC(vop_getattr);
+ x.a_vp = v;
+ x.a_vap = &att;
+ x.a_cred = c;
+ x.a_p = p;
- retval=tcfs_bypass((void*)&x);
- r.flag=(unsigned long)(x.a_vap->va_flags);
- r.end_of_file=x.a_vap->va_size;
+ retval = tcfs_bypass((void*)&x);
+ r.flag = (unsigned long)(x.a_vap->va_flags);
+ r.end_of_file = x.a_vap->va_size;
return r;
}
-int tcfs_xsetflags(struct vnode *v, struct proc *p, struct ucred *c, tcfs_fileinfo *i)
+int
+tcfs_xsetflags(struct vnode *v, struct proc *p, struct ucred *c,
+ tcfs_fileinfo *i)
{
struct vop_setattr_args x;
struct vattr att;
int retval;
- att=va_null;
+ att = va_null;
- att.va_flags=i->flag;
+ att.va_flags = i->flag;
- x.a_desc=VDESC(vop_setattr);
- x.a_vp=v;
- x.a_vap=&att;
- x.a_cred=c;
- x.a_p=p;
+ x.a_desc = VDESC(vop_setattr);
+ x.a_vp = v;
+ x.a_vap = &att;
+ x.a_cred = c;
+ x.a_p = p;
- retval=tcfs_bypass((void*)&x);
+ retval = tcfs_bypass((void*)&x);
return retval;
}
-tcfs_fileinfo tcfs_get_fileinfo(void *a)
+tcfs_fileinfo
+tcfs_get_fileinfo(void *a)
{
struct vop_read_args *arg;
- arg=(struct vop_read_args*)a;
- return tcfs_xgetflags(arg->a_vp,arg->a_uio->uio_procp,arg->a_cred);
+ arg = (struct vop_read_args*)a;
+ return tcfs_xgetflags(arg->a_vp, arg->a_uio->uio_procp, arg->a_cred);
}
-int tcfs_set_fileinfo(void *a, tcfs_fileinfo *i)
+int
+tcfs_set_fileinfo(void *a, tcfs_fileinfo *i)
{
struct vop_read_args *arg;
- arg=(struct vop_read_args*)a;
- return tcfs_xsetflags(arg->a_vp, arg->a_uio->uio_procp,arg->a_cred,i); ;
+ arg = (struct vop_read_args*)a;
+ return tcfs_xsetflags(arg->a_vp, arg->a_uio->uio_procp,
+ arg->a_cred, i);
}
-
diff --git a/sys/miscfs/tcfs/tcfs_fileinfo.h b/sys/miscfs/tcfs/tcfs_fileinfo.h
index b55cb016710..c000bf2fa7c 100644
--- a/sys/miscfs/tcfs/tcfs_fileinfo.h
+++ b/sys/miscfs/tcfs/tcfs_fileinfo.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcfs_fileinfo.h,v 1.2 2000/06/17 17:32:27 provos Exp $ */
+/* $OpenBSD: tcfs_fileinfo.h,v 1.3 2000/06/17 20:25:54 provos Exp $ */
/*
* Copyright 2000 The TCFS Project at http://tcfs.dia.unisa.it/
* All rights reserved.
@@ -25,14 +25,13 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/* Gestione informazioni sui files cifrati
-*/
+/* Management information for files */
typedef struct {
- unsigned long flag;
- unsigned int end_of_file;
- } tcfs_fileinfo;
+ unsigned long flag;
+ unsigned int end_of_file;
+} tcfs_fileinfo;
#define MBFLAG 0x00000010
#define SPFLAG 0x000000e0
@@ -52,7 +51,7 @@ typedef struct {
#define FI_SET_GS(x,y) ((x)->flag=\
((x)->flag & (~GSFLAG))|((y<<8)&GSFLAG))
-/* prototipi */
+/* Function prototypes */
tcfs_fileinfo tcfs_get_fileinfo(void *);
tcfs_fileinfo tcfs_xgetflags(struct vnode *,struct proc *,struct ucred*);
diff --git a/sys/miscfs/tcfs/tcfs_interp.c b/sys/miscfs/tcfs/tcfs_interp.c
index b4ae0674b2e..3b4d9ef9fa6 100644
--- a/sys/miscfs/tcfs/tcfs_interp.c
+++ b/sys/miscfs/tcfs/tcfs_interp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcfs_interp.c,v 1.2 2000/06/17 17:32:27 provos Exp $ */
+/* $OpenBSD: tcfs_interp.c,v 1.3 2000/06/17 20:25:54 provos Exp $ */
/*
* Copyright 2000 The TCFS Project at http://tcfs.dia.unisa.it/
* All rights reserved.
@@ -25,11 +25,12 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include<sys/types.h>
-#include<sys/malloc.h>
-#include<sys/errno.h>
-#include "tcfs_keytab.h"
-#include "tcfs_cipher.h"
+#include <sys/types.h>
+#include <sys/malloc.h>
+#include <sys/errno.h>
+
+#include <miscfs/tcfs/tcfs_keytab.h>
+#include <miscfs/tcfs/tcfs_cipher.h>
int interp(tcfs_grp_data *,unsigned char *);
void doinverse(void);
@@ -76,80 +77,81 @@ unsigned int mod(long a)
}
*/
-int interp(tcfs_grp_data *gd,unsigned char *gidkey)
+int
+interp(tcfs_grp_data *gd,unsigned char *gidkey)
{
unsigned int tp,kkk;
- int i=0,j,l,idx;
- tcfs_grp_uinfo ktmp[MAXUSRPERGRP],*gui;
- unsigned int inv,ttt;
+ int i = 0, j, l, idx;
+ tcfs_grp_uinfo ktmp[MAXUSRPERGRP], *gui;
+ unsigned int inv, ttt;
union bobbit obits;
int k;
- k=gd->gd_k;
+ k = gd->gd_k;
- for (i=0;i<MAXUSRPERGRP && i<k;i++)
- {
- gui=&(gd->gd_part[i]);
- if(!IS_SET_GUI(*gui))
+ for (i = 0; i < MAXUSRPERGRP && i < k; i++) {
+ gui = &(gd->gd_part[i]);
+ if (!IS_SET_GUI(*gui))
continue;
- ktmp[i].gui_uid=gui->gui_uid;
+ ktmp[i].gui_uid = gui->gui_uid;
- for(l=0;l<KEYSIZE/8;l++){
- obits.byte=gui->gui_tcfskey[9*l+8];
- ktmp[i].gui_tcfskey[8*l+0]=mod(obits.bf.b1<<8 | gui->gui_tcfskey[9*l+0]);
- ktmp[i].gui_tcfskey[8*l+1]=mod(obits.bf.b2<<8 | gui->gui_tcfskey[9*l+1]);
- ktmp[i].gui_tcfskey[8*l+2]=mod(obits.bf.b3<<8 | gui->gui_tcfskey[9*l+2]);
- ktmp[i].gui_tcfskey[8*l+3]=mod(obits.bf.b4<<8 | gui->gui_tcfskey[9*l+3]);
- ktmp[i].gui_tcfskey[8*l+4]=mod(obits.bf.b5<<8 | gui->gui_tcfskey[9*l+4]);
- ktmp[i].gui_tcfskey[8*l+5]=mod(obits.bf.b6<<8 | gui->gui_tcfskey[9*l+5]);
- ktmp[i].gui_tcfskey[8*l+6]=mod(obits.bf.b7<<8 | gui->gui_tcfskey[9*l+6]);
- ktmp[i].gui_tcfskey[8*l+7]=mod(obits.bf.b8<<8 | gui->gui_tcfskey[9*l+7]);
+ for(l = 0; l < KEYSIZE/8; l++) {
+ obits.byte = gui->gui_tcfskey[9*l+8];
+ ktmp[i].gui_tcfskey[8*l+0] = mod(obits.bf.b1<<8 | gui->gui_tcfskey[9*l+0]);
+ ktmp[i].gui_tcfskey[8*l+1] = mod(obits.bf.b2<<8 | gui->gui_tcfskey[9*l+1]);
+ ktmp[i].gui_tcfskey[8*l+2] = mod(obits.bf.b3<<8 | gui->gui_tcfskey[9*l+2]);
+ ktmp[i].gui_tcfskey[8*l+3] = mod(obits.bf.b4<<8 | gui->gui_tcfskey[9*l+3]);
+ ktmp[i].gui_tcfskey[8*l+4] = mod(obits.bf.b5<<8 | gui->gui_tcfskey[9*l+4]);
+ ktmp[i].gui_tcfskey[8*l+5] = mod(obits.bf.b6<<8 | gui->gui_tcfskey[9*l+5]);
+ ktmp[i].gui_tcfskey[8*l+6] = mod(obits.bf.b7<<8 | gui->gui_tcfskey[9*l+6]);
+ ktmp[i].gui_tcfskey[8*l+7] = mod(obits.bf.b8<<8 | gui->gui_tcfskey[9*l+7]);
}
i++;
}
- for (idx=0;idx<KEYSIZE;idx++) {
- kkk=0;
- for (i=0;i<k;i++) {
- tp=1;
- for (j=0;j<k;j++) {
- if (j!=i) {
+ for (idx = 0;idx<KEYSIZE;idx++) {
+ kkk = 0;
+ for (i = 0; i < k; i++) {
+ tp = 1;
+ for (j = 0; j < k; j++) {
+ if (j != i) {
inv = inverse[mod(ktmp[i].gui_uid-ktmp[j].gui_uid)];
ttt = mod(inv * mod(-ktmp[j].gui_uid));
tp = mod(tp * ttt);
}
}
tp *= mod(ktmp[i].gui_tcfskey[idx]);
- kkk=(tp+kkk);
+ kkk= (tp + kkk);
}
- gidkey[idx]=(unsigned char)mod(kkk);
+ gidkey[idx] = (unsigned char)mod(kkk);
}
return 0;
}
-void doinverse(void)
+void
+doinverse(void)
{
- int i,j;
- for (i=0;i<257;i++) {
- for (j=0;j<257;j++) {
- if (mod((i*j))==1)
- inverse[i]=j;
+ int i, j;
+ for (i = 0; i < 257; i++) {
+ for (j = 0; j < 257; j++) {
+ if (mod((i*j)) == 1)
+ inverse[i] = j;
}
}
}
-int tcfs_interp(struct tcfs_mount *mp, tcfs_keytab_node* x)
+int
+tcfs_interp(struct tcfs_mount *mp, tcfs_keytab_node* x)
{
void *ks;
char key[KEYSIZE];
interp(x->kn_data,key);
- ks=TCFS_INIT_KEY(mp,key);
+ ks = TCFS_INIT_KEY(mp,key);
if (!ks)
return ENOMEM;
- x->kn_key=ks;
+ x->kn_key = ks;
return TCFS_OK;
}
-
diff --git a/sys/miscfs/tcfs/tcfs_keytab.c b/sys/miscfs/tcfs/tcfs_keytab.c
index 9e1a80e42c5..bee51e6fdfd 100644
--- a/sys/miscfs/tcfs/tcfs_keytab.c
+++ b/sys/miscfs/tcfs/tcfs_keytab.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcfs_keytab.c,v 1.2 2000/06/17 17:32:27 provos Exp $ */
+/* $OpenBSD: tcfs_keytab.c,v 1.3 2000/06/17 20:25:55 provos Exp $ */
/*
* Copyright 2000 The TCFS Project at http://tcfs.dia.unisa.it/
* All rights reserved.
@@ -25,460 +25,453 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include<sys/errno.h>
-#include<sys/types.h>
-#include<sys/systm.h>
-#ifndef _TCFS_KEYTAB_H_
-#include "tcfs_keytab.h"
-#endif
-#include<sys/malloc.h>
-
-tcfs_keytab_node *tcfs_keytab_newnode()
+#include <sys/errno.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <miscfs/tcfs/tcfs_keytab.h>
+#include <sys/malloc.h>
+
+tcfs_keytab_node *
+tcfs_keytab_newnode()
{
tcfs_keytab_node *n;
- n=(tcfs_keytab_node*)malloc(sizeof(tcfs_keytab_node),M_FREE,M_NOWAIT);
- if(!n)
+ n = (tcfs_keytab_node*)malloc(sizeof(tcfs_keytab_node),
+ M_FREE, M_NOWAIT);
+ if (!n)
return n;
- n->kn_key=(void*)0;
- n->kn_data=(tcfs_grp_data*)0;
- n->kn_type=CLEAN;
- n->kn_n=n->kn_p=NIL;
+ n->kn_key = (void*)0;
+ n->kn_data = (tcfs_grp_data*)0;
+ n->kn_type = CLEAN;
+ n->kn_n = n->kn_p = NIL;
return n;
}
-tcfs_keytab_node *tcfs_keytab_newgidnode()
+tcfs_keytab_node *
+tcfs_keytab_newgidnode()
{
tcfs_keytab_node *n;
tcfs_grp_data *gd;
int i;
- n=tcfs_keytab_newnode();
- if(!n)
+ n = tcfs_keytab_newnode();
+ if (!n)
return n;
- gd=(tcfs_grp_data*)malloc(sizeof(tcfs_grp_data),M_FREE,M_NOWAIT);
- if(!gd)
- {
- tcfs_keytab_dispnode(n);
- return NIL;
- }
- gd->gd_n=0;
- gd->gd_k=0;
- for(i=0;i<MAXUSRPERGRP;i++);
- {
- gd->gd_part[i].gui_flag=GUI_CLEAN;
- gd->gd_part[i].gui_uid=65535; /* nobody */
- }
+ gd = (tcfs_grp_data*)malloc(sizeof(tcfs_grp_data), M_FREE, M_NOWAIT);
+ if (!gd) {
+ tcfs_keytab_dispnode(n);
+ return NIL;
+ }
+ gd->gd_n = 0;
+ gd->gd_k = 0;
+ for(i = 0; i < MAXUSRPERGRP; i++); {
+ gd->gd_part[i].gui_flag = GUI_CLEAN;
+ gd->gd_part[i].gui_uid = -2; /* nfs nobody */
+ }
- n->kn_data=gd;
- n->kn_type=GID_KEY;
- n->kn_key=(void*)0;
+ n->kn_data = gd;
+ n->kn_type = GID_KEY;
+ n->kn_key = (void*)0;
return n;
}
-void tcfs_keytab_dispnode(tcfs_keytab_node *n)
+void
+tcfs_keytab_dispnode(tcfs_keytab_node *n)
{
- if(n->kn_key)
+ if (n->kn_key)
free(n->kn_key,M_FREE);
- if(n->kn_data)
+ if (n->kn_data)
free(n->kn_data,M_FREE);
- if(n)
+ if (n)
free(n,M_FREE);
}
-tcfs_keytab *tcfs_keytab_init()
+tcfs_keytab *
+tcfs_keytab_init()
{
tcfs_keytab *x;
int i;
- x=(tcfs_keytab*)malloc(sizeof(tcfs_keytab),M_FREE,M_NOWAIT);
+ x = (tcfs_keytab*)malloc(sizeof(tcfs_keytab),M_FREE,M_NOWAIT);
if (!x)
return x;
- x->cnt=0;
+ x->cnt = 0;
- for(i=0;i<KEYTABSIZE;i++) /*una bzero o simile magari */
- x->node[i]=NIL;
+ for(i = 0; i < KEYTABSIZE; i++) /* one bzero or similar even */
+ x->node[i] = NIL;
return x;
}
-void tcfs_keytab_dispose(tcfs_keytab *kt)
+void
+tcfs_keytab_dispose(tcfs_keytab *kt)
{
tcfs_keytab_node *p,*q;
- int i=0;
+ int i = 0;
if(kt->cnt)
- for(i=0;i<KEYTABSIZE;i++)
- {
- p=kt->node[i];
- while(p!=NIL)
- {
- q=p->kn_n;
- tcfs_keytab_dispnode(p);
- p=q;
- }
+ for(i = 0;i < KEYTABSIZE; i++) {
+ p = kt->node[i];
+ while (p != NIL) {
+ q = p->kn_n;
+ tcfs_keytab_dispnode(p);
+ p = q;
}
+ }
- free(kt,M_FREE);
+ free(kt, M_FREE);
}
-int tcfs_keytab_check_uid(tcfs_keytab *t, uid_t uid)
+int
+tcfs_keytab_check_uid(tcfs_keytab *t, uid_t uid)
{
int pos;
tcfs_keytab_node *p;
- pos=tcfs_keytab_hash(uid);
- p=t->node[pos];
+ pos = tcfs_keytab_hash(uid);
+ p = t->node[pos];
- while(p!=NIL)
- {
- if (IS_UID_NODE(p) && p->kn_uid==uid)
+ while(p!=NIL) {
+ if (IS_UID_NODE(p) && p->kn_uid == uid)
return 1;
p=p->kn_n;
}
return 0;
}
-
-tcfs_keytab_node *tcfs_keytab_fetch_uid(tcfs_keytab *t, uid_t uid)
+tcfs_keytab_node *
+tcfs_keytab_fetch_uid(tcfs_keytab *t, uid_t uid)
{
tcfs_keytab_node *p;
int pos;
- pos=tcfs_keytab_hash(uid);
- p=t->node[pos];
- while(p!=NIL)
- {
- if(IS_UID_NODE(p) && p->kn_uid==uid)
+ pos = tcfs_keytab_hash(uid);
+ p = t->node[pos];
+ while (p != NIL) {
+ if (IS_UID_NODE(p) && p->kn_uid == uid)
break;
- p=p->kn_n;
+ p = p->kn_n;
}
return p;
}
-int tcfs_keytab_check_gid(tcfs_keytab *t, gid_t gid)
+int
+tcfs_keytab_check_gid(tcfs_keytab *t, gid_t gid)
{
tcfs_keytab_node *p;
int pos;
- pos=tcfs_keytab_hash(gid);
- p=t->node[pos];
+ pos = tcfs_keytab_hash(gid);
+ p = t->node[pos];
- while (p!=NIL)
- {
- if(IS_GID_NODE(p) && p->kn_gid==gid && IS_READY_GD(p->kn_data))
+ while (p!=NIL) {
+ if (IS_GID_NODE(p) && p->kn_gid == gid &&
+ IS_READY_GD(p->kn_data))
return 1;
p=p->kn_n;
}
return 0;
}
-
-tcfs_keytab_node *tcfs_keytab_fetch_gid(tcfs_keytab *t, gid_t gid)
+tcfs_keytab_node *
+tcfs_keytab_fetch_gid(tcfs_keytab *t, gid_t gid)
{
tcfs_keytab_node *p;
int pos;
- pos=tcfs_keytab_hash(gid);
- p=t->node[pos];
- while(p!=NIL)
- {
- if(IS_GID_NODE(p) && p->kn_gid==gid)
+ pos = tcfs_keytab_hash(gid);
+ p = t->node[pos];
+ while (p != NIL) {
+ if (IS_GID_NODE(p) && p->kn_gid == gid)
break;
- p=p->kn_n;
+ p = p->kn_n;
}
return p;
}
-
-
-int tcfs_keytab_check_pid(tcfs_keytab *t, uid_t uid, pid_t pid)
+int
+tcfs_keytab_check_pid(tcfs_keytab *t, uid_t uid, pid_t pid)
{
int pos;
tcfs_keytab_node *p;
- pos=tcfs_keytab_hash(pid);
- p=t->node[pos];
+ pos = tcfs_keytab_hash(pid);
+ p = t->node[pos];
- while(p!=NIL)
- {
- if (IS_PID_NODE(p) && p->kn_pid==pid && p->kn_uid==uid)
+ while (p != NIL) {
+ if (IS_PID_NODE(p) && p->kn_pid == pid && p->kn_uid == uid)
return 1;
- p=p->kn_n;
+ p = p->kn_n;
}
return 0;
}
-tcfs_keytab_node *tcfs_keytab_fetch_pid(tcfs_keytab *t, uid_t uid, pid_t pid)
+tcfs_keytab_node *
+tcfs_keytab_fetch_pid(tcfs_keytab *t, uid_t uid, pid_t pid)
{
tcfs_keytab_node *p;
int pos;
- pos=tcfs_keytab_hash(pid);
- p=t->node[pos];
+ pos = tcfs_keytab_hash(pid);
+ p = t->node[pos];
- while(p!=NIL)
- {
- if(IS_PID_NODE(p) && p->kn_pid==pid && p->kn_uid==uid)
+ while (p != NIL) {
+ if (IS_PID_NODE(p) && p->kn_pid == pid && p->kn_uid == uid)
break;
- p=p->kn_n;
+ p = p->kn_n;
}
- return p;
+ return (p);
}
-int tcfs_keytab_push_pid(tcfs_keytab *t, uid_t uid, pid_t pid, void *ks)
+int
+tcfs_keytab_push_pid(tcfs_keytab *t, uid_t uid, pid_t pid, void *ks)
{
- int pos=0;
+ int pos = 0;
tcfs_keytab_node *p,*q;
- if(tcfs_keytab_fetch_pid(t,uid,pid)!=NIL)
- return EINVAL;
+ if (tcfs_keytab_fetch_pid(t, uid, pid) != NIL)
+ return (EINVAL);
- q=tcfs_keytab_newnode();
- if(!q)
- return ENOMEM;
+ q = tcfs_keytab_newnode();
+ if (!q)
+ return (ENOMEM);
- pos=tcfs_keytab_hash(pid);
+ pos = tcfs_keytab_hash(pid);
- p=t->node[pos];
- q->kn_n=p;
- if(p!=NIL)
- p->kn_p=q;
- t->node[pos]=q;
+ p = t->node[pos];
+ q->kn_n = p;
+ if (p != NIL)
+ p->kn_p = q;
+ t->node[pos] = q;
t->cnt++;
- q->kn_uid=uid;
- q->kn_pid=pid;
- q->kn_key=ks;
- q->kn_type=PID_KEY;
+ q->kn_uid = uid;
+ q->kn_pid = pid;
+ q->kn_key = ks;
+ q->kn_type = PID_KEY;
return TCFS_OK;
}
-int tcfs_keytab_push_uid(tcfs_keytab *t, uid_t uid, void *key)
+int
+tcfs_keytab_push_uid(tcfs_keytab *t, uid_t uid, void *key)
{
- int pos=0;
+ int pos = 0;
tcfs_keytab_node *p,*q;
+ if (tcfs_keytab_fetch_uid(t,uid) != NIL)
+ return (EINVAL);
- if(tcfs_keytab_fetch_uid(t,uid)!=NIL)
- return EINVAL;
-
- q=tcfs_keytab_newnode();
- if(!q)
- return ENOMEM;
+ q = tcfs_keytab_newnode();
+ if (!q)
+ return (ENOMEM);
- pos=tcfs_keytab_hash(uid);
+ pos = tcfs_keytab_hash(uid);
- p=t->node[pos];
- q->kn_n=p;
- if(p!=NIL)
- p->kn_p=q;
- t->node[pos]=q;
+ p = t->node[pos];
+ q->kn_n = p;
+ if (p != NIL)
+ p->kn_p = q;
+ t->node[pos] = q;
t->cnt++;
- q->kn_uid=uid;
- q->kn_pid=0;
- q->kn_key=key;
- q->kn_type=UID_KEY;
+ q->kn_uid = uid;
+ q->kn_pid = 0;
+ q->kn_key = key;
+ q->kn_type = UID_KEY;
- return TCFS_OK;
+ return (TCFS_OK);
}
-int tcfs_keytab_push_gidpart(struct tcfs_mount *mp,tcfs_keytab_node *kn,uid_t uid, gid_t gid, int k,char *key)
+int
+tcfs_keytab_push_gidpart(struct tcfs_mount *mp,tcfs_keytab_node *kn,uid_t uid,
+ gid_t gid, int k, char *key)
{
- int i=0;
- int first=-1;
+ int i = 0;
+ int first = -1;
tcfs_grp_data *p;
- p=kn->kn_data;
+ p = kn->kn_data;
- if(IS_FULL_GD(p))
- return EINVAL;
+ if (IS_FULL_GD(p))
+ return (EINVAL);
- for (i=0;i<MAXUSRPERGRP;i++)
- {
- if(first<0 && !IS_SET_GUI(p->gd_part[i]))
- {
- first=i;
- continue;
- }
- if(IS_SET_GUI(p->gd_part[i]) &&
- p->gd_part[i].gui_uid==uid)
- return EINVAL;
+ for (i = 0; i < MAXUSRPERGRP; i++) {
+ if (first < 0 && !IS_SET_GUI(p->gd_part[i])) {
+ first=i;
+ continue;
+ }
+ if(IS_SET_GUI(p->gd_part[i]) && p->gd_part[i].gui_uid == uid)
+ return (EINVAL);
}
- p->gd_part[first].gui_uid=uid;
- p->gd_part[first].gui_flag=GUI_SET;
- memcpy(p->gd_part[first].gui_tcfskey,key,KEYPARTSIZE);
- if(IS_CLEAN_GD(p))
- p->gd_k=k;
+ p->gd_part[first].gui_uid = uid;
+ p->gd_part[first].gui_flag = GUI_SET;
+ memcpy(p->gd_part[first].gui_tcfskey, key, KEYPARTSIZE);
+ if (IS_CLEAN_GD(p))
+ p->gd_k = k;
p->gd_n++;
- if(IS_READY_GD(p)&&(!kn->kn_key))
+ if (IS_READY_GD(p) && (!kn->kn_key))
tcfs_interp(mp,kn);
- return TCFS_OK;
+ return (TCFS_OK);
}
-int tcfs_keytab_rm_gidpart(tcfs_keytab_node *kn, uid_t uid, gid_t gid)
+int
+tcfs_keytab_rm_gidpart(tcfs_keytab_node *kn, uid_t uid, gid_t gid)
{
- int i=0;
+ int i = 0;
tcfs_grp_data *p;
- p=kn->kn_data;
+ p = kn->kn_data;
- if(IS_CLEAN_GD(p))
- return EINVAL;
-
- for (i=0;i<MAXUSRPERGRP;i++)
- if(IS_SET_GUI(p->gd_part[i]))
- if(p->gd_part[i].gui_uid==uid)
- {
- p->gd_part[i].gui_flag=GUI_CLEAN;
- break;
- }
+ if (IS_CLEAN_GD(p))
+ return (EINVAL);
+
+ for (i = 0; i < MAXUSRPERGRP; i++)
+ if (IS_SET_GUI(p->gd_part[i]))
+ if(p->gd_part[i].gui_uid == uid) {
+ p->gd_part[i].gui_flag=GUI_CLEAN;
+ break;
+ }
- if (i==MAXUSRPERGRP)
+ if ( i == MAXUSRPERGRP)
return EINVAL;
p->gd_n--;
- if(!IS_READY_GD(p))
- if(kn->kn_key)
- {
- free(kn->kn_key,M_FREE);
- kn->kn_key=(void*)0;
- }
+ if (!IS_READY_GD(p))
+ if(kn->kn_key) {
+ free(kn->kn_key,M_FREE);
+ kn->kn_key=(void*)0;
+ }
- return TCFS_OK;
+ return (TCFS_OK);
}
-int tcfs_keytab_push_gid(struct tcfs_mount *mp,tcfs_keytab *t, uid_t uid, gid_t gid, int k, char* key)
+int
+tcfs_keytab_push_gid(struct tcfs_mount *mp, tcfs_keytab *t, uid_t uid,
+ gid_t gid, int k, char *key)
{
- int pos=0;
+ int pos = 0;
tcfs_keytab_node *p,*q,*r;
- q=r=tcfs_keytab_fetch_gid(t,gid);
+ q = r = tcfs_keytab_fetch_gid(t,gid);
- if(r==NIL)
- {
- q=tcfs_keytab_newgidnode();
- if(!q)
- return ENOMEM;
+ if (r == NIL) {
+ q = tcfs_keytab_newgidnode();
+ if (!q)
+ return (ENOMEM);
- pos=tcfs_keytab_hash(gid);
+ pos = tcfs_keytab_hash(gid);
- p=t->node[pos];
- q->kn_n=p;
- if(p!=NIL)
- p->kn_p=q;
- t->node[pos]=q;
+ p = t->node[pos];
+ q->kn_n = p;
+ if (p != NIL)
+ p->kn_p = q;
+ t->node[pos] = q;
t->cnt++;
- q->kn_gid=gid;
- q->kn_pid=0;
- q->kn_uid=0;
+ q->kn_gid = gid;
+ q->kn_pid = 0;
+ q->kn_uid = 0;
}
- return tcfs_keytab_push_gidpart(mp,q,uid,gid,k,key);
+ return tcfs_keytab_push_gidpart(mp, q, uid, gid, k, key);
}
-int tcfs_keytab_rm_uid(tcfs_keytab *t, uid_t uid)
+int
+tcfs_keytab_rm_uid(tcfs_keytab *t, uid_t uid)
{
- int pos=0;
+ int pos = 0;
tcfs_keytab_node *p;
- p=tcfs_keytab_fetch_uid(t,uid);
- if(p==NIL)
- return EINVAL;
+ p = tcfs_keytab_fetch_uid(t, uid);
+ if (p == NIL)
+ return (EINVAL);
- if(p->kn_p==NIL)
- {
- pos=tcfs_keytab_hash(uid);
- t->node[pos]=p->kn_n;
- }
- else
- p->kn_p->kn_n=p->kn_n;
+ if (p->kn_p == NIL) {
+ pos = tcfs_keytab_hash(uid);
+ t->node[pos] = p->kn_n;
+ } else
+ p->kn_p->kn_n = p->kn_n;
- if(p->kn_n!=NIL)
- p->kn_n->kn_p=p->kn_p;
+ if (p->kn_n != NIL)
+ p->kn_n->kn_p = p->kn_p;
t->cnt--;
tcfs_keytab_dispnode(p);
- return TCFS_OK;
+ return (TCFS_OK);
}
-int tcfs_keytab_rm_pid(tcfs_keytab *t, uid_t uid, pid_t pid)
+int
+tcfs_keytab_rm_pid(tcfs_keytab *t, uid_t uid, pid_t pid)
{
- int pos=0;
+ int pos = 0;
tcfs_keytab_node *p;
- p=tcfs_keytab_fetch_pid(t,uid,pid);
- if(p==NIL)
- return EINVAL;
+ p = tcfs_keytab_fetch_pid(t,uid,pid);
+ if (p == NIL)
+ return (EINVAL);
- if(p->kn_p==NIL)
- {
- pos=tcfs_keytab_hash(pid);
- t->node[pos]=p->kn_n;
- }
- else
- p->kn_p->kn_n=p->kn_n;
+ if(p->kn_p == NIL) {
+ pos = tcfs_keytab_hash(pid);
+ t->node[pos] = p->kn_n;
+ } else
+ p->kn_p->kn_n = p->kn_n;
- if(p->kn_n!=NIL)
- p->kn_n->kn_p=p->kn_p;
+ if(p->kn_n != NIL)
+ p->kn_n->kn_p = p->kn_p;
t->cnt--;
tcfs_keytab_dispnode(p);
- return TCFS_OK;
+ return (TCFS_OK);
}
-int tcfs_keytab_rm_gid(tcfs_keytab *t, uid_t uid, gid_t gid)
+int
+tcfs_keytab_rm_gid(tcfs_keytab *t, uid_t uid, gid_t gid)
{
- int pos=0,ret=0;
+ int pos = 0,ret = 0;
tcfs_keytab_node *p;
- p=tcfs_keytab_fetch_gid(t,gid);
- if(p==NIL)
- return EINVAL;
+ p = tcfs_keytab_fetch_gid(t,gid);
+ if (p == NIL)
+ return (EINVAL);
- ret=tcfs_keytab_rm_gidpart(p,uid,gid);
+ ret = tcfs_keytab_rm_gidpart(p, uid, gid);
if (ret)
- return ret;
+ return (ret);
- if(!IS_CLEAN_GD(p->kn_data))
- return TCFS_OK;
+ if (!IS_CLEAN_GD(p->kn_data))
+ return (TCFS_OK);
- if(p->kn_p==NIL)
- {
- pos=tcfs_keytab_hash(gid);
- t->node[pos]=p->kn_n;
- }
- else
- p->kn_p->kn_n=p->kn_n;
+ if (p->kn_p == NIL) {
+ pos = tcfs_keytab_hash(gid);
+ t->node[pos] = p->kn_n;
+ } else
+ p->kn_p->kn_n = p->kn_n;
- if(p->kn_n!=NIL)
- p->kn_n->kn_p=p->kn_p;
+ if (p->kn_n != NIL)
+ p->kn_n->kn_p = p->kn_p;
t->cnt--;
tcfs_keytab_dispnode(p);
- return TCFS_OK;
+ return (TCFS_OK);
}
-
diff --git a/sys/miscfs/tcfs/tcfs_keytab.h b/sys/miscfs/tcfs/tcfs_keytab.h
index 871bd840041..cdab1489c89 100644
--- a/sys/miscfs/tcfs/tcfs_keytab.h
+++ b/sys/miscfs/tcfs/tcfs_keytab.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcfs_keytab.h,v 1.2 2000/06/17 17:32:27 provos Exp $ */
+/* $OpenBSD: tcfs_keytab.h,v 1.3 2000/06/17 20:25:55 provos Exp $ */
/*
* Copyright 2000 The TCFS Project at http://tcfs.dia.unisa.it/
* All rights reserved.
@@ -25,15 +25,13 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef _SYS_TYPES_H_
-#include "sys/types.h"
-#endif
-#ifndef _TCFS_MOUNT_H_
+#ifndef _TCFS_KEYTAB_H_
+#define _TCFS_KEYTAB_H_
+
+#include <sys/types.h>
struct tcfs_mount;
-#endif
-#define _TCFS_KEYTAB_H_
-#define KEYTABSIZE 20
+#define KEYTABSIZE 20
#define KEYSIZE 8
#define KEYPARTSIZE (KEYSIZE+KEYSIZE/8)
@@ -53,23 +51,22 @@ struct tcfs_mount;
#define MAXUSRPERGRP 10
-typedef struct
- {
- unsigned char gui_flag;
- uid_t gui_uid;
- unsigned char gui_tcfskey[KEYPARTSIZE];
- } tcfs_grp_uinfo;
+typedef struct {
+ unsigned char gui_flag;
+ uid_t gui_uid;
+ unsigned char gui_tcfskey[KEYPARTSIZE];
+} tcfs_grp_uinfo;
#define GUI_CLEAN 0
#define GUI_SET 1
#define IS_SET_GUI(gui) ((gui).gui_flag==GUI_SET)
-typedef struct _grp_data {
- int gd_flag;
- int gd_n;
- int gd_k;
- tcfs_grp_uinfo gd_part[MAXUSRPERGRP];
- } tcfs_grp_data;
+typedef struct _grp_data {
+ int gd_flag;
+ int gd_n;
+ int gd_k;
+ tcfs_grp_uinfo gd_part[MAXUSRPERGRP];
+} tcfs_grp_data;
#define IS_CLEAN_GD(gd) ((gd)->gd_n==0)
#define IS_FULL_GD(gd) ((gd)->gd_n==MAXUSRPERGRP)
@@ -89,36 +86,37 @@ typedef struct _kn {
} tcfs_keytab_node;
typedef struct _kt {
- unsigned int cnt;
- tcfs_keytab_node* node[KEYTABSIZE];
- } tcfs_keytab;
+ unsigned int cnt;
+ tcfs_keytab_node* node[KEYTABSIZE];
+} tcfs_keytab;
#define NIL ((tcfs_keytab_node*)0)
#ifdef _HAVE_HASH_
-int _tcfs_keytab_hash(unsigned int);
+int _tcfs_keytab_hash __P(unsigned int));
#define tcfs_keytab_hash(x) _tcfs_keytab_hash((unsigned int)(x))
#else
#define tcfs_keytab_hash(u) ((u)%KEYTABSIZE)
#endif
-tcfs_keytab_node *tcfs_keytab_newnode(void);
-tcfs_keytab_node *tcfs_keytab_newgidnode(void);
-void tcfs_keytab_dispnode(tcfs_keytab_node*);
-tcfs_keytab *tcfs_keytab_init(void);
-void tcfs_keytab_dispose(tcfs_keytab*);
-tcfs_keytab_node *tcfs_keytab_fetch_uid(tcfs_keytab *, uid_t);
-int tcfs_keytab_push_gidpart(struct tcfs_mount *,tcfs_keytab_node *,uid_t, gid_t,int,char*);
-tcfs_keytab_node *tcfs_keytab_fetch_gid(tcfs_keytab *, gid_t);
-tcfs_keytab_node *tcfs_keytab_fetch_pid(tcfs_keytab *, uid_t, pid_t);
-int tcfs_keytab_push_uid(tcfs_keytab*, uid_t, void* );
-int tcfs_keytab_push_pid(tcfs_keytab*, uid_t, pid_t, void* );
-int tcfs_keytab_push_gid(struct tcfs_mount *,tcfs_keytab*, uid_t, gid_t,int,char*);
-int tcfs_keytab_rm_uid(tcfs_keytab*, uid_t);
-int tcfs_keytab_rm_pid(tcfs_keytab*, uid_t, pid_t);
-int tcfs_keytab_rm_gidpart(tcfs_keytab_node *,uid_t, gid_t);
-int tcfs_keytab_rm_gid(tcfs_keytab*, uid_t, gid_t);
-int tcfs_interp(struct tcfs_mount *, tcfs_keytab_node*);
-int tcfs_keytab_check_uid(tcfs_keytab *, uid_t);
-int tcfs_keytab_check_pid(tcfs_keytab *, uid_t, pid_t);
-int tcfs_keytab_check_gid(tcfs_keytab *, gid_t);
+tcfs_keytab_node *tcfs_keytab_newnode __P((void));
+tcfs_keytab_node *tcfs_keytab_newgidnode __P((void));
+void tcfs_keytab_dispnode __P((tcfs_keytab_node*));
+tcfs_keytab *tcfs_keytab_init __P((void));
+void tcfs_keytab_dispose __P((tcfs_keytab*));
+tcfs_keytab_node *tcfs_keytab_fetch_uid __P((tcfs_keytab *, uid_t));
+int tcfs_keytab_push_gidpart __P((struct tcfs_mount *,tcfs_keytab_node *,uid_t, gid_t,int,char*));
+tcfs_keytab_node *tcfs_keytab_fetch_gid __P((tcfs_keytab *, gid_t));
+tcfs_keytab_node *tcfs_keytab_fetch_pid __P((tcfs_keytab *, uid_t, pid_t));
+int tcfs_keytab_push_uid __P((tcfs_keytab*, uid_t, void* ));
+int tcfs_keytab_push_pid __P((tcfs_keytab*, uid_t, pid_t, void *));
+int tcfs_keytab_push_gid __P((struct tcfs_mount *,tcfs_keytab *, uid_t, gid_t, int, char *));
+int tcfs_keytab_rm_uid __P((tcfs_keytab *, uid_t));
+int tcfs_keytab_rm_pid __P((tcfs_keytab *, uid_t, pid_t));
+int tcfs_keytab_rm_gidpart __P((tcfs_keytab_node *,uid_t, gid_t));
+int tcfs_keytab_rm_gid __P((tcfs_keytab*, uid_t, gid_t));
+int tcfs_interp __P((struct tcfs_mount *, tcfs_keytab_node*));
+int tcfs_keytab_check_uid __P((tcfs_keytab *, uid_t));
+int tcfs_keytab_check_pid __P((tcfs_keytab *, uid_t, pid_t));
+int tcfs_keytab_check_gid __P((tcfs_keytab *, gid_t));
+#endif /* _TCFS_KEYTAB_H_ */
diff --git a/sys/miscfs/tcfs/tcfs_mount.h b/sys/miscfs/tcfs/tcfs_mount.h
index 024e22ef622..095ed23f3b5 100644
--- a/sys/miscfs/tcfs/tcfs_mount.h
+++ b/sys/miscfs/tcfs/tcfs_mount.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcfs_mount.h,v 1.2 2000/06/17 17:32:27 provos Exp $ */
+/* $OpenBSD: tcfs_mount.h,v 1.3 2000/06/17 20:25:55 provos Exp $ */
/*
* Copyright 2000 The TCFS Project at http://tcfs.dia.unisa.it/
* All rights reserved.
@@ -25,25 +25,23 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef _TCFS_KEYTAB_H_
-#include "tcfs_keytab.h"
-#endif
+#ifndef _TCFS_MOUNT_H_
#define _TCFS_MOUNT_H_
-#ifndef _TCFS_VERSION_H_
-#include "tcfs_version.h"
-#endif
+#include <miscfs/tcfs/tcfs_keytab.h>
+#include <miscfs/tcfs/tcfs_version.h>
#define MaxCipherNameLen 8
struct tcfs_status {
- int status;
- int n_ukey;
- int n_gkey;
- int tcfs_version;
- char cipher_desc[MaxCipherNameLen];
- int cipher_keysize;
- int cipher_version;
- };
+ int status;
+ int n_ukey;
+ int n_gkey;
+ int tcfs_version;
+ char cipher_desc[MaxCipherNameLen];
+ int cipher_keysize;
+ int cipher_version;
+};
+
struct tcfs_args {
char *target; /* Target of loopback */
char *tcfs_key; /* chiave */
@@ -59,8 +57,10 @@ struct tcfs_args {
struct tcfs_mount {
struct mount *tcfsm_vfs;
struct vnode *tcfsm_rootvp; /* Reference to root tcfs_node */
- void* ks;
+ void *ks;
tcfs_keytab *tcfs_uid_kt;
tcfs_keytab *tcfs_gid_kt;
int tcfs_cipher_num;
};
+
+#endif /* _TCFS_MOUNT_H_ */
diff --git a/sys/miscfs/tcfs/tcfs_rw.c b/sys/miscfs/tcfs/tcfs_rw.c
index 6df3dca3d8f..3bf31787b4a 100644
--- a/sys/miscfs/tcfs/tcfs_rw.c
+++ b/sys/miscfs/tcfs/tcfs_rw.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcfs_rw.c,v 1.2 2000/06/17 17:32:27 provos Exp $ */
+/* $OpenBSD: tcfs_rw.c,v 1.3 2000/06/17 20:25:55 provos Exp $ */
/*
* Copyright 2000 The TCFS Project at http://tcfs.dia.unisa.it/
* All rights reserved.
@@ -35,187 +35,167 @@
#include <sys/namei.h>
#include <sys/malloc.h>
#include <sys/buf.h>
+
#include <miscfs/tcfs/tcfs.h>
-#include "tcfs_rw.h"
-#include "tcfs_cipher.h"
+#include <miscfs/tcfs/tcfs_rw.h>
+#include <miscfs/tcfs/tcfs_cipher.h>
-tcfs_opinfo tcfs_get_opinfo(void *a)
+tcfs_opinfo
+tcfs_get_opinfo(void *a)
{
struct vop_read_args *arg;
tcfs_opinfo r;
tcfs_fileinfo *i;
- int iscr=0;
-
+ int iscr = 0;
- arg=(struct vop_read_args*)a;
+ arg = (struct vop_read_args*)a;
- r.i=tcfs_get_fileinfo(a);
- i=&(r.i);
+ r.i = tcfs_get_fileinfo(a);
+ i = &(r.i);
- iscr=FI_CFLAG(i)||FI_GSHAR(i);
+ iscr = FI_CFLAG(i) || FI_GSHAR(i);
- if(!iscr)
- {
- r.tcfs_op_desc=TCFS_NONE;
- return r;
- }
+ if(!iscr) {
+ r.tcfs_op_desc=TCFS_NONE;
+ return (r);
+ }
- r.off=arg->a_uio->uio_offset;
- r.req=arg->a_uio->uio_resid;
-
- if(arg->a_uio->uio_rw==UIO_READ)
- {
- if(r.off<FI_ENDOF(i)-FI_SPURE(i))
- {
- r.tcfs_op_desc=TCFS_READ_C1;
- r.out_boff=BOFF(&r);
- r.out_foff=
- (LAST(&r)>FI_ENDOF(i)-FI_SPURE(i)?FI_ENDOF(i):P_FOFF(&r));
- r.in_boff=r.out_boff;
- r.in_foff=r.out_foff;
- return r;
- }
- else
- {
- r.tcfs_op_desc=TCFS_READ_C2;
- r.out_boff=0;
- r.out_foff=0;
- return r;
+ r.off = arg->a_uio->uio_offset;
+ r.req = arg->a_uio->uio_resid;
+
+ if (arg->a_uio->uio_rw == UIO_READ) {
+ if(r.off<FI_ENDOF(i)-FI_SPURE(i)) {
+ r.tcfs_op_desc = TCFS_READ_C1;
+ r.out_boff = BOFF(&r);
+ r.out_foff = (LAST(&r)>FI_ENDOF(i)-FI_SPURE(i) ?
+ FI_ENDOF(i) : P_FOFF(&r));
+ r.in_boff = r.out_boff;
+ r.in_foff = r.out_foff;
+ return (r);
+ } else {
+ r.tcfs_op_desc = TCFS_READ_C2;
+ r.out_boff = 0;
+ r.out_foff = 0;
+ return (r);
}
}
- if(arg->a_uio->uio_rw==UIO_WRITE)
- {
- if(arg->a_ioflag&IO_APPEND)
- {
- r.off=FI_ENDOF(i)-FI_SPURE(i);
- arg->a_ioflag&=~(IO_APPEND);
+ if (arg->a_uio->uio_rw == UIO_WRITE) {
+ if (arg->a_ioflag&IO_APPEND) {
+ r.off = FI_ENDOF(i)-FI_SPURE(i);
+ arg->a_ioflag &= ~(IO_APPEND);
}
- if(LAST(&r)<FI_ENDOF(i)-FI_SPURE(i))
- {
- if (FI_ENDOF(i)-FI_SPURE(i)-LAST(&r)>BLOCKSIZE)
- {
- r.tcfs_op_desc=TCFS_WRITE_C1;
- r.out_boff=BOFF(&r);
- r.out_foff=FOFF(&r);
- r.in_boff=r.out_boff;
- r.in_foff=r.out_foff;
- return r;
- }
- else
- {
- r.tcfs_op_desc=TCFS_WRITE_C2;
- r.out_boff=BOFF(&r);
- r.out_foff=FI_ENDOF(i)-1;
- r.in_boff=r.out_boff;
- r.in_foff=r.out_foff;
- return r;
- }
+ if (LAST(&r) < FI_ENDOF(i) - FI_SPURE(i)) {
+ if (FI_ENDOF(i) - FI_SPURE(i) - LAST(&r) > BLOCKSIZE) {
+ r.tcfs_op_desc = TCFS_WRITE_C1;
+ r.out_boff = BOFF(&r);
+ r.out_foff = FOFF(&r);
+ r.in_boff = r.out_boff;
+ r.in_foff = r.out_foff;
+ return (r);
+ } else {
+ r.tcfs_op_desc = TCFS_WRITE_C2;
+ r.out_boff = BOFF(&r);
+ r.out_foff = FI_ENDOF(i) - 1;
+ r.in_boff = r.out_boff;
+ r.in_foff = r.out_foff;
+ return (r);
}
- if(LAST(&r)>=FI_ENDOF(i)-FI_SPURE(i))
- {
- r.out_boff=BOFF(&r);
- r.out_foff=P_FOFF(&r);
- if (r.off<=FI_ENDOF(i)-FI_SPURE(i))
- {
- r.tcfs_op_desc=TCFS_WRITE_C3;
- r.in_boff=r.out_boff;
- r.in_foff=r.out_foff;
- return r;
- }
- else
- if(D_BOFF(FI_ENDOF(i))==D_BOFF(r.off))
- {
- r.tcfs_op_desc=TCFS_WRITE_C4;
- r.in_boff=r.out_boff;
- r.in_foff=r.out_foff;
- return r;
- }
- else
- {
- r.tcfs_op_desc=TCFS_WRITE_C5;
- r.in_boff=D_BOFF(FI_ENDOF(i));
- r.in_foff=D_FOFF(FI_ENDOF(i));
- r.out_boff=BOFF(&r);
- r.out_foff=P_FOFF(&r);
- return r;
- }
+ }
+ if (LAST(&r) >= FI_ENDOF(i) - FI_SPURE(i)) {
+ r.out_boff = BOFF(&r);
+ r.out_foff = P_FOFF(&r);
+ if (r.off <= FI_ENDOF(i) - FI_SPURE(i)) {
+ r.tcfs_op_desc = TCFS_WRITE_C3;
+ r.in_boff = r.out_boff;
+ r.in_foff = r.out_foff;
+ return (r);
+ } else if(D_BOFF(FI_ENDOF(i))==D_BOFF(r.off)) {
+ r.tcfs_op_desc = TCFS_WRITE_C4;
+ r.in_boff = r.out_boff;
+ r.in_foff = r.out_foff;
+ return (r);
+ } else {
+ r.tcfs_op_desc = TCFS_WRITE_C5;
+ r.in_boff = D_BOFF(FI_ENDOF(i));
+ r.in_foff = D_FOFF(FI_ENDOF(i));
+ r.out_boff = BOFF(&r);
+ r.out_foff = P_FOFF(&r);
+ return (r);
}
+ }
}
- return r;
+ return (r);
}
-char *tcfs_new_uio_obs(struct uio *old, struct uio **new, int off, int bufsize)
+char *
+tcfs_new_uio_obs(struct uio *old, struct uio **new, int off, int bufsize)
{
char *buffer;
struct uio *u;
struct iovec *n;
- u=malloc(sizeof(struct uio),M_FREE,M_NOWAIT);
- if(!u)
- return (char*)0;
- n=malloc(sizeof(struct iovec),M_FREE,M_NOWAIT);
- if(!n)
- {
- free(u,M_FREE);
- return (char*)0;
- }
- buffer=malloc(bufsize,M_FREE,M_NOWAIT);
- if(!buffer)
- {
- free(u,M_FREE);
- free(n,M_FREE);
- return (char*)0;
- }
-
+ u = malloc(sizeof(struct uio), M_FREE, M_NOWAIT);
+ if (!u)
+ return (NULL);
+ n = malloc(sizeof(struct iovec), M_FREE, M_NOWAIT);
+ if (!n) {
+ free(u, M_FREE);
+ return (NULL);
+ }
+ buffer = malloc(bufsize,M_FREE,M_NOWAIT);
+ if (!buffer) {
+ free(u, M_FREE);
+ free(n, M_FREE);
+ return (NULL);
+ }
- u->uio_offset=off;
- u->uio_resid=bufsize;
- u->uio_iovcnt=1;
- u->uio_segflg=UIO_SYSSPACE;
- u->uio_rw=old->uio_rw;
- u->uio_procp=old->uio_procp;
- u->uio_iov=n;
- n->iov_base=buffer;
- n->iov_len=bufsize;
-
+ u->uio_offset = off;
+ u->uio_resid = bufsize;
+ u->uio_iovcnt = 1;
+ u->uio_segflg = UIO_SYSSPACE;
+ u->uio_rw = old->uio_rw;
+ u->uio_procp = old->uio_procp;
+ u->uio_iov = n;
+ n->iov_base = buffer;
+ n->iov_len = bufsize;
- *new=u;
- return buffer;
+ *new = u;
+ return (buffer);
}
-char *tcfs_new_uio_i(struct uio *old, struct uio **new,tcfs_opinfo *r)
+char *
+tcfs_new_uio_i(struct uio *old, struct uio **new, tcfs_opinfo *r)
{
int bufsize;
- char *buffer=NULL;
+ char *buffer = NULL;
- switch(r->tcfs_op_desc)
- {
- case TCFS_READ_C2:
- buffer=(char*)0;
- return buffer;
- default:
- case TCFS_READ_C1:
- case TCFS_WRITE_C1:
- case TCFS_WRITE_C2:
- case TCFS_WRITE_C3:
- bufsize=r->in_foff-r->in_boff+1;
- break;
+ switch(r->tcfs_op_desc) {
+ case TCFS_READ_C2:
+ buffer = NULL;
+ return buffer;
+ default:
+ case TCFS_READ_C1:
+ case TCFS_WRITE_C1:
+ case TCFS_WRITE_C2:
+ case TCFS_WRITE_C3:
+ bufsize = r->in_foff-r->in_boff + 1;
+ break;
}
- return tcfs_new_uio_obs(old,new,r->in_boff,bufsize);
+ return tcfs_new_uio_obs(old, new, r->in_boff, bufsize);
}
-
-void tcfs_dispose_new_uio(struct uio *vec)
+void
+tcfs_dispose_new_uio(struct uio *vec)
{
- void *p,*q;
- p=(void*)vec;
- q=(void*)vec->uio_iov;
+ void *p, *q;
+ p = (void*)vec;
+ q = (void*)vec->uio_iov;
- free(p,M_FREE);
- free(q,M_FREE);
+ free(p, M_FREE);
+ free(q, M_FREE);
}
int
@@ -226,7 +206,7 @@ tcfs_read(v)
*buffp, /* puntatore all'inizio dei dati utili */
*buffpf; /* puntatore alla fine dei dati utili */
- int bufsize=0; /* taglia del buffer allocato */
+ int bufsize = 0; /* taglia del buffer allocato */
struct uio
*new, /* puntatore all'uio rifatto */
@@ -248,73 +228,65 @@ tcfs_read(v)
struct tcfs_mount *mp;
void *ks;
+ f = tcfs_get_opinfo(v);
- f=tcfs_get_opinfo(v);
-
- if(f.tcfs_op_desc==TCFS_NONE)
+ if (f.tcfs_op_desc == TCFS_NONE)
return tcfs_bypass(v);
- i=&(f.i);
+ i = &(f.i);
- arg=(struct vop_read_args *)v;
- mp=MOUNTTOTCFSMOUNT(arg->a_vp->v_mount);
- ucred=arg->a_cred;
- procp=arg->a_uio->uio_procp;
+ arg = (struct vop_read_args *)v;
+ mp = MOUNTTOTCFSMOUNT(arg->a_vp->v_mount);
+ ucred = arg->a_cred;
+ procp = arg->a_uio->uio_procp;
- if(FI_GSHAR(i))
- {
- ks=tcfs_getgkey(ucred,procp,arg->a_vp);
- if(!ks)
- {
- return EACCES;
- }
- }
- else
- {
- ks=tcfs_getpkey(ucred,procp,arg->a_vp);
- if (!ks)
- ks=tcfs_getukey(ucred,procp,arg->a_vp);
- if (!ks)
- return EACCES;
+ if (FI_GSHAR(i)) {
+ ks = tcfs_getgkey(ucred,procp,arg->a_vp);
+ if (!ks) {
+ return (EACCES);
}
+ } else {
+ ks = tcfs_getpkey(ucred,procp,arg->a_vp);
+ if (!ks)
+ ks = tcfs_getukey(ucred,procp,arg->a_vp);
+ if (!ks)
+ return (EACCES);
+ }
- old=arg->a_uio;
- buffer=tcfs_new_uio_i(old,&new,&f);
+ old = arg->a_uio;
+ buffer = tcfs_new_uio_i(old, &new, &f);
- if (buffer==(char*)0)
- return 0;
+ if (buffer == NULL)
+ return (0);
- arg->a_uio=new;
- bufsize=f.out_foff-f.out_boff+1;
+ arg->a_uio = new;
+ bufsize = f.out_foff - f.out_boff + 1;
- terr=tcfs_bypass(arg);
- chread=bufsize-new->uio_resid;
+ terr = tcfs_bypass(arg);
+ chread = bufsize - new->uio_resid;
+ mkdecrypt(mp, buffer, chread, ks);
- mkdecrypt(mp,buffer,chread,ks);
-
-
- r_off=f.out_boff+chread;
+ r_off = f.out_boff + chread;
- if(r_off>=FI_ENDOF(i))
- e_spure=FI_SPURE(i);
+ if (r_off >= FI_ENDOF(i))
+ e_spure = FI_SPURE(i);
else
- if(r_off>FI_ENDOF(i)-FI_SPURE(i))
- e_spure=FI_SPURE(i)-FI_ENDOF(i)+r_off;
+ if(r_off > FI_ENDOF(i) - FI_SPURE(i))
+ e_spure = FI_SPURE(i) - FI_ENDOF(i) + r_off;
else
- e_spure=0;
+ e_spure = 0;
- buffp=buffer+ROFF(&f);
- if (chread>ROFF(&f))
- {
- chdap=MIN(f.req,chread-ROFF(&f)-e_spure);
- buffpf=buffp+chdap;
+ buffp = buffer + ROFF(&f);
+ if (chread>ROFF(&f)) {
+ chdap = MIN(f.req, chread-ROFF(&f) - e_spure);
+ buffpf = buffp + chdap;
- uiomove(buffp,chdap,old);
- }
- arg->a_uio=old;
+ uiomove(buffp, chdap, old);
+ }
+ arg->a_uio = old;
tcfs_dispose_new_uio(new);
- free(buffer,M_FREE);
+ free(buffer, M_FREE);
return terr;
}
@@ -335,9 +307,9 @@ tcfs_write(v)
int bufsize, /* num. caratteri req. read interna */
terr, /* val. ritorno read interna */
chdap, /* caratteri da passare */
- chread=0, /* caratteri letti dalla read int. */
- chwrote,e_chwrote,
- spure=0; /* ho scritto fino a qui */
+ chread = 0, /* caratteri letti dalla read int. */
+ chwrote, e_chwrote,
+ spure = 0; /* ho scritto fino a qui */
tcfs_opinfo f;
tcfs_fileinfo *i;
@@ -350,294 +322,255 @@ tcfs_write(v)
int e;
-
- arg=(struct vop_read_args *)v;
- ucred=arg->a_cred;
- procp=arg->a_uio->uio_procp;
- mp=MOUNTTOTCFSMOUNT(arg->a_vp->v_mount);
-
+ arg = (struct vop_read_args *)v;
+ ucred = arg->a_cred;
+ procp = arg->a_uio->uio_procp;
+ mp = MOUNTTOTCFSMOUNT(arg->a_vp->v_mount);
- f=tcfs_get_opinfo(arg);
+ f = tcfs_get_opinfo(arg);
- if (f.tcfs_op_desc==TCFS_NONE)
+ if (f.tcfs_op_desc == TCFS_NONE)
return tcfs_bypass(v);
- i=&(f.i);
+ i = &(f.i);
- if(FI_GSHAR(i))
- {
- ks=tcfs_getgkey(ucred,procp,arg->a_vp);
- if(!ks)
- return EACCES;
- }
- else
- {
- ks=tcfs_getpkey(ucred,procp,arg->a_vp);
+ if (FI_GSHAR(i)) {
+ ks = tcfs_getgkey(ucred,procp,arg->a_vp);
+ if (!ks)
+ return (EACCES);
+ } else {
+ ks = tcfs_getpkey(ucred,procp,arg->a_vp);
if (!ks)
- ks=tcfs_getukey(ucred,procp,arg->a_vp);
+ ks = tcfs_getukey(ucred,procp,arg->a_vp);
if (!ks)
- return EACCES;
+ return (EACCES);
}
- old=arg->a_uio;
-
- buffer=(char*)tcfs_new_uio_i(old,&tmp,&f);
- if (buffer==(char*)0)
- return EFAULT;
+ old = arg->a_uio;
- arg->a_uio=tmp;
- arg->a_desc=VDESC(vop_read);
- arg->a_uio->uio_rw=UIO_READ;
+ buffer = (char*)tcfs_new_uio_i(old, &tmp, &f);
+ if (buffer == NULL)
+ return (EFAULT);
- bufsize=f.in_foff-f.in_boff+1;
+ arg->a_uio = tmp;
+ arg->a_desc = VDESC(vop_read);
+ arg->a_uio->uio_rw = UIO_READ;
+ bufsize = f.in_foff-f.in_boff+1;
+ terr = tcfs_bypass(arg);
- terr=tcfs_bypass(arg);
+ switch(f.tcfs_op_desc) {
+ case TCFS_WRITE_C1:
+ case TCFS_WRITE_C2:
+ if(tmp->uio_resid != 0)
+ goto ret;
- switch(f.tcfs_op_desc)
- {
- case TCFS_WRITE_C1:
- case TCFS_WRITE_C2:
- if(tmp->uio_resid!=0)
- goto ret;
-
- chread=bufsize;
- break;
+ chread = bufsize;
+ break;
- case TCFS_WRITE_C3:
- case TCFS_WRITE_C4:
- if(tmp->uio_resid!=(P_FOFF(&f)-FI_ENDOF(i)+1))
- goto ret;
+ case TCFS_WRITE_C3:
+ case TCFS_WRITE_C4:
+ if(tmp->uio_resid != (P_FOFF(&f) - FI_ENDOF(i) + 1))
+ goto ret;
- chread=bufsize;
- break;
+ chread = bufsize;
+ break;
- case TCFS_WRITE_C5:
- if(tmp->uio_resid!=(D_FOFF(FI_ENDOF(i))-FI_ENDOF(i)+1))
- goto ret;
- chread=bufsize;
+ case TCFS_WRITE_C5:
+ if(tmp->uio_resid != (D_FOFF(FI_ENDOF(i)) - FI_ENDOF(i) + 1))
+ goto ret;
+ chread = bufsize;
}
mkdecrypt(mp,buffer,chread,ks);
-
- if(f.tcfs_op_desc==TCFS_WRITE_C4)
- {
-
- for(e=FI_ENDOF(i)-FI_SPURE(i);e<f.off;e++)
- *(buffer+e-f.out_boff)='\0';
-
+ if (f.tcfs_op_desc == TCFS_WRITE_C4) {
+ for(e = FI_ENDOF(i) - FI_SPURE(i); e < f.off; e++)
+ *(buffer + e - f.out_boff) = '\0';
}
-
- if(f.tcfs_op_desc!=TCFS_WRITE_C5)
- {
-
- buffp=buffer+ROFF(&f);
- chdap=f.req;
- buffpf=buffp+chdap;
+ if (f.tcfs_op_desc != TCFS_WRITE_C5) {
+ buffp = buffer + ROFF(&f);
+ chdap = f.req;
+ buffpf = buffp + chdap;
- uiomove(buffp,chdap,old);
+ uiomove(buffp,chdap,old);
- } /*if not TCFS_WRITE_C5 */
- else
- {
- for(e=FI_ENDOF(i)-FI_SPURE(i)-f.in_boff;e<bufsize;e++)
- *(buffer+e)='\0';
- }
+ } else { /*if not TCFS_WRITE_C5 */
+ for (e = FI_ENDOF(i) - FI_SPURE(i) - f.in_boff; e < bufsize;
+ e++)
+ *(buffer+e)='\0';
+ }
- mkencrypt(mp,buffer,bufsize,ks);
+ mkencrypt(mp, buffer, bufsize, ks);
- arg->a_desc=VDESC(vop_write);
- arg->a_uio->uio_rw=UIO_WRITE;
- arg->a_uio->uio_resid=bufsize;
- arg->a_uio->uio_offset=f.in_boff;
- arg->a_uio->uio_iov->iov_base=buffer;
- arg->a_uio->uio_iov->iov_len=bufsize;
- terr=tcfs_bypass(arg);
-
- if (f.tcfs_op_desc==TCFS_WRITE_C5)
- {
-
- tcfs_dispose_new_uio(tmp);
- free(buffer,M_FREE);
-
- bufsize=f.out_foff-f.out_boff+1;
- buffer=tcfs_new_uio_obs(old,&tmp,f.out_boff,bufsize);
- arg->a_uio=tmp;
- arg->a_desc=VDESC(vop_write);
- arg->a_uio->uio_rw=UIO_WRITE;
-
- for(e=0;e<ROFF(&f);e++)
- *(buffer+e)='\0';
-
- buffp=buffer+ROFF(&f);
- chdap=f.req;
- buffpf=buffp+chdap;
-
- uiomove(buffp,chdap,old);
- mkencrypt(mp,buffer,bufsize,ks);
- terr=tcfs_bypass(arg);
+ arg->a_desc = VDESC(vop_write);
+ arg->a_uio->uio_rw = UIO_WRITE;
+ arg->a_uio->uio_resid = bufsize;
+ arg->a_uio->uio_offset = f.in_boff;
+ arg->a_uio->uio_iov->iov_base = buffer;
+ arg->a_uio->uio_iov->iov_len = bufsize;
+ terr = tcfs_bypass(arg);
+
+ if (f.tcfs_op_desc == TCFS_WRITE_C5) {
+ tcfs_dispose_new_uio(tmp);
+ free(buffer, M_FREE);
+
+ bufsize = f.out_foff - f.out_boff + 1;
+ buffer = tcfs_new_uio_obs(old, &tmp, f.out_boff, bufsize);
+ arg->a_uio = tmp;
+ arg->a_desc = VDESC(vop_write);
+ arg->a_uio->uio_rw = UIO_WRITE;
+
+ for(e = 0; e < ROFF(&f); e++)
+ *(buffer+e) = '\0';
+
+ buffp = buffer + ROFF(&f);
+ chdap = f.req;
+ buffpf = buffp+chdap;
+
+ uiomove(buffp, chdap, old);
+ mkencrypt(mp, buffer, bufsize, ks);
+ terr = tcfs_bypass(arg);
}
- chwrote=bufsize-tmp->uio_resid;
- e_chwrote=MIN(f.req,chwrote-ROFF(&f));
-
- switch(f.tcfs_op_desc)
- {
- case TCFS_WRITE_C1:
- case TCFS_WRITE_C2:
- break;
- case TCFS_WRITE_C3:
- if ((f.in_boff+chwrote)>FI_ENDOF(i)-FI_SPURE(i))
- {
-
+ chwrote = bufsize-tmp->uio_resid;
+ e_chwrote = MIN(f.req, chwrote-ROFF(&f));
- if(chwrote>f.req){
- spure=D_SPURE(f.off+f.req);
- } else
- {
- spure=D_SPURE(f.out_boff+chwrote);
- }
+ switch(f.tcfs_op_desc) {
+ case TCFS_WRITE_C1:
+ case TCFS_WRITE_C2:
+ break;
+ case TCFS_WRITE_C3:
+ if ((f.in_boff + chwrote) > FI_ENDOF(i) - FI_SPURE(i)) {
+ if(chwrote > f.req){
+ spure = D_SPURE(f.off + f.req);
+ } else {
+ spure = D_SPURE(f.out_boff + chwrote);
+ }
- FI_SET_SP(i,spure);
- tcfs_set_fileinfo(v,i);
+ FI_SET_SP(i, spure);
+ tcfs_set_fileinfo(v, i);
}
break;
- case TCFS_WRITE_C4:
- case TCFS_WRITE_C5:
- spure=D_SPURE(f.off+f.req);
- FI_SET_SP(i,spure);
- tcfs_set_fileinfo(v,i);
+ case TCFS_WRITE_C4:
+ case TCFS_WRITE_C5:
+ spure = D_SPURE(f.off + f.req);
+ FI_SET_SP(i, spure);
+ tcfs_set_fileinfo(v, i);
break;
+ }
- }
-
-
- old->uio_resid=f.req-e_chwrote;
+ old->uio_resid = f.req - e_chwrote;
-ret:
- arg->a_uio=old;
+ ret:
+ arg->a_uio = old;
tcfs_dispose_new_uio(tmp);
- free(buffer,M_FREE);
- return terr;
+ free(buffer, M_FREE);
+ return (terr);
}
-int tcfs_ed(struct vnode *v,struct proc *p,struct ucred *c, tcfs_fileinfo *i)
+int
+tcfs_ed(struct vnode *v, struct proc *p, struct ucred *c, tcfs_fileinfo *i)
{
struct vop_read_args ra;
struct vop_write_args wa;
struct uio *u;
struct iovec *n;
char *buff;
- unsigned long csize,resid,w_resid;
- unsigned long size,w_size;
- int bufsize,e;
- int retval,sp;
+ unsigned long csize, resid, w_resid;
+ unsigned long size, w_size;
+ int bufsize, e;
+ int retval, sp;
void *ks;
- int encr=0;
+ int encr = 0;
struct tcfs_mount *mp;
- mp=MOUNTTOTCFSMOUNT(v->v_mount);
- encr=FI_CFLAG(i)||FI_GSHAR(i);
+ mp = MOUNTTOTCFSMOUNT(v->v_mount);
+ encr = FI_CFLAG(i) || FI_GSHAR(i);
- if(v->v_type!=VREG)
- return 0;
+ if (v->v_type != VREG)
+ return (0);
- if(FI_GSHAR(i))
- {
- ks=tcfs_getgkey(c,p,v);
+ if (FI_GSHAR(i)) {
+ ks = tcfs_getgkey(c, p, v);
if(!ks)
- return EACCES;
- }
- else
- {
-
- ks=tcfs_getpkey(c,p,v);
- if (!ks)
- ks=tcfs_getukey(c,p,v);
+ return (EACCES);
+ } else {
+ ks = tcfs_getpkey(c,p,v);
if (!ks)
- {
- return EACCES;
- }
-
+ ks = tcfs_getukey(c,p,v);
+ if (!ks)
+ return (EACCES);
}
- u=malloc(sizeof(struct uio),M_FREE,M_NOWAIT);
- n=malloc(sizeof(struct iovec),M_FREE,M_NOWAIT);
-
+ u = malloc(sizeof(struct uio), M_FREE, M_NOWAIT);
+ n = malloc(sizeof(struct iovec), M_FREE, M_NOWAIT);
- size=FI_ENDOF(i);
+ size = FI_ENDOF(i);
- if(encr)
- {
- w_size=D_PFOFF(size);
- sp=D_SPURE(size);
- }
- else
- {
- w_size=size-FI_SPURE(i);
- sp=-FI_SPURE(i);
- }
+ if(encr) {
+ w_size = D_PFOFF(size);
+ sp = D_SPURE(size);
+ } else {
+ w_size=size-FI_SPURE(i);
+ sp = -FI_SPURE(i);
+ }
- csize=0;
- resid=size;
- w_resid=w_size;
+ csize = 0;
+ resid = size;
+ w_resid = w_size;
- bufsize=BLOCKSIZE;
+ bufsize = BLOCKSIZE;
- buff=malloc(BLOCKSIZE,M_FREE,M_NOWAIT);
+ buff = malloc(BLOCKSIZE, M_FREE, M_NOWAIT);
- u->uio_offset=0;
- u->uio_resid=bufsize;
- u->uio_iovcnt=1;
- u->uio_segflg=UIO_SYSSPACE;
- u->uio_procp=p;
- u->uio_iov=n;
+ u->uio_offset = 0;
+ u->uio_resid = bufsize;
+ u->uio_iovcnt = 1;
+ u->uio_segflg = UIO_SYSSPACE;
+ u->uio_procp = p;
+ u->uio_iov = n;
- wa.a_desc=VDESC(vop_write);
- ra.a_desc=VDESC(vop_read);
- wa.a_vp=ra.a_vp=v;
- wa.a_cred=ra.a_cred=c;
- wa.a_ioflag=ra.a_ioflag=0;
- wa.a_uio=ra.a_uio=u;
+ wa.a_desc = VDESC(vop_write);
+ ra.a_desc = VDESC(vop_read);
+ wa.a_vp = ra.a_vp = v;
+ wa.a_cred = ra.a_cred = c;
+ wa.a_ioflag = ra.a_ioflag = 0;
+ wa.a_uio = ra.a_uio = u;
- for(e=0;e<=D_NOBLK(size);e++)
- {
-
- int x,y;
+ for(e = 0; e <= D_NOBLK(size); e++) {
+ int x, y;
- u->uio_offset=csize;
- u->uio_rw=UIO_READ;
- n->iov_base=buff;
- n->iov_len=u->uio_resid=x=MIN(bufsize,resid+1);
+ u->uio_offset = csize;
+ u->uio_rw = UIO_READ;
+ n->iov_base = buff;
+ n->iov_len = u->uio_resid = x = MIN(bufsize, resid + 1);
- retval=tcfs_bypass((void*)&ra);
+ retval = tcfs_bypass((void*)&ra);
-
- u->uio_offset=csize;
- u->uio_rw=UIO_WRITE;
- n->iov_base=buff;
- n->iov_len=u->uio_resid=y=MIN(bufsize,w_resid+1);
+ u->uio_offset = csize;
+ u->uio_rw = UIO_WRITE;
+ n->iov_base = buff;
+ n->iov_len = u->uio_resid = y = MIN(bufsize, w_resid + 1);
if(!encr)
- mkdecrypt(mp,buff,x,ks);
+ mkdecrypt(mp, buff, x, ks);
else
- mkencrypt(mp,buff,y,ks);
+ mkencrypt(mp, buff, y, ks);
- retval=tcfs_bypass((void*)&wa);
+ retval = tcfs_bypass((void*)&wa);
- resid-=x; csize+=x;
- w_resid-=y;
+ resid -= x; csize += x;
+ w_resid -= y;
/* I should call the scheduler here */
}
tcfs_dispose_new_uio(u);
- return sp;
+ return (sp);
}
-
diff --git a/sys/miscfs/tcfs/tcfs_rw.h b/sys/miscfs/tcfs/tcfs_rw.h
index b06241bce2c..964d4f2daf8 100644
--- a/sys/miscfs/tcfs/tcfs_rw.h
+++ b/sys/miscfs/tcfs/tcfs_rw.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcfs_rw.h,v 1.2 2000/06/17 17:32:27 provos Exp $ */
+/* $OpenBSD: tcfs_rw.h,v 1.3 2000/06/17 20:25:55 provos Exp $ */
/*
* Copyright 2000 The TCFS Project at http://tcfs.dia.unisa.it/
* All rights reserved.
@@ -25,22 +25,23 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/* Gestione informazioni sui files cifrati
-*/
+
+#ifndef _TCFS_RW_H_
+#define _TCFS_RW_H_
+
+/* Gestione informazioni sui files cifrati */
#include <miscfs/tcfs/tcfs_fileinfo.h>
typedef struct {
- tcfs_fileinfo i;
- int off;
- int req;
- int tcfs_op_desc;
- int in_boff;
- int in_foff;
- int out_boff;
- int out_foff;
- } tcfs_opinfo;
-
-
+ tcfs_fileinfo i;
+ int off;
+ int req;
+ int tcfs_op_desc;
+ int in_boff;
+ int in_foff;
+ int out_boff;
+ int out_foff;
+} tcfs_opinfo;
/* tcfs_opinfo x */
@@ -68,7 +69,7 @@ typedef struct {
#define TCFS_WRITE_C4 6
#define TCFS_WRITE_C5 7
-/* prototyphes */
+/* prototypes */
char *tcfs_new_uio_i(struct uio*,struct uio**,tcfs_opinfo*);
char *tcfs_new_uio_obs(struct uio*,struct uio**,int off, int ireq);
@@ -77,3 +78,4 @@ void dispose_new_uio(struct uio *);
int tcfs_ed(struct vnode*, struct proc*, struct ucred *, tcfs_fileinfo *);
tcfs_opinfo tcfs_get_opinfo(void*);
+#endif /* _TCFS_RW_H_ */
diff --git a/sys/miscfs/tcfs/tcfs_subr.c b/sys/miscfs/tcfs/tcfs_subr.c
index 9d329efee94..21f77c1890c 100644
--- a/sys/miscfs/tcfs/tcfs_subr.c
+++ b/sys/miscfs/tcfs/tcfs_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcfs_subr.c,v 1.1 2000/06/17 17:16:07 provos Exp $ */
+/* $OpenBSD: tcfs_subr.c,v 1.2 2000/06/17 20:25:55 provos Exp $ */
/* $NetBSD: tcfs_subr.c,v 1.6 1996/05/10 22:50:52 jtk Exp $ */
/*
@@ -125,10 +125,9 @@ loop:
}
}
- return NULLVP;
+ return (NULLVP);
}
-
/*
* Make a new tcfs_node node.
* Vp is the alias vnode, lowervp is the lower vnode.
diff --git a/sys/miscfs/tcfs/tcfs_version.h b/sys/miscfs/tcfs/tcfs_version.h
index 09b6d1cbb41..c07a7f55110 100644
--- a/sys/miscfs/tcfs/tcfs_version.h
+++ b/sys/miscfs/tcfs/tcfs_version.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcfs_version.h,v 1.2 2000/06/17 17:32:29 provos Exp $ */
+/* $OpenBSD: tcfs_version.h,v 1.3 2000/06/17 20:25:55 provos Exp $ */
/*
* Copyright 2000 The TCFS Project at http://tcfs.dia.unisa.it/
* All rights reserved.
@@ -25,6 +25,10 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
+#ifndef _TCFS_VERSION_H_
#define _TCFS_VERSION_H_
+
#define TCFS_VERSION_NUM 0
+#endif /* _TCFS_VERSION_H_ */
diff --git a/sys/miscfs/tcfs/tcfs_vfsops.c b/sys/miscfs/tcfs/tcfs_vfsops.c
index 2b0fc57bb51..ecedf4cd3c3 100644
--- a/sys/miscfs/tcfs/tcfs_vfsops.c
+++ b/sys/miscfs/tcfs/tcfs_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcfs_vfsops.c,v 1.2 2000/06/17 17:32:29 provos Exp $ */
+/* $OpenBSD: tcfs_vfsops.c,v 1.3 2000/06/17 20:25:55 provos Exp $ */
/*
* Copyright 2000 The TCFS Project at http://tcfs.dia.unisa.it/
* All rights reserved.
@@ -64,7 +64,7 @@ tcfs_mount(mp, path, data, ndp, p)
struct vnode *tcfsm_rootvp;
struct tcfs_mount *xmp;
size_t size;
- int tcfs_error=0;
+ int tcfs_error = 0;
#ifdef TCFS_DIAGNOSTIC
printf("tcfs_mount(mp = %p)\n", mp);
@@ -80,8 +80,8 @@ tcfs_mount(mp, path, data, ndp, p)
/* receiving user directives */
if (mp->mnt_flag & MNT_UPDATE) {
int i;
- i=tcfs_exec_cmd(MOUNTTOTCFSMOUNT(mp),&args);
- copyout((caddr_t)&args,data,sizeof(struct tcfs_args));
+ i = tcfs_exec_cmd(MOUNTTOTCFSMOUNT(mp), &args);
+ copyout((caddr_t)&args, data, sizeof(struct tcfs_args));
return i;
}
@@ -157,7 +157,6 @@ tcfs_mount(mp, path, data, ndp, p)
tcfs_error=tcfs_init_mp(xmp,&args);
copyout((caddr_t)&args,data,sizeof(struct tcfs_args));
return (tcfs_error);
-
}
/*
@@ -233,7 +232,7 @@ tcfs_unmount(mp, mntflags, p)
free(mp->mnt_data, M_UFSMNT); /* XXX */
mp->mnt_data = 0;
- return 0;
+ return (0);
}
int
@@ -258,7 +257,7 @@ tcfs_root(mp, vpp)
VREF(vp);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
*vpp = vp;
- return 0;
+ return (0);
}
int
@@ -269,7 +268,6 @@ tcfs_quotactl(mp, cmd, uid, arg, p)
caddr_t arg;
struct proc *p;
{
-
return VFS_QUOTACTL(MOUNTTOTCFSMOUNT(mp)->tcfsm_vfs, cmd, uid, arg, p);
}
diff --git a/sys/miscfs/tcfs/tcfs_vnops.c b/sys/miscfs/tcfs/tcfs_vnops.c
index 4db4a7267b5..13d07e4ff0a 100644
--- a/sys/miscfs/tcfs/tcfs_vnops.c
+++ b/sys/miscfs/tcfs/tcfs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcfs_vnops.c,v 1.2 2000/06/17 17:32:29 provos Exp $ */
+/* $OpenBSD: tcfs_vnops.c,v 1.3 2000/06/17 20:25:55 provos Exp $ */
/*
* Copyright 2000 The TCFS Project at http://tcfs.dia.unisa.it/
* All rights reserved.
@@ -100,7 +100,8 @@ tcfs_bypass(v)
if (descp->vdesc_vp_offsets[i] == VDESC_NO_OFFSET)
break; /* bail out at end of list */
vps_p[i] = this_vp_p =
- VOPARG_OFFSETTO(struct vnode**,descp->vdesc_vp_offsets[i],ap);
+ VOPARG_OFFSETTO(struct vnode**,
+ descp->vdesc_vp_offsets[i], ap);
/*
* We're not guaranteed that any but the first vnode
* are of our type. Check for and don't map any
@@ -178,7 +179,6 @@ tcfs_bypass(v)
out:
return (error);
-
}
@@ -248,7 +248,6 @@ tcfs_reclaim(v)
return (0);
}
-
int
tcfs_print(v)
void *v;
@@ -457,6 +456,6 @@ struct vnodeopv_entry_desc tcfs_vnodeop_entries[] = {
{ &vop_symlink_desc, tcfs_symlink },
{ (struct vnodeop_desc*)NULL, (int(*) __P((void *)))NULL }
};
+
struct vnodeopv_desc tcfs_vnodeop_opv_desc =
{ &tcfs_vnodeop_p, tcfs_vnodeop_entries };
-