diff options
author | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1997-01-20 15:49:55 +0000 |
---|---|---|
committer | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1997-01-20 15:49:55 +0000 |
commit | 1b4184b3f977830ee35da9a9e38c76f24b7a4999 (patch) | |
tree | dbf6332538dd73cb4fd388a54f5f6dc8d792325e /sys/adosfs | |
parent | 09f60acda5a8fc3fa2e690dc8336f0c0b96e5a49 (diff) |
Type pedantery.. a lot of it too, more could be done as well. Sync with
NetBSD 970118 too.
Diffstat (limited to 'sys/adosfs')
-rw-r--r-- | sys/adosfs/adlookup.c | 18 | ||||
-rw-r--r-- | sys/adosfs/adosfs.h | 98 | ||||
-rw-r--r-- | sys/adosfs/adutil.c | 43 | ||||
-rw-r--r-- | sys/adosfs/advfsops.c | 94 | ||||
-rw-r--r-- | sys/adosfs/advnops.c | 190 |
5 files changed, 224 insertions, 219 deletions
diff --git a/sys/adosfs/adlookup.c b/sys/adosfs/adlookup.c index a12f9238a51..b7bc5a26fd9 100644 --- a/sys/adosfs/adlookup.c +++ b/sys/adosfs/adlookup.c @@ -1,5 +1,5 @@ -/* $OpenBSD: adlookup.c,v 1.6 1996/08/23 19:10:57 niklas Exp $ */ -/* $NetBSD: adlookup.c,v 1.13.4.1 1996/05/27 09:53:50 is Exp $ */ +/* $OpenBSD: adlookup.c,v 1.7 1997/01/20 15:49:51 niklas Exp $ */ +/* $NetBSD: adlookup.c,v 1.17 1996/10/25 23:13:58 cgd Exp $ */ /* * Copyright (c) 1994 Christian E. Hopps @@ -75,8 +75,9 @@ adosfs_lookup(v) struct vnode *vdp; /* vnode of search dir */ struct anode *adp; /* anode of search dir */ struct ucred *ucp; /* lookup credentials */ - u_long bn, plen, hval, vpid; - u_char *pelt; + u_int32_t plen, hval, vpid; + daddr_t bn; + char *pelt; #ifdef ADOSFS_DIAGNOSTIC advopprint(sp); @@ -92,7 +93,7 @@ adosfs_lookup(v) last = flags & ISLASTCN; lockp = flags & LOCKPARENT; wantp = flags & (LOCKPARENT | WANTPARENT); - pelt = (u_char *)cnp->cn_nameptr; + pelt = cnp->cn_nameptr; plen = cnp->cn_namelen; nocache = 0; @@ -170,8 +171,8 @@ adosfs_lookup(v) * */ VOP_UNLOCK(vdp); /* race */ - if ((error = VFS_VGET(vdp->v_mount, - (ino_t)adp->pblock, vpp)) != 0) + if ((error = VFS_VGET(vdp->v_mount, ABLKTOINO(adp->pblock), + vpp)) != 0) VOP_LOCK(vdp); else if (last && lockp && (error = VOP_LOCK(vdp))) vput(*vpp); @@ -191,7 +192,8 @@ adosfs_lookup(v) bn = adp->tab[hval]; i = min(adp->tabi[hval], 0); while (bn != 0) { - if ((error = VFS_VGET(vdp->v_mount, (ino_t)bn, vpp)) != 0) { + if ((error = VFS_VGET(vdp->v_mount, ABLKTOINO(bn), vpp)) != + 0) { #ifdef ADOSFS_DIAGNOSTIC printf("[aget] %d)", error); #endif diff --git a/sys/adosfs/adosfs.h b/sys/adosfs/adosfs.h index 82f6180ab71..cfb7fd54607 100644 --- a/sys/adosfs/adosfs.h +++ b/sys/adosfs/adosfs.h @@ -1,5 +1,5 @@ -/* $OpenBSD: adosfs.h,v 1.5 1996/06/10 07:25:18 deraadt Exp $ */ -/* $NetBSD: adosfs.h,v 1.10.4.2 1996/05/27 10:21:26 is Exp $ */ +/* $OpenBSD: adosfs.h,v 1.6 1997/01/20 15:49:52 niklas Exp $ */ +/* $NetBSD: adosfs.h,v 1.12 1996/10/08 22:18:02 thorpej Exp $ */ /* * Copyright (c) 1994 Christian E. Hopps @@ -54,37 +54,37 @@ enum anode_flags { AWANT = 0x1, ALOCKED = 0x2 }; struct anode { LIST_ENTRY(anode) link; enum anode_type type; - char name[31]; /* (r/d/f) name for object */ + char name[31]; /* (r/d/f) name for object */ struct datestamp mtimev; /* (r) volume modified */ struct datestamp created; /* (r) volume created */ - struct datestamp mtime; /* (r/d/f) last modified */ + struct datestamp mtime; /* (r/d/f) last modified */ struct adosfsmount *amp; /* owner file system */ - struct vnode *vp; /* owner vnode */ - u_long fsize; /* (f) size of file in bytes */ - u_long block; /* block num */ - u_long pblock; /* (d/f/e) parent block */ - u_long hashf; /* (d/f) hash forward */ - u_long extb; /* (f/e) extension block number */ - u_long linkto; /* (hd/hf) header this link points at */ - u_long linknext; /* (d/f/hd/hf) next link (or head) in chain */ - u_long lastlindblk; /* (f/hf) last logical indirect block */ - u_long lastindblk; /* (f/hf) last indirect block read */ - u_long *tab; /* (r/d) hash table */ - int *tabi; /* (r/d) table info */ - int ntabent; /* (r/d) number of entries in table */ - int nwords; /* size of blocks in long words */ - int adprot; /* (d/f) amigados protection bits */ - uid_t uid; /* (d/f) uid of directory/file */ - gid_t gid; /* (d/f) gid of directory/file */ - int flags; /* misc flags */ - char *slinkto; /* name of file or dir */ + struct vnode *vp; /* owner vnode */ + u_int32_t fsize; /* (f) size of file in bytes */ + daddr_t block; /* block num */ + daddr_t pblock; /* (d/f/e) parent block */ + daddr_t hashf; /* (d/f) hash forward */ + daddr_t extb; /* (f/e) extension block number */ + daddr_t linkto; /* (hd/hf) hdr this link points at */ + daddr_t linknext; /* (d/f/hd/hf) next chain link/head */ + daddr_t lastlindblk; /* (f/hf) last logical indirect blk */ + daddr_t lastindblk; /* (f/hf) last indirect block read */ + daddr_t *tab; /* (r/d) hash table */ + int *tabi; /* (r/d) table info */ + int ntabent; /* (r/d) number of entries in table */ + int nwords; /* size of blocks in 32-bit words */ + int adprot; /* (d/f) amigados protection bits */ + uid_t uid; /* (d/f) uid of directory/file */ + gid_t gid; /* (d/f) gid of directory/file */ + int flags; /* misc flags */ + char *slinkto; /* name of file or dir */ }; #define VTOA(vp) ((struct anode *)(vp)->v_data) #define ATOV(ap) ((ap)->vp) -#define ANODETABSZ(ap) (((ap)->nwords - 56) * sizeof(long)) #define ANODETABENT(ap) ((ap)->nwords - 56) #define ANODENDATBLKENT(ap) ((ap)->nwords - 56) - +#define ABLKTOINO(bn) ((ino_t)(bn)) +#define AINOTOBLK(bn) ((daddr_t)(bn)) /* * mount data */ @@ -94,20 +94,20 @@ struct adosfsmount { LIST_HEAD(anodechain, anode) anodetab[ANODEHASHSZ]; struct mount *mp; /* owner mount */ u_int32_t dostype; /* type of volume */ - u_long rootb; /* root block number */ - u_long secsperblk; /* sectors per block */ - u_long bsize; /* size of blocks */ - u_long nwords; /* size of blocks in long words */ - u_long dbsize; /* data bytes per block */ - uid_t uid; /* uid of mounting user */ - gid_t gid; /* gid of mounting user */ - u_long mask; /* mode mask */ + daddr_t rootb; /* root block number */ + int secsperblk; /* sectors per block */ + int bsize; /* size of blocks */ + int nwords; /* size of blocks in long words */ + int dbsize; /* data bytes per block */ + uid_t uid; /* uid of mounting user */ + gid_t gid; /* gid of mounting user */ + mode_t mask; /* mode mask */ struct vnode *devvp; /* blk device mounted on */ struct vnode *rootvp; /* out root vnode */ struct netexport export; - u_long *bitmap; /* allocation bitmap */ - u_long numblks; /* number of usable blocks */ - u_long freeblks; /* number of free blocks */ + u_int32_t *bitmap; /* allocation bitmap */ + u_int32_t numblks; /* number of usable blocks */ + u_int32_t freeblks; /* number of free blocks */ }; #define VFSTOADOSFS(mp) ((struct adosfsmount *)(mp)->mnt_data) @@ -135,22 +135,18 @@ struct adosfsmount { /* * utility protos */ -#ifndef m68k -u_int32_t adoswordn __P((struct buf *, int)); -#else -#define adoswordn(bp,wn) (*((u_int32_t *)(bp)->b_data + (wn))) -#endif +#define adoswordn(bp,wn) ntohl(*((u_int32_t *)(bp)->b_data + (wn))) -u_int32_t adoscksum __P((struct buf *, int)); -int adoscaseequ __P((const u_char *, const u_char *, int, int)); -int adoshash __P((const u_char *, int, int, int)); -int adunixprot __P((int)); -int adosfs_getblktype __P((struct adosfsmount *, struct buf *)); +u_int32_t adoscksum __P((struct buf *, int)); +int adoscaseequ __P((const char *, const char *, int, int)); +int adoshash __P((const char *, int, int, int)); +int adunixprot __P((int)); +int adosfs_getblktype __P((struct adosfsmount *, struct buf *)); -struct vnode *adosfs_ahashget __P((struct mount *, ino_t)); -void adosfs_ainshash __P((struct adosfsmount *, struct anode *)); -void adosfs_aremhash __P((struct anode *)); +struct vnode *adosfs_ahashget __P((struct mount *, ino_t)); +void adosfs_ainshash __P((struct adosfsmount *, struct anode *)); +void adosfs_aremhash __P((struct anode *)); -int adosfs_lookup __P((void *)); +int adosfs_lookup __P((void *)); -int (**adosfs_vnodeop_p) __P((void *)); +int (**adosfs_vnodeop_p) __P((void *)); diff --git a/sys/adosfs/adutil.c b/sys/adosfs/adutil.c index fb506cb0298..a1dbd91df24 100644 --- a/sys/adosfs/adutil.c +++ b/sys/adosfs/adutil.c @@ -1,5 +1,5 @@ -/* $OpenBSD: adutil.c,v 1.7 1996/08/10 03:24:36 deraadt Exp $ */ -/* $NetBSD: adutil.c,v 1.10.4.2 1996/05/27 10:21:29 is Exp $ */ +/* $OpenBSD: adutil.c,v 1.8 1997/01/20 15:49:52 niklas Exp $ */ +/* $NetBSD: adutil.c,v 1.15 1996/10/13 02:52:07 christos Exp $ */ /* * Copyright (c) 1994 Christian E. Hopps @@ -46,7 +46,8 @@ * look for anode in the mount's hash table, return locked. */ #define AHASH(an) ((an) & (ANODEHASHSZ - 1)) -static int CapitalChar __P((int, int)); + +static __inline char CapitalChar __P((char, int)); struct vnode * adosfs_ahashget(mp, an) @@ -60,7 +61,7 @@ adosfs_ahashget(mp, an) start_over: for (ap = hp->lh_first; ap != NULL; ap = ap->link.le_next) { - if (ap->block != an) + if (ABLKTOINO(ap->block) != an) continue; if (ap->flags & ALOCKED) { ap->flags |= AWANT; @@ -82,7 +83,8 @@ adosfs_ainshash(amp, ap) struct adosfsmount *amp; struct anode *ap; { - LIST_INSERT_HEAD(&->anodetab[AHASH(ap->block)], ap, link); + LIST_INSERT_HEAD(&->anodetab[AHASH(ABLKTOINO(ap->block))], ap, + link); ap->flags |= ALOCKED; } @@ -101,7 +103,7 @@ adosfs_getblktype(amp, bp) if (adoscksum(bp, amp->nwords)) { #ifdef DIAGNOSTIC printf("adosfs: aget: cksum of blk %ld failed\n", - bp->b_blkno / amp->secsperblk); + bp->b_blkno / amp->secsperblk); #endif return (-1); } @@ -112,7 +114,7 @@ adosfs_getblktype(amp, bp) if (adoswordn(bp, 0) != BPT_SHORT) { #ifdef DIAGNOSTIC printf("adosfs: aget: bad primary type blk %ld\n", - bp->b_blkno / amp->secsperblk); + bp->b_blkno / amp->secsperblk); #endif return (-1); } @@ -150,12 +152,13 @@ adunixprot(adprot) } } -static int +static __inline char CapitalChar(ch, inter) - int ch, inter; + char ch; + int inter; { if ((ch >= 'a' && ch <= 'z') || - (inter && ch >= 0xe0 && ch <= 0xfe && ch != 0xf7)) + (inter && ch >= '\xe0' && ch <= '\xfe' && ch != '\xf7')) return(ch - ('a' - 'A')); return(ch); } @@ -177,7 +180,7 @@ adoscksum(bp, n) int adoscaseequ(name1, name2, len, inter) - const u_char *name1, *name2; + const char *name1, *name2; int len, inter; { while (len-- > 0) @@ -190,14 +193,15 @@ adoscaseequ(name1, name2, len, inter) int adoshash(nam, namlen, nelt, inter) - const u_char *nam; + const char *nam; int namlen, nelt, inter; { int val; val = namlen; while (namlen--) - val = ((val * 13) + CapitalChar(*nam++, inter)) & 0x7ff; + val = ((val * 13) + (u_char)CapitalChar(*nam++, inter)) & + 0x7ff; return(val % nelt); } @@ -222,16 +226,3 @@ tvtods(tvp, dsp) { } #endif - -#ifndef m68k -u_int32_t -adoswordn(bp, wn) - struct buf *bp; - int wn; -{ - /* - * ados stored in network (big endian) order - */ - return(ntohl(*((u_int32_t *)bp->b_data + wn))); -} -#endif diff --git a/sys/adosfs/advfsops.c b/sys/adosfs/advfsops.c index 1dc50cba1e4..7ad7f1b5606 100644 --- a/sys/adosfs/advfsops.c +++ b/sys/adosfs/advfsops.c @@ -1,5 +1,5 @@ -/* $OpenBSD: advfsops.c,v 1.8 1996/08/23 19:11:00 niklas Exp $ */ -/* $NetBSD: advfsops.c,v 1.19.4.1 1996/05/27 10:21:30 is Exp $ */ +/* $OpenBSD: advfsops.c,v 1.9 1997/01/20 15:49:53 niklas Exp $ */ +/* $NetBSD: advfsops.c,v 1.24 1996/12/22 10:10:12 cgd Exp $ */ /* * Copyright (c) 1994 Christian E. Hopps @@ -39,30 +39,32 @@ #include <sys/time.h> #include <sys/malloc.h> #include <sys/disklabel.h> -#include <miscfs/specfs/specdev.h> /* XXX */ #include <sys/fcntl.h> #include <sys/namei.h> #include <sys/ioctl.h> #include <sys/queue.h> #include <sys/buf.h> + +#include <miscfs/specfs/specdev.h> /* XXX */ #include <adosfs/adosfs.h> -void adosfs_init __P((void)); -int adosfs_mount __P((struct mount *, char *, caddr_t, struct nameidata *, - struct proc *)); -int adosfs_start __P((struct mount *, int, struct proc *)); -int adosfs_unmount __P((struct mount *, int, struct proc *)); -int adosfs_root __P((struct mount *, struct vnode **)); -int adosfs_quotactl __P((struct mount *, int, uid_t, caddr_t, struct proc *)); -int adosfs_statfs __P((struct mount *, struct statfs *, struct proc *)); -int adosfs_sync __P((struct mount *, int, struct ucred *, struct proc *)); -int adosfs_vget __P((struct mount *, ino_t, struct vnode **)); -int adosfs_fhtovp __P((struct mount *, struct fid *, struct mbuf *, - struct vnode **, int *, struct ucred **)); -int adosfs_vptofh __P((struct vnode *, struct fid *)); - -int adosfs_mountfs __P((struct vnode *, struct mount *, struct proc *)); -int adosfs_loadbitmap __P((struct adosfsmount *)); +void adosfs_init __P((void)); +int adosfs_mount __P((struct mount *, char *, caddr_t, struct nameidata *, + struct proc *)); +int adosfs_start __P((struct mount *, int, struct proc *)); +int adosfs_unmount __P((struct mount *, int, struct proc *)); +int adosfs_root __P((struct mount *, struct vnode **)); +int adosfs_quotactl __P((struct mount *, int, uid_t, caddr_t, + struct proc *)); +int adosfs_statfs __P((struct mount *, struct statfs *, struct proc *)); +int adosfs_sync __P((struct mount *, int, struct ucred *, struct proc *)); +int adosfs_vget __P((struct mount *, ino_t, struct vnode **)); +int adosfs_fhtovp __P((struct mount *, struct fid *, struct mbuf *, + struct vnode **, int *, struct ucred **)); +int adosfs_vptofh __P((struct vnode *, struct fid *)); + +int adosfs_mountfs __P((struct vnode *, struct mount *, struct proc *)); +int adosfs_loadbitmap __P((struct adosfsmount *)); int adosfs_mount(mp, path, data, ndp, p) @@ -188,7 +190,7 @@ adosfs_mountfs(devvp, mp, p) parp = &dl.d_partitions[part]; amp = malloc(sizeof(struct adosfsmount), M_ADOSFSMNT, M_WAITOK); - bzero((char *)amp, (u_long)sizeof(struct adosfsmount)); + bzero((char *)amp, sizeof(struct adosfsmount)); amp->mp = mp; if (dl.d_type == DTYPE_FLOPPY) { amp->bsize = dl.d_secsize; @@ -219,7 +221,7 @@ adosfs_mountfs(devvp, mp, p) amp->devvp = devvp; mp->mnt_data = (qaddr_t)amp; - mp->mnt_stat.f_fsid.val[0] = (long)devvp->v_rdev; + mp->mnt_stat.f_fsid.val[0] = (int32_t)devvp->v_rdev; mp->mnt_stat.f_fsid.val[1] = makefstype(MOUNT_ADOSFS); mp->mnt_flag |= MNT_LOCAL; devvp->v_specflags |= SI_MOUNTEDON; @@ -304,7 +306,8 @@ adosfs_root(mp, vpp) struct vnode *nvp; int error; - if ((error = VFS_VGET(mp, (ino_t)VFSTOADOSFS(mp)->rootb, &nvp)) != 0) + if ((error = VFS_VGET(mp, ABLKTOINO(VFSTOADOSFS(mp)->rootb), &nvp)) != + 0) return (error); /* XXX verify it's a root block? */ *vpp = nvp; @@ -374,12 +377,12 @@ adosfs_vget(mp, an, vpp) bzero(ap, sizeof(struct anode)); ap->vp = vp; ap->amp = amp; - ap->block = an; + ap->block = AINOTOBLK(an); ap->nwords = amp->nwords; adosfs_ainshash(amp, ap); - if ((error = bread(amp->devvp, an * amp->secsperblk, - amp->bsize, NOCRED, &bp)) != 0) { + if ((error = bread(amp->devvp, an * amp->secsperblk, amp->bsize, + NOCRED, &bp)) != 0) { vput(vp); return (error); } @@ -413,7 +416,7 @@ adosfs_vget(mp, an, vpp) * convert from BCPL string and * from: "part:dir/file" to: "/part/dir/file" */ - nam = bp->b_data + (6 * sizeof(long)); + nam = bp->b_data + (6 * sizeof(u_int32_t)); namlen = strlen(nam); tmp = nam; while (*tmp && *tmp != ':') @@ -468,21 +471,22 @@ adosfs_vget(mp, an, vpp) if (vp->v_type == VDIR) { int i; - ap->tab = malloc(ANODETABSZ(ap) * 2, M_ANODE, M_WAITOK); ap->ntabent = ANODETABENT(ap); + ap->tab = malloc(ap->ntabent * (sizeof(daddr_t) + sizeof(int)), + M_ANODE, M_WAITOK); ap->tabi = (int *)&ap->tab[ap->ntabent]; - bzero(ap->tabi, ANODETABSZ(ap)); + bzero(ap->tabi, ANODETABENT(ap) * sizeof(int)); for (i = 0; i < ap->ntabent; i++) - ap->tab[i] = adoswordn(bp, i + 6); + ap->tab[i] = (daddr_t)adoswordn(bp, i + 6); } /* * misc. */ - ap->pblock = adoswordn(bp, ap->nwords - 3); - ap->hashf = adoswordn(bp, ap->nwords - 4); - ap->linknext = adoswordn(bp, ap->nwords - 10); - ap->linkto = adoswordn(bp, ap->nwords - 11); + ap->pblock = (daddr_t)adoswordn(bp, ap->nwords - 3); + ap->hashf = (daddr_t)adoswordn(bp, ap->nwords - 4); + ap->linknext = (daddr_t)adoswordn(bp, ap->nwords - 10); + ap->linkto = (daddr_t)adoswordn(bp, ap->nwords - 11); /* * setup last indirect block cache. @@ -553,9 +557,9 @@ adosfs_loadbitmap(amp) struct adosfsmount *amp; { struct buf *bp, *mapbp; - u_long bits, bn, n; - int blkix, endix, mapix; - int bmsize; + u_int32_t bits; + daddr_t bn; + int blkix, endix, mapix, bmsize, n; int error; bp = mapbp = NULL; @@ -579,7 +583,7 @@ adosfs_loadbitmap(amp) if (adoscksum(mapbp, amp->nwords)) { #ifdef DIAGNOSTIC printf("adosfs: loadbitmap - cksum of blk %d failed\n", - adoswordn(bp, blkix)); + adoswordn(bp, blkix)); #endif /* XXX Force read-only? Set free space 0? */ break; @@ -598,7 +602,7 @@ adosfs_loadbitmap(amp) } ++blkix; if (mapix < bmsize && blkix == endix) { - bn = adoswordn(bp, blkix); + bn = (daddr_t)adoswordn(bp, blkix); brelse(bp); if ((error = bread(amp->devvp, bn * amp->secsperblk, amp->bsize, NOCRED, &bp)) != 0) @@ -628,11 +632,15 @@ adosfs_loadbitmap(amp) * - check that the generation number matches */ +/* + * This is using the same layout as struct fid from mount.h for the first two + * fields. + */ struct ifid { - ushort ifid_len; - ushort ifid_pad; - int ifid_ino; - long ifid_start; + u_short ifid_len; + u_short ifid_pad; + ino_t ifid_ino; + daddr_t ifid_start; }; int @@ -693,7 +701,7 @@ adosfs_vptofh(vp, fhp) ifhp = (struct ifid *)fhp; ifhp->ifid_len = sizeof(struct ifid); - ifhp->ifid_ino = ap->block; + ifhp->ifid_ino = ABLKTOINO(ap->block); ifhp->ifid_start = ap->block; #ifdef ADOSFS_DIAGNOSTIC diff --git a/sys/adosfs/advnops.c b/sys/adosfs/advnops.c index 4c391ec5af7..ca1b2b101af 100644 --- a/sys/adosfs/advnops.c +++ b/sys/adosfs/advnops.c @@ -1,5 +1,5 @@ -/* $OpenBSD: advnops.c,v 1.7 1996/10/13 21:17:39 niklas Exp $ */ -/* $NetBSD: advnops.c,v 1.28 1996/04/23 05:18:32 veego Exp $ */ +/* $OpenBSD: advnops.c,v 1.8 1997/01/20 15:49:54 niklas Exp $ */ +/* $NetBSD: advnops.c,v 1.32 1996/10/13 02:52:09 christos Exp $ */ /* * Copyright (c) 1994 Christian E. Hopps @@ -44,6 +44,7 @@ #include <sys/stat.h> #include <sys/unistd.h> #include <sys/proc.h> + #include <miscfs/specfs/specdev.h> #include <adosfs/adosfs.h> @@ -100,48 +101,48 @@ int lease_check __P((void *)); #define adosfs_valloc adenotsup struct vnodeopv_entry_desc adosfs_vnodeop_entries[] = { - { &vop_default_desc, vn_default_error }, - { &vop_lookup_desc, adosfs_lookup }, /* lookup */ - { &vop_create_desc, adosfs_create }, /* create */ - { &vop_mknod_desc, adosfs_mknod }, /* mknod */ - { &vop_open_desc, adosfs_open }, /* open */ - { &vop_close_desc, adosfs_close }, /* close */ - { &vop_access_desc, adosfs_access }, /* access */ - { &vop_getattr_desc, adosfs_getattr }, /* getattr */ - { &vop_setattr_desc, adosfs_setattr }, /* setattr */ - { &vop_read_desc, adosfs_read }, /* read */ - { &vop_write_desc, adosfs_write }, /* write */ - { &vop_lease_desc, adosfs_lease_check }, /* lease */ - { &vop_ioctl_desc, adosfs_ioctl }, /* ioctl */ - { &vop_select_desc, adosfs_select }, /* select */ - { &vop_mmap_desc, adosfs_mmap }, /* mmap */ - { &vop_fsync_desc, adosfs_fsync }, /* fsync */ - { &vop_seek_desc, adosfs_seek }, /* seek */ - { &vop_remove_desc, adosfs_remove }, /* remove */ - { &vop_link_desc, adosfs_link }, /* link */ - { &vop_rename_desc, adosfs_rename }, /* rename */ - { &vop_mkdir_desc, adosfs_mkdir }, /* mkdir */ - { &vop_rmdir_desc, adosfs_rmdir }, /* rmdir */ - { &vop_symlink_desc, adosfs_symlink }, /* symlink */ - { &vop_readdir_desc, adosfs_readdir }, /* readdir */ - { &vop_readlink_desc, adosfs_readlink }, /* readlink */ - { &vop_abortop_desc, adosfs_abortop }, /* abortop */ - { &vop_inactive_desc, adosfs_inactive }, /* inactive */ - { &vop_reclaim_desc, adosfs_reclaim }, /* reclaim */ - { &vop_lock_desc, adosfs_lock }, /* lock */ - { &vop_unlock_desc, adosfs_unlock }, /* unlock */ - { &vop_bmap_desc, adosfs_bmap }, /* bmap */ - { &vop_strategy_desc, adosfs_strategy }, /* strategy */ - { &vop_print_desc, adosfs_print }, /* print */ - { &vop_islocked_desc, adosfs_islocked }, /* islocked */ - { &vop_pathconf_desc, adosfs_pathconf }, /* pathconf */ - { &vop_advlock_desc, adosfs_advlock }, /* advlock */ - { &vop_blkatoff_desc, adosfs_blkatoff }, /* blkatoff */ - { &vop_valloc_desc, adosfs_valloc }, /* valloc */ - { &vop_vfree_desc, adosfs_vfree }, /* vfree */ - { &vop_truncate_desc, adosfs_truncate }, /* truncate */ - { &vop_update_desc, adosfs_update }, /* update */ - { &vop_bwrite_desc, adosfs_bwrite }, /* bwrite */ + { &vop_default_desc, vn_default_error }, + { &vop_lookup_desc, adosfs_lookup }, /* lookup */ + { &vop_create_desc, adosfs_create }, /* create */ + { &vop_mknod_desc, adosfs_mknod }, /* mknod */ + { &vop_open_desc, adosfs_open }, /* open */ + { &vop_close_desc, adosfs_close }, /* close */ + { &vop_access_desc, adosfs_access }, /* access */ + { &vop_getattr_desc, adosfs_getattr }, /* getattr */ + { &vop_setattr_desc, adosfs_setattr }, /* setattr */ + { &vop_read_desc, adosfs_read }, /* read */ + { &vop_write_desc, adosfs_write }, /* write */ + { &vop_lease_desc, adosfs_lease_check }, /* lease */ + { &vop_ioctl_desc, adosfs_ioctl }, /* ioctl */ + { &vop_select_desc, adosfs_select }, /* select */ + { &vop_mmap_desc, adosfs_mmap }, /* mmap */ + { &vop_fsync_desc, adosfs_fsync }, /* fsync */ + { &vop_seek_desc, adosfs_seek }, /* seek */ + { &vop_remove_desc, adosfs_remove }, /* remove */ + { &vop_link_desc, adosfs_link }, /* link */ + { &vop_rename_desc, adosfs_rename }, /* rename */ + { &vop_mkdir_desc, adosfs_mkdir }, /* mkdir */ + { &vop_rmdir_desc, adosfs_rmdir }, /* rmdir */ + { &vop_symlink_desc, adosfs_symlink }, /* symlink */ + { &vop_readdir_desc, adosfs_readdir }, /* readdir */ + { &vop_readlink_desc, adosfs_readlink }, /* readlink */ + { &vop_abortop_desc, adosfs_abortop }, /* abortop */ + { &vop_inactive_desc, adosfs_inactive }, /* inactive */ + { &vop_reclaim_desc, adosfs_reclaim }, /* reclaim */ + { &vop_lock_desc, adosfs_lock }, /* lock */ + { &vop_unlock_desc, adosfs_unlock }, /* unlock */ + { &vop_bmap_desc, adosfs_bmap }, /* bmap */ + { &vop_strategy_desc, adosfs_strategy }, /* strategy */ + { &vop_print_desc, adosfs_print }, /* print */ + { &vop_islocked_desc, adosfs_islocked }, /* islocked */ + { &vop_pathconf_desc, adosfs_pathconf }, /* pathconf */ + { &vop_advlock_desc, adosfs_advlock }, /* advlock */ + { &vop_blkatoff_desc, adosfs_blkatoff }, /* blkatoff */ + { &vop_valloc_desc, adosfs_valloc }, /* valloc */ + { &vop_vfree_desc, adosfs_vfree }, /* vfree */ + { &vop_truncate_desc, adosfs_truncate }, /* truncate */ + { &vop_update_desc, adosfs_update }, /* update */ + { &vop_bwrite_desc, adosfs_bwrite }, /* bwrite */ { (struct vnodeop_desc*)NULL, (int(*) __P((void *)))NULL } }; @@ -178,7 +179,7 @@ adosfs_getattr(v) struct vattr *vap; struct adosfsmount *amp; struct anode *ap; - u_long fblks; + u_int32_t fblks; #ifdef ADOSFS_DIAGNOSTIC advopprint(sp); @@ -197,7 +198,7 @@ adosfs_getattr(v) vap->va_gen = 0; vap->va_flags = 0; vap->va_rdev = NODEV; - vap->va_fileid = ap->block; + vap->va_fileid = (long)ap->block; vap->va_type = sp->a_vp->v_type; vap->va_mode = amp->mask & adunixprot(ap->adprot); if (sp->a_vp->v_type == VDIR) { @@ -219,7 +220,7 @@ adosfs_getattr(v) fblks = howmany(ap->fsize, amp->dbsize); fblks += howmany(fblks, ANODENDATBLKENT(ap)); vap->va_bytes = fblks * amp->dbsize; - vap->va_size = ap->fsize; + vap->va_size = (off_t)ap->fsize; vap->va_blocksize = amp->dbsize; } @@ -247,8 +248,9 @@ adosfs_read(v) struct uio *uio; struct buf *bp; daddr_t lbn; - int size, diff, error; - long n, on; + int size, error, n, on; + u_int32_t off; + int64_t diff; #ifdef ADOSFS_DIAGNOSTIC advopprint(sp); @@ -266,16 +268,17 @@ adosfs_read(v) } if (uio->uio_resid == 0) goto reterr; - if (uio->uio_offset < 0) { + if (uio->uio_offset < 0 || uio->uio_offset > UINT_MAX) { /* XXX */ error = EINVAL; goto reterr; } + off = (u_int32_t)uio->uio_offset; /* * to expensive to let general algorithm figure out that * we are beyond the file. Do it now. */ - if (uio->uio_offset >= ap->fsize) + if (off >= ap->fsize) goto reterr; /* @@ -287,24 +290,24 @@ adosfs_read(v) * (which have data blocks without headers) */ size = amp->dbsize; - lbn = uio->uio_offset / size; - on = uio->uio_offset % size; - n = min((u_int)(size - on), uio->uio_resid); - diff = ap->fsize - uio->uio_offset; + lbn = off / size; + on = off % size; + n = min((u_int32_t)(size - on), uio->uio_resid); + diff = ap->fsize - off; /* * check for EOF */ if (diff <= 0) return(0); if (diff < n) - n = diff; + n = (int)diff; /* * read ahead could possibly be worth something * but not much as ados makes little attempt to * make things contigous */ - error = bread(sp->a_vp, lbn * amp->secsperblk, - amp->bsize, NOCRED, &bp); + error = bread(sp->a_vp, lbn * amp->secsperblk, amp->bsize, + NOCRED, &bp); sp->a_vp->v_lastr = lbn; if (!IS_FFS(amp)) { @@ -313,14 +316,14 @@ adosfs_read(v) else if (adoswordn(bp, 0) != BPT_DATA) { #ifdef DIAGNOSTIC printf("adosfs: bad primary type blk %ld\n", - bp->b_blkno / amp->secsperblk); + bp->b_blkno / amp->secsperblk); #endif error=EINVAL; } - else if ( adoscksum(bp, ap->nwords)) { + else if (adoscksum(bp, ap->nwords)) { #ifdef DIAGNOSTIC - printf("adosfs: blk %ld failed cksum.\n", - bp->b_blkno / amp->secsperblk); + printf("adosfs: blk %u failed cksum.\n", + bp->b_blkno / amp->secsperblk); #endif error=EINVAL; } @@ -331,12 +334,13 @@ adosfs_read(v) goto reterr; } #ifdef ADOSFS_DIAGNOSTIC - printf(" %d+%d-%d+%d", lbn, on, lbn, n); + printf(" %u+%u-%u+%u", lbn, on, lbn, n); #endif - n = min(n, (u_int)size - bp->b_resid); - error = uiomove(bp->b_un.b_addr + on + - amp->bsize - amp->dbsize, (int)n, uio); + n = min(n, size - bp->b_resid); /* XXX check types */ + error = uiomove(bp->b_un.b_addr + on + amp->bsize - + amp->dbsize, n, uio); brelse(bp); + off = (u_int32_t)uio->uio_offset; } while (error == 0 && uio->uio_resid > 0 && n != 0); reterr: #ifdef ADOSFS_DIAGNOSTIC @@ -443,11 +447,13 @@ adosfs_strategy(v) goto reterr; } } - if ((long)bp->b_blkno == -1) { +#if 0 + if (bp->b_blkno == UINT_MAX) { /* XXX huh? (was (long)... == -1 */ biodone(bp); error = 0; goto reterr; } +#endif vp = ap->amp->devvp; bp->b_dev = vp->v_rdev; VOCALL(vp->v_op, VOFFSET(vop_strategy), sp); @@ -586,10 +592,8 @@ adosfs_bmap(v) } */ *sp = v; struct anode *ap; struct buf *flbp; - long nb, fcnt, flblk, flblkoff; - daddr_t *bnp; - daddr_t bn; - int error; + daddr_t *bnp, bn, nb, flblk, fcnt; + int error, flblkoff; #ifdef ADOSFS_DIAGNOSTIC advopprint(sp); @@ -631,14 +635,14 @@ adosfs_bmap(v) /* * check last indirect block cache */ - if (flblk < (long)ap->lastlindblk) + if (flblk < ap->lastlindblk) fcnt = 0; else { flblk -= ap->lastlindblk; fcnt = ap->lastlindblk; nb = ap->lastindblk; } - while (flblk >= 0) { + while (1) { if (flbp) brelse(flbp); if (nb == 0) { @@ -654,7 +658,7 @@ adosfs_bmap(v) goto reterr; if (adoscksum(flbp, ap->nwords)) { #ifdef DIAGNOSTIC - printf("adosfs: blk %ld failed cksum.\n", nb); + printf("adosfs: blk %u failed cksum.\n", nb); #endif brelse(flbp); error = EINVAL; @@ -666,7 +670,9 @@ adosfs_bmap(v) ap->lastlindblk = fcnt++; ap->lastindblk = nb; - nb = adoswordn(flbp, ap->nwords - 2); + nb = (daddr_t)adoswordn(flbp, ap->nwords - 2); + if (flblk == 0) + break; flblk--; } /* @@ -675,13 +681,13 @@ adosfs_bmap(v) * valid table entries stored at offset ADBI_NBLKTABENT. */ flblkoff = bn % ANODENDATBLKENT(ap); - if (flblkoff < (long)adoswordn(flbp, 2 /* ADBI_NBLKTABENT */)) { + if (flblkoff < adoswordn(flbp, 2 /* ADBI_NBLKTABENT */)) { flblkoff = (ap->nwords - 51) - flblkoff; *bnp = adoswordn(flbp, flblkoff) * ap->amp->secsperblk; } else { #ifdef DIAGNOSTIC - printf("flblk offset %ld too large in lblk %ld blk %d\n", - flblkoff, bn / ap->amp->secsperblk , flbp->b_blkno); + printf("flblk offset %d too large in lblk %u blk %u\n", + flblkoff, bn / ap->amp->secsperblk, flbp->b_blkno); #endif error = EINVAL; } @@ -689,7 +695,7 @@ adosfs_bmap(v) reterr: #ifdef ADOSFS_DIAGNOSTIC if (error == 0 && bnp) - printf(" %d => %d", bn, *bnp); + printf(" %u => %u", bn, *bnp); printf(" %d)", error); #endif return(error); @@ -711,15 +717,17 @@ adosfs_print(v) return(0); } +/* This is laid out like a standard dirent, except that it is shorter. */ struct adirent { - u_long fileno; - u_short reclen; - char type; - char namlen; - char name[32]; /* maxlen of 30 plus 2 NUL's */ + u_int32_t fileno; + u_int16_t reclen; + u_int8_t type; + u_int8_t namlen; + char name[32]; /* maxlen of 30 plus 2 NUL's */ }; - -int + +/* XXX look over the off_t usage below wrt type safety */ +int adosfs_readdir(v) void *v; { @@ -737,7 +745,7 @@ adosfs_readdir(v) struct adosfsmount *amp; struct vnode *vp; struct uio *uio; - u_long nextbn; + daddr_t nextbn; off_t uoff; #ifdef ADOSFS_DIAGNOSTIC @@ -801,7 +809,7 @@ adosfs_readdir(v) */ ap = NULL; do { - error = VFS_VGET(amp->mp, (ino_t)nextbn, &vp); + error = VFS_VGET(amp->mp, ABLKTOINO(nextbn), &vp); if (error) goto reterr; ap = VTOA(vp); @@ -835,7 +843,7 @@ adosfs_readdir(v) * Fill in dirent record */ bzero(adp, sizeof(struct adirent)); - adp->fileno = ap->block; + adp->fileno = (u_int32_t)ap->block; /* * this deserves an function in kern/vfs_subr.c */ @@ -858,11 +866,11 @@ adosfs_readdir(v) bcopy(ap->name, adp->name, adp->namlen); vput(vp); - error = uiomove((caddr_t) adp, sizeof(struct adirent), uio); + error = uiomove((caddr_t)adp, sizeof(struct adirent), uio); if (error) break; if (sp->a_cookies) { - *sp->a_cookies++ = uoff; + *sp->a_cookies++ = (u_long)uoff; sp->a_ncookies--; } uoff += sizeof(struct adirent); |