2001-11-10 16:22:20 +03:00
|
|
|
/* $NetBSD: msdosfs_vnops.c,v 1.117 2001/11/10 13:26:46 lukem Exp $ */
|
1994-06-29 10:29:24 +04:00
|
|
|
|
1994-07-19 01:38:08 +04:00
|
|
|
/*-
|
1997-10-17 15:23:29 +04:00
|
|
|
* Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
|
|
|
|
* Copyright (C) 1994, 1995, 1997 TooLs GmbH.
|
1994-07-19 01:38:08 +04:00
|
|
|
* All rights reserved.
|
1994-08-21 22:43:49 +04:00
|
|
|
* Original code by Paul Popelka (paulp@uts.amdahl.com) (see below).
|
1994-07-19 01:38:08 +04:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by TooLs GmbH.
|
|
|
|
* 4. The name of TooLs GmbH may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
|
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
|
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
|
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
1993-08-13 15:35:13 +04:00
|
|
|
/*
|
|
|
|
* Written by Paul Popelka (paulp@uts.amdahl.com)
|
1997-11-17 18:36:17 +03:00
|
|
|
*
|
1993-08-13 15:35:13 +04:00
|
|
|
* You can do anything you want with this software, just don't say you wrote
|
|
|
|
* it, and don't remove this notice.
|
1997-11-17 18:36:17 +03:00
|
|
|
*
|
1993-08-13 15:35:13 +04:00
|
|
|
* This software is provided "as is".
|
1997-11-17 18:36:17 +03:00
|
|
|
*
|
1993-08-13 15:35:13 +04:00
|
|
|
* The author supplies this software to be publicly redistributed on the
|
|
|
|
* understanding that the author is not responsible for the correct
|
|
|
|
* functioning of this software in any circumstances and is not liable for
|
|
|
|
* any damages caused by this software.
|
1997-11-17 18:36:17 +03:00
|
|
|
*
|
1993-08-13 15:35:13 +04:00
|
|
|
* October 1992
|
|
|
|
*/
|
|
|
|
|
2001-11-10 16:22:20 +03:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.117 2001/11/10 13:26:46 lukem Exp $");
|
|
|
|
|
1993-12-18 03:50:51 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/namei.h>
|
|
|
|
#include <sys/resourcevar.h> /* defines plimit structure in proc struct */
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/file.h> /* define FWRITE ... */
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/mount.h>
|
|
|
|
#include <sys/vnode.h>
|
1996-02-09 22:13:39 +03:00
|
|
|
#include <sys/signalvar.h>
|
1993-12-18 03:50:51 +03:00
|
|
|
#include <sys/malloc.h>
|
1996-08-10 12:48:24 +04:00
|
|
|
#include <sys/dirent.h>
|
1995-12-01 10:26:58 +03:00
|
|
|
#include <sys/lockf.h>
|
1993-08-13 15:35:13 +04:00
|
|
|
|
1996-09-02 03:47:48 +04:00
|
|
|
#include <miscfs/genfs/genfs.h>
|
|
|
|
#include <miscfs/specfs/specdev.h> /* XXX */ /* defines v_rdev */
|
|
|
|
|
1998-02-05 10:59:28 +03:00
|
|
|
#include <uvm/uvm_extern.h>
|
|
|
|
|
1993-12-18 03:50:51 +03:00
|
|
|
#include <msdosfs/bpb.h>
|
|
|
|
#include <msdosfs/direntry.h>
|
|
|
|
#include <msdosfs/denode.h>
|
|
|
|
#include <msdosfs/msdosfsmount.h>
|
|
|
|
#include <msdosfs/fat.h>
|
1994-09-28 14:31:23 +03:00
|
|
|
|
1993-08-13 15:35:13 +04:00
|
|
|
/*
|
|
|
|
* Some general notes:
|
1997-11-17 18:36:17 +03:00
|
|
|
*
|
1993-08-13 15:35:13 +04:00
|
|
|
* In the ufs filesystem the inodes, superblocks, and indirect blocks are
|
|
|
|
* read/written using the vnode for the filesystem. Blocks that represent
|
|
|
|
* the contents of a file are read/written using the vnode for the file
|
|
|
|
* (including directories when they are read/written as files). This
|
|
|
|
* presents problems for the dos filesystem because data that should be in
|
|
|
|
* an inode (if dos had them) resides in the directory itself. Since we
|
|
|
|
* must update directory entries without the benefit of having the vnode
|
|
|
|
* for the directory we must use the vnode for the filesystem. This means
|
|
|
|
* that when a directory is actually read/written (via read, write, or
|
|
|
|
* readdir, or seek) we must use the vnode for the filesystem instead of
|
|
|
|
* the vnode for the directory as would happen in ufs. This is to insure we
|
2001-06-12 18:59:27 +04:00
|
|
|
* retrieve the correct block from the buffer cache since the hash value is
|
1993-08-13 15:35:13 +04:00
|
|
|
* based upon the vnode address and the desired block number.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create a regular file. On entry the directory to contain the file being
|
|
|
|
* created is locked. We must release before we return. We must also free
|
1994-07-17 01:32:06 +04:00
|
|
|
* the pathname buffer pointed at by cnp->cn_pnbuf, always on error, or
|
|
|
|
* only if the SAVESTART bit in cn_flags is clear on success.
|
1993-08-13 15:35:13 +04:00
|
|
|
*/
|
|
|
|
int
|
1996-02-09 22:13:39 +03:00
|
|
|
msdosfs_create(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-07-17 01:32:06 +04:00
|
|
|
struct vop_create_args /* {
|
|
|
|
struct vnode *a_dvp;
|
|
|
|
struct vnode **a_vpp;
|
|
|
|
struct componentname *a_cnp;
|
|
|
|
struct vattr *a_vap;
|
1996-02-09 22:13:39 +03:00
|
|
|
} */ *ap = v;
|
1994-07-17 01:32:06 +04:00
|
|
|
struct componentname *cnp = ap->a_cnp;
|
1993-08-13 15:35:13 +04:00
|
|
|
struct denode ndirent;
|
|
|
|
struct denode *dep;
|
1994-07-17 01:32:06 +04:00
|
|
|
struct denode *pdep = VTODE(ap->a_dvp);
|
1993-08-13 15:35:13 +04:00
|
|
|
int error;
|
1996-09-02 03:47:48 +04:00
|
|
|
struct timespec ts;
|
1993-08-13 15:35:13 +04:00
|
|
|
|
1994-07-19 01:38:08 +04:00
|
|
|
#ifdef MSDOSFS_DEBUG
|
1997-11-17 00:47:27 +03:00
|
|
|
printf("msdosfs_create(cnp %p, vap %p\n", cnp, ap->a_vap);
|
1994-07-19 01:38:08 +04:00
|
|
|
#endif
|
1993-08-13 15:35:13 +04:00
|
|
|
|
1994-09-28 14:31:23 +03:00
|
|
|
/*
|
|
|
|
* If this is the root directory and there is no space left we
|
|
|
|
* can't do anything. This is because the root directory can not
|
|
|
|
* change size.
|
|
|
|
*/
|
1995-10-15 18:34:19 +03:00
|
|
|
if (pdep->de_StartCluster == MSDOSFSROOT
|
|
|
|
&& pdep->de_fndoffset >= pdep->de_FileSize) {
|
1994-09-28 14:31:23 +03:00
|
|
|
error = ENOSPC;
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
1993-08-13 15:35:13 +04:00
|
|
|
/*
|
|
|
|
* Create a directory entry for the file, then call createde() to
|
|
|
|
* have it installed. NOTE: DOS files are always executable. We
|
|
|
|
* use the absence of the owner write bit to make the file
|
|
|
|
* readonly.
|
|
|
|
*/
|
1994-07-19 01:38:08 +04:00
|
|
|
#ifdef DIAGNOSTIC
|
1994-09-28 14:31:23 +03:00
|
|
|
if ((cnp->cn_flags & HASBUF) == 0)
|
1994-07-17 01:32:06 +04:00
|
|
|
panic("msdosfs_create: no name");
|
|
|
|
#endif
|
1998-08-10 00:51:08 +04:00
|
|
|
memset(&ndirent, 0, sizeof(ndirent));
|
1996-02-09 22:13:39 +03:00
|
|
|
if ((error = uniqdosname(pdep, cnp, ndirent.de_Name)) != 0)
|
1995-10-15 18:34:19 +03:00
|
|
|
goto bad;
|
1997-11-17 18:36:17 +03:00
|
|
|
|
1997-05-08 20:19:43 +04:00
|
|
|
ndirent.de_Attributes = (ap->a_vap->va_mode & S_IWUSR) ?
|
1995-06-02 18:52:34 +04:00
|
|
|
ATTR_ARCHIVE : ATTR_ARCHIVE | ATTR_READONLY;
|
1994-03-03 03:51:30 +03:00
|
|
|
ndirent.de_StartCluster = 0;
|
|
|
|
ndirent.de_FileSize = 0;
|
1993-08-13 15:35:13 +04:00
|
|
|
ndirent.de_dev = pdep->de_dev;
|
|
|
|
ndirent.de_devvp = pdep->de_devvp;
|
1995-11-29 21:28:51 +03:00
|
|
|
ndirent.de_pmp = pdep->de_pmp;
|
1995-11-29 18:08:32 +03:00
|
|
|
ndirent.de_flag = DE_ACCESS | DE_CREATE | DE_UPDATE;
|
1996-09-02 03:47:48 +04:00
|
|
|
TIMEVAL_TO_TIMESPEC(&time, &ts);
|
|
|
|
DETIMES(&ndirent, &ts, &ts, &ts);
|
1996-02-09 22:13:39 +03:00
|
|
|
if ((error = createde(&ndirent, pdep, &dep, cnp)) != 0)
|
1994-09-28 14:31:23 +03:00
|
|
|
goto bad;
|
|
|
|
if ((cnp->cn_flags & SAVESTART) == 0)
|
2000-08-04 00:41:05 +04:00
|
|
|
PNBUF_PUT(cnp->cn_pnbuf);
|
1994-09-28 14:31:23 +03:00
|
|
|
vput(ap->a_dvp);
|
|
|
|
*ap->a_vpp = DETOV(dep);
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
bad:
|
2000-08-04 00:41:05 +04:00
|
|
|
PNBUF_PUT(cnp->cn_pnbuf);
|
1994-09-28 14:31:23 +03:00
|
|
|
vput(ap->a_dvp);
|
|
|
|
return (error);
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1996-02-09 22:13:39 +03:00
|
|
|
msdosfs_mknod(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-07-17 01:32:06 +04:00
|
|
|
struct vop_mknod_args /* {
|
|
|
|
struct vnode *a_dvp;
|
|
|
|
struct vnode **a_vpp;
|
|
|
|
struct componentname *a_cnp;
|
|
|
|
struct vattr *a_vap;
|
1996-02-09 22:13:39 +03:00
|
|
|
} */ *ap = v;
|
1997-11-17 18:36:17 +03:00
|
|
|
|
2001-07-19 23:12:33 +04:00
|
|
|
PNBUF_PUT(ap->a_cnp->cn_pnbuf);
|
|
|
|
vput(ap->a_dvp);
|
|
|
|
return (EINVAL);
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1996-02-09 22:13:39 +03:00
|
|
|
msdosfs_open(v)
|
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
#if 0
|
1994-07-17 01:32:06 +04:00
|
|
|
struct vop_open_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
int a_mode;
|
|
|
|
struct ucred *a_cred;
|
|
|
|
struct proc *a_p;
|
|
|
|
} */ *ap;
|
1996-02-09 22:13:39 +03:00
|
|
|
#endif
|
1994-09-28 14:31:23 +03:00
|
|
|
|
|
|
|
return (0);
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1996-02-09 22:13:39 +03:00
|
|
|
msdosfs_close(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-07-17 01:32:06 +04:00
|
|
|
struct vop_close_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
int a_fflag;
|
|
|
|
struct ucred *a_cred;
|
|
|
|
struct proc *a_p;
|
1996-02-09 22:13:39 +03:00
|
|
|
} */ *ap = v;
|
1994-07-17 01:32:06 +04:00
|
|
|
struct vnode *vp = ap->a_vp;
|
1993-08-13 15:35:13 +04:00
|
|
|
struct denode *dep = VTODE(vp);
|
1996-09-02 03:47:48 +04:00
|
|
|
struct timespec ts;
|
1993-08-13 15:35:13 +04:00
|
|
|
|
1998-03-01 05:20:01 +03:00
|
|
|
simple_lock(&vp->v_interlock);
|
|
|
|
if (vp->v_usecount > 1) {
|
1996-09-02 03:47:48 +04:00
|
|
|
TIMEVAL_TO_TIMESPEC(&time, &ts);
|
|
|
|
DETIMES(dep, &ts, &ts, &ts);
|
|
|
|
}
|
1998-03-01 05:20:01 +03:00
|
|
|
simple_unlock(&vp->v_interlock);
|
1994-09-28 14:31:23 +03:00
|
|
|
return (0);
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
|
|
|
|
1994-09-28 14:31:23 +03:00
|
|
|
int
|
1996-02-09 22:13:39 +03:00
|
|
|
msdosfs_access(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-09-28 14:31:23 +03:00
|
|
|
struct vop_access_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
int a_mode;
|
|
|
|
struct ucred *a_cred;
|
|
|
|
struct proc *a_p;
|
1996-02-09 22:13:39 +03:00
|
|
|
} */ *ap = v;
|
1998-03-01 05:20:01 +03:00
|
|
|
struct vnode *vp = ap->a_vp;
|
|
|
|
struct denode *dep = VTODE(vp);
|
1994-09-28 14:31:23 +03:00
|
|
|
struct msdosfsmount *pmp = dep->de_pmp;
|
1999-08-16 11:43:12 +04:00
|
|
|
mode_t mode = ap->a_mode;
|
1998-03-01 05:20:01 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Disallow write attempts on read-only file systems;
|
|
|
|
* unless the file is a socket, fifo, or a block or
|
|
|
|
* character device resident on the file system.
|
|
|
|
*/
|
|
|
|
if (mode & VWRITE) {
|
|
|
|
switch (vp->v_type) {
|
|
|
|
case VDIR:
|
|
|
|
case VLNK:
|
|
|
|
case VREG:
|
|
|
|
if (vp->v_mount->mnt_flag & MNT_RDONLY)
|
|
|
|
return (EROFS);
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1994-12-27 21:49:09 +03:00
|
|
|
|
1997-05-08 20:19:43 +04:00
|
|
|
if ((dep->de_Attributes & ATTR_READONLY) == 0)
|
|
|
|
mode = S_IRWXU|S_IRWXG|S_IRWXO;
|
|
|
|
else
|
|
|
|
mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
|
1997-05-08 20:43:16 +04:00
|
|
|
return (vaccess(ap->a_vp->v_type, mode & pmp->pm_mask,
|
1997-05-08 20:19:43 +04:00
|
|
|
pmp->pm_uid, pmp->pm_gid, ap->a_mode, ap->a_cred));
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1996-02-09 22:13:39 +03:00
|
|
|
msdosfs_getattr(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-07-17 01:32:06 +04:00
|
|
|
struct vop_getattr_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
struct vattr *a_vap;
|
|
|
|
struct ucred *a_cred;
|
|
|
|
struct proc *a_p;
|
1996-02-09 22:13:39 +03:00
|
|
|
} */ *ap = v;
|
1994-07-17 01:32:06 +04:00
|
|
|
struct denode *dep = VTODE(ap->a_vp);
|
1997-05-08 20:19:43 +04:00
|
|
|
struct msdosfsmount *pmp = dep->de_pmp;
|
1994-07-17 01:32:06 +04:00
|
|
|
struct vattr *vap = ap->a_vap;
|
1997-05-08 20:19:43 +04:00
|
|
|
mode_t mode;
|
1996-09-02 03:47:48 +04:00
|
|
|
struct timespec ts;
|
1997-10-17 15:23:29 +04:00
|
|
|
u_long dirsperblk = pmp->pm_BytesPerSec / sizeof(struct direntry);
|
|
|
|
u_long fileid;
|
1993-08-13 15:35:13 +04:00
|
|
|
|
1996-09-02 03:47:48 +04:00
|
|
|
TIMEVAL_TO_TIMESPEC(&time, &ts);
|
|
|
|
DETIMES(dep, &ts, &ts, &ts);
|
1993-08-13 15:35:13 +04:00
|
|
|
vap->va_fsid = dep->de_dev;
|
|
|
|
/*
|
|
|
|
* The following computation of the fileid must be the same as that
|
|
|
|
* used in msdosfs_readdir() to compute d_fileno. If not, pwd
|
|
|
|
* doesn't work.
|
|
|
|
*/
|
|
|
|
if (dep->de_Attributes & ATTR_DIRECTORY) {
|
1997-10-17 15:23:29 +04:00
|
|
|
fileid = cntobn(pmp, dep->de_StartCluster) * dirsperblk;
|
|
|
|
if (dep->de_StartCluster == MSDOSFSROOT)
|
|
|
|
fileid = 1;
|
1994-04-21 11:47:31 +04:00
|
|
|
} else {
|
1997-10-17 15:23:29 +04:00
|
|
|
fileid = cntobn(pmp, dep->de_dirclust) * dirsperblk;
|
|
|
|
if (dep->de_dirclust == MSDOSFSROOT)
|
|
|
|
fileid = roottobn(pmp, 0) * dirsperblk;
|
|
|
|
fileid += dep->de_diroffset / sizeof(struct direntry);
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
1997-10-17 15:23:29 +04:00
|
|
|
vap->va_fileid = fileid;
|
1997-05-08 20:19:43 +04:00
|
|
|
if ((dep->de_Attributes & ATTR_READONLY) == 0)
|
|
|
|
mode = S_IRWXU|S_IRWXG|S_IRWXO;
|
|
|
|
else
|
|
|
|
mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
|
|
|
|
vap->va_mode = mode & pmp->pm_mask;
|
|
|
|
vap->va_uid = pmp->pm_uid;
|
|
|
|
vap->va_gid = pmp->pm_gid;
|
1993-08-13 15:35:13 +04:00
|
|
|
vap->va_nlink = 1;
|
|
|
|
vap->va_rdev = 0;
|
a whole bunch of changes to improve performance and robustness under load:
- remove special treatment of pager_map mappings in pmaps. this is
required now, since I've removed the globals that expose the address range.
pager_map now uses pmap_kenter_pa() instead of pmap_enter(), so there's
no longer any need to special-case it.
- eliminate struct uvm_vnode by moving its fields into struct vnode.
- rewrite the pageout path. the pager is now responsible for handling the
high-level requests instead of only getting control after a bunch of work
has already been done on its behalf. this will allow us to UBCify LFS,
which needs tighter control over its pages than other filesystems do.
writing a page to disk no longer requires making it read-only, which
allows us to write wired pages without causing all kinds of havoc.
- use a new PG_PAGEOUT flag to indicate that a page should be freed
on behalf of the pagedaemon when it's unlocked. this flag is very similar
to PG_RELEASED, but unlike PG_RELEASED, PG_PAGEOUT can be cleared if the
pageout fails due to eg. an indirect-block buffer being locked.
this allows us to remove the "version" field from struct vm_page,
and together with shrinking "loan_count" from 32 bits to 16,
struct vm_page is now 4 bytes smaller.
- no longer use PG_RELEASED for swap-backed pages. if the page is busy
because it's being paged out, we can't release the swap slot to be
reallocated until that write is complete, but unlike with vnodes we
don't keep a count of in-progress writes so there's no good way to
know when the write is done. instead, when we need to free a busy
swap-backed page, just sleep until we can get it busy ourselves.
- implement a fast-path for extending writes which allows us to avoid
zeroing new pages. this substantially reduces cpu usage.
- encapsulate the data used by the genfs code in a struct genfs_node,
which must be the first element of the filesystem-specific vnode data
for filesystems which use genfs_{get,put}pages().
- eliminate many of the UVM pagerops, since they aren't needed anymore
now that the pager "put" operation is a higher-level operation.
- enhance the genfs code to allow NFS to use the genfs_{get,put}pages
instead of a modified copy.
- clean up struct vnode by removing all the fields that used to be used by
the vfs_cluster.c code (which we don't use anymore with UBC).
- remove kmem_object and mb_object since they were useless.
instead of allocating pages to these objects, we now just allocate
pages with no object. such pages are mapped in the kernel until they
are freed, so we can use the mapping to find the page to free it.
this allows us to remove splvm() protection in several places.
The sum of all these changes improves write throughput on my
decstation 5000/200 to within 1% of the rate of NetBSD 1.5
and reduces the elapsed time for "make release" of a NetBSD 1.5
source tree on my 128MB pc to 10% less than a 1.5 kernel took.
2001-09-16 00:36:31 +04:00
|
|
|
vap->va_size = ap->a_vp->v_size;
|
1997-10-17 15:23:29 +04:00
|
|
|
dos2unixtime(dep->de_MDate, dep->de_MTime, 0, &vap->va_mtime);
|
1995-11-29 18:08:32 +03:00
|
|
|
if (dep->de_pmp->pm_flags & MSDOSFSMNT_LONGNAME) {
|
1997-10-17 15:23:29 +04:00
|
|
|
dos2unixtime(dep->de_ADate, 0, 0, &vap->va_atime);
|
|
|
|
dos2unixtime(dep->de_CDate, dep->de_CTime, dep->de_CHun, &vap->va_ctime);
|
1995-11-29 18:08:32 +03:00
|
|
|
} else {
|
|
|
|
vap->va_atime = vap->va_mtime;
|
|
|
|
vap->va_ctime = vap->va_mtime;
|
|
|
|
}
|
1994-12-27 21:36:21 +03:00
|
|
|
vap->va_flags = 0;
|
2000-07-31 00:16:48 +04:00
|
|
|
if ((dep->de_Attributes & ATTR_ARCHIVE) == 0)
|
1999-08-04 02:02:21 +04:00
|
|
|
vap->va_mode |= S_ARCH1;
|
1993-08-13 15:35:13 +04:00
|
|
|
vap->va_gen = 0;
|
1997-05-08 20:19:43 +04:00
|
|
|
vap->va_blocksize = pmp->pm_bpcluster;
|
|
|
|
vap->va_bytes =
|
|
|
|
(dep->de_FileSize + pmp->pm_crbomask) & ~pmp->pm_crbomask;
|
1994-07-17 01:32:06 +04:00
|
|
|
vap->va_type = ap->a_vp->v_type;
|
1994-09-28 14:31:23 +03:00
|
|
|
return (0);
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1996-02-09 22:13:39 +03:00
|
|
|
msdosfs_setattr(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-07-17 01:32:06 +04:00
|
|
|
struct vop_setattr_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
struct vattr *a_vap;
|
|
|
|
struct ucred *a_cred;
|
|
|
|
struct proc *a_p;
|
1996-02-09 22:13:39 +03:00
|
|
|
} */ *ap = v;
|
1999-08-16 11:43:12 +04:00
|
|
|
int error = 0, de_changed = 0;
|
1994-07-17 01:32:06 +04:00
|
|
|
struct denode *dep = VTODE(ap->a_vp);
|
1997-05-08 20:19:43 +04:00
|
|
|
struct msdosfsmount *pmp = dep->de_pmp;
|
1999-08-16 11:43:12 +04:00
|
|
|
struct vnode *vp = ap->a_vp;
|
1994-07-17 01:32:06 +04:00
|
|
|
struct vattr *vap = ap->a_vap;
|
|
|
|
struct ucred *cred = ap->a_cred;
|
1997-11-17 18:36:17 +03:00
|
|
|
|
1994-07-19 01:38:08 +04:00
|
|
|
#ifdef MSDOSFS_DEBUG
|
1997-11-17 00:47:27 +03:00
|
|
|
printf("msdosfs_setattr(): vp %p, vap %p, cred %p, p %p\n",
|
1996-10-11 02:46:11 +04:00
|
|
|
ap->a_vp, vap, cred, ap->a_p);
|
1994-07-19 01:38:08 +04:00
|
|
|
#endif
|
2000-07-26 02:15:00 +04:00
|
|
|
/*
|
|
|
|
* Note we silently ignore uid or gid changes.
|
|
|
|
*/
|
1997-10-17 03:58:05 +04:00
|
|
|
if ((vap->va_type != VNON) || (vap->va_nlink != (nlink_t)VNOVAL) ||
|
1994-09-28 14:31:23 +03:00
|
|
|
(vap->va_fsid != VNOVAL) || (vap->va_fileid != VNOVAL) ||
|
|
|
|
(vap->va_blocksize != VNOVAL) || (vap->va_rdev != VNOVAL) ||
|
2001-11-04 02:49:58 +03:00
|
|
|
(vap->va_bytes != VNOVAL) || (vap->va_gen != VNOVAL) ||
|
|
|
|
(vap->va_uid != VNOVAL && vap->va_uid != pmp->pm_uid) ||
|
|
|
|
(vap->va_gid != VNOVAL && vap->va_gid != pmp->pm_gid)) {
|
1994-07-19 01:38:08 +04:00
|
|
|
#ifdef MSDOSFS_DEBUG
|
1996-10-13 08:10:34 +04:00
|
|
|
printf("msdosfs_setattr(): returning EINVAL\n");
|
1997-11-17 00:47:27 +03:00
|
|
|
printf(" va_type %d, va_nlink %x, va_fsid %lx, va_fileid %lx\n",
|
1996-10-11 02:46:11 +04:00
|
|
|
vap->va_type, vap->va_nlink, vap->va_fsid, vap->va_fileid);
|
1997-11-17 00:47:27 +03:00
|
|
|
printf(" va_blocksize %lx, va_rdev %x, va_bytes %qx, va_gen %lx\n",
|
1999-07-26 04:14:27 +04:00
|
|
|
vap->va_blocksize, vap->va_rdev, (long long)vap->va_bytes, vap->va_gen);
|
1994-07-19 01:38:08 +04:00
|
|
|
#endif
|
1994-09-28 14:31:23 +03:00
|
|
|
return (EINVAL);
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
1995-11-29 18:08:32 +03:00
|
|
|
/*
|
1999-05-25 03:01:13 +04:00
|
|
|
* Silently ignore attributes modifications on directories.
|
1995-11-29 18:08:32 +03:00
|
|
|
*/
|
1995-09-09 23:38:00 +04:00
|
|
|
if (ap->a_vp->v_type == VDIR)
|
1999-05-25 03:01:13 +04:00
|
|
|
return 0;
|
1995-09-09 23:38:00 +04:00
|
|
|
|
1993-08-13 15:35:13 +04:00
|
|
|
if (vap->va_size != VNOVAL) {
|
1999-08-16 11:43:12 +04:00
|
|
|
if (vp->v_mount->mnt_flag & MNT_RDONLY)
|
|
|
|
return (EROFS);
|
1996-02-09 22:13:39 +03:00
|
|
|
error = detrunc(dep, (u_long)vap->va_size, 0, cred, ap->a_p);
|
|
|
|
if (error)
|
1994-09-28 14:31:23 +03:00
|
|
|
return (error);
|
1999-08-16 11:43:12 +04:00
|
|
|
de_changed = 1;
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
1996-02-01 03:31:05 +03:00
|
|
|
if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL) {
|
1999-08-16 11:43:12 +04:00
|
|
|
if (vp->v_mount->mnt_flag & MNT_RDONLY)
|
|
|
|
return (EROFS);
|
1997-05-08 20:19:43 +04:00
|
|
|
if (cred->cr_uid != pmp->pm_uid &&
|
1995-06-02 18:54:53 +04:00
|
|
|
(error = suser(cred, &ap->a_p->p_acflag)) &&
|
1997-11-17 18:36:17 +03:00
|
|
|
((vap->va_vaflags & VA_UTIMES_NULL) == 0 ||
|
1995-06-02 18:52:34 +04:00
|
|
|
(error = VOP_ACCESS(ap->a_vp, VWRITE, cred, ap->a_p))))
|
|
|
|
return (error);
|
1997-05-08 20:19:43 +04:00
|
|
|
if ((pmp->pm_flags & MSDOSFSMNT_NOWIN95) == 0 &&
|
|
|
|
vap->va_atime.tv_sec != VNOVAL)
|
1997-10-17 15:23:29 +04:00
|
|
|
unix2dostime(&vap->va_atime, &dep->de_ADate, NULL, NULL);
|
1996-02-01 03:31:05 +03:00
|
|
|
if (vap->va_mtime.tv_sec != VNOVAL)
|
1997-10-17 15:23:29 +04:00
|
|
|
unix2dostime(&vap->va_mtime, &dep->de_MDate, &dep->de_MTime, NULL);
|
1995-09-09 23:38:00 +04:00
|
|
|
dep->de_Attributes |= ATTR_ARCHIVE;
|
1995-06-02 19:33:22 +04:00
|
|
|
dep->de_flag |= DE_MODIFIED;
|
1999-08-16 11:43:12 +04:00
|
|
|
de_changed = 1;
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
|
|
|
/*
|
1995-01-04 09:32:19 +03:00
|
|
|
* DOS files only have the ability to have their writability
|
1993-08-13 15:35:13 +04:00
|
|
|
* attribute set, so we use the owner write bit to set the readonly
|
|
|
|
* attribute.
|
|
|
|
*/
|
1994-09-28 14:31:23 +03:00
|
|
|
if (vap->va_mode != (mode_t)VNOVAL) {
|
1999-08-16 11:43:12 +04:00
|
|
|
if (vp->v_mount->mnt_flag & MNT_RDONLY)
|
|
|
|
return (EROFS);
|
1997-05-08 20:19:43 +04:00
|
|
|
if (cred->cr_uid != pmp->pm_uid &&
|
1995-06-02 18:52:34 +04:00
|
|
|
(error = suser(cred, &ap->a_p->p_acflag)))
|
|
|
|
return (error);
|
|
|
|
/* We ignore the read and execute bits. */
|
1997-05-08 20:19:43 +04:00
|
|
|
if (vap->va_mode & S_IWUSR)
|
1993-08-13 15:35:13 +04:00
|
|
|
dep->de_Attributes &= ~ATTR_READONLY;
|
|
|
|
else
|
|
|
|
dep->de_Attributes |= ATTR_READONLY;
|
1995-06-02 19:33:22 +04:00
|
|
|
dep->de_flag |= DE_MODIFIED;
|
1999-08-16 11:43:12 +04:00
|
|
|
de_changed = 1;
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
1994-12-27 21:36:21 +03:00
|
|
|
/*
|
|
|
|
* Allow the `archived' bit to be toggled.
|
|
|
|
*/
|
|
|
|
if (vap->va_flags != VNOVAL) {
|
1999-08-16 11:43:12 +04:00
|
|
|
if (vp->v_mount->mnt_flag & MNT_RDONLY)
|
|
|
|
return (EROFS);
|
1997-05-08 20:19:43 +04:00
|
|
|
if (cred->cr_uid != pmp->pm_uid &&
|
1995-06-02 18:52:34 +04:00
|
|
|
(error = suser(cred, &ap->a_p->p_acflag)))
|
|
|
|
return (error);
|
1994-12-27 21:36:21 +03:00
|
|
|
if (vap->va_flags & SF_ARCHIVED)
|
|
|
|
dep->de_Attributes &= ~ATTR_ARCHIVE;
|
|
|
|
else
|
|
|
|
dep->de_Attributes |= ATTR_ARCHIVE;
|
1995-06-02 19:33:22 +04:00
|
|
|
dep->de_flag |= DE_MODIFIED;
|
1999-08-16 11:43:12 +04:00
|
|
|
de_changed = 1;
|
1994-12-27 21:36:21 +03:00
|
|
|
}
|
1999-08-16 11:43:12 +04:00
|
|
|
|
|
|
|
if (de_changed)
|
|
|
|
return (deupdat(dep, 1));
|
|
|
|
else
|
|
|
|
return (0);
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1996-02-09 22:13:39 +03:00
|
|
|
msdosfs_read(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-07-17 01:32:06 +04:00
|
|
|
struct vop_read_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
struct uio *a_uio;
|
|
|
|
int a_ioflag;
|
|
|
|
struct ucred *a_cred;
|
1996-02-09 22:13:39 +03:00
|
|
|
} */ *ap = v;
|
1993-08-13 15:35:13 +04:00
|
|
|
int error = 0;
|
2000-04-23 02:45:37 +04:00
|
|
|
int64_t diff;
|
1995-09-09 23:38:00 +04:00
|
|
|
int blsize;
|
1993-08-13 15:35:13 +04:00
|
|
|
long n;
|
|
|
|
long on;
|
|
|
|
daddr_t lbn;
|
2000-11-27 11:39:39 +03:00
|
|
|
void *win;
|
|
|
|
vsize_t bytelen;
|
1993-08-13 15:35:13 +04:00
|
|
|
struct buf *bp;
|
1994-07-17 01:32:06 +04:00
|
|
|
struct vnode *vp = ap->a_vp;
|
1993-08-13 15:35:13 +04:00
|
|
|
struct denode *dep = VTODE(vp);
|
|
|
|
struct msdosfsmount *pmp = dep->de_pmp;
|
1994-07-17 01:32:06 +04:00
|
|
|
struct uio *uio = ap->a_uio;
|
1993-08-13 15:35:13 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If they didn't ask for any data, then we are done.
|
|
|
|
*/
|
2000-11-27 11:39:39 +03:00
|
|
|
|
1993-08-13 15:35:13 +04:00
|
|
|
if (uio->uio_resid == 0)
|
1994-09-28 14:31:23 +03:00
|
|
|
return (0);
|
1993-08-13 15:35:13 +04:00
|
|
|
if (uio->uio_offset < 0)
|
1994-09-28 14:31:23 +03:00
|
|
|
return (EINVAL);
|
2001-09-23 02:20:00 +04:00
|
|
|
if (uio->uio_offset >= dep->de_FileSize)
|
2001-09-23 02:14:29 +04:00
|
|
|
return (0);
|
1993-08-13 15:35:13 +04:00
|
|
|
|
2000-11-27 11:39:39 +03:00
|
|
|
if (vp->v_type == VREG) {
|
|
|
|
while (uio->uio_resid > 0) {
|
2001-02-27 07:37:44 +03:00
|
|
|
bytelen = MIN(dep->de_FileSize - uio->uio_offset,
|
2000-11-27 11:39:39 +03:00
|
|
|
uio->uio_resid);
|
|
|
|
|
|
|
|
if (bytelen == 0)
|
|
|
|
break;
|
a whole bunch of changes to improve performance and robustness under load:
- remove special treatment of pager_map mappings in pmaps. this is
required now, since I've removed the globals that expose the address range.
pager_map now uses pmap_kenter_pa() instead of pmap_enter(), so there's
no longer any need to special-case it.
- eliminate struct uvm_vnode by moving its fields into struct vnode.
- rewrite the pageout path. the pager is now responsible for handling the
high-level requests instead of only getting control after a bunch of work
has already been done on its behalf. this will allow us to UBCify LFS,
which needs tighter control over its pages than other filesystems do.
writing a page to disk no longer requires making it read-only, which
allows us to write wired pages without causing all kinds of havoc.
- use a new PG_PAGEOUT flag to indicate that a page should be freed
on behalf of the pagedaemon when it's unlocked. this flag is very similar
to PG_RELEASED, but unlike PG_RELEASED, PG_PAGEOUT can be cleared if the
pageout fails due to eg. an indirect-block buffer being locked.
this allows us to remove the "version" field from struct vm_page,
and together with shrinking "loan_count" from 32 bits to 16,
struct vm_page is now 4 bytes smaller.
- no longer use PG_RELEASED for swap-backed pages. if the page is busy
because it's being paged out, we can't release the swap slot to be
reallocated until that write is complete, but unlike with vnodes we
don't keep a count of in-progress writes so there's no good way to
know when the write is done. instead, when we need to free a busy
swap-backed page, just sleep until we can get it busy ourselves.
- implement a fast-path for extending writes which allows us to avoid
zeroing new pages. this substantially reduces cpu usage.
- encapsulate the data used by the genfs code in a struct genfs_node,
which must be the first element of the filesystem-specific vnode data
for filesystems which use genfs_{get,put}pages().
- eliminate many of the UVM pagerops, since they aren't needed anymore
now that the pager "put" operation is a higher-level operation.
- enhance the genfs code to allow NFS to use the genfs_{get,put}pages
instead of a modified copy.
- clean up struct vnode by removing all the fields that used to be used by
the vfs_cluster.c code (which we don't use anymore with UBC).
- remove kmem_object and mb_object since they were useless.
instead of allocating pages to these objects, we now just allocate
pages with no object. such pages are mapped in the kernel until they
are freed, so we can use the mapping to find the page to free it.
this allows us to remove splvm() protection in several places.
The sum of all these changes improves write throughput on my
decstation 5000/200 to within 1% of the rate of NetBSD 1.5
and reduces the elapsed time for "make release" of a NetBSD 1.5
source tree on my 128MB pc to 10% less than a 1.5 kernel took.
2001-09-16 00:36:31 +04:00
|
|
|
win = ubc_alloc(&vp->v_uobj, uio->uio_offset,
|
2000-11-27 11:39:39 +03:00
|
|
|
&bytelen, UBC_READ);
|
|
|
|
error = uiomove(win, bytelen, uio);
|
|
|
|
ubc_release(win, 0);
|
|
|
|
if (error)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
dep->de_flag |= DE_ACCESS;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this loop is only for directories now */
|
1993-08-13 15:35:13 +04:00
|
|
|
do {
|
1995-10-15 18:34:19 +03:00
|
|
|
lbn = de_cluster(pmp, uio->uio_offset);
|
1993-08-13 15:35:13 +04:00
|
|
|
on = uio->uio_offset & pmp->pm_crbomask;
|
2001-02-27 07:37:44 +03:00
|
|
|
n = MIN(pmp->pm_bpcluster - on, uio->uio_resid);
|
2000-04-23 02:45:37 +04:00
|
|
|
if (uio->uio_offset >= dep->de_FileSize)
|
1994-09-28 14:31:23 +03:00
|
|
|
return (0);
|
2000-04-23 02:45:37 +04:00
|
|
|
/* file size (and hence diff) may be up to 4GB */
|
|
|
|
diff = dep->de_FileSize - uio->uio_offset;
|
1995-09-09 23:38:00 +04:00
|
|
|
if (diff < n)
|
2000-04-23 02:45:37 +04:00
|
|
|
n = (long) diff;
|
2000-11-27 11:39:39 +03:00
|
|
|
|
|
|
|
/* convert cluster # to block # */
|
|
|
|
error = pcbmap(dep, lbn, &lbn, 0, &blsize);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
|
1993-08-13 15:35:13 +04:00
|
|
|
/*
|
|
|
|
* If we are operating on a directory file then be sure to
|
|
|
|
* do i/o with the vnode for the filesystem instead of the
|
|
|
|
* vnode for the directory.
|
|
|
|
*/
|
2000-11-27 11:39:39 +03:00
|
|
|
error = bread(pmp->pm_devvp, lbn, blsize, NOCRED, &bp);
|
2001-02-27 07:37:44 +03:00
|
|
|
n = MIN(n, pmp->pm_bpcluster - bp->b_resid);
|
1993-08-13 15:35:13 +04:00
|
|
|
if (error) {
|
|
|
|
brelse(bp);
|
1994-09-28 14:31:23 +03:00
|
|
|
return (error);
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
1994-07-17 01:32:06 +04:00
|
|
|
error = uiomove(bp->b_data + on, (int) n, uio);
|
1993-08-13 15:35:13 +04:00
|
|
|
brelse(bp);
|
|
|
|
} while (error == 0 && uio->uio_resid > 0 && n != 0);
|
2000-11-27 11:39:39 +03:00
|
|
|
|
|
|
|
out:
|
1998-08-02 22:57:23 +04:00
|
|
|
if ((ap->a_ioflag & IO_SYNC) == IO_SYNC)
|
|
|
|
error = deupdat(dep, 1);
|
1994-09-28 14:31:23 +03:00
|
|
|
return (error);
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Write data to a file or directory.
|
|
|
|
*/
|
|
|
|
int
|
1996-02-09 22:13:39 +03:00
|
|
|
msdosfs_write(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-07-17 01:32:06 +04:00
|
|
|
struct vop_write_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
struct uio *a_uio;
|
|
|
|
int a_ioflag;
|
|
|
|
struct ucred *a_cred;
|
1996-02-09 22:13:39 +03:00
|
|
|
} */ *ap = v;
|
1993-08-13 15:35:13 +04:00
|
|
|
int resid;
|
1994-09-28 14:31:23 +03:00
|
|
|
u_long osize;
|
1996-02-09 22:13:39 +03:00
|
|
|
int error = 0;
|
1994-07-19 01:38:08 +04:00
|
|
|
u_long count;
|
1994-07-17 01:32:06 +04:00
|
|
|
int ioflag = ap->a_ioflag;
|
2000-11-27 11:39:39 +03:00
|
|
|
void *win;
|
|
|
|
vsize_t bytelen;
|
|
|
|
off_t oldoff;
|
1994-07-17 01:32:06 +04:00
|
|
|
struct uio *uio = ap->a_uio;
|
1993-08-13 15:35:13 +04:00
|
|
|
struct proc *p = uio->uio_procp;
|
1994-07-17 01:32:06 +04:00
|
|
|
struct vnode *vp = ap->a_vp;
|
1993-08-13 15:35:13 +04:00
|
|
|
struct denode *dep = VTODE(vp);
|
|
|
|
struct msdosfsmount *pmp = dep->de_pmp;
|
1994-07-17 01:32:06 +04:00
|
|
|
struct ucred *cred = ap->a_cred;
|
1997-11-17 18:36:17 +03:00
|
|
|
|
1994-07-19 01:38:08 +04:00
|
|
|
#ifdef MSDOSFS_DEBUG
|
1997-11-17 18:36:17 +03:00
|
|
|
printf("msdosfs_write(vp %p, uio %p, ioflag %x, cred %p\n",
|
1996-10-11 02:46:11 +04:00
|
|
|
vp, uio, ioflag, cred);
|
1997-11-17 18:36:17 +03:00
|
|
|
printf("msdosfs_write(): diroff %lu, dirclust %lu, startcluster %lu\n",
|
1996-10-11 02:46:11 +04:00
|
|
|
dep->de_diroffset, dep->de_dirclust, dep->de_StartCluster);
|
1994-07-19 01:38:08 +04:00
|
|
|
#endif
|
1993-08-13 15:35:13 +04:00
|
|
|
|
1995-11-29 18:08:32 +03:00
|
|
|
switch (vp->v_type) {
|
|
|
|
case VREG:
|
1993-08-13 15:35:13 +04:00
|
|
|
if (ioflag & IO_APPEND)
|
|
|
|
uio->uio_offset = dep->de_FileSize;
|
1995-11-29 18:08:32 +03:00
|
|
|
break;
|
|
|
|
case VDIR:
|
|
|
|
return EISDIR;
|
|
|
|
default:
|
1993-08-13 15:35:13 +04:00
|
|
|
panic("msdosfs_write(): bad file type");
|
1995-11-29 18:08:32 +03:00
|
|
|
}
|
1993-08-13 15:35:13 +04:00
|
|
|
|
1994-07-17 01:32:06 +04:00
|
|
|
if (uio->uio_offset < 0)
|
1994-09-28 14:31:23 +03:00
|
|
|
return (EINVAL);
|
1994-07-17 01:32:06 +04:00
|
|
|
|
1993-08-13 15:35:13 +04:00
|
|
|
if (uio->uio_resid == 0)
|
1994-09-28 14:31:23 +03:00
|
|
|
return (0);
|
1993-08-13 15:35:13 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If they've exceeded their filesize limit, tell them about it.
|
|
|
|
*/
|
1995-11-29 18:08:32 +03:00
|
|
|
if (p &&
|
1993-08-13 15:35:13 +04:00
|
|
|
((uio->uio_offset + uio->uio_resid) >
|
1995-11-29 18:08:32 +03:00
|
|
|
p->p_rlimit[RLIMIT_FSIZE].rlim_cur)) {
|
1993-08-13 15:35:13 +04:00
|
|
|
psignal(p, SIGXFSZ);
|
1994-09-28 14:31:23 +03:00
|
|
|
return (EFBIG);
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the offset we are starting the write at is beyond the end of
|
|
|
|
* the file, then they've done a seek. Unix filesystems allow
|
|
|
|
* files with holes in them, DOS doesn't so we must fill the hole
|
1994-07-17 01:32:06 +04:00
|
|
|
* with zeroed blocks.
|
1993-08-13 15:35:13 +04:00
|
|
|
*/
|
|
|
|
if (uio->uio_offset > dep->de_FileSize) {
|
1996-02-09 22:13:39 +03:00
|
|
|
if ((error = deextend(dep, uio->uio_offset, cred)) != 0)
|
1994-09-28 14:31:23 +03:00
|
|
|
return (error);
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remember some values in case the write fails.
|
|
|
|
*/
|
|
|
|
resid = uio->uio_resid;
|
|
|
|
osize = dep->de_FileSize;
|
|
|
|
|
1994-07-19 01:38:08 +04:00
|
|
|
/*
|
|
|
|
* If we write beyond the end of the file, extend it to its ultimate
|
|
|
|
* size ahead of the time to hopefully get a contiguous area.
|
|
|
|
*/
|
|
|
|
if (uio->uio_offset + resid > osize) {
|
1994-09-28 14:31:23 +03:00
|
|
|
count = de_clcount(pmp, uio->uio_offset + resid) -
|
|
|
|
de_clcount(pmp, osize);
|
|
|
|
if ((error = extendfile(dep, count, NULL, NULL, 0)) &&
|
|
|
|
(error != ENOSPC || (ioflag & IO_UNIT)))
|
1994-07-19 01:38:08 +04:00
|
|
|
goto errexit;
|
2001-11-06 10:18:14 +03:00
|
|
|
}
|
1997-11-17 18:36:17 +03:00
|
|
|
|
2000-11-27 11:39:39 +03:00
|
|
|
if (dep->de_FileSize < uio->uio_offset + resid) {
|
|
|
|
dep->de_FileSize = uio->uio_offset + resid;
|
|
|
|
uvm_vnp_setsize(vp, dep->de_FileSize);
|
|
|
|
}
|
|
|
|
|
1993-08-13 15:35:13 +04:00
|
|
|
do {
|
2000-11-27 11:39:39 +03:00
|
|
|
oldoff = uio->uio_offset;
|
a whole bunch of changes to improve performance and robustness under load:
- remove special treatment of pager_map mappings in pmaps. this is
required now, since I've removed the globals that expose the address range.
pager_map now uses pmap_kenter_pa() instead of pmap_enter(), so there's
no longer any need to special-case it.
- eliminate struct uvm_vnode by moving its fields into struct vnode.
- rewrite the pageout path. the pager is now responsible for handling the
high-level requests instead of only getting control after a bunch of work
has already been done on its behalf. this will allow us to UBCify LFS,
which needs tighter control over its pages than other filesystems do.
writing a page to disk no longer requires making it read-only, which
allows us to write wired pages without causing all kinds of havoc.
- use a new PG_PAGEOUT flag to indicate that a page should be freed
on behalf of the pagedaemon when it's unlocked. this flag is very similar
to PG_RELEASED, but unlike PG_RELEASED, PG_PAGEOUT can be cleared if the
pageout fails due to eg. an indirect-block buffer being locked.
this allows us to remove the "version" field from struct vm_page,
and together with shrinking "loan_count" from 32 bits to 16,
struct vm_page is now 4 bytes smaller.
- no longer use PG_RELEASED for swap-backed pages. if the page is busy
because it's being paged out, we can't release the swap slot to be
reallocated until that write is complete, but unlike with vnodes we
don't keep a count of in-progress writes so there's no good way to
know when the write is done. instead, when we need to free a busy
swap-backed page, just sleep until we can get it busy ourselves.
- implement a fast-path for extending writes which allows us to avoid
zeroing new pages. this substantially reduces cpu usage.
- encapsulate the data used by the genfs code in a struct genfs_node,
which must be the first element of the filesystem-specific vnode data
for filesystems which use genfs_{get,put}pages().
- eliminate many of the UVM pagerops, since they aren't needed anymore
now that the pager "put" operation is a higher-level operation.
- enhance the genfs code to allow NFS to use the genfs_{get,put}pages
instead of a modified copy.
- clean up struct vnode by removing all the fields that used to be used by
the vfs_cluster.c code (which we don't use anymore with UBC).
- remove kmem_object and mb_object since they were useless.
instead of allocating pages to these objects, we now just allocate
pages with no object. such pages are mapped in the kernel until they
are freed, so we can use the mapping to find the page to free it.
this allows us to remove splvm() protection in several places.
The sum of all these changes improves write throughput on my
decstation 5000/200 to within 1% of the rate of NetBSD 1.5
and reduces the elapsed time for "make release" of a NetBSD 1.5
source tree on my 128MB pc to 10% less than a 1.5 kernel took.
2001-09-16 00:36:31 +04:00
|
|
|
bytelen = uio->uio_resid;
|
1993-08-13 15:35:13 +04:00
|
|
|
|
a whole bunch of changes to improve performance and robustness under load:
- remove special treatment of pager_map mappings in pmaps. this is
required now, since I've removed the globals that expose the address range.
pager_map now uses pmap_kenter_pa() instead of pmap_enter(), so there's
no longer any need to special-case it.
- eliminate struct uvm_vnode by moving its fields into struct vnode.
- rewrite the pageout path. the pager is now responsible for handling the
high-level requests instead of only getting control after a bunch of work
has already been done on its behalf. this will allow us to UBCify LFS,
which needs tighter control over its pages than other filesystems do.
writing a page to disk no longer requires making it read-only, which
allows us to write wired pages without causing all kinds of havoc.
- use a new PG_PAGEOUT flag to indicate that a page should be freed
on behalf of the pagedaemon when it's unlocked. this flag is very similar
to PG_RELEASED, but unlike PG_RELEASED, PG_PAGEOUT can be cleared if the
pageout fails due to eg. an indirect-block buffer being locked.
this allows us to remove the "version" field from struct vm_page,
and together with shrinking "loan_count" from 32 bits to 16,
struct vm_page is now 4 bytes smaller.
- no longer use PG_RELEASED for swap-backed pages. if the page is busy
because it's being paged out, we can't release the swap slot to be
reallocated until that write is complete, but unlike with vnodes we
don't keep a count of in-progress writes so there's no good way to
know when the write is done. instead, when we need to free a busy
swap-backed page, just sleep until we can get it busy ourselves.
- implement a fast-path for extending writes which allows us to avoid
zeroing new pages. this substantially reduces cpu usage.
- encapsulate the data used by the genfs code in a struct genfs_node,
which must be the first element of the filesystem-specific vnode data
for filesystems which use genfs_{get,put}pages().
- eliminate many of the UVM pagerops, since they aren't needed anymore
now that the pager "put" operation is a higher-level operation.
- enhance the genfs code to allow NFS to use the genfs_{get,put}pages
instead of a modified copy.
- clean up struct vnode by removing all the fields that used to be used by
the vfs_cluster.c code (which we don't use anymore with UBC).
- remove kmem_object and mb_object since they were useless.
instead of allocating pages to these objects, we now just allocate
pages with no object. such pages are mapped in the kernel until they
are freed, so we can use the mapping to find the page to free it.
this allows us to remove splvm() protection in several places.
The sum of all these changes improves write throughput on my
decstation 5000/200 to within 1% of the rate of NetBSD 1.5
and reduces the elapsed time for "make release" of a NetBSD 1.5
source tree on my 128MB pc to 10% less than a 1.5 kernel took.
2001-09-16 00:36:31 +04:00
|
|
|
win = ubc_alloc(&vp->v_uobj, oldoff, &bytelen, UBC_WRITE);
|
2000-11-27 11:39:39 +03:00
|
|
|
error = uiomove(win, bytelen, uio);
|
|
|
|
ubc_release(win, 0);
|
|
|
|
if (error) {
|
|
|
|
break;
|
|
|
|
}
|
1993-08-13 15:35:13 +04:00
|
|
|
|
|
|
|
/*
|
2000-11-27 11:39:39 +03:00
|
|
|
* flush what we just wrote if necessary.
|
|
|
|
* XXXUBC simplistic async flushing.
|
1993-08-13 15:35:13 +04:00
|
|
|
*/
|
2000-11-27 11:39:39 +03:00
|
|
|
|
a whole bunch of changes to improve performance and robustness under load:
- remove special treatment of pager_map mappings in pmaps. this is
required now, since I've removed the globals that expose the address range.
pager_map now uses pmap_kenter_pa() instead of pmap_enter(), so there's
no longer any need to special-case it.
- eliminate struct uvm_vnode by moving its fields into struct vnode.
- rewrite the pageout path. the pager is now responsible for handling the
high-level requests instead of only getting control after a bunch of work
has already been done on its behalf. this will allow us to UBCify LFS,
which needs tighter control over its pages than other filesystems do.
writing a page to disk no longer requires making it read-only, which
allows us to write wired pages without causing all kinds of havoc.
- use a new PG_PAGEOUT flag to indicate that a page should be freed
on behalf of the pagedaemon when it's unlocked. this flag is very similar
to PG_RELEASED, but unlike PG_RELEASED, PG_PAGEOUT can be cleared if the
pageout fails due to eg. an indirect-block buffer being locked.
this allows us to remove the "version" field from struct vm_page,
and together with shrinking "loan_count" from 32 bits to 16,
struct vm_page is now 4 bytes smaller.
- no longer use PG_RELEASED for swap-backed pages. if the page is busy
because it's being paged out, we can't release the swap slot to be
reallocated until that write is complete, but unlike with vnodes we
don't keep a count of in-progress writes so there's no good way to
know when the write is done. instead, when we need to free a busy
swap-backed page, just sleep until we can get it busy ourselves.
- implement a fast-path for extending writes which allows us to avoid
zeroing new pages. this substantially reduces cpu usage.
- encapsulate the data used by the genfs code in a struct genfs_node,
which must be the first element of the filesystem-specific vnode data
for filesystems which use genfs_{get,put}pages().
- eliminate many of the UVM pagerops, since they aren't needed anymore
now that the pager "put" operation is a higher-level operation.
- enhance the genfs code to allow NFS to use the genfs_{get,put}pages
instead of a modified copy.
- clean up struct vnode by removing all the fields that used to be used by
the vfs_cluster.c code (which we don't use anymore with UBC).
- remove kmem_object and mb_object since they were useless.
instead of allocating pages to these objects, we now just allocate
pages with no object. such pages are mapped in the kernel until they
are freed, so we can use the mapping to find the page to free it.
this allows us to remove splvm() protection in several places.
The sum of all these changes improves write throughput on my
decstation 5000/200 to within 1% of the rate of NetBSD 1.5
and reduces the elapsed time for "make release" of a NetBSD 1.5
source tree on my 128MB pc to 10% less than a 1.5 kernel took.
2001-09-16 00:36:31 +04:00
|
|
|
if (oldoff >> 16 != uio->uio_offset >> 16) {
|
|
|
|
simple_lock(&vp->v_uobj.vmobjlock);
|
|
|
|
error = vp->v_uobj.pgops->pgo_put(
|
|
|
|
&vp->v_uobj, (oldoff >> 16) << 16,
|
2000-11-27 11:39:39 +03:00
|
|
|
(uio->uio_offset >> 16) << 16, PGO_CLEANIT);
|
|
|
|
}
|
1993-08-13 15:35:13 +04:00
|
|
|
} while (error == 0 && uio->uio_resid > 0);
|
a whole bunch of changes to improve performance and robustness under load:
- remove special treatment of pager_map mappings in pmaps. this is
required now, since I've removed the globals that expose the address range.
pager_map now uses pmap_kenter_pa() instead of pmap_enter(), so there's
no longer any need to special-case it.
- eliminate struct uvm_vnode by moving its fields into struct vnode.
- rewrite the pageout path. the pager is now responsible for handling the
high-level requests instead of only getting control after a bunch of work
has already been done on its behalf. this will allow us to UBCify LFS,
which needs tighter control over its pages than other filesystems do.
writing a page to disk no longer requires making it read-only, which
allows us to write wired pages without causing all kinds of havoc.
- use a new PG_PAGEOUT flag to indicate that a page should be freed
on behalf of the pagedaemon when it's unlocked. this flag is very similar
to PG_RELEASED, but unlike PG_RELEASED, PG_PAGEOUT can be cleared if the
pageout fails due to eg. an indirect-block buffer being locked.
this allows us to remove the "version" field from struct vm_page,
and together with shrinking "loan_count" from 32 bits to 16,
struct vm_page is now 4 bytes smaller.
- no longer use PG_RELEASED for swap-backed pages. if the page is busy
because it's being paged out, we can't release the swap slot to be
reallocated until that write is complete, but unlike with vnodes we
don't keep a count of in-progress writes so there's no good way to
know when the write is done. instead, when we need to free a busy
swap-backed page, just sleep until we can get it busy ourselves.
- implement a fast-path for extending writes which allows us to avoid
zeroing new pages. this substantially reduces cpu usage.
- encapsulate the data used by the genfs code in a struct genfs_node,
which must be the first element of the filesystem-specific vnode data
for filesystems which use genfs_{get,put}pages().
- eliminate many of the UVM pagerops, since they aren't needed anymore
now that the pager "put" operation is a higher-level operation.
- enhance the genfs code to allow NFS to use the genfs_{get,put}pages
instead of a modified copy.
- clean up struct vnode by removing all the fields that used to be used by
the vfs_cluster.c code (which we don't use anymore with UBC).
- remove kmem_object and mb_object since they were useless.
instead of allocating pages to these objects, we now just allocate
pages with no object. such pages are mapped in the kernel until they
are freed, so we can use the mapping to find the page to free it.
this allows us to remove splvm() protection in several places.
The sum of all these changes improves write throughput on my
decstation 5000/200 to within 1% of the rate of NetBSD 1.5
and reduces the elapsed time for "make release" of a NetBSD 1.5
source tree on my 128MB pc to 10% less than a 1.5 kernel took.
2001-09-16 00:36:31 +04:00
|
|
|
if (error == 0 && ioflag & IO_SYNC) {
|
|
|
|
simple_lock(&vp->v_uobj.vmobjlock);
|
|
|
|
error = vp->v_uobj.pgops->pgo_put(&vp->v_uobj, oldoff,
|
|
|
|
oldoff + bytelen, PGO_CLEANIT|PGO_SYNCIO);
|
|
|
|
}
|
2000-11-27 11:39:39 +03:00
|
|
|
dep->de_flag |= DE_UPDATE;
|
1993-08-13 15:35:13 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If the write failed and they want us to, truncate the file back
|
|
|
|
* to the size it was before the write was attempted.
|
|
|
|
*/
|
1994-07-19 01:38:08 +04:00
|
|
|
errexit:
|
|
|
|
if (error) {
|
a whole bunch of changes to improve performance and robustness under load:
- remove special treatment of pager_map mappings in pmaps. this is
required now, since I've removed the globals that expose the address range.
pager_map now uses pmap_kenter_pa() instead of pmap_enter(), so there's
no longer any need to special-case it.
- eliminate struct uvm_vnode by moving its fields into struct vnode.
- rewrite the pageout path. the pager is now responsible for handling the
high-level requests instead of only getting control after a bunch of work
has already been done on its behalf. this will allow us to UBCify LFS,
which needs tighter control over its pages than other filesystems do.
writing a page to disk no longer requires making it read-only, which
allows us to write wired pages without causing all kinds of havoc.
- use a new PG_PAGEOUT flag to indicate that a page should be freed
on behalf of the pagedaemon when it's unlocked. this flag is very similar
to PG_RELEASED, but unlike PG_RELEASED, PG_PAGEOUT can be cleared if the
pageout fails due to eg. an indirect-block buffer being locked.
this allows us to remove the "version" field from struct vm_page,
and together with shrinking "loan_count" from 32 bits to 16,
struct vm_page is now 4 bytes smaller.
- no longer use PG_RELEASED for swap-backed pages. if the page is busy
because it's being paged out, we can't release the swap slot to be
reallocated until that write is complete, but unlike with vnodes we
don't keep a count of in-progress writes so there's no good way to
know when the write is done. instead, when we need to free a busy
swap-backed page, just sleep until we can get it busy ourselves.
- implement a fast-path for extending writes which allows us to avoid
zeroing new pages. this substantially reduces cpu usage.
- encapsulate the data used by the genfs code in a struct genfs_node,
which must be the first element of the filesystem-specific vnode data
for filesystems which use genfs_{get,put}pages().
- eliminate many of the UVM pagerops, since they aren't needed anymore
now that the pager "put" operation is a higher-level operation.
- enhance the genfs code to allow NFS to use the genfs_{get,put}pages
instead of a modified copy.
- clean up struct vnode by removing all the fields that used to be used by
the vfs_cluster.c code (which we don't use anymore with UBC).
- remove kmem_object and mb_object since they were useless.
instead of allocating pages to these objects, we now just allocate
pages with no object. such pages are mapped in the kernel until they
are freed, so we can use the mapping to find the page to free it.
this allows us to remove splvm() protection in several places.
The sum of all these changes improves write throughput on my
decstation 5000/200 to within 1% of the rate of NetBSD 1.5
and reduces the elapsed time for "make release" of a NetBSD 1.5
source tree on my 128MB pc to 10% less than a 1.5 kernel took.
2001-09-16 00:36:31 +04:00
|
|
|
detrunc(dep, osize, ioflag & IO_SYNC, NOCRED, NULL);
|
|
|
|
uio->uio_offset -= resid - uio->uio_resid;
|
|
|
|
uio->uio_resid = resid;
|
1998-08-02 22:57:23 +04:00
|
|
|
} else if ((ioflag & IO_SYNC) == IO_SYNC)
|
1995-06-02 19:33:22 +04:00
|
|
|
error = deupdat(dep, 1);
|
a whole bunch of changes to improve performance and robustness under load:
- remove special treatment of pager_map mappings in pmaps. this is
required now, since I've removed the globals that expose the address range.
pager_map now uses pmap_kenter_pa() instead of pmap_enter(), so there's
no longer any need to special-case it.
- eliminate struct uvm_vnode by moving its fields into struct vnode.
- rewrite the pageout path. the pager is now responsible for handling the
high-level requests instead of only getting control after a bunch of work
has already been done on its behalf. this will allow us to UBCify LFS,
which needs tighter control over its pages than other filesystems do.
writing a page to disk no longer requires making it read-only, which
allows us to write wired pages without causing all kinds of havoc.
- use a new PG_PAGEOUT flag to indicate that a page should be freed
on behalf of the pagedaemon when it's unlocked. this flag is very similar
to PG_RELEASED, but unlike PG_RELEASED, PG_PAGEOUT can be cleared if the
pageout fails due to eg. an indirect-block buffer being locked.
this allows us to remove the "version" field from struct vm_page,
and together with shrinking "loan_count" from 32 bits to 16,
struct vm_page is now 4 bytes smaller.
- no longer use PG_RELEASED for swap-backed pages. if the page is busy
because it's being paged out, we can't release the swap slot to be
reallocated until that write is complete, but unlike with vnodes we
don't keep a count of in-progress writes so there's no good way to
know when the write is done. instead, when we need to free a busy
swap-backed page, just sleep until we can get it busy ourselves.
- implement a fast-path for extending writes which allows us to avoid
zeroing new pages. this substantially reduces cpu usage.
- encapsulate the data used by the genfs code in a struct genfs_node,
which must be the first element of the filesystem-specific vnode data
for filesystems which use genfs_{get,put}pages().
- eliminate many of the UVM pagerops, since they aren't needed anymore
now that the pager "put" operation is a higher-level operation.
- enhance the genfs code to allow NFS to use the genfs_{get,put}pages
instead of a modified copy.
- clean up struct vnode by removing all the fields that used to be used by
the vfs_cluster.c code (which we don't use anymore with UBC).
- remove kmem_object and mb_object since they were useless.
instead of allocating pages to these objects, we now just allocate
pages with no object. such pages are mapped in the kernel until they
are freed, so we can use the mapping to find the page to free it.
this allows us to remove splvm() protection in several places.
The sum of all these changes improves write throughput on my
decstation 5000/200 to within 1% of the rate of NetBSD 1.5
and reduces the elapsed time for "make release" of a NetBSD 1.5
source tree on my 128MB pc to 10% less than a 1.5 kernel took.
2001-09-16 00:36:31 +04:00
|
|
|
KASSERT(vp->v_size == dep->de_FileSize);
|
1994-09-28 14:31:23 +03:00
|
|
|
return (error);
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1996-09-02 03:47:48 +04:00
|
|
|
msdosfs_update(v)
|
1996-02-09 22:13:39 +03:00
|
|
|
void *v;
|
|
|
|
{
|
1996-09-02 03:47:48 +04:00
|
|
|
struct vop_update_args /* {
|
1994-07-17 01:32:06 +04:00
|
|
|
struct vnode *a_vp;
|
1996-09-02 03:47:48 +04:00
|
|
|
struct timespec *a_access;
|
|
|
|
struct timespec *a_modify;
|
2000-05-14 03:43:06 +04:00
|
|
|
int a_flags;
|
1996-02-09 22:13:39 +03:00
|
|
|
} */ *ap = v;
|
1996-09-02 03:47:48 +04:00
|
|
|
struct buf *bp;
|
|
|
|
struct direntry *dirp;
|
|
|
|
struct denode *dep;
|
|
|
|
int error;
|
|
|
|
struct timespec ts;
|
1993-08-13 15:35:13 +04:00
|
|
|
|
1996-09-02 03:47:48 +04:00
|
|
|
if (ap->a_vp->v_mount->mnt_flag & MNT_RDONLY)
|
|
|
|
return (0);
|
|
|
|
dep = VTODE(ap->a_vp);
|
|
|
|
TIMEVAL_TO_TIMESPEC(&time, &ts);
|
1999-03-05 23:47:06 +03:00
|
|
|
DETIMES(dep,
|
|
|
|
ap->a_access ? ap->a_access : &ts,
|
|
|
|
ap->a_modify ? ap->a_modify : &ts, &ts);
|
1996-09-02 03:47:48 +04:00
|
|
|
if ((dep->de_flag & DE_MODIFIED) == 0)
|
|
|
|
return (0);
|
|
|
|
dep->de_flag &= ~DE_MODIFIED;
|
|
|
|
if (dep->de_Attributes & ATTR_DIRECTORY)
|
|
|
|
return (0);
|
|
|
|
if (dep->de_refcnt <= 0)
|
|
|
|
return (0);
|
|
|
|
error = readde(dep, &bp, &dirp);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
DE_EXTERNALIZE(dirp, dep);
|
2000-05-14 03:43:06 +04:00
|
|
|
if (ap->a_flags & (UPDATE_WAIT|UPDATE_DIROP))
|
1996-09-02 03:47:48 +04:00
|
|
|
return (bwrite(bp));
|
|
|
|
else {
|
|
|
|
bdwrite(bp);
|
|
|
|
return (0);
|
|
|
|
}
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1996-09-02 03:47:48 +04:00
|
|
|
* Flush the blocks of a file to disk.
|
1997-11-17 18:36:17 +03:00
|
|
|
*
|
1996-09-02 03:47:48 +04:00
|
|
|
* This function is worthless for vnodes that represent directories. Maybe we
|
|
|
|
* could just do a sync if they try an fsync on a directory file.
|
1993-08-13 15:35:13 +04:00
|
|
|
*/
|
|
|
|
int
|
1996-02-09 22:13:39 +03:00
|
|
|
msdosfs_remove(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-07-17 01:32:06 +04:00
|
|
|
struct vop_remove_args /* {
|
|
|
|
struct vnode *a_dvp;
|
|
|
|
struct vnode *a_vp;
|
|
|
|
struct componentname *a_cnp;
|
1996-02-09 22:13:39 +03:00
|
|
|
} */ *ap = v;
|
1994-07-17 01:32:06 +04:00
|
|
|
struct denode *dep = VTODE(ap->a_vp);
|
|
|
|
struct denode *ddep = VTODE(ap->a_dvp);
|
1994-09-28 14:31:23 +03:00
|
|
|
int error;
|
1993-08-13 15:35:13 +04:00
|
|
|
|
1997-07-01 00:20:31 +04:00
|
|
|
if (ap->a_vp->v_type == VDIR)
|
|
|
|
error = EPERM;
|
|
|
|
else
|
|
|
|
error = removede(ddep, dep);
|
1994-07-19 01:38:08 +04:00
|
|
|
#ifdef MSDOSFS_DEBUG
|
2000-02-01 13:33:18 +03:00
|
|
|
printf("msdosfs_remove(), dep %p, v_usecount %ld\n",
|
|
|
|
dep, ap->a_vp->v_usecount);
|
1994-07-19 01:38:08 +04:00
|
|
|
#endif
|
1993-08-13 15:35:13 +04:00
|
|
|
if (ddep == dep)
|
1994-07-19 01:38:08 +04:00
|
|
|
vrele(ap->a_vp);
|
1993-08-13 15:35:13 +04:00
|
|
|
else
|
1994-07-19 01:38:08 +04:00
|
|
|
vput(ap->a_vp); /* causes msdosfs_inactive() to be called
|
1993-08-13 15:35:13 +04:00
|
|
|
* via vrele() */
|
1994-07-19 01:38:08 +04:00
|
|
|
vput(ap->a_dvp);
|
1994-09-28 14:31:23 +03:00
|
|
|
return (error);
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* DOS filesystems don't know what links are. But since we already called
|
|
|
|
* msdosfs_lookup() with create and lockparent, the parent is locked so we
|
|
|
|
* have to free it before we return the error.
|
|
|
|
*/
|
|
|
|
int
|
1996-02-09 22:13:39 +03:00
|
|
|
msdosfs_link(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-07-17 01:32:06 +04:00
|
|
|
struct vop_link_args /* {
|
1996-02-09 17:45:36 +03:00
|
|
|
struct vnode *a_dvp;
|
1994-07-17 01:32:06 +04:00
|
|
|
struct vnode *a_vp;
|
|
|
|
struct componentname *a_cnp;
|
1996-02-09 22:13:39 +03:00
|
|
|
} */ *ap = v;
|
1994-09-28 14:31:23 +03:00
|
|
|
|
1996-02-09 17:45:36 +03:00
|
|
|
VOP_ABORTOP(ap->a_dvp, ap->a_cnp);
|
|
|
|
vput(ap->a_dvp);
|
1994-12-27 21:00:26 +03:00
|
|
|
return (EOPNOTSUPP);
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Renames on files require moving the denode to a new hash queue since the
|
|
|
|
* denode's location is used to compute which hash queue to put the file
|
|
|
|
* in. Unless it is a rename in place. For example "mv a b".
|
1997-11-17 18:36:17 +03:00
|
|
|
*
|
1993-08-13 15:35:13 +04:00
|
|
|
* What follows is the basic algorithm:
|
1997-11-17 18:36:17 +03:00
|
|
|
*
|
1994-07-17 01:32:06 +04:00
|
|
|
* if (file move) {
|
|
|
|
* if (dest file exists) {
|
|
|
|
* remove dest file
|
|
|
|
* }
|
|
|
|
* if (dest and src in same directory) {
|
|
|
|
* rewrite name in existing directory slot
|
|
|
|
* } else {
|
|
|
|
* write new entry in dest directory
|
|
|
|
* update offset and dirclust in denode
|
|
|
|
* move denode to new hash chain
|
|
|
|
* clear old directory entry
|
|
|
|
* }
|
|
|
|
* } else {
|
|
|
|
* directory move
|
|
|
|
* if (dest directory exists) {
|
|
|
|
* if (dest is not empty) {
|
|
|
|
* return ENOTEMPTY
|
|
|
|
* }
|
|
|
|
* remove dest directory
|
|
|
|
* }
|
|
|
|
* if (dest and src in same directory) {
|
|
|
|
* rewrite name in existing entry
|
|
|
|
* } else {
|
|
|
|
* be sure dest is not a child of src directory
|
|
|
|
* write entry in dest directory
|
|
|
|
* update "." and ".." in moved directory
|
|
|
|
* update offset and dirclust in denode
|
|
|
|
* move denode to new hash chain
|
|
|
|
* clear old directory entry for moved directory
|
|
|
|
* }
|
|
|
|
* }
|
1997-11-17 18:36:17 +03:00
|
|
|
*
|
1994-07-17 01:32:06 +04:00
|
|
|
* On entry:
|
|
|
|
* source's parent directory is unlocked
|
|
|
|
* source file or directory is unlocked
|
|
|
|
* destination's parent directory is locked
|
|
|
|
* destination file or directory is locked if it exists
|
1997-11-17 18:36:17 +03:00
|
|
|
*
|
1994-07-17 01:32:06 +04:00
|
|
|
* On exit:
|
|
|
|
* all denodes should be released
|
|
|
|
*
|
|
|
|
* Notes:
|
|
|
|
* I'm not sure how the memory containing the pathnames pointed at by the
|
|
|
|
* componentname structures is freed, there may be some memory bleeding
|
|
|
|
* for each rename done.
|
1993-08-13 15:35:13 +04:00
|
|
|
*/
|
|
|
|
int
|
1996-02-09 22:13:39 +03:00
|
|
|
msdosfs_rename(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-07-17 01:32:06 +04:00
|
|
|
struct vop_rename_args /* {
|
|
|
|
struct vnode *a_fdvp;
|
|
|
|
struct vnode *a_fvp;
|
|
|
|
struct componentname *a_fcnp;
|
|
|
|
struct vnode *a_tdvp;
|
|
|
|
struct vnode *a_tvp;
|
|
|
|
struct componentname *a_tcnp;
|
1996-02-09 22:13:39 +03:00
|
|
|
} */ *ap = v;
|
1994-09-28 14:31:23 +03:00
|
|
|
struct vnode *tvp = ap->a_tvp;
|
2000-03-30 16:23:20 +04:00
|
|
|
struct vnode *tdvp = ap->a_tdvp;
|
1994-09-28 14:31:23 +03:00
|
|
|
struct vnode *fvp = ap->a_fvp;
|
2000-03-30 16:23:20 +04:00
|
|
|
struct vnode *fdvp = ap->a_fdvp;
|
|
|
|
struct componentname *tcnp = ap->a_tcnp;
|
|
|
|
struct componentname *fcnp = ap->a_fcnp;
|
1998-03-01 05:20:01 +03:00
|
|
|
struct proc *p = tcnp->cn_proc;
|
2000-03-30 16:23:20 +04:00
|
|
|
struct denode *ip, *xp, *dp, *zp;
|
1995-09-09 23:38:00 +04:00
|
|
|
u_char toname[11], oldname[11];
|
1995-10-15 18:34:19 +03:00
|
|
|
u_long from_diroffset, to_diroffset;
|
|
|
|
u_char to_count;
|
1994-09-28 14:31:23 +03:00
|
|
|
int doingdirectory = 0, newparent = 0;
|
1993-08-13 15:35:13 +04:00
|
|
|
int error;
|
|
|
|
u_long cn;
|
|
|
|
daddr_t bn;
|
|
|
|
struct msdosfsmount *pmp;
|
|
|
|
struct direntry *dotdotp;
|
|
|
|
struct buf *bp;
|
2000-07-26 00:56:10 +04:00
|
|
|
int fdvp_dorele = 0;
|
1993-08-13 15:35:13 +04:00
|
|
|
|
1994-09-28 14:31:23 +03:00
|
|
|
pmp = VFSTOMSDOSFS(fdvp->v_mount);
|
1993-08-13 15:35:13 +04:00
|
|
|
|
1994-09-28 14:31:23 +03:00
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if ((tcnp->cn_flags & HASBUF) == 0 ||
|
|
|
|
(fcnp->cn_flags & HASBUF) == 0)
|
|
|
|
panic("msdosfs_rename: no name");
|
|
|
|
#endif
|
|
|
|
/*
|
|
|
|
* Check for cross-device rename.
|
|
|
|
*/
|
|
|
|
if ((fvp->v_mount != tdvp->v_mount) ||
|
|
|
|
(tvp && (fvp->v_mount != tvp->v_mount))) {
|
1994-01-12 06:33:33 +03:00
|
|
|
error = EXDEV;
|
1994-09-28 14:31:23 +03:00
|
|
|
abortit:
|
|
|
|
VOP_ABORTOP(tdvp, tcnp);
|
|
|
|
if (tdvp == tvp)
|
|
|
|
vrele(tdvp);
|
|
|
|
else
|
|
|
|
vput(tdvp);
|
|
|
|
if (tvp)
|
|
|
|
vput(tvp);
|
|
|
|
VOP_ABORTOP(fdvp, fcnp);
|
|
|
|
vrele(fdvp);
|
|
|
|
vrele(fvp);
|
|
|
|
return (error);
|
1994-01-12 06:33:33 +03:00
|
|
|
}
|
|
|
|
|
1997-10-17 15:23:29 +04:00
|
|
|
/*
|
|
|
|
* If source and dest are the same, do nothing.
|
|
|
|
*/
|
|
|
|
if (tvp == fvp) {
|
|
|
|
error = 0;
|
|
|
|
goto abortit;
|
|
|
|
}
|
|
|
|
|
1994-09-28 14:31:23 +03:00
|
|
|
/* */
|
1998-03-01 05:20:01 +03:00
|
|
|
if ((error = vn_lock(fvp, LK_EXCLUSIVE)) != 0)
|
1994-09-28 14:31:23 +03:00
|
|
|
goto abortit;
|
|
|
|
dp = VTODE(fdvp);
|
|
|
|
ip = VTODE(fvp);
|
1993-08-13 15:35:13 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Be sure we are not renaming ".", "..", or an alias of ".". This
|
|
|
|
* leads to a crippled directory tree. It's pretty tough to do a
|
|
|
|
* "ls" or "pwd" with the "." directory entry missing, and "cd .."
|
|
|
|
* doesn't work if the ".." entry is missing.
|
|
|
|
*/
|
1994-09-28 14:31:23 +03:00
|
|
|
if (ip->de_Attributes & ATTR_DIRECTORY) {
|
|
|
|
/*
|
|
|
|
* Avoid ".", "..", and aliases of "." for obvious reasons.
|
|
|
|
*/
|
|
|
|
if ((fcnp->cn_namelen == 1 && fcnp->cn_nameptr[0] == '.') ||
|
1997-06-27 02:23:17 +04:00
|
|
|
dp == ip ||
|
|
|
|
(fcnp->cn_flags & ISDOTDOT) ||
|
|
|
|
(tcnp->cn_flags & ISDOTDOT) ||
|
1995-09-09 23:38:00 +04:00
|
|
|
(ip->de_flag & DE_RENAME)) {
|
1998-03-01 05:20:01 +03:00
|
|
|
VOP_UNLOCK(fvp, 0);
|
1994-09-28 14:31:23 +03:00
|
|
|
error = EINVAL;
|
|
|
|
goto abortit;
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
1995-09-09 23:38:00 +04:00
|
|
|
ip->de_flag |= DE_RENAME;
|
1994-09-28 14:31:23 +03:00
|
|
|
doingdirectory++;
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1994-09-28 14:31:23 +03:00
|
|
|
* When the target exists, both the directory
|
|
|
|
* and target vnodes are returned locked.
|
|
|
|
*/
|
|
|
|
dp = VTODE(tdvp);
|
|
|
|
xp = tvp ? VTODE(tvp) : NULL;
|
1995-09-09 23:38:00 +04:00
|
|
|
/*
|
|
|
|
* Remember direntry place to use for destination
|
|
|
|
*/
|
|
|
|
to_diroffset = dp->de_fndoffset;
|
1995-10-15 18:34:19 +03:00
|
|
|
to_count = dp->de_fndcnt;
|
1994-09-28 14:31:23 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If ".." must be changed (ie the directory gets a new
|
|
|
|
* parent) then the source directory must not be in the
|
2001-08-24 14:24:45 +04:00
|
|
|
* directory hierarchy above the target, as this would
|
1994-09-28 14:31:23 +03:00
|
|
|
* orphan everything below the source directory. Also
|
|
|
|
* the user must have write permission in the source so
|
1997-11-17 18:36:17 +03:00
|
|
|
* as to be able to change "..". We must repeat the call
|
1994-09-28 14:31:23 +03:00
|
|
|
* to namei, as the parent directory is unlocked by the
|
|
|
|
* call to doscheckpath().
|
1993-08-13 15:35:13 +04:00
|
|
|
*/
|
1998-03-01 05:20:01 +03:00
|
|
|
error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred, p);
|
|
|
|
VOP_UNLOCK(fvp, 0);
|
1994-09-28 14:31:23 +03:00
|
|
|
if (VTODE(fdvp)->de_StartCluster != VTODE(tdvp)->de_StartCluster)
|
1993-08-13 15:35:13 +04:00
|
|
|
newparent = 1;
|
1995-09-09 23:38:00 +04:00
|
|
|
vrele(fdvp);
|
1994-09-28 14:31:23 +03:00
|
|
|
if (doingdirectory && newparent) {
|
|
|
|
if (error) /* write access check above */
|
1993-08-13 15:35:13 +04:00
|
|
|
goto bad;
|
1994-09-28 14:31:23 +03:00
|
|
|
if (xp != NULL)
|
|
|
|
vput(tvp);
|
1995-10-15 18:34:19 +03:00
|
|
|
/*
|
|
|
|
* doscheckpath() vput()'s dp,
|
|
|
|
* so we have to do a relookup afterwards
|
|
|
|
*/
|
1996-02-09 22:13:39 +03:00
|
|
|
if ((error = doscheckpath(ip, dp)) != 0)
|
1994-09-28 14:31:23 +03:00
|
|
|
goto out;
|
|
|
|
if ((tcnp->cn_flags & SAVESTART) == 0)
|
|
|
|
panic("msdosfs_rename: lost to startdir");
|
1996-02-09 22:13:39 +03:00
|
|
|
if ((error = relookup(tdvp, &tvp, tcnp)) != 0)
|
1994-09-28 14:31:23 +03:00
|
|
|
goto out;
|
|
|
|
dp = VTODE(tdvp);
|
|
|
|
xp = tvp ? VTODE(tvp) : NULL;
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
|
|
|
|
1994-09-28 14:31:23 +03:00
|
|
|
if (xp != NULL) {
|
|
|
|
/*
|
|
|
|
* Target must be empty if a directory and have no links
|
|
|
|
* to it. Also, ensure source and target are compatible
|
|
|
|
* (both directories, or both not directories).
|
|
|
|
*/
|
|
|
|
if (xp->de_Attributes & ATTR_DIRECTORY) {
|
|
|
|
if (!dosdirempty(xp)) {
|
1993-08-13 15:35:13 +04:00
|
|
|
error = ENOTEMPTY;
|
|
|
|
goto bad;
|
|
|
|
}
|
1994-09-28 14:31:23 +03:00
|
|
|
if (!doingdirectory) {
|
|
|
|
error = ENOTDIR;
|
1993-08-13 15:35:13 +04:00
|
|
|
goto bad;
|
|
|
|
}
|
1994-09-28 14:31:23 +03:00
|
|
|
} else if (doingdirectory) {
|
|
|
|
error = EISDIR;
|
1993-08-13 15:35:13 +04:00
|
|
|
goto bad;
|
|
|
|
}
|
1996-02-09 22:13:39 +03:00
|
|
|
if ((error = removede(dp, xp)) != 0)
|
1994-09-28 14:31:23 +03:00
|
|
|
goto bad;
|
2000-02-02 00:33:57 +03:00
|
|
|
cache_purge(tvp);
|
1994-09-28 14:31:23 +03:00
|
|
|
vput(tvp);
|
|
|
|
xp = NULL;
|
1995-09-09 23:38:00 +04:00
|
|
|
}
|
|
|
|
|
1996-07-15 23:12:13 +04:00
|
|
|
/*
|
|
|
|
* Convert the filename in tcnp into a dos filename. We copy this
|
|
|
|
* into the denode and directory entry for the destination
|
|
|
|
* file/directory.
|
|
|
|
*/
|
|
|
|
if ((error = uniqdosname(VTODE(tdvp), tcnp, toname)) != 0)
|
|
|
|
goto abortit;
|
|
|
|
|
1995-09-09 23:38:00 +04:00
|
|
|
/*
|
|
|
|
* Since from wasn't locked at various places above,
|
|
|
|
* have to do a relookup here.
|
|
|
|
*/
|
|
|
|
fcnp->cn_flags &= ~MODMASK;
|
|
|
|
fcnp->cn_flags |= LOCKPARENT | LOCKLEAF;
|
|
|
|
if ((fcnp->cn_flags & SAVESTART) == 0)
|
|
|
|
panic("msdosfs_rename: lost from startdir");
|
|
|
|
if (!newparent)
|
1998-03-01 05:20:01 +03:00
|
|
|
VOP_UNLOCK(tdvp, 0);
|
1995-09-09 23:38:00 +04:00
|
|
|
(void) relookup(fdvp, &fvp, fcnp);
|
|
|
|
if (fvp == NULL) {
|
1993-08-13 15:35:13 +04:00
|
|
|
/*
|
1995-09-09 23:38:00 +04:00
|
|
|
* From name has disappeared.
|
1993-08-13 15:35:13 +04:00
|
|
|
*/
|
1995-09-09 23:38:00 +04:00
|
|
|
if (doingdirectory)
|
|
|
|
panic("rename: lost dir entry");
|
|
|
|
vrele(ap->a_fvp);
|
|
|
|
if (newparent)
|
1998-03-01 05:20:01 +03:00
|
|
|
VOP_UNLOCK(tdvp, 0);
|
1995-09-09 23:38:00 +04:00
|
|
|
vrele(tdvp);
|
|
|
|
return 0;
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
2000-07-26 00:56:10 +04:00
|
|
|
fdvp_dorele = 1;
|
1995-09-09 23:38:00 +04:00
|
|
|
xp = VTODE(fvp);
|
1995-10-15 18:34:19 +03:00
|
|
|
zp = VTODE(fdvp);
|
|
|
|
from_diroffset = zp->de_fndoffset;
|
1993-08-13 15:35:13 +04:00
|
|
|
|
|
|
|
/*
|
1995-09-09 23:38:00 +04:00
|
|
|
* Ensure that the directory entry still exists and has not
|
|
|
|
* changed till now. If the source is a file the entry may
|
|
|
|
* have been unlinked or renamed. In either case there is
|
|
|
|
* no further work to be done. If the source is a directory
|
|
|
|
* then it cannot have been rmdir'ed or renamed; this is
|
|
|
|
* prohibited by the DE_RENAME flag.
|
1993-08-13 15:35:13 +04:00
|
|
|
*/
|
1995-09-09 23:38:00 +04:00
|
|
|
if (xp != ip) {
|
|
|
|
if (doingdirectory)
|
|
|
|
panic("rename: lost dir entry");
|
|
|
|
vrele(ap->a_fvp);
|
1998-03-01 05:20:01 +03:00
|
|
|
VOP_UNLOCK(fvp, 0);
|
1995-09-09 23:38:00 +04:00
|
|
|
if (newparent)
|
1998-03-01 05:20:01 +03:00
|
|
|
VOP_UNLOCK(fdvp, 0);
|
1995-09-09 23:38:00 +04:00
|
|
|
xp = NULL;
|
1994-04-21 11:47:31 +04:00
|
|
|
} else {
|
1995-09-09 23:38:00 +04:00
|
|
|
vrele(fvp);
|
|
|
|
xp = NULL;
|
1993-08-13 15:35:13 +04:00
|
|
|
|
|
|
|
/*
|
1995-10-15 18:34:19 +03:00
|
|
|
* First write a new entry in the destination
|
|
|
|
* directory and mark the entry in the source directory
|
|
|
|
* as deleted. Then move the denode to the correct hash
|
|
|
|
* chain for its new location in the filesystem. And, if
|
|
|
|
* we moved a directory, then update its .. entry to point
|
|
|
|
* to the new parent directory.
|
1993-08-13 15:35:13 +04:00
|
|
|
*/
|
1998-08-10 00:51:08 +04:00
|
|
|
memcpy(oldname, ip->de_Name, 11);
|
|
|
|
memcpy(ip->de_Name, toname, 11); /* update denode */
|
1995-10-15 18:34:19 +03:00
|
|
|
dp->de_fndoffset = to_diroffset;
|
|
|
|
dp->de_fndcnt = to_count;
|
1996-02-09 22:13:39 +03:00
|
|
|
error = createde(ip, dp, (struct denode **)0, tcnp);
|
|
|
|
if (error) {
|
1998-08-10 00:51:08 +04:00
|
|
|
memcpy(ip->de_Name, oldname, 11);
|
1995-10-15 18:34:19 +03:00
|
|
|
if (newparent)
|
1998-03-01 05:20:01 +03:00
|
|
|
VOP_UNLOCK(fdvp, 0);
|
|
|
|
VOP_UNLOCK(fvp, 0);
|
1995-10-15 18:34:19 +03:00
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
ip->de_refcnt++;
|
|
|
|
zp->de_fndoffset = from_diroffset;
|
1996-02-09 22:13:39 +03:00
|
|
|
if ((error = removede(zp, ip)) != 0) {
|
1995-10-15 18:34:19 +03:00
|
|
|
/* XXX should really panic here, fs is corrupt */
|
|
|
|
if (newparent)
|
1998-03-01 05:20:01 +03:00
|
|
|
VOP_UNLOCK(fdvp, 0);
|
|
|
|
VOP_UNLOCK(fvp, 0);
|
1995-10-15 18:34:19 +03:00
|
|
|
goto bad;
|
|
|
|
}
|
2000-02-02 00:33:57 +03:00
|
|
|
cache_purge(fvp);
|
1995-10-15 18:34:19 +03:00
|
|
|
if (!doingdirectory) {
|
1996-02-09 22:13:39 +03:00
|
|
|
error = pcbmap(dp, de_cluster(pmp, to_diroffset), 0,
|
|
|
|
&ip->de_dirclust, 0);
|
|
|
|
if (error) {
|
1995-09-09 23:38:00 +04:00
|
|
|
/* XXX should really panic here, fs is corrupt */
|
1995-10-15 18:34:19 +03:00
|
|
|
if (newparent)
|
1998-03-01 05:20:01 +03:00
|
|
|
VOP_UNLOCK(fdvp, 0);
|
|
|
|
VOP_UNLOCK(fvp, 0);
|
1995-09-09 23:38:00 +04:00
|
|
|
goto bad;
|
|
|
|
}
|
1998-09-21 19:17:42 +04:00
|
|
|
ip->de_diroffset = to_diroffset;
|
1995-10-15 18:34:19 +03:00
|
|
|
if (ip->de_dirclust != MSDOSFSROOT)
|
1998-09-21 19:17:42 +04:00
|
|
|
ip->de_diroffset &= pmp->pm_crbomask;
|
1995-10-15 18:34:19 +03:00
|
|
|
}
|
|
|
|
reinsert(ip);
|
|
|
|
if (newparent)
|
1998-03-01 05:20:01 +03:00
|
|
|
VOP_UNLOCK(fdvp, 0);
|
1995-10-15 18:34:19 +03:00
|
|
|
}
|
1997-11-17 18:36:17 +03:00
|
|
|
|
1995-10-15 18:34:19 +03:00
|
|
|
/*
|
|
|
|
* If we moved a directory to a new parent directory, then we must
|
|
|
|
* fixup the ".." entry in the moved directory.
|
|
|
|
*/
|
|
|
|
if (doingdirectory && newparent) {
|
|
|
|
cn = ip->de_StartCluster;
|
|
|
|
if (cn == MSDOSFSROOT) {
|
|
|
|
/* this should never happen */
|
|
|
|
panic("msdosfs_rename: updating .. in root directory?\n");
|
|
|
|
} else
|
|
|
|
bn = cntobn(pmp, cn);
|
1996-02-09 22:13:39 +03:00
|
|
|
error = bread(pmp->pm_devvp, bn, pmp->pm_bpcluster,
|
|
|
|
NOCRED, &bp);
|
|
|
|
if (error) {
|
1995-10-15 18:34:19 +03:00
|
|
|
/* XXX should really panic here, fs is corrupt */
|
|
|
|
brelse(bp);
|
1998-03-01 05:20:01 +03:00
|
|
|
VOP_UNLOCK(fvp, 0);
|
1995-10-15 18:34:19 +03:00
|
|
|
goto bad;
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
1995-10-15 18:34:19 +03:00
|
|
|
dotdotp = (struct direntry *)bp->b_data + 1;
|
|
|
|
putushort(dotdotp->deStartCluster, dp->de_StartCluster);
|
1996-02-09 22:13:39 +03:00
|
|
|
if ((error = bwrite(bp)) != 0) {
|
1995-10-15 18:34:19 +03:00
|
|
|
/* XXX should really panic here, fs is corrupt */
|
1998-03-01 05:20:01 +03:00
|
|
|
VOP_UNLOCK(fvp, 0);
|
1995-10-15 18:34:19 +03:00
|
|
|
goto bad;
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
1994-09-28 14:31:23 +03:00
|
|
|
}
|
1995-09-09 23:38:00 +04:00
|
|
|
|
1998-03-01 05:20:01 +03:00
|
|
|
VOP_UNLOCK(fvp, 0);
|
1994-09-28 14:31:23 +03:00
|
|
|
bad:
|
|
|
|
if (xp)
|
|
|
|
vput(tvp);
|
|
|
|
vput(tdvp);
|
|
|
|
out:
|
1995-09-09 23:38:00 +04:00
|
|
|
ip->de_flag &= ~DE_RENAME;
|
2000-07-26 00:56:10 +04:00
|
|
|
if (fdvp_dorele)
|
|
|
|
vrele(fdvp);
|
1994-09-28 14:31:23 +03:00
|
|
|
vrele(fvp);
|
|
|
|
return (error);
|
|
|
|
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
struct {
|
|
|
|
struct direntry dot;
|
|
|
|
struct direntry dotdot;
|
1994-09-28 14:31:23 +03:00
|
|
|
} dosdirtemplate = {
|
1996-02-09 22:13:39 +03:00
|
|
|
{ ". ", " ", /* the . entry */
|
|
|
|
ATTR_DIRECTORY, /* file attribute */
|
1997-10-17 15:23:29 +04:00
|
|
|
0, /* reserved */
|
|
|
|
0, { 0, 0 }, { 0, 0 }, /* create time & date */
|
|
|
|
{ 0, 0 }, /* access date */
|
|
|
|
{ 0, 0 }, /* high bits of start cluster */
|
1996-02-09 22:13:39 +03:00
|
|
|
{ 210, 4 }, { 210, 4 }, /* modify time & date */
|
|
|
|
{ 0, 0 }, /* startcluster */
|
|
|
|
{ 0, 0, 0, 0 } /* filesize */
|
|
|
|
},
|
|
|
|
{ ".. ", " ", /* the .. entry */
|
|
|
|
ATTR_DIRECTORY, /* file attribute */
|
1997-10-17 15:23:29 +04:00
|
|
|
0, /* reserved */
|
|
|
|
0, { 0, 0 }, { 0, 0 }, /* create time & date */
|
|
|
|
{ 0, 0 }, /* access date */
|
|
|
|
{ 0, 0 }, /* high bits of start cluster */
|
1996-02-09 22:13:39 +03:00
|
|
|
{ 210, 4 }, { 210, 4 }, /* modify time & date */
|
|
|
|
{ 0, 0 }, /* startcluster */
|
|
|
|
{ 0, 0, 0, 0 } /* filesize */
|
|
|
|
}
|
1993-08-13 15:35:13 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
int
|
1996-02-09 22:13:39 +03:00
|
|
|
msdosfs_mkdir(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-07-17 01:32:06 +04:00
|
|
|
struct vop_mkdir_args /* {
|
|
|
|
struct vnode *a_dvp;
|
|
|
|
struvt vnode **a_vpp;
|
|
|
|
struvt componentname *a_cnp;
|
|
|
|
struct vattr *a_vap;
|
1996-02-09 22:13:39 +03:00
|
|
|
} */ *ap = v;
|
1994-09-28 14:31:23 +03:00
|
|
|
struct componentname *cnp = ap->a_cnp;
|
|
|
|
struct denode ndirent;
|
|
|
|
struct denode *dep;
|
|
|
|
struct denode *pdep = VTODE(ap->a_dvp);
|
1993-08-13 15:35:13 +04:00
|
|
|
int error;
|
1994-09-28 14:31:23 +03:00
|
|
|
int bn;
|
1997-10-17 15:23:29 +04:00
|
|
|
u_long newcluster, pcl;
|
1993-08-13 15:35:13 +04:00
|
|
|
struct direntry *denp;
|
1994-09-28 14:31:23 +03:00
|
|
|
struct msdosfsmount *pmp = pdep->de_pmp;
|
1993-08-13 15:35:13 +04:00
|
|
|
struct buf *bp;
|
1996-09-02 03:47:48 +04:00
|
|
|
struct timespec ts;
|
2000-03-27 13:44:45 +04:00
|
|
|
int async = pdep->de_pmp->pm_mountp->mnt_flag & MNT_ASYNC;
|
1993-08-13 15:35:13 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If this is the root directory and there is no space left we
|
|
|
|
* can't do anything. This is because the root directory can not
|
|
|
|
* change size.
|
|
|
|
*/
|
1995-10-15 18:34:19 +03:00
|
|
|
if (pdep->de_StartCluster == MSDOSFSROOT
|
|
|
|
&& pdep->de_fndoffset >= pdep->de_FileSize) {
|
1994-09-28 14:31:23 +03:00
|
|
|
error = ENOSPC;
|
|
|
|
goto bad2;
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate a cluster to hold the about to be created directory.
|
|
|
|
*/
|
2000-03-27 21:40:26 +04:00
|
|
|
error = clusteralloc(pmp, 0, 1, &newcluster, NULL);
|
1996-02-09 22:13:39 +03:00
|
|
|
if (error)
|
1994-09-28 14:31:23 +03:00
|
|
|
goto bad2;
|
|
|
|
|
1998-08-10 00:51:08 +04:00
|
|
|
memset(&ndirent, 0, sizeof(ndirent));
|
1996-11-08 18:51:49 +03:00
|
|
|
ndirent.de_pmp = pmp;
|
1996-09-02 03:47:48 +04:00
|
|
|
ndirent.de_flag = DE_ACCESS | DE_CREATE | DE_UPDATE;
|
|
|
|
TIMEVAL_TO_TIMESPEC(&time, &ts);
|
|
|
|
DETIMES(&ndirent, &ts, &ts, &ts);
|
1997-11-17 18:36:17 +03:00
|
|
|
|
1993-08-13 15:35:13 +04:00
|
|
|
/*
|
|
|
|
* Now fill the cluster with the "." and ".." entries. And write
|
|
|
|
* the cluster to disk. This way it is there for the parent
|
|
|
|
* directory to be pointing at if there were a crash.
|
|
|
|
*/
|
|
|
|
bn = cntobn(pmp, newcluster);
|
1994-04-21 11:47:31 +04:00
|
|
|
/* always succeeds */
|
|
|
|
bp = getblk(pmp->pm_devvp, bn, pmp->pm_bpcluster, 0, 0);
|
1998-08-10 00:51:08 +04:00
|
|
|
memset(bp->b_data, 0, pmp->pm_bpcluster);
|
|
|
|
memcpy(bp->b_data, &dosdirtemplate, sizeof dosdirtemplate);
|
1994-09-28 14:31:23 +03:00
|
|
|
denp = (struct direntry *)bp->b_data;
|
|
|
|
putushort(denp[0].deStartCluster, newcluster);
|
1995-11-29 18:08:32 +03:00
|
|
|
putushort(denp[0].deCDate, ndirent.de_CDate);
|
|
|
|
putushort(denp[0].deCTime, ndirent.de_CTime);
|
1997-10-17 15:23:29 +04:00
|
|
|
denp[0].deCHundredth = ndirent.de_CHun;
|
1995-11-29 18:08:32 +03:00
|
|
|
putushort(denp[0].deADate, ndirent.de_ADate);
|
|
|
|
putushort(denp[0].deMDate, ndirent.de_MDate);
|
|
|
|
putushort(denp[0].deMTime, ndirent.de_MTime);
|
1997-10-17 15:23:29 +04:00
|
|
|
pcl = pdep->de_StartCluster;
|
|
|
|
if (FAT32(pmp) && pcl == pmp->pm_rootdirblk)
|
|
|
|
pcl = 0;
|
|
|
|
putushort(denp[1].deStartCluster, pcl);
|
1995-11-29 18:08:32 +03:00
|
|
|
putushort(denp[1].deCDate, ndirent.de_CDate);
|
|
|
|
putushort(denp[1].deCTime, ndirent.de_CTime);
|
1997-10-17 15:23:29 +04:00
|
|
|
denp[1].deCHundredth = ndirent.de_CHun;
|
1995-11-29 18:08:32 +03:00
|
|
|
putushort(denp[1].deADate, ndirent.de_ADate);
|
|
|
|
putushort(denp[1].deMDate, ndirent.de_MDate);
|
|
|
|
putushort(denp[1].deMTime, ndirent.de_MTime);
|
1997-10-17 15:23:29 +04:00
|
|
|
if (FAT32(pmp)) {
|
|
|
|
putushort(denp[0].deHighClust, newcluster >> 16);
|
|
|
|
putushort(denp[1].deHighClust, pdep->de_StartCluster >> 16);
|
|
|
|
}
|
|
|
|
|
2000-03-27 13:44:45 +04:00
|
|
|
if (async)
|
|
|
|
bdwrite(bp);
|
|
|
|
else if ((error = bwrite(bp)) != 0)
|
1994-09-28 14:31:23 +03:00
|
|
|
goto bad;
|
1993-08-13 15:35:13 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Now build up a directory entry pointing to the newly allocated
|
|
|
|
* cluster. This will be written to an empty slot in the parent
|
|
|
|
* directory.
|
|
|
|
*/
|
1994-09-28 14:31:23 +03:00
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if ((cnp->cn_flags & HASBUF) == 0)
|
|
|
|
panic("msdosfs_mkdir: no name");
|
1994-07-19 01:38:08 +04:00
|
|
|
#endif
|
1996-02-09 22:13:39 +03:00
|
|
|
if ((error = uniqdosname(pdep, cnp, ndirent.de_Name)) != 0)
|
1995-10-15 18:34:19 +03:00
|
|
|
goto bad;
|
1997-11-17 18:36:17 +03:00
|
|
|
|
1994-09-28 14:31:23 +03:00
|
|
|
ndirent.de_Attributes = ATTR_DIRECTORY;
|
|
|
|
ndirent.de_StartCluster = newcluster;
|
|
|
|
ndirent.de_FileSize = 0;
|
|
|
|
ndirent.de_dev = pdep->de_dev;
|
|
|
|
ndirent.de_devvp = pdep->de_devvp;
|
1996-02-09 22:13:39 +03:00
|
|
|
if ((error = createde(&ndirent, pdep, &dep, cnp)) != 0)
|
1994-09-28 14:31:23 +03:00
|
|
|
goto bad;
|
|
|
|
if ((cnp->cn_flags & SAVESTART) == 0)
|
2000-08-04 00:41:05 +04:00
|
|
|
PNBUF_PUT(cnp->cn_pnbuf);
|
1994-09-28 14:31:23 +03:00
|
|
|
vput(ap->a_dvp);
|
|
|
|
*ap->a_vpp = DETOV(dep);
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
bad:
|
|
|
|
clusterfree(pmp, newcluster, NULL);
|
|
|
|
bad2:
|
2000-08-04 00:41:05 +04:00
|
|
|
PNBUF_PUT(cnp->cn_pnbuf);
|
1994-07-19 01:38:08 +04:00
|
|
|
vput(ap->a_dvp);
|
1994-09-28 14:31:23 +03:00
|
|
|
return (error);
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1996-02-09 22:13:39 +03:00
|
|
|
msdosfs_rmdir(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-07-17 01:32:06 +04:00
|
|
|
struct vop_rmdir_args /* {
|
|
|
|
struct vnode *a_dvp;
|
|
|
|
struct vnode *a_vp;
|
|
|
|
struct componentname *a_cnp;
|
1996-02-09 22:13:39 +03:00
|
|
|
} */ *ap = v;
|
2000-03-30 16:23:20 +04:00
|
|
|
struct vnode *vp = ap->a_vp;
|
|
|
|
struct vnode *dvp = ap->a_dvp;
|
|
|
|
struct componentname *cnp = ap->a_cnp;
|
|
|
|
struct denode *ip, *dp;
|
1994-09-28 14:31:23 +03:00
|
|
|
int error;
|
1993-08-13 15:35:13 +04:00
|
|
|
|
1994-09-28 14:31:23 +03:00
|
|
|
ip = VTODE(vp);
|
|
|
|
dp = VTODE(dvp);
|
1993-08-13 15:35:13 +04:00
|
|
|
/*
|
1994-09-28 14:31:23 +03:00
|
|
|
* No rmdir "." please.
|
1993-08-13 15:35:13 +04:00
|
|
|
*/
|
1994-09-28 14:31:23 +03:00
|
|
|
if (dp == ip) {
|
|
|
|
vrele(dvp);
|
|
|
|
vput(vp);
|
|
|
|
return (EINVAL);
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
|
|
|
/*
|
1994-09-28 14:31:23 +03:00
|
|
|
* Verify the directory is empty (and valid).
|
|
|
|
* (Rmdir ".." won't be valid since
|
|
|
|
* ".." will contain a reference to
|
|
|
|
* the current directory and thus be
|
|
|
|
* non-empty.)
|
1993-08-13 15:35:13 +04:00
|
|
|
*/
|
1994-09-28 14:31:23 +03:00
|
|
|
error = 0;
|
1995-09-09 23:38:00 +04:00
|
|
|
if (!dosdirempty(ip) || ip->de_flag & DE_RENAME) {
|
1993-08-13 15:35:13 +04:00
|
|
|
error = ENOTEMPTY;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Delete the entry from the directory. For dos filesystems this
|
|
|
|
* gets rid of the directory entry on disk, the in memory copy
|
|
|
|
* still exists but the de_refcnt is <= 0. This prevents it from
|
1994-07-19 01:38:08 +04:00
|
|
|
* being found by deget(). When the vput() on dep is done we give
|
1993-08-13 15:35:13 +04:00
|
|
|
* up access and eventually msdosfs_reclaim() will be called which
|
|
|
|
* will remove it from the denode cache.
|
|
|
|
*/
|
1996-02-09 22:13:39 +03:00
|
|
|
if ((error = removede(dp, ip)) != 0)
|
1993-08-13 15:35:13 +04:00
|
|
|
goto out;
|
|
|
|
/*
|
|
|
|
* This is where we decrement the link count in the parent
|
|
|
|
* directory. Since dos filesystems don't do this we just purge
|
|
|
|
* the name cache and let go of the parent directory denode.
|
|
|
|
*/
|
1994-09-28 14:31:23 +03:00
|
|
|
cache_purge(dvp);
|
|
|
|
vput(dvp);
|
|
|
|
dvp = NULL;
|
1993-08-13 15:35:13 +04:00
|
|
|
/*
|
|
|
|
* Truncate the directory that is being deleted.
|
|
|
|
*/
|
1994-09-28 14:31:23 +03:00
|
|
|
error = detrunc(ip, (u_long)0, IO_SYNC, cnp->cn_cred, cnp->cn_proc);
|
|
|
|
cache_purge(vp);
|
|
|
|
out:
|
|
|
|
if (dvp)
|
|
|
|
vput(dvp);
|
|
|
|
vput(vp);
|
|
|
|
return (error);
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* DOS filesystems don't know what symlinks are.
|
|
|
|
*/
|
|
|
|
int
|
1996-02-09 22:13:39 +03:00
|
|
|
msdosfs_symlink(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-07-17 01:32:06 +04:00
|
|
|
struct vop_symlink_args /* {
|
|
|
|
struct vnode *a_dvp;
|
|
|
|
struct vnode **a_vpp;
|
|
|
|
struct componentname *a_cnp;
|
|
|
|
struct vattr *a_vap;
|
|
|
|
char *a_target;
|
1996-02-09 22:13:39 +03:00
|
|
|
} */ *ap = v;
|
1993-08-13 15:35:13 +04:00
|
|
|
|
1996-02-09 17:45:36 +03:00
|
|
|
VOP_ABORTOP(ap->a_dvp, ap->a_cnp);
|
|
|
|
vput(ap->a_dvp);
|
|
|
|
return (EOPNOTSUPP);
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1996-02-09 22:13:39 +03:00
|
|
|
msdosfs_readdir(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-07-17 01:32:06 +04:00
|
|
|
struct vop_readdir_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
struct uio *a_uio;
|
|
|
|
struct ucred *a_cred;
|
|
|
|
int *a_eofflag;
|
1998-03-01 05:20:01 +03:00
|
|
|
off_t **a_cookies;
|
|
|
|
int *a_ncookies;
|
1996-02-09 22:13:39 +03:00
|
|
|
} */ *ap = v;
|
1993-08-13 15:35:13 +04:00
|
|
|
int error = 0;
|
|
|
|
int diff;
|
|
|
|
long n;
|
1995-09-09 23:38:00 +04:00
|
|
|
int blsize;
|
1993-08-13 15:35:13 +04:00
|
|
|
long on;
|
|
|
|
long lost;
|
|
|
|
long count;
|
|
|
|
u_long cn;
|
|
|
|
u_long fileno;
|
1997-10-17 15:23:29 +04:00
|
|
|
u_long dirsperblk;
|
1993-08-13 15:35:13 +04:00
|
|
|
long bias = 0;
|
1994-09-28 14:31:23 +03:00
|
|
|
daddr_t bn, lbn;
|
1993-08-13 15:35:13 +04:00
|
|
|
struct buf *bp;
|
1994-07-17 01:32:06 +04:00
|
|
|
struct denode *dep = VTODE(ap->a_vp);
|
1993-08-13 15:35:13 +04:00
|
|
|
struct msdosfsmount *pmp = dep->de_pmp;
|
|
|
|
struct direntry *dentp;
|
1994-09-28 14:31:23 +03:00
|
|
|
struct dirent dirbuf;
|
1994-07-17 01:32:06 +04:00
|
|
|
struct uio *uio = ap->a_uio;
|
1998-03-01 05:20:01 +03:00
|
|
|
off_t *cookies = NULL;
|
1998-04-21 13:37:23 +04:00
|
|
|
int ncookies = 0, nc = 0;
|
1999-11-05 02:08:57 +03:00
|
|
|
off_t offset, uio_off;
|
1995-10-15 18:34:19 +03:00
|
|
|
int chksum = -1;
|
1997-11-17 18:36:17 +03:00
|
|
|
|
1994-07-19 01:38:08 +04:00
|
|
|
#ifdef MSDOSFS_DEBUG
|
1997-11-17 00:47:27 +03:00
|
|
|
printf("msdosfs_readdir(): vp %p, uio %p, cred %p, eofflagp %p\n",
|
1996-10-11 02:46:11 +04:00
|
|
|
ap->a_vp, uio, ap->a_cred, ap->a_eofflag);
|
1994-07-19 01:38:08 +04:00
|
|
|
#endif
|
1993-08-13 15:35:13 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* msdosfs_readdir() won't operate properly on regular files since
|
2000-03-14 02:52:25 +03:00
|
|
|
* it does i/o only with the filesystem vnode, and hence can
|
1993-08-13 15:35:13 +04:00
|
|
|
* retrieve the wrong block from the buffer cache for a plain file.
|
|
|
|
* So, fail attempts to readdir() on a plain file.
|
|
|
|
*/
|
|
|
|
if ((dep->de_Attributes & ATTR_DIRECTORY) == 0)
|
1994-09-28 14:31:23 +03:00
|
|
|
return (ENOTDIR);
|
1993-08-13 15:35:13 +04:00
|
|
|
|
1995-10-15 18:34:19 +03:00
|
|
|
/*
|
|
|
|
* To be safe, initialize dirbuf
|
|
|
|
*/
|
1998-08-10 00:51:08 +04:00
|
|
|
memset(dirbuf.d_name, 0, sizeof(dirbuf.d_name));
|
1997-11-17 18:36:17 +03:00
|
|
|
|
1993-08-13 15:35:13 +04:00
|
|
|
/*
|
|
|
|
* If the user buffer is smaller than the size of one dos directory
|
|
|
|
* entry or the file offset is not a multiple of the size of a
|
|
|
|
* directory entry, then we fail the read.
|
|
|
|
*/
|
|
|
|
count = uio->uio_resid & ~(sizeof(struct direntry) - 1);
|
1994-09-28 14:31:23 +03:00
|
|
|
offset = uio->uio_offset;
|
1993-08-13 15:35:13 +04:00
|
|
|
if (count < sizeof(struct direntry) ||
|
1994-09-28 14:31:23 +03:00
|
|
|
(offset & (sizeof(struct direntry) - 1)))
|
|
|
|
return (EINVAL);
|
|
|
|
lost = uio->uio_resid - count;
|
1993-08-13 15:35:13 +04:00
|
|
|
uio->uio_resid = count;
|
1999-11-05 02:08:57 +03:00
|
|
|
uio_off = uio->uio_offset;
|
1993-08-13 15:35:13 +04:00
|
|
|
|
1998-03-01 05:20:01 +03:00
|
|
|
if (ap->a_ncookies) {
|
1998-04-21 13:37:23 +04:00
|
|
|
nc = uio->uio_resid / 16;
|
2000-08-03 04:54:23 +04:00
|
|
|
cookies = malloc(nc * sizeof (off_t), M_TEMP, M_WAITOK);
|
1998-03-01 05:20:01 +03:00
|
|
|
*ap->a_cookies = cookies;
|
|
|
|
}
|
1997-10-17 15:23:29 +04:00
|
|
|
|
|
|
|
dirsperblk = pmp->pm_BytesPerSec / sizeof(struct direntry);
|
|
|
|
|
1993-08-13 15:35:13 +04:00
|
|
|
/*
|
|
|
|
* If they are reading from the root directory then, we simulate
|
|
|
|
* the . and .. entries since these don't exist in the root
|
|
|
|
* directory. We also set the offset bias to make up for having to
|
|
|
|
* simulate these entries. By this I mean that at file offset 64 we
|
|
|
|
* read the first entry in the root directory that lives on disk.
|
|
|
|
*/
|
1997-10-17 15:23:29 +04:00
|
|
|
if (dep->de_StartCluster == MSDOSFSROOT
|
|
|
|
|| (FAT32(pmp) && dep->de_StartCluster == pmp->pm_rootdirblk)) {
|
1996-10-11 02:46:11 +04:00
|
|
|
#if 0
|
1996-10-13 08:10:34 +04:00
|
|
|
printf("msdosfs_readdir(): going after . or .. in root dir, offset %d\n",
|
1996-10-11 02:46:11 +04:00
|
|
|
offset);
|
|
|
|
#endif
|
1993-08-13 15:35:13 +04:00
|
|
|
bias = 2 * sizeof(struct direntry);
|
1994-09-28 14:31:23 +03:00
|
|
|
if (offset < bias) {
|
1995-09-09 23:38:00 +04:00
|
|
|
for (n = (int)offset / sizeof(struct direntry);
|
1994-09-28 14:31:23 +03:00
|
|
|
n < 2; n++) {
|
1997-10-17 15:23:29 +04:00
|
|
|
if (FAT32(pmp))
|
|
|
|
dirbuf.d_fileno = cntobn(pmp,
|
|
|
|
pmp->pm_rootdirblk)
|
|
|
|
* dirsperblk;
|
|
|
|
else
|
|
|
|
dirbuf.d_fileno = 1;
|
1994-09-28 14:31:23 +03:00
|
|
|
dirbuf.d_type = DT_DIR;
|
|
|
|
switch (n) {
|
|
|
|
case 0:
|
|
|
|
dirbuf.d_namlen = 1;
|
|
|
|
strcpy(dirbuf.d_name, ".");
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
dirbuf.d_namlen = 2;
|
|
|
|
strcpy(dirbuf.d_name, "..");
|
|
|
|
break;
|
|
|
|
}
|
1996-03-08 21:13:05 +03:00
|
|
|
dirbuf.d_reclen = DIRENT_SIZE(&dirbuf);
|
1994-09-28 14:31:23 +03:00
|
|
|
if (uio->uio_resid < dirbuf.d_reclen)
|
|
|
|
goto out;
|
1996-02-09 22:13:39 +03:00
|
|
|
error = uiomove((caddr_t) &dirbuf,
|
|
|
|
dirbuf.d_reclen, uio);
|
|
|
|
if (error)
|
1994-09-28 14:31:23 +03:00
|
|
|
goto out;
|
|
|
|
offset += sizeof(struct direntry);
|
1999-11-05 02:08:57 +03:00
|
|
|
uio_off = offset;
|
1994-09-28 14:31:23 +03:00
|
|
|
if (cookies) {
|
|
|
|
*cookies++ = offset;
|
1998-03-01 05:20:01 +03:00
|
|
|
ncookies++;
|
1998-04-21 13:37:23 +04:00
|
|
|
if (ncookies >= nc)
|
|
|
|
goto out;
|
1993-09-14 17:13:45 +04:00
|
|
|
}
|
1993-09-07 19:40:14 +04:00
|
|
|
}
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
|
|
|
}
|
1994-09-28 14:31:23 +03:00
|
|
|
|
|
|
|
while (uio->uio_resid > 0) {
|
1995-10-15 18:34:19 +03:00
|
|
|
lbn = de_cluster(pmp, offset - bias);
|
1994-09-28 14:31:23 +03:00
|
|
|
on = (offset - bias) & pmp->pm_crbomask;
|
2001-02-27 07:37:44 +03:00
|
|
|
n = MIN(pmp->pm_bpcluster - on, uio->uio_resid);
|
1994-09-28 14:31:23 +03:00
|
|
|
diff = dep->de_FileSize - (offset - bias);
|
1993-08-13 15:35:13 +04:00
|
|
|
if (diff <= 0)
|
|
|
|
break;
|
2001-02-27 07:37:44 +03:00
|
|
|
n = MIN(n, diff);
|
1996-02-09 22:13:39 +03:00
|
|
|
if ((error = pcbmap(dep, lbn, &bn, &cn, &blsize)) != 0)
|
1994-09-28 14:31:23 +03:00
|
|
|
break;
|
1996-02-09 22:13:39 +03:00
|
|
|
error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp);
|
|
|
|
if (error) {
|
1993-08-13 15:35:13 +04:00
|
|
|
brelse(bp);
|
1994-09-28 14:31:23 +03:00
|
|
|
return (error);
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
2001-02-27 07:37:44 +03:00
|
|
|
n = MIN(n, blsize - bp->b_resid);
|
1993-08-13 15:35:13 +04:00
|
|
|
|
|
|
|
/*
|
1994-09-28 14:31:23 +03:00
|
|
|
* Convert from dos directory entries to fs-independent
|
|
|
|
* directory entries.
|
1993-08-13 15:35:13 +04:00
|
|
|
*/
|
1994-09-28 14:31:23 +03:00
|
|
|
for (dentp = (struct direntry *)(bp->b_data + on);
|
|
|
|
(char *)dentp < bp->b_data + on + n;
|
1995-10-15 18:34:19 +03:00
|
|
|
dentp++, offset += sizeof(struct direntry)) {
|
1996-10-11 02:46:11 +04:00
|
|
|
#if 0
|
1997-11-17 18:36:17 +03:00
|
|
|
|
1996-10-13 08:10:34 +04:00
|
|
|
printf("rd: dentp %08x prev %08x crnt %08x deName %02x attr %02x\n",
|
1996-10-11 02:46:11 +04:00
|
|
|
dentp, prev, crnt, dentp->deName[0], dentp->deAttributes);
|
|
|
|
#endif
|
1993-08-13 15:35:13 +04:00
|
|
|
/*
|
1994-09-28 14:31:23 +03:00
|
|
|
* If this is an unused entry, we can stop.
|
|
|
|
*/
|
|
|
|
if (dentp->deName[0] == SLOT_EMPTY) {
|
|
|
|
brelse(bp);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
/*
|
1995-10-15 18:34:19 +03:00
|
|
|
* Skip deleted entries.
|
1993-08-13 15:35:13 +04:00
|
|
|
*/
|
1995-10-15 18:34:19 +03:00
|
|
|
if (dentp->deName[0] == SLOT_DELETED) {
|
|
|
|
chksum = -1;
|
|
|
|
continue;
|
|
|
|
}
|
1997-11-17 18:36:17 +03:00
|
|
|
|
1995-10-15 18:34:19 +03:00
|
|
|
/*
|
|
|
|
* Handle Win95 long directory entries
|
|
|
|
*/
|
|
|
|
if (dentp->deAttributes == ATTR_WIN95) {
|
|
|
|
if (pmp->pm_flags & MSDOSFSMNT_SHORTNAME)
|
|
|
|
continue;
|
|
|
|
chksum = win2unixfn((struct winentry *)dentp, &dirbuf, chksum);
|
|
|
|
continue;
|
|
|
|
}
|
1997-11-17 18:36:17 +03:00
|
|
|
|
1995-10-15 18:34:19 +03:00
|
|
|
/*
|
|
|
|
* Skip volume labels
|
|
|
|
*/
|
|
|
|
if (dentp->deAttributes & ATTR_VOLUME) {
|
|
|
|
chksum = -1;
|
1994-09-28 14:31:23 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* This computation of d_fileno must match
|
|
|
|
* the computation of va_fileid in
|
|
|
|
* msdosfs_getattr.
|
|
|
|
*/
|
|
|
|
if (dentp->deAttributes & ATTR_DIRECTORY) {
|
|
|
|
fileno = getushort(dentp->deStartCluster);
|
1997-10-17 15:23:29 +04:00
|
|
|
if (FAT32(pmp))
|
|
|
|
fileno |= getushort(dentp->deHighClust) << 16;
|
|
|
|
/* if this is the root directory */
|
1994-09-28 14:31:23 +03:00
|
|
|
if (fileno == MSDOSFSROOT)
|
1997-10-17 15:23:29 +04:00
|
|
|
if (FAT32(pmp))
|
|
|
|
fileno = cntobn(pmp,
|
|
|
|
pmp->pm_rootdirblk)
|
|
|
|
* dirsperblk;
|
|
|
|
else
|
|
|
|
fileno = 1;
|
|
|
|
else
|
|
|
|
fileno = cntobn(pmp, fileno) * dirsperblk;
|
|
|
|
dirbuf.d_fileno = fileno;
|
|
|
|
dirbuf.d_type = DT_DIR;
|
1994-04-21 11:47:31 +04:00
|
|
|
} else {
|
1997-11-08 22:18:57 +03:00
|
|
|
dirbuf.d_fileno = offset / sizeof(struct direntry);
|
1997-10-17 15:23:29 +04:00
|
|
|
dirbuf.d_type = DT_REG;
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
1995-11-03 22:36:41 +03:00
|
|
|
if (chksum != winChksum(dentp->deName))
|
1995-10-15 18:34:19 +03:00
|
|
|
dirbuf.d_namlen = dos2unixfn(dentp->deName,
|
1995-11-29 18:08:32 +03:00
|
|
|
(u_char *)dirbuf.d_name,
|
|
|
|
pmp->pm_flags & MSDOSFSMNT_SHORTNAME);
|
1995-11-03 22:36:41 +03:00
|
|
|
else
|
1995-10-15 18:34:19 +03:00
|
|
|
dirbuf.d_name[dirbuf.d_namlen] = 0;
|
|
|
|
chksum = -1;
|
1996-03-08 21:13:05 +03:00
|
|
|
dirbuf.d_reclen = DIRENT_SIZE(&dirbuf);
|
1994-09-28 14:31:23 +03:00
|
|
|
if (uio->uio_resid < dirbuf.d_reclen) {
|
|
|
|
brelse(bp);
|
|
|
|
goto out;
|
1993-09-14 17:13:45 +04:00
|
|
|
}
|
1996-02-09 22:13:39 +03:00
|
|
|
error = uiomove((caddr_t) &dirbuf,
|
|
|
|
dirbuf.d_reclen, uio);
|
|
|
|
if (error) {
|
1994-09-28 14:31:23 +03:00
|
|
|
brelse(bp);
|
|
|
|
goto out;
|
|
|
|
}
|
1999-11-05 02:08:57 +03:00
|
|
|
uio_off = offset + sizeof(struct direntry);
|
1994-09-28 14:31:23 +03:00
|
|
|
if (cookies) {
|
1995-11-03 22:36:41 +03:00
|
|
|
*cookies++ = offset + sizeof(struct direntry);
|
1998-03-01 05:20:01 +03:00
|
|
|
ncookies++;
|
1998-04-21 13:37:23 +04:00
|
|
|
if (ncookies >= nc) {
|
|
|
|
brelse(bp);
|
|
|
|
goto out;
|
|
|
|
}
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
brelse(bp);
|
1993-09-07 19:40:14 +04:00
|
|
|
}
|
1993-08-13 15:35:13 +04:00
|
|
|
|
1994-09-28 14:31:23 +03:00
|
|
|
out:
|
1999-11-05 02:08:57 +03:00
|
|
|
uio->uio_offset = uio_off;
|
1994-09-28 14:31:23 +03:00
|
|
|
uio->uio_resid += lost;
|
|
|
|
if (dep->de_FileSize - (offset - bias) <= 0)
|
1994-07-17 01:32:06 +04:00
|
|
|
*ap->a_eofflag = 1;
|
1993-08-13 15:35:13 +04:00
|
|
|
else
|
1994-07-17 01:32:06 +04:00
|
|
|
*ap->a_eofflag = 0;
|
1998-03-01 05:20:01 +03:00
|
|
|
|
|
|
|
if (ap->a_ncookies) {
|
|
|
|
if (error) {
|
2000-08-03 04:54:23 +04:00
|
|
|
free(*ap->a_cookies, M_TEMP);
|
1998-03-01 05:20:01 +03:00
|
|
|
*ap->a_ncookies = 0;
|
|
|
|
*ap->a_cookies = NULL;
|
|
|
|
} else
|
|
|
|
*ap->a_ncookies = ncookies;
|
|
|
|
}
|
1994-09-28 14:31:23 +03:00
|
|
|
return (error);
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* DOS filesystems don't know what symlinks are.
|
|
|
|
*/
|
|
|
|
int
|
1996-02-09 22:13:39 +03:00
|
|
|
msdosfs_readlink(v)
|
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
#if 0
|
1994-07-17 01:32:06 +04:00
|
|
|
struct vop_readlink_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
struct uio *a_uio;
|
|
|
|
struct ucred *a_cred;
|
|
|
|
} */ *ap;
|
1996-02-09 22:13:39 +03:00
|
|
|
#endif
|
1994-09-28 14:31:23 +03:00
|
|
|
|
|
|
|
return (EINVAL);
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1994-07-17 01:32:06 +04:00
|
|
|
* vp - address of vnode file the file
|
|
|
|
* bn - which cluster we are interested in mapping to a filesystem block number.
|
|
|
|
* vpp - returns the vnode for the block special file holding the filesystem
|
|
|
|
* containing the file of interest
|
|
|
|
* bnp - address of where to return the filesystem relative block number
|
1993-08-13 15:35:13 +04:00
|
|
|
*/
|
|
|
|
int
|
1996-02-09 22:13:39 +03:00
|
|
|
msdosfs_bmap(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-07-17 01:32:06 +04:00
|
|
|
struct vop_bmap_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
daddr_t a_bn;
|
|
|
|
struct vnode **a_vpp;
|
|
|
|
daddr_t *a_bnp;
|
|
|
|
int *a_runp;
|
1996-02-09 22:13:39 +03:00
|
|
|
} */ *ap = v;
|
1994-07-17 01:32:06 +04:00
|
|
|
struct denode *dep = VTODE(ap->a_vp);
|
1993-08-13 15:35:13 +04:00
|
|
|
|
1994-07-17 01:32:06 +04:00
|
|
|
if (ap->a_vpp != NULL)
|
|
|
|
*ap->a_vpp = dep->de_devvp;
|
|
|
|
if (ap->a_bnp == NULL)
|
1994-09-28 14:31:23 +03:00
|
|
|
return (0);
|
1994-07-17 01:32:06 +04:00
|
|
|
if (ap->a_runp) {
|
|
|
|
/*
|
|
|
|
* Sequential clusters should be counted here.
|
|
|
|
*/
|
|
|
|
*ap->a_runp = 0;
|
|
|
|
}
|
1999-04-21 21:13:22 +04:00
|
|
|
return (pcbmap(dep, ap->a_bn, ap->a_bnp, 0, 0));
|
1994-07-17 01:32:06 +04:00
|
|
|
}
|
|
|
|
|
1994-12-13 23:14:30 +03:00
|
|
|
int
|
1996-02-09 22:13:39 +03:00
|
|
|
msdosfs_reallocblks(v)
|
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
#if 0
|
1994-07-17 01:32:06 +04:00
|
|
|
struct vop_reallocblks_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
struct cluster_save *a_buflist;
|
1996-02-09 22:13:39 +03:00
|
|
|
} */ *ap = v;
|
|
|
|
#endif
|
1994-09-28 14:31:23 +03:00
|
|
|
|
1994-07-17 01:32:06 +04:00
|
|
|
/* Currently no support for clustering */ /* XXX */
|
1994-09-28 14:31:23 +03:00
|
|
|
return (ENOSPC);
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1996-02-09 22:13:39 +03:00
|
|
|
msdosfs_strategy(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-07-17 01:32:06 +04:00
|
|
|
struct vop_strategy_args /* {
|
|
|
|
struct buf *a_bp;
|
1996-02-09 22:13:39 +03:00
|
|
|
} */ *ap = v;
|
1994-07-17 01:32:06 +04:00
|
|
|
struct buf *bp = ap->a_bp;
|
1993-08-13 15:35:13 +04:00
|
|
|
struct denode *dep = VTODE(bp->b_vp);
|
|
|
|
struct vnode *vp;
|
1994-07-19 01:38:08 +04:00
|
|
|
int error = 0;
|
1993-08-13 15:35:13 +04:00
|
|
|
|
|
|
|
if (bp->b_vp->v_type == VBLK || bp->b_vp->v_type == VCHR)
|
|
|
|
panic("msdosfs_strategy: spec");
|
|
|
|
/*
|
|
|
|
* If we don't already know the filesystem relative block number
|
|
|
|
* then get it using pcbmap(). If pcbmap() returns the block
|
|
|
|
* number as -1 then we've got a hole in the file. DOS filesystems
|
|
|
|
* don't allow files with holes, so we shouldn't ever see this.
|
|
|
|
*/
|
|
|
|
if (bp->b_blkno == bp->b_lblkno) {
|
1996-02-09 22:13:39 +03:00
|
|
|
error = pcbmap(dep, de_bn2cn(dep->de_pmp, bp->b_lblkno),
|
|
|
|
&bp->b_blkno, 0, 0);
|
|
|
|
if (error)
|
1994-07-19 01:38:08 +04:00
|
|
|
bp->b_blkno = -1;
|
|
|
|
if (bp->b_blkno == -1)
|
1993-08-13 15:35:13 +04:00
|
|
|
clrbuf(bp);
|
|
|
|
}
|
1994-07-19 01:38:08 +04:00
|
|
|
if (bp->b_blkno == -1) {
|
1993-08-13 15:35:13 +04:00
|
|
|
biodone(bp);
|
1994-09-28 14:31:23 +03:00
|
|
|
return (error);
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
2000-11-27 11:39:39 +03:00
|
|
|
|
1993-08-13 15:35:13 +04:00
|
|
|
/*
|
|
|
|
* Read/write the block from/to the disk that contains the desired
|
|
|
|
* file block.
|
|
|
|
*/
|
2000-11-27 11:39:39 +03:00
|
|
|
|
1993-08-13 15:35:13 +04:00
|
|
|
vp = dep->de_devvp;
|
|
|
|
bp->b_dev = vp->v_rdev;
|
1994-07-17 01:32:06 +04:00
|
|
|
VOCALL(vp->v_op, VOFFSET(vop_strategy), ap);
|
1994-09-28 14:31:23 +03:00
|
|
|
return (0);
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1996-02-09 22:13:39 +03:00
|
|
|
msdosfs_print(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-07-17 01:32:06 +04:00
|
|
|
struct vop_print_args /* {
|
|
|
|
struct vnode *vp;
|
1996-02-09 22:13:39 +03:00
|
|
|
} */ *ap = v;
|
1994-07-17 01:32:06 +04:00
|
|
|
struct denode *dep = VTODE(ap->a_vp);
|
1993-08-13 15:35:13 +04:00
|
|
|
|
1996-10-13 08:10:34 +04:00
|
|
|
printf(
|
1997-10-17 15:23:29 +04:00
|
|
|
"tag VT_MSDOSFS, startcluster %ld, dircluster %ld, diroffset %ld ",
|
1996-03-20 03:45:40 +03:00
|
|
|
dep->de_StartCluster, dep->de_dirclust, dep->de_diroffset);
|
1998-03-01 05:20:01 +03:00
|
|
|
printf(" dev %d, %d ", major(dep->de_dev), minor(dep->de_dev));
|
1999-07-08 05:05:58 +04:00
|
|
|
lockmgr_printinfo(&ap->a_vp->v_lock);
|
1998-03-01 05:20:01 +03:00
|
|
|
printf("\n");
|
1996-02-09 22:13:39 +03:00
|
|
|
return (0);
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1996-02-09 22:13:39 +03:00
|
|
|
msdosfs_advlock(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-07-17 01:32:06 +04:00
|
|
|
struct vop_advlock_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
caddr_t a_id;
|
|
|
|
int a_op;
|
|
|
|
struct flock *a_fl;
|
|
|
|
int a_flags;
|
1996-02-09 22:13:39 +03:00
|
|
|
} */ *ap = v;
|
2000-03-30 16:23:20 +04:00
|
|
|
struct denode *dep = VTODE(ap->a_vp);
|
1994-09-28 14:31:23 +03:00
|
|
|
|
2000-07-22 19:26:11 +04:00
|
|
|
return lf_advlock(ap, &dep->de_lockf, dep->de_FileSize);
|
1993-08-13 15:35:13 +04:00
|
|
|
}
|
|
|
|
|
1994-07-17 01:32:06 +04:00
|
|
|
int
|
1996-02-09 22:13:39 +03:00
|
|
|
msdosfs_pathconf(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-07-17 01:32:06 +04:00
|
|
|
struct vop_pathconf_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
int a_name;
|
1994-10-20 07:22:35 +03:00
|
|
|
register_t *a_retval;
|
1996-02-09 22:13:39 +03:00
|
|
|
} */ *ap = v;
|
1995-11-29 18:08:32 +03:00
|
|
|
struct msdosfsmount *pmp = VTODE(ap->a_vp)->de_pmp;
|
1994-09-28 14:31:23 +03:00
|
|
|
|
1994-07-17 01:32:06 +04:00
|
|
|
switch (ap->a_name) {
|
|
|
|
case _PC_LINK_MAX:
|
|
|
|
*ap->a_retval = 1;
|
1994-09-28 14:31:23 +03:00
|
|
|
return (0);
|
1994-07-17 01:32:06 +04:00
|
|
|
case _PC_NAME_MAX:
|
1995-11-29 18:08:32 +03:00
|
|
|
*ap->a_retval = pmp->pm_flags & MSDOSFSMNT_LONGNAME ? WIN_MAXLEN : 12;
|
1994-09-28 14:31:23 +03:00
|
|
|
return (0);
|
1994-07-17 01:32:06 +04:00
|
|
|
case _PC_PATH_MAX:
|
1994-09-28 14:31:23 +03:00
|
|
|
*ap->a_retval = PATH_MAX;
|
|
|
|
return (0);
|
1994-07-17 01:32:06 +04:00
|
|
|
case _PC_CHOWN_RESTRICTED:
|
|
|
|
*ap->a_retval = 1;
|
1994-09-28 14:31:23 +03:00
|
|
|
return (0);
|
1994-07-17 01:32:06 +04:00
|
|
|
case _PC_NO_TRUNC:
|
|
|
|
*ap->a_retval = 0;
|
1994-09-28 14:31:23 +03:00
|
|
|
return (0);
|
1998-08-03 18:19:57 +04:00
|
|
|
case _PC_SYNC_IO:
|
|
|
|
*ap->a_retval = 1;
|
|
|
|
return (0);
|
1999-03-22 22:21:07 +03:00
|
|
|
case _PC_FILESIZEBITS:
|
|
|
|
*ap->a_retval = 32;
|
|
|
|
return (0);
|
1994-07-17 01:32:06 +04:00
|
|
|
default:
|
1994-09-28 14:31:23 +03:00
|
|
|
return (EINVAL);
|
1994-07-17 01:32:06 +04:00
|
|
|
}
|
1994-09-28 14:31:23 +03:00
|
|
|
/* NOTREACHED */
|
1994-07-17 01:32:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Global vfs data structures for msdosfs */
|
1996-02-09 22:13:39 +03:00
|
|
|
int (**msdosfs_vnodeop_p) __P((void *));
|
2001-01-22 15:17:35 +03:00
|
|
|
const struct vnodeopv_entry_desc msdosfs_vnodeop_entries[] = {
|
1994-07-17 01:32:06 +04:00
|
|
|
{ &vop_default_desc, vn_default_error },
|
|
|
|
{ &vop_lookup_desc, msdosfs_lookup }, /* lookup */
|
|
|
|
{ &vop_create_desc, msdosfs_create }, /* create */
|
|
|
|
{ &vop_mknod_desc, msdosfs_mknod }, /* mknod */
|
|
|
|
{ &vop_open_desc, msdosfs_open }, /* open */
|
|
|
|
{ &vop_close_desc, msdosfs_close }, /* close */
|
|
|
|
{ &vop_access_desc, msdosfs_access }, /* access */
|
|
|
|
{ &vop_getattr_desc, msdosfs_getattr }, /* getattr */
|
|
|
|
{ &vop_setattr_desc, msdosfs_setattr }, /* setattr */
|
|
|
|
{ &vop_read_desc, msdosfs_read }, /* read */
|
|
|
|
{ &vop_write_desc, msdosfs_write }, /* write */
|
1994-12-13 23:14:30 +03:00
|
|
|
{ &vop_lease_desc, msdosfs_lease_check }, /* lease */
|
1999-08-04 00:19:16 +04:00
|
|
|
{ &vop_fcntl_desc, genfs_fcntl }, /* fcntl */
|
1994-07-17 01:32:06 +04:00
|
|
|
{ &vop_ioctl_desc, msdosfs_ioctl }, /* ioctl */
|
1996-09-07 16:40:22 +04:00
|
|
|
{ &vop_poll_desc, msdosfs_poll }, /* poll */
|
1999-08-19 07:42:23 +04:00
|
|
|
{ &vop_revoke_desc, msdosfs_revoke }, /* revoke */
|
1994-07-17 01:32:06 +04:00
|
|
|
{ &vop_mmap_desc, msdosfs_mmap }, /* mmap */
|
|
|
|
{ &vop_fsync_desc, msdosfs_fsync }, /* fsync */
|
|
|
|
{ &vop_seek_desc, msdosfs_seek }, /* seek */
|
|
|
|
{ &vop_remove_desc, msdosfs_remove }, /* remove */
|
|
|
|
{ &vop_link_desc, msdosfs_link }, /* link */
|
|
|
|
{ &vop_rename_desc, msdosfs_rename }, /* rename */
|
|
|
|
{ &vop_mkdir_desc, msdosfs_mkdir }, /* mkdir */
|
|
|
|
{ &vop_rmdir_desc, msdosfs_rmdir }, /* rmdir */
|
|
|
|
{ &vop_symlink_desc, msdosfs_symlink }, /* symlink */
|
|
|
|
{ &vop_readdir_desc, msdosfs_readdir }, /* readdir */
|
|
|
|
{ &vop_readlink_desc, msdosfs_readlink }, /* readlink */
|
|
|
|
{ &vop_abortop_desc, msdosfs_abortop }, /* abortop */
|
|
|
|
{ &vop_inactive_desc, msdosfs_inactive }, /* inactive */
|
|
|
|
{ &vop_reclaim_desc, msdosfs_reclaim }, /* reclaim */
|
1999-07-08 05:05:58 +04:00
|
|
|
{ &vop_lock_desc, genfs_lock }, /* lock */
|
|
|
|
{ &vop_unlock_desc, genfs_unlock }, /* unlock */
|
1994-07-17 01:32:06 +04:00
|
|
|
{ &vop_bmap_desc, msdosfs_bmap }, /* bmap */
|
|
|
|
{ &vop_strategy_desc, msdosfs_strategy }, /* strategy */
|
|
|
|
{ &vop_print_desc, msdosfs_print }, /* print */
|
1999-07-08 05:05:58 +04:00
|
|
|
{ &vop_islocked_desc, genfs_islocked }, /* islocked */
|
1994-07-17 01:32:06 +04:00
|
|
|
{ &vop_pathconf_desc, msdosfs_pathconf }, /* pathconf */
|
|
|
|
{ &vop_advlock_desc, msdosfs_advlock }, /* advlock */
|
|
|
|
{ &vop_reallocblks_desc, msdosfs_reallocblks }, /* reallocblks */
|
1996-09-02 03:47:48 +04:00
|
|
|
{ &vop_update_desc, msdosfs_update }, /* update */
|
|
|
|
{ &vop_bwrite_desc, vn_bwrite }, /* bwrite */
|
2000-11-27 11:39:39 +03:00
|
|
|
{ &vop_getpages_desc, genfs_getpages }, /* getpages */
|
|
|
|
{ &vop_putpages_desc, genfs_putpages }, /* putpages */
|
|
|
|
{ NULL, NULL }
|
1993-08-13 15:35:13 +04:00
|
|
|
};
|
2001-01-22 15:17:35 +03:00
|
|
|
const struct vnodeopv_desc msdosfs_vnodeop_opv_desc =
|
1994-07-17 01:32:06 +04:00
|
|
|
{ &msdosfs_vnodeop_p, msdosfs_vnodeop_entries };
|