summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Natano <natano@cvs.openbsd.org>2016-09-01 08:40:40 +0000
committerMartin Natano <natano@cvs.openbsd.org>2016-09-01 08:40:40 +0000
commitfab71394eec13ccf8ac9468dc448fbfb27e58ba0 (patch)
treed0e325b8759e6d6754ea578ee2426171606d3cff
parent4ba539e35e5d3852bc00f4d828abc4006cb5212f (diff)
Remove the unused ntfs write code. ok benno beck
-rw-r--r--sys/ntfs/ntfs_subr.c148
-rw-r--r--sys/ntfs/ntfs_subr.h4
-rw-r--r--sys/ntfs/ntfs_vfsops.c18
-rw-r--r--sys/ntfs/ntfs_vnops.c75
4 files changed, 15 insertions, 230 deletions
diff --git a/sys/ntfs/ntfs_subr.c b/sys/ntfs/ntfs_subr.c
index 3587145c159..834d6f160d5 100644
--- a/sys/ntfs/ntfs_subr.c
+++ b/sys/ntfs/ntfs_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntfs_subr.c,v 1.47 2016/08/31 15:13:57 tom Exp $ */
+/* $OpenBSD: ntfs_subr.c,v 1.48 2016/09/01 08:40:39 natano Exp $ */
/* $NetBSD: ntfs_subr.c,v 1.4 2003/04/10 21:37:32 jdolecek Exp $ */
/*-
@@ -1336,152 +1336,6 @@ ntfs_filesize(struct ntfsmount *ntmp, struct fnode *fp, u_int64_t *size,
}
/*
- * This is one of the write routines.
- */
-int
-ntfs_writeattr_plain(struct ntfsmount *ntmp, struct ntnode *ip,
- u_int32_t attrnum, char *attrname, off_t roff, size_t rsize, void *rdata,
- size_t *initp, struct uio *uio)
-{
- size_t init;
- int error = 0;
- off_t off = roff;
- size_t left = rsize, towrite;
- caddr_t data = rdata;
- struct ntvattr *vap;
- *initp = 0;
-
- while (left) {
- error = ntfs_ntvattrget(ntmp, ip, attrnum, attrname,
- ntfs_btocn(off), &vap);
- if (error)
- return (error);
- towrite = MIN(left, ntfs_cntob(vap->va_vcnend + 1) - off);
- DDPRINTF("ntfs_writeattr_plain: o: %lld, s: %zu "
- "(%llu - %llu)\n", off, towrite,
- vap->va_vcnstart, vap->va_vcnend);
- error = ntfs_writentvattr_plain(ntmp, ip, vap,
- off - ntfs_cntob(vap->va_vcnstart),
- towrite, data, &init, uio);
- if (error) {
- DPRINTF("ntfs_writeattr_plain: ntfs_writentvattr_plain "
- "failed: o: %lld, s: %zu\n", off, towrite);
- DPRINTF("ntfs_writeattr_plain: attrib: %llu - %llu\n",
- vap->va_vcnstart, vap->va_vcnend);
- ntfs_ntvattrrele(vap);
- break;
- }
- ntfs_ntvattrrele(vap);
- left -= towrite;
- off += towrite;
- data = data + towrite;
- *initp += init;
- }
-
- return (error);
-}
-
-/*
- * This is one of the write routines.
- *
- * ntnode should be locked.
- */
-int
-ntfs_writentvattr_plain(struct ntfsmount *ntmp, struct ntnode *ip,
- struct ntvattr *vap, off_t roff, size_t rsize, void *rdata, size_t *initp,
- struct uio *uio)
-{
- int error = 0;
- off_t off;
- int cnt;
- cn_t ccn, ccl, cn, cl;
- caddr_t data = rdata;
- struct buf *bp;
- size_t left, tocopy;
-
- *initp = 0;
-
- if ((vap->va_flag & NTFS_AF_INRUN) == 0) {
- DPRINTF("ntfs_writevattr_plain: CAN'T WRITE RES. ATTRIBUTE\n");
- return ENOTTY;
- }
-
- DDPRINTF("ntfs_writentvattr_plain: data in run: %lu chains\n",
- vap->va_vruncnt);
-
- off = roff;
- left = rsize;
-
- for (cnt = 0; left && (cnt < vap->va_vruncnt); cnt++) {
- ccn = vap->va_vruncn[cnt];
- ccl = vap->va_vruncl[cnt];
-
- DDPRINTF("ntfs_writentvattr_plain: left %zu, cn: 0x%llx, "
- "cl: %llu, off: %lld\n", left, ccn, ccl, off);
-
- if (ntfs_cntob(ccl) < off) {
- off -= ntfs_cntob(ccl);
- cnt++;
- continue;
- }
- if (!ccn && ip->i_number != NTFS_BOOTINO)
- continue; /* XXX */
-
- ccl -= ntfs_btocn(off);
- cn = ccn + ntfs_btocn(off);
- off = ntfs_btocnoff(off);
-
- while (left && ccl) {
- /*
- * Always read and write single clusters at a time -
- * we need to avoid requesting differently-sized
- * blocks at the same disk offsets to avoid
- * confusing the buffer cache.
- */
- tocopy = MIN(left, ntfs_cntob(1) - off);
- cl = ntfs_btocl(tocopy + off);
- KASSERT(cl == 1 && tocopy <= ntfs_cntob(1));
- DDPRINTF("ntfs_writentvattr_plain: write: cn: 0x%llx "
- "cl: %llu, off: %lld len: %zu, left: %zu\n",
- cn, cl, off, tocopy, left);
- if ((off == 0) && (tocopy == ntfs_cntob(cl)))
- {
- bp = getblk(ntmp->ntm_devvp, ntfs_cntobn(cn),
- ntfs_cntob(cl), 0, 0);
- clrbuf(bp);
- } else {
- error = bread(ntmp->ntm_devvp, ntfs_cntobn(cn),
- ntfs_cntob(cl), &bp);
- if (error) {
- brelse(bp);
- return (error);
- }
- }
- if (uio) {
- error = uiomove(bp->b_data + off, tocopy, uio);
- if (error != 0)
- break;
- } else
- memcpy(bp->b_data + off, data, tocopy);
- bawrite(bp);
- data = data + tocopy;
- *initp += tocopy;
- off = 0;
- left -= tocopy;
- cn += cl;
- ccl -= cl;
- }
- }
-
- if (left && error == 0) {
- printf("ntfs_writentvattr_plain: POSSIBLE RUN ERROR\n");
- error = EINVAL;
- }
-
- return (error);
-}
-
-/*
* This is one of the read routines.
*
* ntnode should be locked.
diff --git a/sys/ntfs/ntfs_subr.h b/sys/ntfs/ntfs_subr.h
index 89707b4ae7f..ab342c69c25 100644
--- a/sys/ntfs/ntfs_subr.h
+++ b/sys/ntfs/ntfs_subr.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntfs_subr.h,v 1.9 2014/01/19 18:35:45 tedu Exp $ */
+/* $OpenBSD: ntfs_subr.h,v 1.10 2016/09/01 08:40:39 natano Exp $ */
/* $NetBSD: ntfs_subr.h,v 1.1 2002/12/23 17:38:33 jdolecek Exp $ */
/*-
@@ -91,8 +91,6 @@ int ntfs_ntvattrget(struct ntfsmount *, struct ntnode *, u_int32_t, const char *
void ntfs_ntref(struct ntnode *);
void ntfs_ntrele(struct ntnode *);
int ntfs_loadntnode( struct ntfsmount *, struct ntnode * );
-int ntfs_writentvattr_plain(struct ntfsmount *, struct ntnode *, struct ntvattr *, off_t, size_t, void *, size_t *, struct uio *);
-int ntfs_writeattr_plain(struct ntfsmount *, struct ntnode *, u_int32_t, char *, off_t, size_t, void *, size_t *, struct uio *);
int ntfs_fget(struct ntfsmount *, struct ntnode *, int, char *, struct fnode **);
void ntfs_frele(struct fnode *);
int ntfs_ntreaddir(struct ntfsmount *, struct fnode *, u_int32_t, struct attr_indexentry **, struct proc *);
diff --git a/sys/ntfs/ntfs_vfsops.c b/sys/ntfs/ntfs_vfsops.c
index 8666d6de710..5c56fbb94cb 100644
--- a/sys/ntfs/ntfs_vfsops.c
+++ b/sys/ntfs/ntfs_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntfs_vfsops.c,v 1.53 2016/08/13 20:53:17 guenther Exp $ */
+/* $OpenBSD: ntfs_vfsops.c,v 1.54 2016/09/01 08:40:39 natano Exp $ */
/* $NetBSD: ntfs_vfsops.c,v 1.7 2003/04/24 07:50:19 christos Exp $ */
/*-
@@ -122,7 +122,6 @@ ntfs_mount(struct mount *mp, const char *path, void *data,
struct ntfs_args args;
char fname[MNAMELEN];
char fspec[MNAMELEN];
- mode_t amode;
ntfs_nthashinit();
@@ -193,9 +192,8 @@ ntfs_mount(struct mount *mp, const char *path, void *data,
* requested device.
*/
if (p->p_ucred->cr_uid) {
- amode = (mp->mnt_flag & MNT_RDONLY) ? VREAD : (VREAD | VWRITE);
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);
- err = VOP_ACCESS(devvp, amode, p->p_ucred, p);
+ err = VOP_ACCESS(devvp, VREAD, p->p_ucred, p);
VOP_UNLOCK(devvp, p);
if (err)
goto error_2;
@@ -282,7 +280,7 @@ ntfs_mountfs(struct vnode *devvp, struct mount *mp, struct ntfs_args *argsp,
struct buf *bp;
struct ntfsmount *ntmp = NULL;
dev_t dev = devvp->v_rdev;
- int error, ronly, ncount, i;
+ int error, ncount, i;
struct vnode *vp;
/*
@@ -303,8 +301,7 @@ ntfs_mountfs(struct vnode *devvp, struct mount *mp, struct ntfs_args *argsp,
if (error)
return (error);
- ronly = (mp->mnt_flag & MNT_RDONLY) != 0;
- error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, p);
+ error = VOP_OPEN(devvp, FREAD, FSCRED, p);
if (error)
return (error);
@@ -464,7 +461,7 @@ out:
/* lock the device vnode before calling VOP_CLOSE() */
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);
- (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, p);
+ (void)VOP_CLOSE(devvp, FREAD, NOCRED, p);
VOP_UNLOCK(devvp, p);
return (error);
@@ -480,7 +477,7 @@ int
ntfs_unmount(struct mount *mp, int mntflags, struct proc *p)
{
struct ntfsmount *ntmp;
- int error, ronly = 0, flags, i;
+ int error, flags, i;
DPRINTF("ntfs_unmount: unmounting...\n");
ntmp = VFSTONTFS(mp);
@@ -524,8 +521,7 @@ ntfs_unmount(struct mount *mp, int mntflags, struct proc *p)
/* lock the device vnode before calling VOP_CLOSE() */
vn_lock(ntmp->ntm_devvp, LK_EXCLUSIVE | LK_RETRY, p);
vinvalbuf(ntmp->ntm_devvp, V_SAVE, NOCRED, p, 0, 0);
- (void)VOP_CLOSE(ntmp->ntm_devvp, ronly ? FREAD : FREAD|FWRITE,
- NOCRED, p);
+ (void)VOP_CLOSE(ntmp->ntm_devvp, FREAD, NOCRED, p);
vput(ntmp->ntm_devvp);
/* free the toupper table, if this has been last mounted ntfs volume */
diff --git a/sys/ntfs/ntfs_vnops.c b/sys/ntfs/ntfs_vnops.c
index 2bc16a68f17..b63268151ce 100644
--- a/sys/ntfs/ntfs_vnops.c
+++ b/sys/ntfs/ntfs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntfs_vnops.c,v 1.41 2016/03/19 12:04:16 natano Exp $ */
+/* $OpenBSD: ntfs_vnops.c,v 1.42 2016/09/01 08:40:39 natano Exp $ */
/* $NetBSD: ntfs_vnops.c,v 1.6 2003/04/10 21:57:26 jdolecek Exp $ */
/*
@@ -57,7 +57,6 @@
#include <sys/unistd.h> /* for pathconf(2) constants */
int ntfs_read(void *);
-int ntfs_write(void *);
int ntfs_getattr(void *);
int ntfs_inactive(void *);
int ntfs_print(void *);
@@ -292,29 +291,8 @@ ntfs_strategy(void *v)
bzero(bp->b_data + toread, bp->b_bcount - toread);
}
} else {
- size_t tmp;
- u_int32_t towrite;
-
- if (ntfs_cntob(bp->b_blkno) + bp->b_bcount >= fp->f_size) {
- printf("ntfs_strategy: CAN'T EXTEND FILE\n");
- bp->b_error = error = EFBIG;
- bp->b_flags |= B_ERROR;
- } else {
- towrite = MIN(bp->b_bcount,
- fp->f_size - ntfs_cntob(bp->b_blkno));
- DPRINTF("ntfs_strategy: towrite: %u, fsize: %llu\n",
- towrite, fp->f_size);
-
- error = ntfs_writeattr_plain(ntmp, ip, fp->f_attrtype,
- fp->f_attrname, ntfs_cntob(bp->b_blkno),towrite,
- bp->b_data, &tmp, NULL);
-
- if (error) {
- printf("ntfs_strategy: ntfs_writeattr fail\n");
- bp->b_error = error;
- bp->b_flags |= B_ERROR;
- }
- }
+ bp->b_error = error = EROFS;
+ bp->b_flags |= B_ERROR;
}
s = splbio();
biodone(bp);
@@ -323,42 +301,6 @@ ntfs_strategy(void *v)
}
int
-ntfs_write(void *v)
-{
- struct vop_write_args *ap = v;
- struct vnode *vp = ap->a_vp;
- struct fnode *fp = VTOF(vp);
- struct ntnode *ip = FTONT(fp);
- struct uio *uio = ap->a_uio;
- struct ntfsmount *ntmp = ip->i_mp;
- u_int64_t towrite;
- size_t written;
- int error;
-
- DPRINTF("ntfs_write: ino: %u, off: %lld resid: %zu, segflg: %d\n",
- ip->i_number, uio->uio_offset, uio->uio_resid, uio->uio_segflg);
- DPRINTF("ntfs_write: filesize: %llu", fp->f_size);
-
- if (uio->uio_resid + uio->uio_offset > fp->f_size) {
- printf("ntfs_write: CAN'T WRITE BEYOND END OF FILE\n");
- return (EFBIG);
- }
-
- towrite = MIN(uio->uio_resid, fp->f_size - uio->uio_offset);
-
- DPRINTF(", towrite: %llu\n", towrite);
-
- error = ntfs_writeattr_plain(ntmp, ip, fp->f_attrtype,
- fp->f_attrname, uio->uio_offset, towrite, NULL, &written, uio);
-#ifdef NTFS_DEBUG
- if (error)
- printf("ntfs_write: ntfs_writeattr failed: %d\n", error);
-#endif
-
- return (error);
-}
-
-int
ntfs_access(void *v)
{
struct vop_access_args *ap = v;
@@ -372,18 +314,15 @@ ntfs_access(void *v)
DPRINTF("ntfs_access: %u\n", ip->i_number);
/*
- * 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.
+ * Disallow write attempts unless the file is a socket, fifo, or
+ * a block or character device resident on the file system.
*/
if (mode & VWRITE) {
switch ((int)vp->v_type) {
case VDIR:
case VLNK:
case VREG:
- if (vp->v_mount->mnt_flag & MNT_RDONLY)
- return (EROFS);
- break;
+ return (EROFS);
}
}
@@ -606,7 +545,6 @@ ntfs_lookup(void *v)
return (error);
if ((cnp->cn_flags & ISLASTCN) &&
- (dvp->v_mount->mnt_flag & MNT_RDONLY) &&
(cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME))
return (EROFS);
@@ -746,5 +684,4 @@ struct vops ntfs_vops = {
.vop_strategy = ntfs_strategy,
.vop_bwrite = vop_generic_bwrite,
.vop_read = ntfs_read,
- .vop_write = ntfs_write,
};