Deleted Added
full compact
ext2_vfsops.c (71576) ext2_vfsops.c (71699)
1/*
2 * modified for EXT2FS support in Lites 1.1
3 *
4 * Aug 1995, Godmar Back (gback@cs.utah.edu)
5 * University of Utah, Department of Computer Science
6 */
7/*
8 * Copyright (c) 1989, 1991, 1993, 1994

--- 23 unchanged lines hidden (view full) ---

32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 *
39 * @(#)ffs_vfsops.c 8.8 (Berkeley) 4/18/94
1/*
2 * modified for EXT2FS support in Lites 1.1
3 *
4 * Aug 1995, Godmar Back (gback@cs.utah.edu)
5 * University of Utah, Department of Computer Science
6 */
7/*
8 * Copyright (c) 1989, 1991, 1993, 1994

--- 23 unchanged lines hidden (view full) ---

32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 *
39 * @(#)ffs_vfsops.c 8.8 (Berkeley) 4/18/94
40 * $FreeBSD: head/sys/gnu/fs/ext2fs/ext2_vfsops.c 71576 2001-01-24 12:35:55Z jasone $
40 * $FreeBSD: head/sys/gnu/fs/ext2fs/ext2_vfsops.c 71699 2001-01-27 00:01:31Z jhb $
41 */
42
43#include "opt_quota.h"
44
45#include <sys/param.h>
46#include <sys/systm.h>
47#include <sys/namei.h>
48#include <sys/proc.h>

--- 133 unchanged lines hidden (view full) ---

