Added declarations, fixed bugs due to missing decls. At least one of them

could panic a system. (I know, it paniced mine!).
This commit is contained in:
Poul-Henning Kamp 1994-09-27 20:42:59 +00:00
parent c172c3e66a
commit c3c6d51ea0
16 changed files with 336 additions and 222 deletions

View file

@ -1,4 +1,4 @@
/* $Id$ */
/* $Id: fat.h,v 1.1 1994/09/19 15:41:40 dfr Exp $ */
/* $NetBSD: fat.h,v 1.4 1994/08/21 18:43:57 ws Exp $ */
/*-
@ -94,4 +94,18 @@ int clusteralloc __P((struct msdosfsmount *pmp, u_long start, u_long count, u_lo
int fatentry __P((int function, struct msdosfsmount *pmp, u_long cluster, u_long *oldcontents, u_long newcontents));
int freeclusterchain __P((struct msdosfsmount *pmp, u_long startchain));
int extendfile __P((struct denode *dep, u_long count, struct buf **bpp, u_long *ncp, int flags));
void fc_purge __P((struct denode *dep, u_int frcn));
void fc_lookup __P((struct denode *dep, u_long findcn, u_long *frcnp, u_long *fsrcnp));
int readep __P((struct msdosfsmount *pmp, u_long dirclu, u_long dirofs, struct buf **bpp, struct direntry **epp));
int readde __P((struct denode *dep, struct buf **bpp, struct direntry **epp));
int deextend __P((struct denode *dep, off_t length, struct ucred *cred));
int fillinusemap __P((struct msdosfsmount *pmp));
int reinsert __P((struct denode *dep));
int dosdirempty __P((struct denode *dep));
int createde __P((struct denode *dep, struct denode *ddep, struct denode **depp));
int deupdat __P((struct denode *dep, struct timespec *tp, int waitfor));
int removede __P((struct denode *pdep, struct denode *dep));
int detrunc __P((struct denode *dep, u_long length, int flags, struct ucred *cred, struct proc *p));
int doscheckpath __P(( struct denode *source, struct denode *target));
#endif /* KERNEL */

View file

