Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Replace individual queries for partition information with
details: https://anonhg.NetBSD.org/src/rev/0c5983fabe27
branches: trunk
changeset: 751294:0c5983fabe27
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Sun Jan 31 10:30:40 2010 +0000
description:
Replace individual queries for partition information with
new helper function.
diffstat:
sys/fs/msdosfs/msdosfs_vfsops.c | 50 ++++++++--------------------------------
sys/ufs/ext2fs/ext2fs_vfsops.c | 34 ++++++++++++++-------------
2 files changed, 28 insertions(+), 56 deletions(-)
diffs (166 lines):
diff -r 3e6575d91157 -r 0c5983fabe27 sys/fs/msdosfs/msdosfs_vfsops.c
--- a/sys/fs/msdosfs/msdosfs_vfsops.c Sun Jan 31 09:27:40 2010 +0000
+++ b/sys/fs/msdosfs/msdosfs_vfsops.c Sun Jan 31 10:30:40 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msdosfs_vfsops.c,v 1.78 2010/01/26 21:29:48 mlelstv Exp $ */
+/* $NetBSD: msdosfs_vfsops.c,v 1.79 2010/01/31 10:30:40 mlelstv Exp $ */
/*-
* Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.78 2010/01/26 21:29:48 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.79 2010/01/31 10:30:40 mlelstv Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
@@ -464,15 +464,15 @@
struct msdosfsmount *pmp;
struct buf *bp;
dev_t dev = devvp->v_rdev;
- struct partinfo dpart;
union bootsector *bsp;
struct byte_bpb33 *b33;
struct byte_bpb50 *b50;
struct byte_bpb710 *b710;
- u_int8_t SecPerClust;
+ uint8_t SecPerClust;
int ronly, error, tmp;
- int bsize, secsize;
- u_int64_t psize;
+ int bsize;
+ uint64_t psize;
+ unsigned secsize;
/* Flush out any old buffers remaining from a previous use. */
if ((error = vinvalbuf(devvp, V_SAVE, l->l_cred, l, 0, 0)) != 0)
@@ -483,40 +483,10 @@
bp = NULL; /* both used in error_exit */
pmp = NULL;
- /*
- * We need the disklabel to calculate the size of a FAT entry
- * later on.
- *
- * There might still be parts of the msdos fs driver which assume
- * that the size of a disk block will always be 512 bytes.
- * Let's root them out...
- */
- error = VOP_IOCTL(devvp, DIOCGPART, &dpart, FREAD, NOCRED);
- if (error == 0) {
- secsize = dpart.disklab->d_secsize;
- psize = dpart.part->p_size;
- } else {
- struct dkwedge_info dkw;
- struct disk *pdk;
- error = VOP_IOCTL(devvp, DIOCGWEDGEINFO, &dkw, FREAD, NOCRED);
- secsize = 512; /* XXX */
- psize = -1;
- if (error) {
- if (error != ENOTTY) {
- DPRINTF(("Error getting partition info %d\n",
- error));
- goto error_exit;
- }
- } else {
- pdk = disk_find(dkw.dkw_parent);
- if (pdk == NULL) {
- error = ENODEV;
- goto error_exit;
- }
- secsize = DEV_BSIZE << pdk->dk_blkshift;
- psize = dkw.dkw_size;
- }
- }
+ error = getdisksize(devvp, &psize, &secsize);
+ if (error)
+ goto error_exit;
+
if (argp->flags & MSDOSFSMNT_GEMDOSFS) {
bsize = secsize;
if (bsize != 512) {
diff -r 3e6575d91157 -r 0c5983fabe27 sys/ufs/ext2fs/ext2fs_vfsops.c
--- a/sys/ufs/ext2fs/ext2fs_vfsops.c Sun Jan 31 09:27:40 2010 +0000
+++ b/sys/ufs/ext2fs/ext2fs_vfsops.c Sun Jan 31 10:30:40 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ext2fs_vfsops.c,v 1.153 2010/01/08 11:35:11 pooka Exp $ */
+/* $NetBSD: ext2fs_vfsops.c,v 1.154 2010/01/31 10:36:20 mlelstv Exp $ */
/*
* Copyright (c) 1989, 1991, 1993, 1994
@@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.153 2010/01/08 11:35:11 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.154 2010/01/31 10:36:20 mlelstv Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
@@ -521,8 +521,9 @@
struct buf *bp;
struct m_ext2fs *fs;
struct ext2fs *newfs;
- struct partinfo dpart;
- int i, size, error;
+ int i, error;
+ uint64_t numsecs;
+ unsigned secsize;
void *cp;
struct ufsmount *ump;
@@ -542,11 +543,12 @@
/*
* Step 2: re-read superblock from disk.
*/
- if (VOP_IOCTL(devvp, DIOCGPART, &dpart, FREAD, NOCRED) != 0)
- size = DEV_BSIZE;
- else
- size = dpart.disklab->d_secsize;
- error = bread(devvp, (daddr_t)(SBOFF / size), SBSIZE, NOCRED, 0, &bp);
+ error = getdisksize(devvp, &numsecs, &secsize);
+ if (error) {
+ brelse(bp, 0);
+ return (error);
+ }
+ error = bread(devvp, (daddr_t)(SBOFF / secsize), SBSIZE, NOCRED, 0, &bp);
if (error) {
brelse(bp, 0);
return (error);
@@ -667,8 +669,9 @@
struct ext2fs *fs;
struct m_ext2fs *m_fs;
dev_t dev;
- struct partinfo dpart;
- int error, i, size, ronly;
+ int error, i, ronly;
+ uint64_t numsecs;
+ unsigned secsize;
kauth_cred_t cred;
struct proc *p;
@@ -684,10 +687,9 @@
return (error);
ronly = (mp->mnt_flag & MNT_RDONLY) != 0;
- if (VOP_IOCTL(devvp, DIOCGPART, &dpart, FREAD, cred) != 0)
- size = DEV_BSIZE;
- else
- size = dpart.disklab->d_secsize;
+ error = getdisksize(devvp, &numsecs, &secsize);
+ if (error)
+ return (error);
bp = NULL;
ump = NULL;
@@ -695,7 +697,7 @@
#ifdef DEBUG_EXT2
printf("ext2 sb size: %d\n", sizeof(struct ext2fs));
#endif
- error = bread(devvp, (SBOFF / size), SBSIZE, cred, 0, &bp);
+ error = bread(devvp, (SBOFF / secsize), SBSIZE, cred, 0, &bp);
if (error)
goto out;
fs = (struct ext2fs *)bp->b_data;
Home |
Main Index |
Thread Index |
Old Index