summaryrefslogtreecommitdiffstats
path: root/sys/fs/msdosfs
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>2002-08-25 01:08:27 +0000
committerbde <bde@FreeBSD.org>2002-08-25 01:08:27 +0000
commit53d26ca284b05ed4c4198c9b1c688c6b53edac48 (patch)
tree0011c769bf506c700a4c48c54a27061943c766d8 /sys/fs/msdosfs
parentf564aa3816f438c5c77be284e0e86883220fa4fd (diff)
downloadFreeBSD-src-53d26ca284b05ed4c4198c9b1c688c6b53edac48.zip
FreeBSD-src-53d26ca284b05ed4c4198c9b1c688c6b53edac48.tar.gz
Fixed printf format errors and style bugs in previous commit.
Diffstat (limited to 'sys/fs/msdosfs')
-rw-r--r--sys/fs/msdosfs/msdosfs_vfsops.c87
1 files changed, 78 insertions, 9 deletions
diff --git a/sys/fs/msdosfs/msdosfs_vfsops.c b/sys/fs/msdosfs/msdosfs_vfsops.c
index cf68ec1..aca1604 100644
--- a/sys/fs/msdosfs/msdosfs_vfsops.c
+++ b/sys/fs/msdosfs/msdosfs_vfsops.c
@@ -51,6 +51,8 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/conf.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
#include <sys/namei.h>
#include <sys/proc.h>
#include <sys/kernel.h>
@@ -61,7 +63,6 @@
#include <sys/fcntl.h>
#include <sys/malloc.h>
#include <sys/stat.h> /* defines ALLPERMS */
-#include <sys/mutex.h>
#include <fs/msdosfs/bpb.h>
#include <fs/msdosfs/bootsect.h>
@@ -70,8 +71,6 @@
#include <fs/msdosfs/msdosfsmount.h>
#include <fs/msdosfs/fat.h>
-#define MSDOSFS_DFLTBSIZE 4096
-
#if 1 /*def PC98*/
/*
* XXX - The boot signature formatted by NEC PC-98 DOS looks like a
@@ -86,6 +85,8 @@
MALLOC_DEFINE(M_MSDOSFSMNT, "MSDOSFS mount", "MSDOSFS mount structure");
static MALLOC_DEFINE(M_MSDOSFSFAT, "MSDOSFS FAT", "MSDOSFS file allocation table");
+int bdemsd = 0;
+
static int update_mp(struct mount *mp, struct msdosfs_args *argp);
static int mountmsdosfs(struct vnode *devvp, struct mount *mp,
struct thread *td, struct msdosfs_args *argp);
@@ -142,6 +143,67 @@ update_mp(mp, argp)
return 0;
}
+#if 0
+int
+msdosfs_mountroot()
+{
+ register struct mount *mp;
+ struct thread *td = curthread; /* XXX */
+ size_t size;
+ int error;
+ struct msdosfs_args args;
+
+ if (root_device->dv_class != DV_DISK)
+ return (ENODEV);
+
+ /*
+ * Get vnodes for swapdev and rootdev.
+ */
+ if (bdevvp(rootdev, &rootvp))
+ panic("msdosfs_mountroot: can't setup rootvp");
+
+ mp = malloc((u_long)sizeof(struct mount), M_MOUNT, M_WAITOK | M_ZERO);
+ mp->mnt_op = &msdosfs_vfsops;
+ mp->mnt_flag = 0;
+ TAILQ_INIT(&mp->mnt_nvnodelist);
+ TAILQ_INIT(&mp->mnt_reservedvnlist);
+
+ args.flags = 0;
+ args.uid = 0;
+ args.gid = 0;
+ args.mask = 0777;
+
+ if ((error = mountmsdosfs(rootvp, mp, p, &args)) != 0) {
+ free(mp, M_MOUNT);
+ return (error);
+ }
+
+ if ((error = update_mp(mp, &args)) != 0) {
+ (void)msdosfs_unmount(mp, 0, td);
+ free(mp, M_MOUNT);
+ return (error);
+ }
+
+ if ((error = vfs_lock(mp)) != 0) {
+ (void)msdosfs_unmount(mp, 0, td);
+ free(mp, M_MOUNT);
+ return (error);
+ }
+
+ TAILQ_INSERT_TAIL(&mountlist, mp, mnt_list);
+ mp->mnt_vnodecovered = NULLVP;
+ (void) copystr("/", mp->mnt_stat.f_mntonname, MNAMELEN - 1,
+ &size);
+ bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size);
+ (void) copystr(ROOTNAME, mp->mnt_stat.f_mntfromname, MNAMELEN - 1,
+ &size);
+ bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
+ (void)msdosfs_statfs(mp, &mp->mnt_stat, td);
+ vfs_unlock(mp);
+ return (0);
+}
+#endif
+
/*
* mp - path - addr in user space of mount point (ie /usr or whatever)
* data - addr in user space of mount params including the name of the block
@@ -330,9 +392,9 @@ mountmsdosfs(devvp, mp, td, argp)
* Read the boot sector of the filesystem, and then check the
* boot signature. If not a dos boot sector then error out.
*
- * NOTE: 2048 is a maximum sector size in current...
+ * NOTE: 8192 is a magic size that works for ffs.
*/
- error = bread(devvp, 0, 2048, NOCRED, &bp);
+ error = bread(devvp, 0, 8192, NOCRED, &bp);
if (error)
goto error_exit;
bp->b_flags |= B_AGE;
@@ -493,7 +555,7 @@ mountmsdosfs(devvp, mp, td, argp)
if (FAT12(pmp))
pmp->pm_fatblocksize = 3 * pmp->pm_BytesPerSec;
else
- pmp->pm_fatblocksize = MSDOSFS_DFLTBSIZE;
+ pmp->pm_fatblocksize = PAGE_SIZE; /* XXX */
pmp->pm_fatblocksec = pmp->pm_fatblocksize / DEV_BSIZE;
pmp->pm_bnshift = ffs(DEV_BSIZE) - 1;
@@ -546,8 +608,9 @@ mountmsdosfs(devvp, mp, td, argp)
* Check and validate (or perhaps invalidate?) the fsinfo structure?
*/
if (pmp->pm_fsinfo && pmp->pm_nxtfree > pmp->pm_maxcluster) {
- printf("Next free cluster in FSInfo (%u) exceeds maxcluster (%u)\n",
- pmp->pm_nxtfree, pmp->pm_maxcluster);
+ printf(
+ "Next free cluster in FSInfo (%lu) exceeds maxcluster (%lu)\n",
+ pmp->pm_nxtfree, pmp->pm_maxcluster);
error = EINVAL;
goto error_exit;
}
@@ -751,7 +814,7 @@ loop:
if (vp->v_type == VNON ||
((dep->de_flag &
(DE_ACCESS | DE_CREATE | DE_UPDATE | DE_MODIFIED)) == 0 &&
- (TAILQ_EMPTY(&vp->v_dirtyblkhd) || waitfor == MNT_LAZY))) {
+ TAILQ_EMPTY(&vp->v_dirtyblkhd))) {
mtx_unlock(&vp->v_interlock);
mtx_lock(&mntvnode_mtx);
continue;
@@ -777,6 +840,12 @@ loop:
*/
if (waitfor != MNT_LAZY) {
vn_lock(pmp->pm_devvp, LK_EXCLUSIVE | LK_RETRY, td);
+ if (!TAILQ_EMPTY(&pmp->pm_devvp->v_dirtyblkhd)) {
+ if (bdemsd)
+ Debugger("msdosfs: flush fs control info");
+ else
+ printf("msdosfs: flush fs control info\n");
+ }
error = VOP_FSYNC(pmp->pm_devvp, cred, waitfor, td);
if (error)
allerror = error;
OpenPOWER on IntegriCloud