182 char *path;
183 caddr_t data; /* this is actually a (struct ufs_args *) */
184 struct nameidata *ndp;
185 struct proc *p;
186{
187 struct vnode *devvp;
188 struct ufs_args args;
189 struct ufsmount *ump = 0;
41 */
42
43#include "opt_quota.h"
44
45#include <sys/param.h>
46#include <sys/systm.h>
47#include <sys/namei.h>
48#include <sys/proc.h>

--- 133 unchanged lines hidden (view full) ---

182 char *path;
183 caddr_t data; /* this is actually a (struct ufs_args *) */
184 struct nameidata *ndp;
185 struct proc *p;
186{
187 struct vnode *devvp;
188 struct ufs_args args;
189 struct ufsmount *ump = 0;
190 struct ucred *uc;
191 register struct ext2_sb_info *fs;
192 size_t size;
193 int error, flags;
194 mode_t accessmode;
195
196 if ((error = copyin(data, (caddr_t)&args, sizeof (struct ufs_args))) != 0)
197 return (error);
198 /*

--- 28 unchanged lines hidden (view full) ---

227 return (EPERM);
228 if (fs->s_rd_only && (mp->mnt_kern_flag & MNTK_WANTRDWR)) {
229 /*
230 * If upgrade to read-write by non-root, then verify
231 * that user has necessary permissions on the device.
232 */
233 if (suser(p)) {
234 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);
190 register struct ext2_sb_info *fs;
191 size_t size;
192 int error, flags;
193 mode_t accessmode;
194
195 if ((error = copyin(data, (caddr_t)&args, sizeof (struct ufs_args))) != 0)
196 return (error);
197 /*

--- 28 unchanged lines hidden (view full) ---

226 return (EPERM);
227 if (fs->s_rd_only && (mp->mnt_kern_flag & MNTK_WANTRDWR)) {
228 /*
229 * If upgrade to read-write by non-root, then verify
230 * that user has necessary permissions on the device.
231 */
232 if (suser(p)) {
233 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);
235 PROC_LOCK(p);
236 uc = p->p_ucred;
237 crhold(uc);
238 PROC_UNLOCK(p);
239 if ((error = VOP_ACCESS(devvp, VREAD | VWRITE,
234 if ((error = VOP_ACCESS(devvp, VREAD | VWRITE,
240 uc, p)) != 0) {
241 crfree(uc);
235 p->p_ucred, p)) != 0) {
242 VOP_UNLOCK(devvp, 0, p);
243 return (error);
244 }
236 VOP_UNLOCK(devvp, 0, p);
237 return (error);
238 }
245 crfree(uc);
246 VOP_UNLOCK(devvp, 0, p);
247 }
248
249 if ((fs->s_es->s_state & EXT2_VALID_FS) == 0 ||
250 (fs->s_es->s_state & EXT2_ERROR_FS)) {
251 if (mp->mnt_flag & MNT_FORCE) {
252 printf(
253"WARNING: %s was not properly dismounted\n",

--- 35 unchanged lines hidden (view full) ---

289 * If mount by non-root, then verify that user has necessary
290 * permissions on the device.
291 */
292 if (suser(p)) {
293 accessmode = VREAD;
294 if ((mp->mnt_flag & MNT_RDONLY) == 0)
295 accessmode |= VWRITE;
296 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);
239 VOP_UNLOCK(devvp, 0, p);
240 }
241
242 if ((fs->s_es->s_state & EXT2_VALID_FS) == 0 ||
243 (fs->s_es->s_state & EXT2_ERROR_FS)) {
244 if (mp->mnt_flag & MNT_FORCE) {
245 printf(
246"WARNING: %s was not properly dismounted\n",

--- 35 unchanged lines hidden (view full) ---

282 * If mount by non-root, then verify that user has necessary
283 * permissions on the device.
284 */
285 if (suser(p)) {
286 accessmode = VREAD;
287 if ((mp->mnt_flag & MNT_RDONLY) == 0)
288 accessmode |= VWRITE;
289 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);
297 PROC_LOCK(p);
298 uc = p->p_ucred;
299 crhold(uc);
300 PROC_UNLOCK(p);
301 if ((error = VOP_ACCESS(devvp, accessmode, uc, p)) != 0) {
302 crfree(uc);
290 if ((error = VOP_ACCESS(devvp, accessmode, p->p_ucred, p)) != 0) {
303 vput(devvp);
304 return (error);
305 }
291 vput(devvp);
292 return (error);
293 }
306 crfree(uc);
307 VOP_UNLOCK(devvp, 0, p);
308 }
309
310 if ((mp->mnt_flag & MNT_UPDATE) == 0) {
311 error = ext2_mountfs(devvp, mp, p);
312 } else {
313 if (devvp != ump->um_devvp)
314 error = EINVAL; /* needs translation */

--- 309 unchanged lines hidden (view full) ---

624static int
625ext2_mountfs(devvp, mp, p)
626 register struct vnode *devvp;
627 struct mount *mp;
628 struct proc *p;
629{
630 register struct ufsmount *ump;
631 struct buf *bp;
294 VOP_UNLOCK(devvp, 0, p);
295 }
296
297 if ((mp->mnt_flag & MNT_UPDATE) == 0) {
298 error = ext2_mountfs(devvp, mp, p);
299 } else {
300 if (devvp != ump->um_devvp)
301 error = EINVAL; /* needs translation */

--- 309 unchanged lines hidden (view full) ---

611static int
612ext2_mountfs(devvp, mp, p)
613 register struct vnode *devvp;
614 struct mount *mp;
615 struct proc *p;
616{
617 register struct ufsmount *ump;
618 struct buf *bp;
632 struct ucred *uc;
633 register struct ext2_sb_info *fs;
634 struct ext2_super_block * es;
635 dev_t dev = devvp->v_rdev;
636 struct partinfo dpart;
637 int havepart = 0;
638 int error, i, size;
639 int ronly;
640
641 /*
642 * Disallow multiple mounts of the same device.
643 * Disallow mounting of a device that is currently in use
644 * (except for root, which might share swap device for miniroot).
645 * Flush out any old buffers remaining from a previous use.
646 */
647 if ((error = vfs_mountedon(devvp)) != 0)
648 return (error);
649 if (vcount(devvp) > 1 && devvp != rootvp)
650 return (EBUSY);
619 register struct ext2_sb_info *fs;
620 struct ext2_super_block * es;
621 dev_t dev = devvp->v_rdev;
622 struct partinfo dpart;
623 int havepart = 0;
624 int error, i, size;
625 int ronly;
626
627 /*
628 * Disallow multiple mounts of the same device.
629 * Disallow mounting of a device that is currently in use
630 * (except for root, which might share swap device for miniroot).
631 * Flush out any old buffers remaining from a previous use.
632 */
633 if ((error = vfs_mountedon(devvp)) != 0)
634 return (error);
635 if (vcount(devvp) > 1 && devvp != rootvp)
636 return (EBUSY);
651 PROC_LOCK(p);
652 uc = p->p_ucred;
653 crhold(uc);
654 PROC_UNLOCK(p);
655 if ((error = vinvalbuf(devvp, V_SAVE, uc, p, 0, 0)) != 0) {
656 crfree(uc);
637 if ((error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0)) != 0)
657 return (error);
638 return (error);
658 }
659 crfree(uc);
660#ifdef READONLY
661/* turn on this to force it to be read-only */
662 mp->mnt_flag |= MNT_RDONLY;
663#endif
664
665 ronly = (mp->mnt_flag & MNT_RDONLY) != 0;
666 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);
667 error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, p);

--- 557 unchanged lines hidden ---
639#ifdef READONLY
640/* turn on this to force it to be read-only */
641 mp->mnt_flag |= MNT_RDONLY;
642#endif
643
644 ronly = (mp->mnt_flag & MNT_RDONLY) != 0;
645 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);
646 error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, p);

--- 557 unchanged lines hidden ---