| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: vnd.c,v 1.186 2008/07/19 13:58:08 kardel Exp $ */ | | 1 | /* $NetBSD: vnd.c,v 1.187 2008/09/24 07:57:30 ad Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Jason R. Thorpe. | | 8 | * by Jason R. Thorpe. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -120,27 +120,27 @@ | | | @@ -120,27 +120,27 @@ |
120 | * systems where the block-level operations are not implemented for | | 120 | * systems where the block-level operations are not implemented for |
121 | * whatever reason. | | 121 | * whatever reason. |
122 | * | | 122 | * |
123 | * NOTE 2: There is a security issue involved with this driver. | | 123 | * NOTE 2: There is a security issue involved with this driver. |
124 | * Once mounted all access to the contents of the "mapped" file via | | 124 | * Once mounted all access to the contents of the "mapped" file via |
125 | * the special file is controlled by the permissions on the special | | 125 | * the special file is controlled by the permissions on the special |
126 | * file, the protection of the mapped file is ignored (effectively, | | 126 | * file, the protection of the mapped file is ignored (effectively, |
127 | * by using root credentials in all transactions). | | 127 | * by using root credentials in all transactions). |
128 | * | | 128 | * |
129 | * NOTE 3: Doesn't interact with leases, should it? | | 129 | * NOTE 3: Doesn't interact with leases, should it? |
130 | */ | | 130 | */ |
131 | | | 131 | |
132 | #include <sys/cdefs.h> | | 132 | #include <sys/cdefs.h> |
133 | __KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.186 2008/07/19 13:58:08 kardel Exp $"); | | 133 | __KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.187 2008/09/24 07:57:30 ad Exp $"); |
134 | | | 134 | |
135 | #if defined(_KERNEL_OPT) | | 135 | #if defined(_KERNEL_OPT) |
136 | #include "fs_nfs.h" | | 136 | #include "fs_nfs.h" |
137 | #include "opt_vnd.h" | | 137 | #include "opt_vnd.h" |
138 | #endif | | 138 | #endif |
139 | | | 139 | |
140 | #include <sys/param.h> | | 140 | #include <sys/param.h> |
141 | #include <sys/systm.h> | | 141 | #include <sys/systm.h> |
142 | #include <sys/namei.h> | | 142 | #include <sys/namei.h> |
143 | #include <sys/proc.h> | | 143 | #include <sys/proc.h> |
144 | #include <sys/kthread.h> | | 144 | #include <sys/kthread.h> |
145 | #include <sys/errno.h> | | 145 | #include <sys/errno.h> |
146 | #include <sys/buf.h> | | 146 | #include <sys/buf.h> |
| @@ -1786,27 +1786,28 @@ compstrategy(struct buf *bp, off_t bn) | | | @@ -1786,27 +1786,28 @@ compstrategy(struct buf *bp, off_t bn) |
1786 | if (comp_block >= vnd->sc_comp_numoffs) { | | 1786 | if (comp_block >= vnd->sc_comp_numoffs) { |
1787 | bp->b_error = EINVAL; | | 1787 | bp->b_error = EINVAL; |
1788 | splx(s); | | 1788 | splx(s); |
1789 | return; | | 1789 | return; |
1790 | } | | 1790 | } |
1791 | | | 1791 | |
1792 | /* read in the compressed block, if not in buffer */ | | 1792 | /* read in the compressed block, if not in buffer */ |
1793 | if (comp_block != vnd->sc_comp_buffblk) { | | 1793 | if (comp_block != vnd->sc_comp_buffblk) { |
1794 | length = vnd->sc_comp_offsets[comp_block + 1] - | | 1794 | length = vnd->sc_comp_offsets[comp_block + 1] - |
1795 | vnd->sc_comp_offsets[comp_block]; | | 1795 | vnd->sc_comp_offsets[comp_block]; |
1796 | vn_lock(vnd->sc_vp, LK_EXCLUSIVE | LK_RETRY); | | 1796 | vn_lock(vnd->sc_vp, LK_EXCLUSIVE | LK_RETRY); |
1797 | error = vn_rdwr(UIO_READ, vnd->sc_vp, vnd->sc_comp_buff, | | 1797 | error = vn_rdwr(UIO_READ, vnd->sc_vp, vnd->sc_comp_buff, |
1798 | length, vnd->sc_comp_offsets[comp_block], | | 1798 | length, vnd->sc_comp_offsets[comp_block], |
1799 | UIO_SYSSPACE, IO_UNIT, vnd->sc_cred, NULL, NULL); | | 1799 | UIO_SYSSPACE, IO_NODELOCKED|IO_UNIT, vnd->sc_cred, |
| | | 1800 | NULL, NULL); |
1800 | if (error) { | | 1801 | if (error) { |
1801 | bp->b_error = error; | | 1802 | bp->b_error = error; |
1802 | VOP_UNLOCK(vnd->sc_vp, 0); | | 1803 | VOP_UNLOCK(vnd->sc_vp, 0); |
1803 | splx(s); | | 1804 | splx(s); |
1804 | return; | | 1805 | return; |
1805 | } | | 1806 | } |
1806 | /* uncompress the buffer */ | | 1807 | /* uncompress the buffer */ |
1807 | vnd->sc_comp_stream.next_in = vnd->sc_comp_buff; | | 1808 | vnd->sc_comp_stream.next_in = vnd->sc_comp_buff; |
1808 | vnd->sc_comp_stream.avail_in = length; | | 1809 | vnd->sc_comp_stream.avail_in = length; |
1809 | vnd->sc_comp_stream.next_out = vnd->sc_comp_decombuf; | | 1810 | vnd->sc_comp_stream.next_out = vnd->sc_comp_decombuf; |
1810 | vnd->sc_comp_stream.avail_out = vnd->sc_comp_blksz; | | 1811 | vnd->sc_comp_stream.avail_out = vnd->sc_comp_blksz; |
1811 | inflateReset(&vnd->sc_comp_stream); | | 1812 | inflateReset(&vnd->sc_comp_stream); |
1812 | error = inflate(&vnd->sc_comp_stream, Z_FINISH); | | 1813 | error = inflate(&vnd->sc_comp_stream, Z_FINISH); |