@ -1,4 +1,4 @@
/* $Id$ */
/* $Id: msdosfs_conv.c,v 1.1 1994/09/19 15:41:40 dfr Exp $ */
/* $NetBSD: msdosfs_conv.c,v 1.6.2.1 1994/08/30 02:27:57 cgd Exp $ */
/*
@ -23,6 +23,7 @@
#include <sys/param.h>
#include <sys/time.h>
#include <sys/kernel.h> /* defines tz */
#include <sys/systm.h> /* defines tz */
/*
* MSDOSFS include files.
@ -166,8 +167,9 @@ dos2unixtime(dd, dt, tsp)
*/
month = (dd & DD_MONTH_MASK) >> DD_MONTH_SHIFT;
if (month == 0) {
printf("dos2unixtime(): month value out of range (%d)\n",
month);
printf(
"dos2unixtime(): month value out of range (%ld)\n",
month);
month = 1;
}
for (m = 0; m < month - 1; m++) {

View file

@ -1,4 +1,4 @@
/* $Id$ */
/* $Id: msdosfs_denode.c,v 1.1 1994/09/19 15:41:41 dfr Exp $ */
/* $NetBSD: msdosfs_denode.c,v 1.9 1994/08/21 18:44:00 ws Exp $ */
/*-
@ -55,8 +55,11 @@
#include <sys/proc.h>
#include <sys/buf.h>
#include <sys/vnode.h>
#include <sys/types.h>
#include <sys/kernel.h> /* defines "time" */
#include <vm/vm.h>
#include <msdosfs/bpb.h>
#include <msdosfs/msdosfsmount.h>
#include <msdosfs/direntry.h>
@ -110,7 +113,8 @@ msdosfs_hashins(dep)
struct denode **depp, *deq;
depp = &dehashtbl[DEHASH(dep->de_dev, dep->de_dirclust + dep->de_diroffset)];
if (deq = *depp)
deq = *depp;
if (deq)
deq->de_prev = &dep->de_next;
dep->de_next = deq;
dep->de_prev = depp;
@ -129,7 +133,8 @@ msdosfs_hashrem(dep)
struct denode *dep;
{
struct denode *deq;
if (deq = dep->de_next)
deq = dep->de_next;
if (deq)
deq->de_prev = dep->de_prev;
*dep->de_prev = deq;
#ifdef DIAGNOSTIC
@ -197,7 +202,8 @@ deget(pmp, dirclust, diroffset, direntptr, depp)
* entry that represented the file happens to be reused while the
* deleted file is still open.
*/
if (ldep = msdosfs_hashget(dev, dirclust, diroffset)) {
ldep = msdosfs_hashget(dev, dirclust, diroffset);
if (ldep) {
*depp = ldep;
return 0;
}
@ -208,7 +214,8 @@ deget(pmp, dirclust, diroffset, direntptr, depp)
* copy it from the passed disk buffer.
*/
/* getnewvnode() does a VREF() on the vnode */
if (error = getnewvnode(VT_MSDOSFS, mntp, msdosfs_vnodeop_p, &nvp)) {
error = getnewvnode(VT_MSDOSFS, mntp, msdosfs_vnodeop_p, &nvp);
if (error) {
*depp = 0;
return error;
}
@ -309,11 +316,8 @@ deupdat(dep, tp, waitfor)
int waitfor;
{
int error;
daddr_t bn;
int diro;
struct buf *bp;
struct direntry *dirp;
struct msdosfsmount *pmp = dep->de_pmp;
struct timespec ts;
struct vnode *vp = DETOV(dep);
@ -338,7 +342,8 @@ deupdat(dep, tp, waitfor)
* Read in the cluster containing the directory entry we want to
* update.
*/
if (error = readde(dep, &bp, &dirp))
error = readde(dep, &bp, &dirp);
if (error)
return error;
/*
@ -388,6 +393,7 @@ detrunc(dep, length, flags, cred, p)
int isadir = dep->de_Attributes & ATTR_DIRECTORY;
struct buf *bp;
struct msdosfsmount *pmp = dep->de_pmp;
struct timespec ts;
#ifdef MSDOSFS_DEBUG
printf("detrunc(): file %s, length %d, flags %d\n", dep->de_Name, length, flags);
@ -402,7 +408,8 @@ detrunc(dep, length, flags, cred, p)
* directory's life.
*/
if (DETOV(dep)->v_flag & VROOT) {
printf("detrunc(): can't truncate root directory, clust %d, offset %d\n",
printf(
"detrunc(): can't truncate root directory, clust %ld, offset %ld\n",
dep->de_dirclust, dep->de_diroffset);
return EINVAL;
}
@ -426,7 +433,8 @@ detrunc(dep, length, flags, cred, p)
dep->de_StartCluster = 0;
eofentry = ~0;
} else {
if (error = pcbmap(dep, de_clcount(pmp, length) - 1, 0, &eofentry)) {
error = pcbmap(dep, de_clcount(pmp, length) - 1, 0, &eofentry);
if (error) {
#ifdef MSDOSFS_DEBUG
printf("detrunc(): pcbmap fails %d\n", error);
#endif
@ -480,7 +488,8 @@ detrunc(dep, length, flags, cred, p)
dep->de_flag |= DE_UPDATE;
vflags = (length > 0 ? V_SAVE : 0) | V_SAVEMETA;
vinvalbuf(DETOV(dep), vflags, cred, p, 0, 0);
allerror = deupdat(dep, &time, 1);
TIMEVAL_TO_TIMESPEC(&time, &ts);
allerror = deupdat(dep, &ts, 1);
#ifdef MSDOSFS_DEBUG
printf("detrunc(): allerror %d, eofentry %d\n",
allerror, eofentry);
@ -525,6 +534,7 @@ deextend(dep, length, cred)
struct msdosfsmount *pmp = dep->de_pmp;
u_long count;
int error;
struct timespec ts;
/*
* The root of a DOS filesystem cannot be extended.
@ -537,7 +547,8 @@ deextend(dep, length, cred)
* Is this really important?
*/
if (dep->de_Attributes & ATTR_DIRECTORY) {
if (error = suser(cred, NULL))
error = suser(cred, NULL);
if (error)
return error;
}
@ -551,7 +562,8 @@ deextend(dep, length, cred)
if (count > 0) {
if (count > pmp->pm_freeclustercount)
return ENOSPC;
if (error = extendfile(dep, count, NULL, NULL, DE_CLEAR)) {
error = extendfile(dep, count, NULL, NULL, DE_CLEAR);
if (error) {
/* truncate the added clusters away again */
(void) detrunc(dep, dep->de_FileSize, 0, cred, NULL);
return error;
@ -560,7 +572,8 @@ deextend(dep, length, cred)
dep->de_flag |= DE_UPDATE;
dep->de_FileSize = length;
return deupdat(dep, &time, 1);
TIMEVAL_TO_TIMESPEC(&time, &ts);
return deupdat(dep, &ts, 1);
}
/*
@ -570,8 +583,6 @@ deextend(dep, length, cred)
int reinsert(dep)
struct denode *dep;
{
union dehead *deh;
/*
* Fix up the denode cache. If the denode is for a directory,
* there is nothing to do since the hash is based on the starting
@ -595,7 +606,6 @@ msdosfs_reclaim(ap)
{
struct vnode *vp = ap->a_vp;
struct denode *dep = VTODE(vp);
int i;
extern int prtactive;
#ifdef MSDOSFS_DEBUG
@ -638,6 +648,7 @@ msdosfs_inactive(ap)
struct denode *dep = VTODE(vp);
int error = 0;
extern int prtactive;
struct timespec ts;
#ifdef MSDOSFS_DEBUG
printf("msdosfs_inactive(): dep %08x, de_Name[0] %x\n", dep, dep->de_Name[0]);
@ -671,7 +682,8 @@ msdosfs_inactive(ap)
dep->de_flag |= DE_UPDATE;
dep->de_Name[0] = SLOT_DELETED;
}
DE_UPDAT(dep, &time, 0);
TIMEVAL_TO_TIMESPEC(&time, &ts);
DE_UPDAT(dep, &ts, 0);
VOP_UNLOCK(vp);
dep->de_flag = 0;

View file

@ -1,4 +1,4 @@
/* $Id$ */
/* $Id: msdosfs_fat.c,v 1.1 1994/09/19 15:41:43 dfr Exp $ */
/* $NetBSD: msdosfs_fat.c,v 1.12 1994/08/21 18:44:04 ws Exp $ */
/*-
@ -85,10 +85,6 @@ int fc_largedistance; /* off by more than LMMAX */
/* Byte offset in FAT on filesystem pmp, cluster cn */
#define FATOFS(pmp, cn) (FAT12(pmp) ? (cn) * 3 / 2 : (cn) * 2)
void fc_lookup(struct denode *dep, u_long findcn,
u_long *frcnp, u_long *fsrcnp);
void fc_purge(struct denode *dep, u_int frcn);
static void
fatblock(pmp, ofs, bnp, sizep, bop)
struct msdosfsmount *pmp;
@ -255,7 +251,8 @@ hiteof:;
* Find the closest entry in the fat cache to the cluster we are looking
* for.
*/
void fc_lookup(dep, findcn, frcnp, fsrcnp)
void
fc_lookup(dep, findcn, frcnp, fsrcnp)
struct denode *dep;
u_long findcn;
u_long *frcnp;
@ -471,7 +468,8 @@ fatentry(function, pmp, cn, oldcontents, newcontents)
byteoffset = FATOFS(pmp, cn);
fatblock(pmp, byteoffset, &bn, &bsize, &bo);
if (error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp))
error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp);
if (error)
return error;
if (function & FAT_GET) {
@ -540,7 +538,8 @@ fatchain(pmp, start, count, fillwith)
while (count > 0) {
byteoffset = FATOFS(pmp, start);
fatblock(pmp, byteoffset, &bn, &bsize, &bo);
if (error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp))
error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp);
if (error)
return error;
while (count > 0) {
start++;
@ -603,7 +602,8 @@ chainlength(pmp, start, count)
while (++idx <= max_idx) {
if (len >= count)
break;
if (map = pmp->pm_inusemap[idx]) {
map = pmp->pm_inusemap[idx];
if (map) {
len += ffs(map) - 1;
break;
}
@ -670,7 +670,6 @@ clusteralloc(pmp, start, count, fillwith, retcluster, got)
u_long *retcluster;
u_long *got;
{
int error;
u_long idx;
u_long len, newst, foundcn, foundl, cn, l;
u_int map;
@ -768,7 +767,8 @@ freeclusterchain(pmp, cluster)
if (lbn != bn) {
if (bp)
updatefats(pmp, bp, bn);
if (error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp))
error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp);
if (error)
return error;
lbn = bn;
}
@ -916,7 +916,8 @@ extendfile(dep, count, bpp, ncp, flags)
cn = 0;
else
cn = dep->de_fc[FC_LASTFC].fc_fsrcn + 1;
if (error = clusteralloc(pmp, cn, count, CLUST_EOFE, &cn, &got))
error = clusteralloc(pmp, cn, count, CLUST_EOFE, &cn, &got);
if (error)
return error;
count -= got;

View file

@ -1,4 +1,4 @@
/* $Id$ */
/* $Id: msdosfs_lookup.c,v 1.1 1994/09/19 15:41:44 dfr Exp $ */
/* $NetBSD: msdosfs_lookup.c,v 1.14 1994/08/21 18:44:07 ws Exp $ */
/*-
@ -53,6 +53,7 @@
#include <sys/buf.h>
#include <sys/vnode.h>
#include <sys/mount.h>
#include <sys/systm.h>
#include <msdosfs/bpb.h>
#include <msdosfs/direntry.h>
@ -137,7 +138,8 @@ msdosfs_lookup(ap)
* See if the component of the pathname we are looking for is in
* the directory cache. If so then do a few things and return.
*/
if (error = cache_lookup(vdp, vpp, cnp)) {
error = cache_lookup(vdp, vpp, cnp);
if (error) {
int vpid;
if (error == ENOENT)
@ -172,7 +174,8 @@ msdosfs_lookup(ap)
if (lockparent && pdp != vdp && (flags & ISLASTCN))
VOP_UNLOCK(pdp);
}
if (error = VOP_LOCK(pdp))
error = VOP_LOCK(pdp);
if (error)
return error;
vdp = pdp;
dp = VTODE(vdp);
@ -227,12 +230,14 @@ msdosfs_lookup(ap)
*/
rootreloff = 0;
for (frcn = 0;; frcn++) {
if (error = pcbmap(dp, frcn, &bn, &cluster)) {
error = pcbmap(dp, frcn, &bn, &cluster);
if (error) {
if (error == E2BIG)
break;
return error;
}
if (error = bread(pmp->pm_devvp, bn, pmp->pm_bpcluster, NOCRED, &bp))
error = bread(pmp->pm_devvp, bn, pmp->pm_bpcluster,NOCRED,&bp);
if (error)
return error;
for (diroff = 0; diroff < pmp->pm_depclust; diroff++) {
dep = (struct direntry *) bp->b_data + diroff;
@ -459,7 +464,6 @@ createde(dep, ddep, depp)
struct denode *ddep;
struct denode **depp;
{
int bn;
int error;
u_long dirclust, diroffset;
struct direntry *ndep;
@ -479,7 +483,8 @@ createde(dep, ddep, depp)
* case.
*/
if (ddep->de_fndclust == (u_long)-1) {
if (error = extendfile(ddep, 1, &bp, &dirclust, DE_CLEAR))
error = extendfile(ddep, 1, &bp, &dirclust, DE_CLEAR);
if (error)
return error;
ndep = (struct direntry *) bp->b_data;
/*
@ -515,7 +520,8 @@ createde(dep, ddep, depp)
if (error)
return error;
}
if (error = bwrite(bp)) {
error = bwrite(bp);
if (error) {
vput(DETOV(*depp)); /* free the vnode we got on error */
return error;
}
@ -659,7 +665,6 @@ doscheckpath(source, target)
struct denode *target;
{
daddr_t scn;
struct denode dummy;
struct msdosfsmount *pmp;
struct direntry *ep;
struct denode *dep;
@ -737,7 +742,8 @@ readep(pmp, dirclu, dirofs, bpp, epp)
daddr_t bn;
bn = detobn(pmp, dirclu, dirofs);
if (error = bread(pmp->pm_devvp, bn, pmp->pm_bpcluster, NOCRED, bpp)) {
error = bread(pmp->pm_devvp, bn, pmp->pm_bpcluster, NOCRED, bpp);
if (error) {
*bpp = NULL;
return error;
}

View file

@ -1,4 +1,4 @@
/* $Id: msdosfs_vfsops.c,v 1.2 1994/09/19 19:24:44 dfr Exp $ */
/* $Id: msdosfs_vfsops.c,v 1.3 1994/09/21 03:47:16 wollman Exp $ */
/* $NetBSD: msdosfs_vfsops.c,v 1.19 1994/08/21 18:44:10 ws Exp $ */
/*-
@ -93,7 +93,8 @@ msdosfs_mount(mp, path, data, ndp, p)
/*
* Copy in the args for the mount request.
*/
if (error = copyin(data, (caddr_t) & args, sizeof(struct msdosfs_args)))
error = copyin(data, (caddr_t) & args, sizeof(struct msdosfs_args));
if (error)
return error;
/*
@ -259,17 +260,20 @@ mountmsdosfs(devvp, mp, p)
* old buffers from this filesystem. Presumably this prevents us
* from running into buffers that are the wrong blocksize.
*/
if (error = vfs_mountedon(devvp))
error = vfs_mountedon(devvp);
if (error)
return error;
if (vcount(devvp) > 1)
return EBUSY;
if (error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0))
error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0);
if (error)
return error;
/*
* Now open the block special file.
*/
if (error = VOP_OPEN(devvp, ronly ? FREAD : FREAD | FWRITE, FSCRED, p))
error = VOP_OPEN(devvp, ronly ? FREAD : FREAD | FWRITE, FSCRED, p);
if (error)
return error;
needclose = 1;
#ifdef HDSUPPORT
@ -287,7 +291,8 @@ mountmsdosfs(devvp, mp, p)
* also add some checking on the bsOemName field. So far I've seen
* the following values: "IBM 3.3" "MSDOS3.3" "MSDOS5.0"
*/
if (error = bread(devvp, 0, 512, NOCRED, &bp0))
error = bread(devvp, 0, 512, NOCRED, &bp0);
if (error)
goto error_exit;
bp0->b_flags |= B_AGE;
bsp = (union bootsector *) bp0->b_data;
@ -493,7 +498,6 @@ msdosfs_unmount(mp, mntflags, p)
int flags = 0;
int error;
struct msdosfsmount *pmp = (struct msdosfsmount *) mp->mnt_data;
struct vnode *vp = pmp->pm_devvp;
/* only the mounter, or superuser can unmount */
if ((p->p_cred->p_ruid != pmp->pm_mounter) &&
@ -507,7 +511,8 @@ msdosfs_unmount(mp, mntflags, p)
}
#ifdef QUOTA
#endif
if (error = vflush(mp, NULLVP, flags))
error = vflush(mp, NULLVP, flags);
if (error)
return error;
pmp->pm_devvp->v_specflags &= ~SI_MOUNTEDON;
#ifdef MSDOSFS_DEBUG
@ -561,6 +566,7 @@ msdosfs_quotactl(mp, cmds, uid, arg, p)
struct proc *p;
{
#ifdef QUOTA
return EOPNOTSUPP;
#else
return EOPNOTSUPP;
#endif
@ -646,7 +652,8 @@ loop:
continue;
if (vget(vp, 1)) /* not there anymore? */
goto loop;
if (error = VOP_FSYNC(vp, cred, waitfor, p))
error = VOP_FSYNC(vp, cred, waitfor, p);
if (error)
allerror = error;
vput(vp); /* done with this one */
}
@ -654,7 +661,8 @@ loop:
/*
* Flush filesystem control info.
*/
if (error = VOP_FSYNC(pmp->pm_devvp, cred, waitfor, p))
error = VOP_FSYNC(pmp->pm_devvp, cred, waitfor, p);
if (error)
allerror = error;
return allerror;
}

View file

@ -1,4 +1,4 @@
/* $Id: msdosfs_vnops.c,v 1.1 1994/09/19 15:41:46 dfr Exp $ */
/* $Id: msdosfs_vnops.c,v 1.2 1994/09/21 03:47:17 wollman Exp $ */
/* $NetBSD: msdosfs_vnops.c,v 1.20 1994/08/21 18:44:13 ws Exp $ */
/*-
@ -62,6 +62,9 @@
#include <miscfs/specfs/specdev.h> /* XXX */ /* defines v_rdev */
#include <sys/malloc.h>
#include <sys/dir.h> /* defines dirent structure */
#include <sys/signalvar.h>
#include <vm/vm.h>
#include <msdosfs/bpb.h>
#include <msdosfs/direntry.h>
@ -152,7 +155,6 @@ msdosfs_mknod(ap)
} */ *ap;
{
int error;
struct denode *pdep = VTODE(ap->a_dvp);
switch (ap->a_vap->va_type) {
case VDIR:
@ -382,12 +384,14 @@ msdosfs_setattr(ap)
if (vap->va_size != VNOVAL) {
if (ap->a_vp->v_type == VDIR)
return EISDIR;
if (error = detrunc(dep, vap->va_size, 0, cred, ap->a_p))
error = detrunc(dep, vap->va_size, 0, cred, ap->a_p);
if (error)
return error;
}
if (vap->va_mtime.ts_sec != VNOVAL) {
dep->de_flag |= DE_UPDATE;
if (error = deupdat(dep, &vap->va_mtime, 1))
error = deupdat(dep, &vap->va_mtime, 1);
if (error)
return error;
}
@ -406,7 +410,8 @@ msdosfs_setattr(ap)
}
if (vap->va_flags != VNOVAL) {
if (error = suser(cred, &ap->a_p->p_acflag))
error = suser(cred, &ap->a_p->p_acflag);
if (error)
return error;
if (cred->cr_uid == 0)
dep->de_flag = vap->va_flags;
@ -433,7 +438,6 @@ msdosfs_read(ap)
int isadir;
long n;
long on;
daddr_t bn;
daddr_t lbn;
daddr_t rablock;
int rasize;
@ -539,7 +543,9 @@ msdosfs_write(ap)
struct denode *dep = VTODE(vp);
struct msdosfsmount *pmp = dep->de_pmp;
struct ucred *cred = ap->a_cred;
struct timespec ts;
TIMEVAL_TO_TIMESPEC(&time, &ts);
#ifdef MSDOSFS_DEBUG
printf("msdosfs_write(vp %08x, uio %08x, ioflag %08x, cred %08x\n",
vp, uio, ioflag, cred);
@ -627,7 +633,8 @@ msdosfs_write(ap)
do {
bn = de_blk(pmp, uio->uio_offset);
if (isadir) {
if (error = pcbmap(dep, bn, &bn, 0))
error = pcbmap(dep, bn, &bn, 0);
if (error)
break;
} else if (bn > lastcn) {
error = ENOSPC;
@ -650,8 +657,9 @@ msdosfs_write(ap)
*/
if (!isadir) {
if (bp->b_blkno == bp->b_lblkno) {
if (error = pcbmap(dep, bp->b_lblkno,
&bp->b_blkno, 0))
error = pcbmap(dep, bp->b_lblkno,
&bp->b_blkno, 0);
if (error)
bp->b_blkno = -1;
}
if (bp->b_blkno == -1) {
@ -665,7 +673,8 @@ msdosfs_write(ap)
/*
* The block we need to write into exists, so read it in.
*/
if (error = bread(thisvp, bn, pmp->pm_bpcluster, cred, &bp))
error = bread(thisvp, bn, pmp->pm_bpcluster, cred, &bp);
if (error)
break;
}
@ -719,7 +728,7 @@ errexit:
error = 0;
}
} else {
error = deupdat(dep, &time, 1);
error = deupdat(dep, &ts, 1);
}
return error;
}
@ -780,7 +789,9 @@ msdosfs_fsync(ap)
{
struct vnode *vp = ap->a_vp;
int wait = ap->a_waitfor == MNT_WAIT;
int error;
struct timespec ts;
TIMEVAL_TO_TIMESPEC(&time, &ts);
#if 0
/*
@ -790,7 +801,7 @@ msdosfs_fsync(ap)
*/
vflushbuf(vp, wait ? B_SYNC : 0);
#endif
return deupdat(VTODE(vp), &time, wait);
return deupdat(VTODE(vp), &ts, wait);
}
/*
@ -1004,14 +1015,13 @@ msdosfs_rename(ap)
/* doscheckpath() vput()'s tddep */
error = doscheckpath(fdep, tddep);
tddep = NULL;
if (error) {
if (error)
goto bad;
}
if ((ap->a_tcnp->cn_flags & SAVESTART) == 0)
panic("msdosfs_rename(): lost to startdir");
if (error = relookup(ap->a_tdvp, &tvp, ap->a_tcnp)) {
error = relookup(ap->a_tdvp, &tvp, ap->a_tcnp);
if (error)
goto bad;
}
tddep = VTODE(ap->a_tdvp);
tdep = tvp ? VTODE(tvp) : NULL;
}
@ -1039,9 +1049,9 @@ msdosfs_rename(ap)
}
to_dirclust = tdep->de_dirclust;
to_diroffset = tdep->de_diroffset;
if (error = removede(tddep,tdep)) {
error = removede(tddep,tdep);
if (error)
goto bad;
}
vput(ap->a_tvp);
tdep = NULL;
@ -1060,15 +1070,15 @@ msdosfs_rename(ap)
if (newparent == 0) {
/* tddep and fddep point to the same denode here */
VOP_LOCK(ap->a_fvp); /* ap->a_fdvp is already locked */
if (error = readep(fddep->de_pmp,
fdep->de_dirclust,
fdep->de_diroffset,
&bp, &ep)) {
error = readep(fddep->de_pmp, fdep->de_dirclust,
fdep->de_diroffset, &bp, &ep);
if (error) {
VOP_UNLOCK(ap->a_fvp);
goto bad;
}
bcopy(toname, ep->deName, 11);
if (error = bwrite(bp)) {
error = bwrite(bp);
if (error) {
VOP_UNLOCK(ap->a_fvp);
goto bad;
}
@ -1107,16 +1117,16 @@ msdosfs_rename(ap)
goto bad;
}
VOP_LOCK(ap->a_fdvp);
if (error = readep(fddep->de_pmp,
fddep->de_fndclust,
fddep->de_fndoffset,
&bp, &ep)) {
error = readep(fddep->de_pmp, fddep->de_fndclust,
fddep->de_fndoffset, &bp, &ep);
if (error) {
VOP_UNLOCK(ap->a_fvp);
VOP_UNLOCK(ap->a_fdvp);
goto bad;
}
ep->deName[0] = SLOT_DELETED;
if (error = bwrite(bp)) {
error = bwrite(bp);
if (error) {
VOP_UNLOCK(ap->a_fvp);
VOP_UNLOCK(ap->a_fdvp);
goto bad;
@ -1171,19 +1181,21 @@ struct {
struct direntry dot;
struct direntry dotdot;
} dosdirtemplate = {
". ", " ", /* the . entry */
ATTR_DIRECTORY, /* file attribute */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* resevered */
210, 4, 210, 4, /* time and date */
0, 0, /* startcluster */
0, 0, 0, 0, /* filesize */
".. ", " ", /* the .. entry */
ATTR_DIRECTORY, /* file attribute */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* resevered */
210, 4, 210, 4, /* time and date */
0, 0, /* startcluster */
0, 0, 0, 0, /* filesize */
{
". ", " ", /* the . entry */
ATTR_DIRECTORY, /* file attribute */
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, /* resevered */
{210, 4}, {210, 4}, /* time and date */
{0, 0}, /* startcluster */
{0, 0, 0, 0}, /* filesize */
},{
".. ", " ", /* the .. entry */
ATTR_DIRECTORY, /* file attribute */
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, /* resevered */
{210, 4}, {210, 4}, /* time and date */
{0, 0}, /* startcluster */
{0, 0, 0, 0}, /* filesize */
}
};
int
@ -1225,7 +1237,8 @@ msdosfs_mkdir(ap)
/*
* Allocate a cluster to hold the about to be created directory.
*/
if (error = clusteralloc(pmp, 0, 1, CLUST_EOFE, &newcluster, NULL)) {
error = clusteralloc(pmp, 0, 1, CLUST_EOFE, &newcluster, NULL);
if (error) {
free(ap->a_cnp->cn_pnbuf, M_NAMEI);
vput(ap->a_dvp);
return error;
@ -1251,7 +1264,8 @@ msdosfs_mkdir(ap)
putushort(denp->deStartCluster, pdep->de_StartCluster);
putushort(denp->deDate, dDate);
putushort(denp->deTime, dTime);
if (error = bwrite(bp)) {
error = bwrite(bp);
if (error) {
clusterfree(pmp, newcluster, NULL);
free(ap->a_cnp->cn_pnbuf, M_NAMEI);
vput(ap->a_dvp);
@ -1326,7 +1340,8 @@ msdosfs_rmdir(ap)
* up access and eventually msdosfs_reclaim() will be called which
* will remove it from the denode cache.
*/
if (error = removede(ddep,dep))
error = removede(ddep,dep);
if (error)
goto out;
/*
@ -1341,7 +1356,7 @@ msdosfs_rmdir(ap)
/*
* Truncate the directory that is being deleted.
*/
error = detrunc(dep, (u_long) 0, IO_SYNC);
error = detrunc(dep, (u_long) 0, IO_SYNC, NOCRED, NULL);
cache_purge(DETOV(dep));
out: ;
@ -1364,8 +1379,6 @@ msdosfs_symlink(ap)
char *a_target;
} */ *ap;
{
struct denode *pdep = VTODE(ap->a_dvp);
free(ap->a_cnp->cn_pnbuf, M_NAMEI);
vput(ap->a_dvp);
return EINVAL;
@ -1430,7 +1443,6 @@ msdosfs_readdir(ap)
struct dirent *prev;
struct dirent *crnt;
u_char dirbuf[512]; /* holds converted dos directories */
int i = 0;
struct uio *uio = ap->a_uio;
int ncookies = 1;
u_int* cookies = NULL;
@ -1756,7 +1768,6 @@ msdosfs_bmap(ap)
} */ *ap;
{
struct denode *dep = VTODE(ap->a_vp);
struct msdosfsmount *pmp = dep->de_pmp;
if (ap->a_vpp != NULL)
*ap->a_vpp = dep->de_devvp;
@ -1789,7 +1800,6 @@ msdosfs_strategy(ap)
{
struct buf *bp = ap->a_bp;
struct denode *dep = VTODE(bp->b_vp);
struct msdosfsmount *pmp = dep->de_pmp;
struct vnode *vp;
int error = 0;
@ -1802,7 +1812,8 @@ msdosfs_strategy(ap)
* don't allow files with holes, so we shouldn't ever see this.
*/
if (bp->b_blkno == bp->b_lblkno) {
if (error = pcbmap(dep, bp->b_lblkno, &bp->b_blkno, 0))
error = pcbmap(dep, bp->b_lblkno, &bp->b_blkno, 0);
if (error)
bp->b_blkno = -1;
if (bp->b_blkno == -1)
clrbuf(bp);
@ -1831,15 +1842,16 @@ msdosfs_print(ap)
{
struct denode *dep = VTODE(ap->a_vp);
printf("tag VT_MSDOSFS, startcluster %d, dircluster %d, diroffset %d ",
printf(
"tag VT_MSDOSFS, startcluster %d, dircluster %ld, diroffset %ld ",
dep->de_StartCluster, dep->de_dirclust, dep->de_diroffset);
printf(" dev %d, %d, %s\n",
major(dep->de_dev), minor(dep->de_dev),
dep->de_flag & DE_LOCKED ? "(LOCKED)" : "");
if (dep->de_lockholder) {
printf(" owner pid %d", dep->de_lockholder);
printf(" owner pid %d", (int)dep->de_lockholder);
if (dep->de_lockwaiter)
printf(" waiting pid %d", dep->de_lockwaiter);
printf(" waiting pid %d", (int)dep->de_lockwaiter);
printf("\n");
}
return 0;

View file

@ -1,4 +1,4 @@
/* $Id$ */
/* $Id: msdosfsmount.h,v 1.1 1994/09/19 15:41:48 dfr Exp $ */
/* $NetBSD: msdosfsmount.h,v 1.7 1994/08/21 18:44:17 ws Exp $ */
/*-
@ -181,3 +181,5 @@ int msdosfs_sync __P((struct mount *, int, struct ucred *, struct proc *));
int msdosfs_fhtovp __P((struct mount *, struct fid *, struct mbuf *, struct vnode **, int *, struct ucred **));
int msdosfs_vptofh __P((struct vnode *, struct fid *));
int msdosfs_init __P(());
int mountmsdosfs __P((struct vnode *devvp, struct mount *mp, struct proc *p));

View file

@ -1,4 +1,4 @@
/* $Id$ */
/* $Id: fat.h,v 1.1 1994/09/19 15:41:40 dfr Exp $ */
/* $NetBSD: fat.h,v 1.4 1994/08/21 18:43:57 ws Exp $ */
/*-
@ -94,4 +94,18 @@ int clusteralloc __P((struct msdosfsmount *pmp, u_long start, u_long count, u_lo
int fatentry __P((int function, struct msdosfsmount *pmp, u_long cluster, u_long *oldcontents, u_long newcontents));
int freeclusterchain __P((struct msdosfsmount *pmp, u_long startchain));
int extendfile __P((struct denode *dep, u_long count, struct buf **bpp, u_long *ncp, int flags));
void fc_purge __P((struct denode *dep, u_int frcn));
void fc_lookup __P((struct denode *dep, u_long findcn, u_long *frcnp, u_long *fsrcnp));
int readep __P((struct msdosfsmount *pmp, u_long dirclu, u_long dirofs, struct buf **bpp, struct direntry **epp));
int readde __P((struct denode *dep, struct buf **bpp, struct direntry **epp));
int deextend __P((struct denode *dep, off_t length, struct ucred *cred));
int fillinusemap __P((struct msdosfsmount *pmp));
int reinsert __P((struct denode *dep));
int dosdirempty __P((struct denode *dep));
int createde __P((struct denode *dep, struct denode *ddep, struct denode **depp));
int deupdat __P((struct denode *dep, struct timespec *tp, int waitfor));
int removede __P((struct denode *pdep, struct denode *dep));
int detrunc __P((struct denode *dep, u_long length, int flags, struct ucred *cred, struct proc *p));
int doscheckpath __P(( struct denode *source, struct denode *target));
#endif /* KERNEL */

View file

@ -1,4 +1,4 @@
/* $Id$ */
/* $Id: msdosfs_conv.c,v 1.1 1994/09/19 15:41:40 dfr Exp $ */
/* $NetBSD: msdosfs_conv.c,v 1.6.2.1 1994/08/30 02:27:57 cgd Exp $ */
/*
@ -23,6 +23,7 @@
#include <sys/param.h>
#include <sys/time.h>
#include <sys/kernel.h> /* defines tz */
#include <sys/systm.h> /* defines tz */
/*
* MSDOSFS include files.
@ -166,8 +167,9 @@ dos2unixtime(dd, dt, tsp)
*/
month = (dd & DD_MONTH_MASK) >> DD_MONTH_SHIFT;
if (month == 0) {
printf("dos2unixtime(): month value out of range (%d)\n",
month);
printf(
"dos2unixtime(): month value out of range (%ld)\n",
month);
month = 1;
}
for (m = 0; m < month - 1; m++) {

View file

@ -1,4 +1,4 @@
/* $Id$ */
/* $Id: msdosfs_denode.c,v 1.1 1994/09/19 15:41:41 dfr Exp $ */
/* $NetBSD: msdosfs_denode.c,v 1.9 1994/08/21 18:44:00 ws Exp $ */
/*-
@ -55,8 +55,11 @@
#include <sys/proc.h>
#include <sys/buf.h>
#include <sys/vnode.h>
#include <sys/types.h>
#include <sys/kernel.h> /* defines "time" */
#include <vm/vm.h>
#include <msdosfs/bpb.h>
#include <msdosfs/msdosfsmount.h>
#include <msdosfs/direntry.h>
@ -110,7 +113,8 @@ msdosfs_hashins(dep)
struct denode **depp, *deq;
depp = &dehashtbl[DEHASH(dep->de_dev, dep->de_dirclust + dep->de_diroffset)];
if (deq = *depp)
deq = *depp;
if (deq)
deq->de_prev = &dep->de_next;
dep->de_next = deq;
dep->de_prev = depp;
@ -129,7 +133,8 @@ msdosfs_hashrem(dep)
struct denode *dep;
{
struct denode *deq;
if (deq = dep->de_next)
deq = dep->de_next;
if (deq)
deq->de_prev = dep->de_prev;
*dep->de_prev = deq;
#ifdef DIAGNOSTIC
@ -197,7 +202,8 @@ deget(pmp, dirclust, diroffset, direntptr, depp)
* entry that represented the file happens to be reused while the
* deleted file is still open.
*/
if (ldep = msdosfs_hashget(dev, dirclust, diroffset)) {
ldep = msdosfs_hashget(dev, dirclust, diroffset);
if (ldep) {
*depp = ldep;
return 0;
}
@ -208,7 +214,8 @@ deget(pmp, dirclust, diroffset, direntptr, depp)
* copy it from the passed disk buffer.
*/
/* getnewvnode() does a VREF() on the vnode */
if (error = getnewvnode(VT_MSDOSFS, mntp, msdosfs_vnodeop_p, &nvp)) {
error = getnewvnode(VT_MSDOSFS, mntp, msdosfs_vnodeop_p, &nvp);
if (error) {
*depp = 0;
return error;
}
@ -309,11 +316,8 @@ deupdat(dep, tp, waitfor)
int waitfor;
{
int error;
daddr_t bn;
int diro;
struct buf *bp;
struct direntry *dirp;
struct msdosfsmount *pmp = dep->de_pmp;
struct timespec ts;
struct vnode *vp = DETOV(dep);
@ -338,7 +342,8 @@ deupdat(dep, tp, waitfor)
* Read in the cluster containing the directory entry we want to
* update.
*/
if (error = readde(dep, &bp, &dirp))
error = readde(dep, &bp, &dirp);
if (error)
return error;
/*
@ -388,6 +393,7 @@ detrunc(dep, length, flags, cred, p)
int isadir = dep->de_Attributes & ATTR_DIRECTORY;
struct buf *bp;
struct msdosfsmount *pmp = dep->de_pmp;
struct timespec ts;
#ifdef MSDOSFS_DEBUG
printf("detrunc(): file %s, length %d, flags %d\n", dep->de_Name, length, flags);
@ -402,7 +408,8 @@ detrunc(dep, length, flags, cred, p)
* directory's life.
*/
if (DETOV(dep)->v_flag & VROOT) {
printf("detrunc(): can't truncate root directory, clust %d, offset %d\n",
printf(
"detrunc(): can't truncate root directory, clust %ld, offset %ld\n",
dep->de_dirclust, dep->de_diroffset);
return EINVAL;
}
@ -426,7 +433,8 @@ detrunc(dep, length, flags, cred, p)
dep->de_StartCluster = 0;
eofentry = ~0;
} else {
if (error = pcbmap(dep, de_clcount(pmp, length) - 1, 0, &eofentry)) {
error = pcbmap(dep, de_clcount(pmp, length) - 1, 0, &eofentry);
if (error) {
#ifdef MSDOSFS_DEBUG
printf("detrunc(): pcbmap fails %d\n", error);
#endif
@ -480,7 +488,8 @@ detrunc(dep, length, flags, cred, p)
dep->de_flag |= DE_UPDATE;
vflags = (length > 0 ? V_SAVE : 0) | V_SAVEMETA;
vinvalbuf(DETOV(dep), vflags, cred, p, 0, 0);
allerror = deupdat(dep, &time, 1);
TIMEVAL_TO_TIMESPEC(&time, &ts);
allerror = deupdat(dep, &ts, 1);
#ifdef MSDOSFS_DEBUG
printf("detrunc(): allerror %d, eofentry %d\n",
allerror, eofentry);
@ -525,6 +534,7 @@ deextend(dep, length, cred)
struct msdosfsmount *pmp = dep->de_pmp;
u_long count;
int error;
struct timespec ts;
/*
* The root of a DOS filesystem cannot be extended.
@ -537,7 +547,8 @@ deextend(dep, length, cred)
* Is this really important?
*/
if (dep->de_Attributes & ATTR_DIRECTORY) {
if (error = suser(cred, NULL))
error = suser(cred, NULL);
if (error)
return error;
}
@ -551,7 +562,8 @@ deextend(dep, length, cred)
if (count > 0) {
if (count > pmp->pm_freeclustercount)
return ENOSPC;
if (error = extendfile(dep, count, NULL, NULL, DE_CLEAR)) {
error = extendfile(dep, count, NULL, NULL, DE_CLEAR);
if (error) {
/* truncate the added clusters away again */
(void) detrunc(dep, dep->de_FileSize, 0, cred, NULL);
return error;
@ -560,7 +572,8 @@ deextend(dep, length, cred)
dep->de_flag |= DE_UPDATE;
dep->de_FileSize = length;
return deupdat(dep, &time, 1);
TIMEVAL_TO_TIMESPEC(&time, &ts);
return deupdat(dep, &ts, 1);
}
/*
@ -570,8 +583,6 @@ deextend(dep, length, cred)
int reinsert(dep)
struct denode *dep;
{
union dehead *deh;
/*
* Fix up the denode cache. If the denode is for a directory,
* there is nothing to do since the hash is based on the starting
@ -595,7 +606,6 @@ msdosfs_reclaim(ap)
{
struct vnode *vp = ap->a_vp;
struct denode *dep = VTODE(vp);
int i;
extern int prtactive;
#ifdef MSDOSFS_DEBUG
@ -638,6 +648,7 @@ msdosfs_inactive(ap)
struct denode *dep = VTODE(vp);
int error = 0;
extern int prtactive;
struct timespec ts;
#ifdef MSDOSFS_DEBUG
printf("msdosfs_inactive(): dep %08x, de_Name[0] %x\n", dep, dep->de_Name[0]);
@ -671,7 +682,8 @@ msdosfs_inactive(ap)
dep->de_flag |= DE_UPDATE;
dep->de_Name[0] = SLOT_DELETED;
}
DE_UPDAT(dep, &time, 0);
TIMEVAL_TO_TIMESPEC(&time, &ts);
DE_UPDAT(dep, &ts, 0);
VOP_UNLOCK(vp);
dep->de_flag = 0;

View file

@ -1,4 +1,4 @@
/* $Id$ */
/* $Id: msdosfs_fat.c,v 1.1 1994/09/19 15:41:43 dfr Exp $ */
/* $NetBSD: msdosfs_fat.c,v 1.12 1994/08/21 18:44:04 ws Exp $ */
/*-
@ -85,10 +85,6 @@ int fc_largedistance; /* off by more than LMMAX */
/* Byte offset in FAT on filesystem pmp, cluster cn */
#define FATOFS(pmp, cn) (FAT12(pmp) ? (cn) * 3 / 2 : (cn) * 2)
void fc_lookup(struct denode *dep, u_long findcn,
u_long *frcnp, u_long *fsrcnp);
void fc_purge(struct denode *dep, u_int frcn);
static void
fatblock(pmp, ofs, bnp, sizep, bop)
struct msdosfsmount *pmp;
@ -255,7 +251,8 @@ hiteof:;
* Find the closest entry in the fat cache to the cluster we are looking
* for.
*/
void fc_lookup(dep, findcn, frcnp, fsrcnp)
void
fc_lookup(dep, findcn, frcnp, fsrcnp)
struct denode *dep;
u_long findcn;
u_long *frcnp;
@ -471,7 +468,8 @@ fatentry(function, pmp, cn, oldcontents, newcontents)
byteoffset = FATOFS(pmp, cn);
fatblock(pmp, byteoffset, &bn, &bsize, &bo);
if (error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp))
error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp);
if (error)
return error;
if (function & FAT_GET) {
@ -540,7 +538,8 @@ fatchain(pmp, start, count, fillwith)
while (count > 0) {
byteoffset = FATOFS(pmp, start);
fatblock(pmp, byteoffset, &bn, &bsize, &bo);
if (error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp))
error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp);
if (error)
return error;
while (count > 0) {
start++;
@ -603,7 +602,8 @@ chainlength(pmp, start, count)
while (++idx <= max_idx) {
if (len >= count)
break;
if (map = pmp->pm_inusemap[idx]) {
map = pmp->pm_inusemap[idx];
if (map) {
len += ffs(map) - 1;
break;
}
@ -670,7 +670,6 @@ clusteralloc(pmp, start, count, fillwith, retcluster, got)
u_long *retcluster;
u_long *got;
{
int error;
u_long idx;
u_long len, newst, foundcn, foundl, cn, l;
u_int map;
@ -768,7 +767,8 @@ freeclusterchain(pmp, cluster)
if (lbn != bn) {
if (bp)
updatefats(pmp, bp, bn);
if (error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp))
error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp);
if (error)
return error;
lbn = bn;
}
@ -916,7 +916,8 @@ extendfile(dep, count, bpp, ncp, flags)
cn = 0;
else
cn = dep->de_fc[FC_LASTFC].fc_fsrcn + 1;
if (error = clusteralloc(pmp, cn, count, CLUST_EOFE, &cn, &got))
error = clusteralloc(pmp, cn, count, CLUST_EOFE, &cn, &got);
if (error)
return error;
count -= got;

View file

@ -1,4 +1,4 @@
/* $Id$ */
/* $Id: msdosfs_lookup.c,v 1.1 1994/09/19 15:41:44 dfr Exp $ */
/* $NetBSD: msdosfs_lookup.c,v 1.14 1994/08/21 18:44:07 ws Exp $ */
/*-
@ -53,6 +53,7 @@
#include <sys/buf.h>
#include <sys/vnode.h>
#include <sys/mount.h>
#include <sys/systm.h>
#include <msdosfs/bpb.h>
#include <msdosfs/direntry.h>
@ -137,7 +138,8 @@ msdosfs_lookup(ap)
* See if the component of the pathname we are looking for is in
* the directory cache. If so then do a few things and return.
*/
if (error = cache_lookup(vdp, vpp, cnp)) {
error = cache_lookup(vdp, vpp, cnp);
if (error) {
int vpid;
if (error == ENOENT)
@ -172,7 +174,8 @@ msdosfs_lookup(ap)
if (lockparent && pdp != vdp && (flags & ISLASTCN))
VOP_UNLOCK(pdp);
}
if (error = VOP_LOCK(pdp))
error = VOP_LOCK(pdp);
if (error)
return error;
vdp = pdp;
dp = VTODE(vdp);
@ -227,12 +230,14 @@ msdosfs_lookup(ap)
*/
rootreloff = 0;
for (frcn = 0;; frcn++) {
if (error = pcbmap(dp, frcn, &bn, &cluster)) {
error = pcbmap(dp, frcn, &bn, &cluster);
if (error) {
if (error == E2BIG)
break;
return error;
}
if (error = bread(pmp->pm_devvp, bn, pmp->pm_bpcluster, NOCRED, &bp))
error = bread(pmp->pm_devvp, bn, pmp->pm_bpcluster,NOCRED,&bp);
if (error)
return error;
for (diroff = 0; diroff < pmp->pm_depclust; diroff++) {
dep = (struct direntry *) bp->b_data + diroff;
@ -459,7 +464,6 @@ createde(dep, ddep, depp)
struct denode *ddep;
struct denode **depp;
{
int bn;
int error;
u_long dirclust, diroffset;
struct direntry *ndep;
@ -479,7 +483,8 @@ createde(dep, ddep, depp)
* case.
*/
if (ddep->de_fndclust == (u_long)-1) {
if (error = extendfile(ddep, 1, &bp, &dirclust, DE_CLEAR))
error = extendfile(ddep, 1, &bp, &dirclust, DE_CLEAR);
if (error)
return error;
ndep = (struct direntry *) bp->b_data;
/*
@ -515,7 +520,8 @@ createde(dep, ddep, depp)
if (error)
return error;
}
if (error = bwrite(bp)) {
error = bwrite(bp);
if (error) {
vput(DETOV(*depp)); /* free the vnode we got on error */
return error;
}
@ -659,7 +665,6 @@ doscheckpath(source, target)
struct denode *target;
{
daddr_t scn;
struct denode dummy;
struct msdosfsmount *pmp;
struct direntry *ep;
struct denode *dep;
@ -737,7 +742,8 @@ readep(pmp, dirclu, dirofs, bpp, epp)
daddr_t bn;
bn = detobn(pmp, dirclu, dirofs);
if (error = bread(pmp->pm_devvp, bn, pmp->pm_bpcluster, NOCRED, bpp)) {
error = bread(pmp->pm_devvp, bn, pmp->pm_bpcluster, NOCRED, bpp);
if (error) {
*bpp = NULL;
return error;
}

View file

@ -1,4 +1,4 @@
/* $Id: msdosfs_vfsops.c,v 1.2 1994/09/19 19:24:44 dfr Exp $ */
/* $Id: msdosfs_vfsops.c,v 1.3 1994/09/21 03:47:16 wollman Exp $ */
/* $NetBSD: msdosfs_vfsops.c,v 1.19 1994/08/21 18:44:10 ws Exp $ */
/*-
@ -93,7 +93,8 @@ msdosfs_mount(mp, path, data, ndp, p)
/*
* Copy in the args for the mount request.
*/
if (error = copyin(data, (caddr_t) & args, sizeof(struct msdosfs_args)))
error = copyin(data, (caddr_t) & args, sizeof(struct msdosfs_args));
if (error)
return error;
/*
@ -259,17 +260,20 @@ mountmsdosfs(devvp, mp, p)
* old buffers from this filesystem. Presumably this prevents us
* from running into buffers that are the wrong blocksize.
*/
if (error = vfs_mountedon(devvp))
error = vfs_mountedon(devvp);
if (error)
return error;
if (vcount(devvp) > 1)
return EBUSY;
if (error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0))
error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0);
if (error)
return error;
/*
* Now open the block special file.
*/
if (error = VOP_OPEN(devvp, ronly ? FREAD : FREAD | FWRITE, FSCRED, p))
error = VOP_OPEN(devvp, ronly ? FREAD : FREAD | FWRITE, FSCRED, p);
if (error)
return error;
needclose = 1;
#ifdef HDSUPPORT
@ -287,7 +291,8 @@ mountmsdosfs(devvp, mp, p)
* also add some checking on the bsOemName field. So far I've seen
* the following values: "IBM 3.3" "MSDOS3.3" "MSDOS5.0"
*/
if (error = bread(devvp, 0, 512, NOCRED, &bp0))
error = bread(devvp, 0, 512, NOCRED, &bp0);
if (error)
goto error_exit;
bp0->b_flags |= B_AGE;
bsp = (union bootsector *) bp0->b_data;
@ -493,7 +498,6 @@ msdosfs_unmount(mp, mntflags, p)
int flags = 0;
int error;
struct msdosfsmount *pmp = (struct msdosfsmount *) mp->mnt_data;
struct vnode *vp = pmp->pm_devvp;
/* only the mounter, or superuser can unmount */
if ((p->p_cred->p_ruid != pmp->pm_mounter) &&
@ -507,7 +511,8 @@ msdosfs_unmount(mp, mntflags, p)
}
#ifdef QUOTA
#endif
if (error = vflush(mp, NULLVP, flags))
error = vflush(mp, NULLVP, flags);
if (error)
return error;
pmp->pm_devvp->v_specflags &= ~SI_MOUNTEDON;
#ifdef MSDOSFS_DEBUG
@ -561,6 +566,7 @@ msdosfs_quotactl(mp, cmds, uid, arg, p)
struct proc *p;
{
#ifdef QUOTA
return EOPNOTSUPP;
#else
return EOPNOTSUPP;
#endif
@ -646,7 +652,8 @@ loop:
continue;
if (vget(vp, 1)) /* not there anymore? */
goto loop;
if (error = VOP_FSYNC(vp, cred, waitfor, p))
error = VOP_FSYNC(vp, cred, waitfor, p);
if (error)
allerror = error;
vput(vp); /* done with this one */
}
@ -654,7 +661,8 @@ loop:
/*
* Flush filesystem control info.
*/
if (error = VOP_FSYNC(pmp->pm_devvp, cred, waitfor, p))
error = VOP_FSYNC(pmp->pm_devvp, cred, waitfor, p);
if (error)
allerror = error;
return allerror;
}

View file

@ -1,4 +1,4 @@
/* $Id: msdosfs_vnops.c,v 1.1 1994/09/19 15:41:46 dfr Exp $ */
/* $Id: msdosfs_vnops.c,v 1.2 1994/09/21 03:47:17 wollman Exp $ */
/* $NetBSD: msdosfs_vnops.c,v 1.20 1994/08/21 18:44:13 ws Exp $ */
/*-
@ -62,6 +62,9 @@
#include <miscfs/specfs/specdev.h> /* XXX */ /* defines v_rdev */
#include <sys/malloc.h>
#include <sys/dir.h> /* defines dirent structure */
#include <sys/signalvar.h>
#include <vm/vm.h>
#include <msdosfs/bpb.h>
#include <msdosfs/direntry.h>
@ -152,7 +155,6 @@ msdosfs_mknod(ap)
} */ *ap;
{
int error;
struct denode *pdep = VTODE(ap->a_dvp);
switch (ap->a_vap->va_type) {
case VDIR:
@ -382,12 +384,14 @@ msdosfs_setattr(ap)
if (vap->va_size != VNOVAL) {
if (ap->a_vp->v_type == VDIR)
return EISDIR;
if (error = detrunc(dep, vap->va_size, 0, cred, ap->a_p))
error = detrunc(dep, vap->va_size, 0, cred, ap->a_p);
if (error)
return error;
}
if (vap->va_mtime.ts_sec != VNOVAL) {
dep->de_flag |= DE_UPDATE;
if (error = deupdat(dep, &vap->va_mtime, 1))
error = deupdat(dep, &vap->va_mtime, 1);
if (error)
return error;
}
@ -406,7 +410,8 @@ msdosfs_setattr(ap)
}
if (vap->va_flags != VNOVAL) {
if (error = suser(cred, &ap->a_p->p_acflag))
error = suser(cred, &ap->a_p->p_acflag);
if (error)
return error;
if (cred->cr_uid == 0)
dep->de_flag = vap->va_flags;
@ -433,7 +438,6 @@ msdosfs_read(ap)
int isadir;
long n;
long on;
daddr_t bn;
daddr_t lbn;
daddr_t rablock;
int rasize;
@ -539,7 +543,9 @@ msdosfs_write(ap)
struct denode *dep = VTODE(vp);
struct msdosfsmount *pmp = dep->de_pmp;
struct ucred *cred = ap->a_cred;
struct timespec ts;
TIMEVAL_TO_TIMESPEC(&time, &ts);
#ifdef MSDOSFS_DEBUG
printf("msdosfs_write(vp %08x, uio %08x, ioflag %08x, cred %08x\n",
vp, uio, ioflag, cred);
@ -627,7 +633,8 @@ msdosfs_write(ap)
do {
bn = de_blk(pmp, uio->uio_offset);
if (isadir) {
if (error = pcbmap(dep, bn, &bn, 0))
error = pcbmap(dep, bn, &bn, 0);
if (error)
break;
} else if (bn > lastcn) {
error = ENOSPC;
@ -650,8 +657,9 @@ msdosfs_write(ap)
*/
if (!isadir) {
if (bp->b_blkno == bp->b_lblkno) {
if (error = pcbmap(dep, bp->b_lblkno,
&bp->b_blkno, 0))
error = pcbmap(dep, bp->b_lblkno,
&bp->b_blkno, 0);
if (error)
bp->b_blkno = -1;
}
if (bp->b_blkno == -1) {
@ -665,7 +673,8 @@ msdosfs_write(ap)
/*
* The block we need to write into exists, so read it in.
*/
if (error = bread(thisvp, bn, pmp->pm_bpcluster, cred, &bp))
error = bread(thisvp, bn, pmp->pm_bpcluster, cred, &bp);
if (error)
break;
}
@ -719,7 +728,7 @@ errexit:
error = 0;
}
} else {
error = deupdat(dep, &time, 1);
error = deupdat(dep, &ts, 1);
}
return error;
}
@ -780,7 +789,9 @@ msdosfs_fsync(ap)
{
struct vnode *vp = ap->a_vp;
int wait = ap->a_waitfor == MNT_WAIT;
int error;
struct timespec ts;
TIMEVAL_TO_TIMESPEC(&time, &ts);
#if 0
/*
@ -790,7 +801,7 @@ msdosfs_fsync(ap)
*/
vflushbuf(vp, wait ? B_SYNC : 0);
#endif
return deupdat(VTODE(vp), &time, wait);
return deupdat(VTODE(vp), &ts, wait);
}
/*
@ -1004,14 +1015,13 @@ msdosfs_rename(ap)
/* doscheckpath() vput()'s tddep */
error = doscheckpath(fdep, tddep);
tddep = NULL;
if (error) {
if (error)
goto bad;
}
if ((ap->a_tcnp->cn_flags & SAVESTART) == 0)
panic("msdosfs_rename(): lost to startdir");
if (error = relookup(ap->a_tdvp, &tvp, ap->a_tcnp)) {
error = relookup(ap->a_tdvp, &tvp, ap->a_tcnp);
if (error)
goto bad;
}
tddep = VTODE(ap->a_tdvp);
tdep = tvp ? VTODE(tvp) : NULL;
}
@ -1039,9 +1049,9 @@ msdosfs_rename(ap)
}
to_dirclust = tdep->de_dirclust;
to_diroffset = tdep->de_diroffset;
if (error = removede(tddep,tdep)) {
error = removede(tddep,tdep);
if (error)
goto bad;
}
vput(ap->a_tvp);
tdep = NULL;
@ -1060,15 +1070,15 @@ msdosfs_rename(ap)
if (newparent == 0) {
/* tddep and fddep point to the same denode here */
VOP_LOCK(ap->a_fvp); /* ap->a_fdvp is already locked */
if (error = readep(fddep->de_pmp,
fdep->de_dirclust,
fdep->de_diroffset,
&bp, &ep)) {
error = readep(fddep->de_pmp, fdep->de_dirclust,
fdep->de_diroffset, &bp, &ep);
if (error) {
VOP_UNLOCK(ap->a_fvp);
goto bad;
}
bcopy(toname, ep->deName, 11);
if (error = bwrite(bp)) {
error = bwrite(bp);
if (error) {
VOP_UNLOCK(ap->a_fvp);
goto bad;
}
@ -1107,16 +1117,16 @@ msdosfs_rename(ap)
goto bad;
}
VOP_LOCK(ap->a_fdvp);
if (error = readep(fddep->de_pmp,
fddep->de_fndclust,
fddep->de_fndoffset,
&bp, &ep)) {
error = readep(fddep->de_pmp, fddep->de_fndclust,
fddep->de_fndoffset, &bp, &ep);
if (error) {
VOP_UNLOCK(ap->a_fvp);
VOP_UNLOCK(ap->a_fdvp);
goto bad;
}
ep->deName[0] = SLOT_DELETED;
if (error = bwrite(bp)) {
error = bwrite(bp);
if (error) {
VOP_UNLOCK(ap->a_fvp);
VOP_UNLOCK(ap->a_fdvp);
goto bad;
@ -1171,19 +1181,21 @@ struct {
struct direntry dot;
struct direntry dotdot;
} dosdirtemplate = {
". ", " ", /* the . entry */
ATTR_DIRECTORY, /* file attribute */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* resevered */
210, 4, 210, 4, /* time and date */
0, 0, /* startcluster */
0, 0, 0, 0, /* filesize */
".. ", " ", /* the .. entry */
ATTR_DIRECTORY, /* file attribute */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* resevered */
210, 4, 210, 4, /* time and date */
0, 0, /* startcluster */
0, 0, 0, 0, /* filesize */
{
". ", " ", /* the . entry */
ATTR_DIRECTORY, /* file attribute */
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, /* resevered */
{210, 4}, {210, 4}, /* time and date */
{0, 0}, /* startcluster */
{0, 0, 0, 0}, /* filesize */
},{
".. ", " ", /* the .. entry */
ATTR_DIRECTORY, /* file attribute */
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, /* resevered */
{210, 4}, {210, 4}, /* time and date */
{0, 0}, /* startcluster */
{0, 0, 0, 0}, /* filesize */
}
};
int
@ -1225,7 +1237,8 @@ msdosfs_mkdir(ap)
/*
* Allocate a cluster to hold the about to be created directory.
*/
if (error = clusteralloc(pmp, 0, 1, CLUST_EOFE, &newcluster, NULL)) {
error = clusteralloc(pmp, 0, 1, CLUST_EOFE, &newcluster, NULL);
if (error) {
free(ap->a_cnp->cn_pnbuf, M_NAMEI);
vput(ap->a_dvp);
return error;
@ -1251,7 +1264,8 @@ msdosfs_mkdir(ap)
putushort(denp->deStartCluster, pdep->de_StartCluster);
putushort(denp->deDate, dDate);
putushort(denp->deTime, dTime);
if (error = bwrite(bp)) {
error = bwrite(bp);
if (error) {
clusterfree(pmp, newcluster, NULL);
free(ap->a_cnp->cn_pnbuf, M_NAMEI);
vput(ap->a_dvp);
@ -1326,7 +1340,8 @@ msdosfs_rmdir(ap)
* up access and eventually msdosfs_reclaim() will be called which
* will remove it from the denode cache.
*/
if (error = removede(ddep,dep))
error = removede(ddep,dep);
if (error)
goto out;
/*
@ -1341,7 +1356,7 @@ msdosfs_rmdir(ap)
/*
* Truncate the directory that is being deleted.
*/
error = detrunc(dep, (u_long) 0, IO_SYNC);
error = detrunc(dep, (u_long) 0, IO_SYNC, NOCRED, NULL);
cache_purge(DETOV(dep));
out: ;
@ -1364,8 +1379,6 @@ msdosfs_symlink(ap)
char *a_target;
} */ *ap;
{
struct denode *pdep = VTODE(ap->a_dvp);
free(ap->a_cnp->cn_pnbuf, M_NAMEI);
vput(ap->a_dvp);
return EINVAL;
@ -1430,7 +1443,6 @@ msdosfs_readdir(ap)
struct dirent *prev;
struct dirent *crnt;
u_char dirbuf[512]; /* holds converted dos directories */
int i = 0;
struct uio *uio = ap->a_uio;
int ncookies = 1;
u_int* cookies = NULL;
@ -1756,7 +1768,6 @@ msdosfs_bmap(ap)
} */ *ap;
{
struct denode *dep = VTODE(ap->a_vp);
struct msdosfsmount *pmp = dep->de_pmp;
if (ap->a_vpp != NULL)
*ap->a_vpp = dep->de_devvp;
@ -1789,7 +1800,6 @@ msdosfs_strategy(ap)
{
struct buf *bp = ap->a_bp;
struct denode *dep = VTODE(bp->b_vp);
struct msdosfsmount *pmp = dep->de_pmp;
struct vnode *vp;
int error = 0;
@ -1802,7 +1812,8 @@ msdosfs_strategy(ap)
* don't allow files with holes, so we shouldn't ever see this.
*/
if (bp->b_blkno == bp->b_lblkno) {
if (error = pcbmap(dep, bp->b_lblkno, &bp->b_blkno, 0))
error = pcbmap(dep, bp->b_lblkno, &bp->b_blkno, 0);
if (error)
bp->b_blkno = -1;
if (bp->b_blkno == -1)
clrbuf(bp);
@ -1831,15 +1842,16 @@ msdosfs_print(ap)
{
struct denode *dep = VTODE(ap->a_vp);
printf("tag VT_MSDOSFS, startcluster %d, dircluster %d, diroffset %d ",
printf(
"tag VT_MSDOSFS, startcluster %d, dircluster %ld, diroffset %ld ",
dep->de_StartCluster, dep->de_dirclust, dep->de_diroffset);
printf(" dev %d, %d, %s\n",
major(dep->de_dev), minor(dep->de_dev),
dep->de_flag & DE_LOCKED ? "(LOCKED)" : "");
if (dep->de_lockholder) {
printf(" owner pid %d", dep->de_lockholder);
printf(" owner pid %d", (int)dep->de_lockholder);
if (dep->de_lockwaiter)
printf(" waiting pid %d", dep->de_lockwaiter);
printf(" waiting pid %d", (int)dep->de_lockwaiter);
printf("\n");
}
return 0;

View file

@ -1,4 +1,4 @@
/* $Id$ */
/* $Id: msdosfsmount.h,v 1.1 1994/09/19 15:41:48 dfr Exp $ */
/* $NetBSD: msdosfsmount.h,v 1.7 1994/08/21 18:44:17 ws Exp $ */
/*-
@ -181,3 +181,5 @@ int msdosfs_sync __P((struct mount *, int, struct ucred *, struct proc *));
int msdosfs_fhtovp __P((struct mount *, struct fid *, struct mbuf *, struct vnode **, int *, struct ucred **));
int msdosfs_vptofh __P((struct vnode *, struct fid *));
int msdosfs_init __P(());
int mountmsdosfs __P((struct vnode *devvp, struct mount *mp, struct proc *p));