Re: remove ntfs write code

2016-09-01 Thread Theo de Raadt
Removing unfinished write support makes sense.  Who knows, maybe
it makes read support more sustainable...
 



Re: remove ntfs write code

2016-09-01 Thread Ted Unangst
Martin Natano wrote:
> mount_ntfs forces the mount point to be MNT_RDONLY, so the write parts
> in ntfs are never used. OK to remove?

i think so.

by the way, this code is probably a dead end, compared to the fuse code. is
that right? but we should keep it around for a while until we're sure the fuse
code is a good replacement.



Re: remove ntfs write code

2016-09-01 Thread Martin Natano
On Wed, Aug 31, 2016 at 05:17:41PM -0600, Bob Beck wrote:
> Yes, ok beck@
> 
> to be shortly followed by the ntfs code - don't we have a fuse version of
> this?

There's the ntfs_3g port benno uses. Iirc, access via ntfs_3g is
somewhat slower than with the native filesystem (not that I care).


> 
> 
> On Wed, Aug 31, 2016 at 3:34 PM, Martin Natano  wrote:
> 
> > mount_ntfs forces the mount point to be MNT_RDONLY, so the write parts
> > in ntfs are never used. OK to remove?
> >
> > natano
> >
> >
> > Index: ntfs/ntfs_subr.c
> > ===
> > RCS file: /cvs/src/sys/ntfs/ntfs_subr.c,v
> > retrieving revision 1.47
> > diff -u -p -r1.47 ntfs_subr.c
> > --- ntfs/ntfs_subr.c31 Aug 2016 15:13:57 -  1.47
> > +++ ntfs/ntfs_subr.c31 Aug 2016 19:58:31 -
> > @@ -1336,152 +1336,6 @@ ntfs_filesize(struct ntfsmount *ntmp, st
> >  }
> >
> >  /*
> > - * 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), );
> > -   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, , 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_tccn, 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
> > -

Re: remove ntfs write code

2016-08-31 Thread Bob Beck
Yes, ok beck@

to be shortly followed by the ntfs code - don't we have a fuse version of
this?


On Wed, Aug 31, 2016 at 3:34 PM, Martin Natano  wrote:

> mount_ntfs forces the mount point to be MNT_RDONLY, so the write parts
> in ntfs are never used. OK to remove?
>
> natano
>
>
> Index: ntfs/ntfs_subr.c
> ===
> RCS file: /cvs/src/sys/ntfs/ntfs_subr.c,v
> retrieving revision 1.47
> diff -u -p -r1.47 ntfs_subr.c
> --- ntfs/ntfs_subr.c31 Aug 2016 15:13:57 -  1.47
> +++ ntfs/ntfs_subr.c31 Aug 2016 19:58:31 -
> @@ -1336,152 +1336,6 @@ ntfs_filesize(struct ntfsmount *ntmp, st
>  }
>
>  /*
> - * 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), );
> -   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, , 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_tccn, 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, 

Re: remove ntfs write code

2016-08-31 Thread Sebastian Benoit
as far as i'm concerned ok benno@

btw i have incresingly problems with mounting ntfs partions (read-only) with
this and use the ntfs_3g fuse port.

Martin Natano(nat...@natano.net) on 2016.08.31 23:34:43 +0200:
> mount_ntfs forces the mount point to be MNT_RDONLY, so the write parts
> in ntfs are never used. OK to remove?
> 
> natano
> 
> 
> Index: ntfs/ntfs_subr.c
> ===
> RCS file: /cvs/src/sys/ntfs/ntfs_subr.c,v
> retrieving revision 1.47
> diff -u -p -r1.47 ntfs_subr.c
> --- ntfs/ntfs_subr.c  31 Aug 2016 15:13:57 -  1.47
> +++ ntfs/ntfs_subr.c  31 Aug 2016 19:58:31 -
> @@ -1336,152 +1336,6 @@ ntfs_filesize(struct ntfsmount *ntmp, st
>  }
>  
>  /*
> - * 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), );
> - 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, , 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_tccn, 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)))
> - {
> - 

remove ntfs write code

2016-08-31 Thread Martin Natano
mount_ntfs forces the mount point to be MNT_RDONLY, so the write parts
in ntfs are never used. OK to remove?

natano


Index: ntfs/ntfs_subr.c
===
RCS file: /cvs/src/sys/ntfs/ntfs_subr.c,v
retrieving revision 1.47
diff -u -p -r1.47 ntfs_subr.c
--- ntfs/ntfs_subr.c31 Aug 2016 15:13:57 -  1.47
+++ ntfs/ntfs_subr.c31 Aug 2016 19:58:31 -
@@ -1336,152 +1336,6 @@ ntfs_filesize(struct ntfsmount *ntmp, st
 }
 
 /*
- * 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), );
-   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, , 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_tccn, 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),
-