From: Matthew Dillon Date: Wed, 24 Aug 2005 21:14:21 +0000 (+0000) Subject: When writing UNDO records, only try to output the file contents for VREG X-Git-Tag: v2.0.1~6189 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/25bae9ce570b90c81a505c631cb6ef44ccbed273 When writing UNDO records, only try to output the file contents for VREG vnodes (fixes a panic). When writing the UNDO record for a symlink, write out the contents of the symlink. --- diff --git a/sys/kern/vfs_jops.c b/sys/kern/vfs_jops.c index e13c9a02f7..df9c055b43 100644 --- a/sys/kern/vfs_jops.c +++ b/sys/kern/vfs_jops.c @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/kern/vfs_jops.c,v 1.19 2005/08/24 20:28:31 dillon Exp $ + * $DragonFly: src/sys/kern/vfs_jops.c,v 1.20 2005/08/24 21:14:21 dillon Exp $ */ /* * Each mount point may have zero or more independantly configured journals @@ -2040,7 +2040,7 @@ jrecord_undo_file(struct jrecord *jrec, struct vnode *vp, int jrflags, * with a link count > 1. The undo code needs to locate the inode and * regenerate the hardlink. */ - if (jrflags & JRUNDO_FILEDATA) { + if ((jrflags & JRUNDO_FILEDATA) && attr.va_type == VREG) { if (attr.va_size != VNOVAL) { if (bytes == -1) bytes = attr.va_size - off; @@ -2052,6 +2052,28 @@ jrecord_undo_file(struct jrecord *jrec, struct vnode *vp, int jrflags, error = EINVAL; } } + if ((jrflags & JRUNDO_FILEDATA) && attr.va_type == VLNK) { + struct iovec aiov; + struct uio auio; + char *buf; + + buf = malloc(PATH_MAX, M_JOURNAL, M_WAITOK); + aiov.iov_base = buf; + aiov.iov_len = PATH_MAX; + auio.uio_iov = &aiov; + auio.uio_iovcnt = 1; + auio.uio_offset = 0; + auio.uio_rw = UIO_READ; + auio.uio_segflg = UIO_SYSSPACE; + auio.uio_td = curthread; + auio.uio_resid = PATH_MAX; + error = VOP_READLINK(vp, &auio, proc0.p_ucred); + if (error == 0) { + jrecord_leaf(jrec, JLEAF_SYMLINKDATA, buf, + PATH_MAX - auio.uio_resid); + } + free(buf, M_JOURNAL); + } done: if (error) jrecord_leaf(jrec, JLEAF_ERROR, &error, sizeof(error)); diff --git a/sys/kern/vfs_journal.c b/sys/kern/vfs_journal.c index 63b5395f25..0934cbde3b 100644 --- a/sys/kern/vfs_journal.c +++ b/sys/kern/vfs_journal.c @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/kern/vfs_journal.c,v 1.19 2005/08/24 20:28:31 dillon Exp $ + * $DragonFly: src/sys/kern/vfs_journal.c,v 1.20 2005/08/24 21:14:21 dillon Exp $ */ /* * Each mount point may have zero or more independantly configured journals @@ -2040,7 +2040,7 @@ jrecord_undo_file(struct jrecord *jrec, struct vnode *vp, int jrflags, * with a link count > 1. The undo code needs to locate the inode and * regenerate the hardlink. */ - if (jrflags & JRUNDO_FILEDATA) { + if ((jrflags & JRUNDO_FILEDATA) && attr.va_type == VREG) { if (attr.va_size != VNOVAL) { if (bytes == -1) bytes = attr.va_size - off; @@ -2052,6 +2052,28 @@ jrecord_undo_file(struct jrecord *jrec, struct vnode *vp, int jrflags, error = EINVAL; } } + if ((jrflags & JRUNDO_FILEDATA) && attr.va_type == VLNK) { + struct iovec aiov; + struct uio auio; + char *buf; + + buf = malloc(PATH_MAX, M_JOURNAL, M_WAITOK); + aiov.iov_base = buf; + aiov.iov_len = PATH_MAX; + auio.uio_iov = &aiov; + auio.uio_iovcnt = 1; + auio.uio_offset = 0; + auio.uio_rw = UIO_READ; + auio.uio_segflg = UIO_SYSSPACE; + auio.uio_td = curthread; + auio.uio_resid = PATH_MAX; + error = VOP_READLINK(vp, &auio, proc0.p_ucred); + if (error == 0) { + jrecord_leaf(jrec, JLEAF_SYMLINKDATA, buf, + PATH_MAX - auio.uio_resid); + } + free(buf, M_JOURNAL); + } done: if (error) jrecord_leaf(jrec, JLEAF_ERROR, &error, sizeof(error));