- sys/msdosfs moved to sys/fs/msdosfs
- msdos.ko renamed to msdosfs.ko - /usr/include/msdosfs moved to /usr/include/fs/msdosfs
This commit is contained in:
parent
74c5a70065
commit
6662aea4f0
@ -743,7 +743,11 @@ struct sockaddr_dl;
|
||||
*/
|
||||
#ifdef HAVE_MSDOSFS_MSDOSFSMOUNT_H
|
||||
# include <msdosfs/msdosfsmount.h>
|
||||
#endif /* HAVE_MSDOSFS_MSDOSFSMOUNT_H */
|
||||
#else /* not HAVE_MSDOSFS_MSDOSFSMOUNT_H */
|
||||
# ifdef HAVE_FS_MSDOSFS_MSDOSFSMOUNT_H
|
||||
# include <fs/msdosfs/msdosfsmount.h>
|
||||
# endif /* HAVE_FS_MSDOSFS_MSDOSFSMOUNT_H */
|
||||
#endif /* not HAVE_MSDOSFS_MSDOSFSMOUNT_H */
|
||||
|
||||
/*
|
||||
* Actions to take if <sys/fs/tmp.h> exists.
|
||||
|
@ -24,6 +24,8 @@
|
||||
..
|
||||
fifofs
|
||||
..
|
||||
msdosfs
|
||||
..
|
||||
nullfs
|
||||
..
|
||||
portalfs
|
||||
@ -49,8 +51,6 @@
|
||||
..
|
||||
machine
|
||||
..
|
||||
msdosfs
|
||||
..
|
||||
net
|
||||
..
|
||||
netatalk
|
||||
|
@ -39,15 +39,16 @@ SFILES= soundcard.h joystick.h
|
||||
LFILES= aio.h errno.h fcntl.h inttypes.h linker_set.h poll.h syslog.h \
|
||||
termios.h ucontext.h
|
||||
|
||||
LDIRS= cam msdosfs net netatalk netatm netgraph netinet netinet6 \
|
||||
LDIRS= cam net netatalk netatm netgraph netinet netinet6 \
|
||||
netipx netkey netnatm netncp netns netsmb nfs ntfs nwfs pccard posix4 \
|
||||
sys vm
|
||||
|
||||
LNOHEADERDIRS= fs isofs ufs dev
|
||||
|
||||
LSUBDIRS= cam/scsi dev/ppbus dev/usb dev/wi \
|
||||
fs/fdescfs fs/fifofs fs/nullfs fs/portalfs fs/procfs fs/smbfs \
|
||||
fs/umapfs fs/unionfs isofs/cd9660 ufs/ffs ufs/mfs ufs/ufs
|
||||
fs/fdescfs fs/fifofs fs/msdosfs fs/nullfs fs/portalfs \
|
||||
fs/procfs fs/smbfs fs/umapfs fs/unionfs isofs/cd9660 \
|
||||
ufs/ffs ufs/mfs ufs/ufs
|
||||
|
||||
# For SHARED=symlinks, cam is a symlink, so cam/scsi is taken care of
|
||||
LSYMSUBDIRS= ${LSUBDIRS:Ncam/scsi}
|
||||
|
@ -39,7 +39,7 @@ static const char rcsid[] =
|
||||
#include <sys/mount.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <msdosfs/msdosfsmount.h>
|
||||
#include <fs/msdosfs/msdosfsmount.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
|
@ -39,7 +39,7 @@ static const char rcsid[] =
|
||||
#include <sys/mount.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <msdosfs/msdosfsmount.h>
|
||||
#include <fs/msdosfs/msdosfsmount.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
|
@ -63,7 +63,7 @@ static const char rcsid[] =
|
||||
#include <nfs/nfsproto.h>
|
||||
#include <nfs/nfs.h>
|
||||
#include <ufs/ufs/ufsmount.h>
|
||||
#include <msdosfs/msdosfsmount.h>
|
||||
#include <fs/msdosfs/msdosfsmount.h>
|
||||
#include <ntfs/ntfsmount.h>
|
||||
#include <isofs/cd9660/cd9660_mount.h> /* XXX need isofs in include */
|
||||
|
||||
|
@ -179,6 +179,8 @@ per-process file descriptors file system
|
||||
.It Pa fifofs/
|
||||
.St -p1003.1
|
||||
FIFOs file system
|
||||
.It Pa msdosfs/
|
||||
MS-DOS file system
|
||||
.It Pa nullfs/
|
||||
loopback file system
|
||||
.It Pa portalfs/
|
||||
@ -211,8 +213,6 @@ see
|
||||
.Xr kerberos 1
|
||||
.It Pa machine/
|
||||
machine-specific C include files
|
||||
.It Pa msdosfs/
|
||||
MS-DOS file system
|
||||
.It Pa net/
|
||||
misc network C include files
|
||||
.It Pa netatalk/
|
||||
|
@ -89,7 +89,7 @@ cd9660_load="NO" # ISO 9660 filesystem
|
||||
coda_load="NO" # CODA filesystem
|
||||
fdescfs_load="NO" # Filedescriptors filesystem
|
||||
mfs_load="NO" # Memory filesystem
|
||||
msdos_load="NO" # FAT-12/16/32
|
||||
msdosfs_load="NO" # FAT-12/16/32
|
||||
nfs_load="NO" # NFS
|
||||
ntfs_load="NO" # NTFS
|
||||
nullfs_load="NO" # Null filesystem
|
||||
|
@ -598,6 +598,12 @@ fs/hpfs/hpfs_lookup.c optional hpfs
|
||||
fs/hpfs/hpfs_subr.c optional hpfs
|
||||
fs/hpfs/hpfs_vfsops.c optional hpfs
|
||||
fs/hpfs/hpfs_vnops.c optional hpfs
|
||||
fs/msdosfs/msdosfs_conv.c optional msdosfs
|
||||
fs/msdosfs/msdosfs_denode.c optional msdosfs
|
||||
fs/msdosfs/msdosfs_fat.c optional msdosfs
|
||||
fs/msdosfs/msdosfs_lookup.c optional msdosfs
|
||||
fs/msdosfs/msdosfs_vfsops.c optional msdosfs
|
||||
fs/msdosfs/msdosfs_vnops.c optional msdosfs
|
||||
fs/nullfs/null_subr.c optional nullfs
|
||||
fs/nullfs/null_vfsops.c optional nullfs
|
||||
fs/nullfs/null_vnops.c optional nullfs
|
||||
@ -833,12 +839,6 @@ libkern/strtol.c standard
|
||||
libkern/strtoq.c standard
|
||||
libkern/strtoul.c standard
|
||||
libkern/strtouq.c standard
|
||||
msdosfs/msdosfs_conv.c optional msdosfs
|
||||
msdosfs/msdosfs_denode.c optional msdosfs
|
||||
msdosfs/msdosfs_fat.c optional msdosfs
|
||||
msdosfs/msdosfs_lookup.c optional msdosfs
|
||||
msdosfs/msdosfs_vfsops.c optional msdosfs
|
||||
msdosfs/msdosfs_vnops.c optional msdosfs
|
||||
net/bpf.c standard
|
||||
net/bpf_filter.c optional bpf
|
||||
bpf.h standard \
|
||||
|
@ -61,7 +61,7 @@
|
||||
/*
|
||||
* MSDOSFS include files.
|
||||
*/
|
||||
#include <msdosfs/direntry.h>
|
||||
#include <fs/msdosfs/direntry.h>
|
||||
|
||||
/*
|
||||
* Total number of days that have passed for each month in a regular year.
|
||||
|
@ -61,11 +61,11 @@
|
||||
#include <vm/vm.h>
|
||||
#include <vm/vm_extern.h>
|
||||
|
||||
#include <msdosfs/bpb.h>
|
||||
#include <msdosfs/msdosfsmount.h>
|
||||
#include <msdosfs/direntry.h>
|
||||
#include <msdosfs/denode.h>
|
||||
#include <msdosfs/fat.h>
|
||||
#include <fs/msdosfs/bpb.h>
|
||||
#include <fs/msdosfs/msdosfsmount.h>
|
||||
#include <fs/msdosfs/direntry.h>
|
||||
#include <fs/msdosfs/denode.h>
|
||||
#include <fs/msdosfs/fat.h>
|
||||
|
||||
static MALLOC_DEFINE(M_MSDOSFSNODE, "MSDOSFS node", "MSDOSFS vnode private part");
|
||||
|
||||
|
@ -61,11 +61,11 @@
|
||||
/*
|
||||
* msdosfs include files.
|
||||
*/
|
||||
#include <msdosfs/bpb.h>
|
||||
#include <msdosfs/msdosfsmount.h>
|
||||
#include <msdosfs/direntry.h>
|
||||
#include <msdosfs/denode.h>
|
||||
#include <msdosfs/fat.h>
|
||||
#include <fs/msdosfs/bpb.h>
|
||||
#include <fs/msdosfs/msdosfsmount.h>
|
||||
#include <fs/msdosfs/direntry.h>
|
||||
#include <fs/msdosfs/denode.h>
|
||||
#include <fs/msdosfs/fat.h>
|
||||
|
||||
/*
|
||||
* Fat cache stats.
|
||||
|
@ -56,11 +56,11 @@
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/mount.h>
|
||||
|
||||
#include <msdosfs/bpb.h>
|
||||
#include <msdosfs/direntry.h>
|
||||
#include <msdosfs/denode.h>
|
||||
#include <msdosfs/msdosfsmount.h>
|
||||
#include <msdosfs/fat.h>
|
||||
#include <fs/msdosfs/bpb.h>
|
||||
#include <fs/msdosfs/direntry.h>
|
||||
#include <fs/msdosfs/denode.h>
|
||||
#include <fs/msdosfs/msdosfsmount.h>
|
||||
#include <fs/msdosfs/fat.h>
|
||||
|
||||
/*
|
||||
* When we search a directory the blocks containing directory entries are
|
||||
|
@ -63,12 +63,12 @@
|
||||
#include <sys/stat.h> /* defines ALLPERMS */
|
||||
#include <sys/mutex.h>
|
||||
|
||||
#include <msdosfs/bpb.h>
|
||||
#include <msdosfs/bootsect.h>
|
||||
#include <msdosfs/direntry.h>
|
||||
#include <msdosfs/denode.h>
|
||||
#include <msdosfs/msdosfsmount.h>
|
||||
#include <msdosfs/fat.h>
|
||||
#include <fs/msdosfs/bpb.h>
|
||||
#include <fs/msdosfs/bootsect.h>
|
||||
#include <fs/msdosfs/direntry.h>
|
||||
#include <fs/msdosfs/denode.h>
|
||||
#include <fs/msdosfs/msdosfsmount.h>
|
||||
#include <fs/msdosfs/fat.h>
|
||||
|
||||
#define MSDOSFS_DFLTBSIZE 4096
|
||||
|
||||
|
@ -70,11 +70,11 @@
|
||||
|
||||
#include <machine/mutex.h>
|
||||
|
||||
#include <msdosfs/bpb.h>
|
||||
#include <msdosfs/direntry.h>
|
||||
#include <msdosfs/denode.h>
|
||||
#include <msdosfs/msdosfsmount.h>
|
||||
#include <msdosfs/fat.h>
|
||||
#include <fs/msdosfs/bpb.h>
|
||||
#include <fs/msdosfs/direntry.h>
|
||||
#include <fs/msdosfs/denode.h>
|
||||
#include <fs/msdosfs/msdosfsmount.h>
|
||||
#include <fs/msdosfs/fat.h>
|
||||
|
||||
#define DOS_FILESIZE_MAX 0xffffffff
|
||||
|
||||
|
@ -31,6 +31,7 @@ COMM= ${SYS}/conf/*.[ch] \
|
||||
${SYS}/fs/deadfs/*.[ch] \
|
||||
${SYS}/fs/fdescfs/*.[ch] \
|
||||
${SYS}/fs/fifofs/*.[ch] \
|
||||
${SYS}/fs/msdosfs/*.[ch] \
|
||||
${SYS}/fs/nullfs/*.[ch] \
|
||||
${SYS}/fs/portalfs/*.[ch] \
|
||||
${SYS}/fs/procfs/*.[ch] \
|
||||
@ -39,7 +40,6 @@ COMM= ${SYS}/conf/*.[ch] \
|
||||
${SYS}/fs/unionfs/*.[ch] \
|
||||
${SYS}/isofs/cd9660/*.[ch] \
|
||||
${SYS}/kern/*.[ch] \
|
||||
${SYS}/msdosfs/*.[ch] \
|
||||
${SYS}/net/*.[ch] \
|
||||
${SYS}/netatalk/*.[ch] \
|
||||
${SYS}/netatm/*.[ch] \
|
||||
@ -59,7 +59,6 @@ COMM= ${SYS}/conf/*.[ch] \
|
||||
|
||||
COMMDIR1= ${SYS}/conf \
|
||||
${SYS}/kern \
|
||||
${SYS}/msdosfs \
|
||||
${SYS}/net \
|
||||
${SYS}/netatalk \
|
||||
${SYS}/netatm \
|
||||
@ -95,6 +94,7 @@ COMMDIR2= ${SYS}/dev/advansys \
|
||||
${SYS}/fs/devfs \
|
||||
${SYS}/fs/fdescfs \
|
||||
${SYS}/fs/fifofs \
|
||||
${SYS}/fs/msdosfs \
|
||||
${SYS}/fs/nullfs \
|
||||
${SYS}/fs/portalfs \
|
||||
${SYS}/fs/procfs \
|
||||
|
@ -9,7 +9,7 @@ _random= random
|
||||
SUBDIR= 3dfx accf_data accf_http agp aha amr an aue \
|
||||
cam ccd cd9660 coda cue dc de dgm digi ed fdescfs fxp if_disc if_ef \
|
||||
if_ppp if_sl if_tap if_tun ip6fw ipfilter ipfw ispfw joy kue \
|
||||
libmchain linux lnc md mfs mii mlx msdos ncp netgraph nfs nge ntfs \
|
||||
libmchain linux lnc md mfs mii mlx msdosfs ncp netgraph nfs nge ntfs \
|
||||
nullfs nwfs pcn portalfs procfs ${_random} \
|
||||
rl rp sf sis sk sn snp sound sppp ste sym syscons sysvipc ti tl twe \
|
||||
tx udbp ugen uhid ukbd ulpt umapfs umass umodem ums unionfs urio usb \
|
||||
|
@ -1,15 +0,0 @@
|
||||
# $FreeBSD$
|
||||
|
||||
.PATH: ${.CURDIR}/../../msdosfs
|
||||
|
||||
KMOD= msdos
|
||||
SRCS= vnode_if.h \
|
||||
msdosfs_conv.c msdosfs_denode.c msdosfs_fat.c msdosfs_lookup.c \
|
||||
msdosfs_vfsops.c msdosfs_vnops.c
|
||||
NOMAN=
|
||||
|
||||
.if ${MACHINE} == "pc98"
|
||||
CFLAGS+= -DPC98
|
||||
.endif
|
||||
|
||||
.include <bsd.kmod.mk>
|
@ -1,8 +1,8 @@
|
||||
# $FreeBSD$
|
||||
|
||||
.PATH: ${.CURDIR}/../../msdosfs
|
||||
.PATH: ${.CURDIR}/../../fs/msdosfs
|
||||
|
||||
KMOD= msdos
|
||||
KMOD= msdosfs
|
||||
SRCS= vnode_if.h \
|
||||
msdosfs_conv.c msdosfs_denode.c msdosfs_fat.c msdosfs_lookup.c \
|
||||
msdosfs_vfsops.c msdosfs_vnops.c
|
||||
|
@ -1,113 +0,0 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $NetBSD: bootsect.h,v 1.9 1997/11/17 15:36:17 ws Exp $ */
|
||||
|
||||
/*
|
||||
* Written by Paul Popelka (paulp@uts.amdahl.com)
|
||||
*
|
||||
* You can do anything you want with this software, just don't say you wrote
|
||||
* it, and don't remove this notice.
|
||||
*
|
||||
* This software is provided "as is".
|
||||
*
|
||||
* The author supplies this software to be publicly redistributed on the
|
||||
* understanding that the author is not responsible for the correct
|
||||
* functioning of this software in any circumstances and is not liable for
|
||||
* any damages caused by this software.
|
||||
*
|
||||
* October 1992
|
||||
*/
|
||||
|
||||
/*
|
||||
* Format of a boot sector. This is the first sector on a DOS floppy disk
|
||||
* or the fist sector of a partition on a hard disk. But, it is not the
|
||||
* first sector of a partitioned hard disk.
|
||||
*/
|
||||
struct bootsector33 {
|
||||
u_int8_t bsJump[3]; /* jump inst E9xxxx or EBxx90 */
|
||||
int8_t bsOemName[8]; /* OEM name and version */
|
||||
int8_t bsBPB[19]; /* BIOS parameter block */
|
||||
int8_t bsDriveNumber; /* drive number (0x80) */
|
||||
int8_t bsBootCode[479]; /* pad so struct is 512b */
|
||||
u_int8_t bsBootSectSig0;
|
||||
u_int8_t bsBootSectSig1;
|
||||
#define BOOTSIG0 0x55
|
||||
#define BOOTSIG1 0xaa
|
||||
};
|
||||
|
||||
struct extboot {
|
||||
int8_t exDriveNumber; /* drive number (0x80) */
|
||||
int8_t exReserved1; /* reserved */
|
||||
int8_t exBootSignature; /* ext. boot signature (0x29) */
|
||||
#define EXBOOTSIG 0x29
|
||||
int8_t exVolumeID[4]; /* volume ID number */
|
||||
int8_t exVolumeLabel[11]; /* volume label */
|
||||
int8_t exFileSysType[8]; /* fs type (FAT12 or FAT16) */
|
||||
};
|
||||
|
||||
struct bootsector50 {
|
||||
u_int8_t bsJump[3]; /* jump inst E9xxxx or EBxx90 */
|
||||
int8_t bsOemName[8]; /* OEM name and version */
|
||||
int8_t bsBPB[25]; /* BIOS parameter block */
|
||||
int8_t bsExt[26]; /* Bootsector Extension */
|
||||
int8_t bsBootCode[448]; /* pad so structure is 512b */
|
||||
u_int8_t bsBootSectSig0;
|
||||
u_int8_t bsBootSectSig1;
|
||||
#define BOOTSIG0 0x55
|
||||
#define BOOTSIG1 0xaa
|
||||
};
|
||||
|
||||
struct bootsector710 {
|
||||
u_int8_t bsJump[3]; /* jump inst E9xxxx or EBxx90 */
|
||||
int8_t bsOEMName[8]; /* OEM name and version */
|
||||
int8_t bsPBP[53]; /* BIOS parameter block */
|
||||
int8_t bsExt[26]; /* Bootsector Extension */
|
||||
int8_t bsBootCode[418]; /* pad so structure is 512b */
|
||||
u_int8_t bsBootSectSig2; /* 2 & 3 are only defined for FAT32? */
|
||||
u_int8_t bsBootSectSig3;
|
||||
u_int8_t bsBootSectSig0;
|
||||
u_int8_t bsBootSectSig1;
|
||||
#define BOOTSIG0 0x55
|
||||
#define BOOTSIG1 0xaa
|
||||
#define BOOTSIG2 0
|
||||
#define BOOTSIG3 0
|
||||
};
|
||||
#ifdef atari
|
||||
/*
|
||||
* The boot sector on a gemdos fs is a little bit different from the msdos fs
|
||||
* format. Currently there is no need to declare a separate structure, the
|
||||
* bootsector33 struct will do.
|
||||
*/
|
||||
#if 0
|
||||
struct bootsec_atari {
|
||||
u_int8_t bsBranch[2]; /* branch inst if auto-boot */
|
||||
int8_t bsFiller[6]; /* anything or nothing */
|
||||
int8_t bsSerial[3]; /* serial no. for mediachange */
|
||||
int8_t bsBPB[19]; /* BIOS parameter block */
|
||||
int8_t bsBootCode[482]; /* pad so struct is 512b */
|
||||
};
|
||||
#endif
|
||||
#endif /* atari */
|
||||
|
||||
union bootsector {
|
||||
struct bootsector33 bs33;
|
||||
struct bootsector50 bs50;
|
||||
struct bootsector710 bs710;
|
||||
};
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* Shorthand for fields in the bpb.
|
||||
*/
|
||||
#define bsBytesPerSec bsBPB.bpbBytesPerSec
|
||||
#define bsSectPerClust bsBPB.bpbSectPerClust
|
||||
#define bsResSectors bsBPB.bpbResSectors
|
||||
#define bsFATS bsBPB.bpbFATS
|
||||
#define bsRootDirEnts bsBPB.bpbRootDirEnts
|
||||
#define bsSectors bsBPB.bpbSectors
|
||||
#define bsMedia bsBPB.bpbMedia
|
||||
#define bsFATsecs bsBPB.bpbFATsecs
|
||||
#define bsSectPerTrack bsBPB.bpbSectPerTrack
|
||||
#define bsHeads bsBPB.bpbHeads
|
||||
#define bsHiddenSecs bsBPB.bpbHiddenSecs
|
||||
#define bsHugeSectors bsBPB.bpbHugeSectors
|
||||
#endif
|
@ -1,215 +0,0 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $NetBSD: bpb.h,v 1.7 1997/11/17 15:36:24 ws Exp $ */
|
||||
|
||||
/*
|
||||
* Written by Paul Popelka (paulp@uts.amdahl.com)
|
||||
*
|
||||
* You can do anything you want with this software, just don't say you wrote
|
||||
* it, and don't remove this notice.
|
||||
*
|
||||
* This software is provided "as is".
|
||||
*
|
||||
* The author supplies this software to be publicly redistributed on the
|
||||
* understanding that the author is not responsible for the correct
|
||||
* functioning of this software in any circumstances and is not liable for
|
||||
* any damages caused by this software.
|
||||
*
|
||||
* October 1992
|
||||
*/
|
||||
|
||||
/*
|
||||
* BIOS Parameter Block (BPB) for DOS 3.3
|
||||
*/
|
||||
struct bpb33 {
|
||||
u_int16_t bpbBytesPerSec; /* bytes per sector */
|
||||
u_int8_t bpbSecPerClust; /* sectors per cluster */
|
||||
u_int16_t bpbResSectors; /* number of reserved sectors */
|
||||
u_int8_t bpbFATs; /* number of FATs */
|
||||
u_int16_t bpbRootDirEnts; /* number of root directory entries */
|
||||
u_int16_t bpbSectors; /* total number of sectors */
|
||||
u_int8_t bpbMedia; /* media descriptor */
|
||||
u_int16_t bpbFATsecs; /* number of sectors per FAT */
|
||||
u_int16_t bpbSecPerTrack; /* sectors per track */
|
||||
u_int16_t bpbHeads; /* number of heads */
|
||||
u_int16_t bpbHiddenSecs; /* number of hidden sectors */
|
||||
};
|
||||
|
||||
/*
|
||||
* BPB for DOS 5.0 The difference is bpbHiddenSecs is a short for DOS 3.3,
|
||||
* and bpbHugeSectors is not in the 3.3 bpb.
|
||||
*/
|
||||
struct bpb50 {
|
||||
u_int16_t bpbBytesPerSec; /* bytes per sector */
|
||||
u_int8_t bpbSecPerClust; /* sectors per cluster */
|
||||
u_int16_t bpbResSectors; /* number of reserved sectors */
|
||||
u_int8_t bpbFATs; /* number of FATs */
|
||||
u_int16_t bpbRootDirEnts; /* number of root directory entries */
|
||||
u_int16_t bpbSectors; /* total number of sectors */
|
||||
u_int8_t bpbMedia; /* media descriptor */
|
||||
u_int16_t bpbFATsecs; /* number of sectors per FAT */
|
||||
u_int16_t bpbSecPerTrack; /* sectors per track */
|
||||
u_int16_t bpbHeads; /* number of heads */
|
||||
u_int32_t bpbHiddenSecs; /* # of hidden sectors */
|
||||
u_int32_t bpbHugeSectors; /* # of sectors if bpbSectors == 0 */
|
||||
};
|
||||
|
||||
/*
|
||||
* BPB for DOS 7.10 (FAT32). This one has a few extensions to bpb50.
|
||||
*/
|
||||
struct bpb710 {
|
||||
u_int16_t bpbBytesPerSec; /* bytes per sector */
|
||||
u_int8_t bpbSecPerClust; /* sectors per cluster */
|
||||
u_int16_t bpbResSectors; /* number of reserved sectors */
|
||||
u_int8_t bpbFATs; /* number of FATs */
|
||||
u_int16_t bpbRootDirEnts; /* number of root directory entries */
|
||||
u_int16_t bpbSectors; /* total number of sectors */
|
||||
u_int8_t bpbMedia; /* media descriptor */
|
||||
u_int16_t bpbFATsecs; /* number of sectors per FAT */
|
||||
u_int16_t bpbSecPerTrack; /* sectors per track */
|
||||
u_int16_t bpbHeads; /* number of heads */
|
||||
u_int32_t bpbHiddenSecs; /* # of hidden sectors */
|
||||
u_int32_t bpbHugeSectors; /* # of sectors if bpbSectors == 0 */
|
||||
u_int32_t bpbBigFATsecs; /* like bpbFATsecs for FAT32 */
|
||||
u_int16_t bpbExtFlags; /* extended flags: */
|
||||
#define FATNUM 0xf /* mask for numbering active FAT */
|
||||
#define FATMIRROR 0x80 /* FAT is mirrored (like it always was) */
|
||||
u_int16_t bpbFSVers; /* filesystem version */
|
||||
#define FSVERS 0 /* currently only 0 is understood */
|
||||
u_int32_t bpbRootClust; /* start cluster for root directory */
|
||||
u_int16_t bpbFSInfo; /* filesystem info structure sector */
|
||||
u_int16_t bpbBackup; /* backup boot sector */
|
||||
/* There is a 12 byte filler here, but we ignore it */
|
||||
};
|
||||
|
||||
#ifdef atari
|
||||
/*
|
||||
* BPB for gemdos filesystems. Atari leaves the obsolete stuff undefined.
|
||||
* Currently there is no need for a separate BPB structure.
|
||||
*/
|
||||
#if 0
|
||||
struct bpb_a {
|
||||
u_int16_t bpbBytesPerSec; /* bytes per sector */
|
||||
u_int8_t bpbSecPerClust; /* sectors per cluster */
|
||||
u_int16_t bpbResSectors; /* number of reserved sectors */
|
||||
u_int8_t bpbFATs; /* number of FATs */
|
||||
u_int16_t bpbRootDirEnts; /* number of root directory entries */
|
||||
u_int16_t bpbSectors; /* total number of sectors */
|
||||
u_int8_t bpbUseless1; /* meaningless on gemdos fs */
|
||||
u_int16_t bpbFATsecs; /* number of sectors per FAT */
|
||||
u_int16_t bpbUseless2; /* meaningless for harddisk fs */
|
||||
u_int16_t bpbUseless3; /* meaningless for harddisk fs */
|
||||
u_int16_t bpbHiddenSecs; /* the TOS-BIOS ignores this */
|
||||
};
|
||||
#endif
|
||||
#endif /* atari */
|
||||
|
||||
/*
|
||||
* The following structures represent how the bpb's look on disk. shorts
|
||||
* and longs are just character arrays of the appropriate length. This is
|
||||
* because the compiler forces shorts and longs to align on word or
|
||||
* halfword boundaries.
|
||||
*
|
||||
* XXX The little-endian code here assumes that the processor can access
|
||||
* 16-bit and 32-bit quantities on byte boundaries. If this is not true,
|
||||
* use the macros for the big-endian case.
|
||||
*/
|
||||
|
||||
#include <machine/endian.h>
|
||||
|
||||
#ifdef __i386__
|
||||
#define UNLALIGNED_ACCESS
|
||||
#endif
|
||||
|
||||
#if (BYTE_ORDER == LITTLE_ENDIAN) && defined(UNALIGNED_ACCESS)
|
||||
#define getushort(x) *((u_int16_t *)(x))
|
||||
#define getulong(x) *((u_int32_t *)(x))
|
||||
#define putushort(p, v) (*((u_int16_t *)(p)) = (v))
|
||||
#define putulong(p, v) (*((u_int32_t *)(p)) = (v))
|
||||
#else
|
||||
#define getushort(x) (((u_int8_t *)(x))[0] + (((u_int8_t *)(x))[1] << 8))
|
||||
#define getulong(x) (((u_int8_t *)(x))[0] + (((u_int8_t *)(x))[1] << 8) \
|
||||
+ (((u_int8_t *)(x))[2] << 16) \
|
||||
+ (((u_int8_t *)(x))[3] << 24))
|
||||
#define putushort(p, v) (((u_int8_t *)(p))[0] = (v), \
|
||||
((u_int8_t *)(p))[1] = (v) >> 8)
|
||||
#define putulong(p, v) (((u_int8_t *)(p))[0] = (v), \
|
||||
((u_int8_t *)(p))[1] = (v) >> 8, \
|
||||
((u_int8_t *)(p))[2] = (v) >> 16,\
|
||||
((u_int8_t *)(p))[3] = (v) >> 24)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* BIOS Parameter Block (BPB) for DOS 3.3
|
||||
*/
|
||||
struct byte_bpb33 {
|
||||
int8_t bpbBytesPerSec[2]; /* bytes per sector */
|
||||
int8_t bpbSecPerClust; /* sectors per cluster */
|
||||
int8_t bpbResSectors[2]; /* number of reserved sectors */
|
||||
int8_t bpbFATs; /* number of FATs */
|
||||
int8_t bpbRootDirEnts[2]; /* number of root directory entries */
|
||||
int8_t bpbSectors[2]; /* total number of sectors */
|
||||
int8_t bpbMedia; /* media descriptor */
|
||||
int8_t bpbFATsecs[2]; /* number of sectors per FAT */
|
||||
int8_t bpbSecPerTrack[2]; /* sectors per track */
|
||||
int8_t bpbHeads[2]; /* number of heads */
|
||||
int8_t bpbHiddenSecs[2]; /* number of hidden sectors */
|
||||
};
|
||||
|
||||
/*
|
||||
* BPB for DOS 5.0 The difference is bpbHiddenSecs is a short for DOS 3.3,
|
||||
* and bpbHugeSectors is not in the 3.3 bpb.
|
||||
*/
|
||||
struct byte_bpb50 {
|
||||
int8_t bpbBytesPerSec[2]; /* bytes per sector */
|
||||
int8_t bpbSecPerClust; /* sectors per cluster */
|
||||
int8_t bpbResSectors[2]; /* number of reserved sectors */
|
||||
int8_t bpbFATs; /* number of FATs */
|
||||
int8_t bpbRootDirEnts[2]; /* number of root directory entries */
|
||||
int8_t bpbSectors[2]; /* total number of sectors */
|
||||
int8_t bpbMedia; /* media descriptor */
|
||||
int8_t bpbFATsecs[2]; /* number of sectors per FAT */
|
||||
int8_t bpbSecPerTrack[2]; /* sectors per track */
|
||||
int8_t bpbHeads[2]; /* number of heads */
|
||||
int8_t bpbHiddenSecs[4]; /* number of hidden sectors */
|
||||
int8_t bpbHugeSectors[4]; /* # of sectors if bpbSectors == 0 */
|
||||
};
|
||||
|
||||
/*
|
||||
* BPB for DOS 7.10 (FAT32). This one has a few extensions to bpb50.
|
||||
*/
|
||||
struct byte_bpb710 {
|
||||
u_int8_t bpbBytesPerSec[2]; /* bytes per sector */
|
||||
u_int8_t bpbSecPerClust; /* sectors per cluster */
|
||||
u_int8_t bpbResSectors[2]; /* number of reserved sectors */
|
||||
u_int8_t bpbFATs; /* number of FATs */
|
||||
u_int8_t bpbRootDirEnts[2]; /* number of root directory entries */
|
||||
u_int8_t bpbSectors[2]; /* total number of sectors */
|
||||
u_int8_t bpbMedia; /* media descriptor */
|
||||
u_int8_t bpbFATsecs[2]; /* number of sectors per FAT */
|
||||
u_int8_t bpbSecPerTrack[2]; /* sectors per track */
|
||||
u_int8_t bpbHeads[2]; /* number of heads */
|
||||
u_int8_t bpbHiddenSecs[4]; /* # of hidden sectors */
|
||||
u_int8_t bpbHugeSectors[4]; /* # of sectors if bpbSectors == 0 */
|
||||
u_int8_t bpbBigFATsecs[4]; /* like bpbFATsecs for FAT32 */
|
||||
u_int8_t bpbExtFlags[2]; /* extended flags: */
|
||||
u_int8_t bpbFSVers[2]; /* filesystem version */
|
||||
u_int8_t bpbRootClust[4]; /* start cluster for root directory */
|
||||
u_int8_t bpbFSInfo[2]; /* filesystem info structure sector */
|
||||
u_int8_t bpbBackup[2]; /* backup boot sector */
|
||||
/* There is a 12 byte filler here, but we ignore it */
|
||||
};
|
||||
|
||||
/*
|
||||
* FAT32 FSInfo block.
|
||||
*/
|
||||
struct fsinfo {
|
||||
u_int8_t fsisig1[4];
|
||||
u_int8_t fsifill1[480];
|
||||
u_int8_t fsisig2[4];
|
||||
u_int8_t fsinfree[4];
|
||||
u_int8_t fsinxtfree[4];
|
||||
u_int8_t fsifill2[12];
|
||||
u_int8_t fsisig3[4];
|
||||
u_int8_t fsifill3[508];
|
||||
u_int8_t fsisig4[4];
|
||||
};
|
@ -1,285 +0,0 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $NetBSD: denode.h,v 1.25 1997/11/17 15:36:28 ws Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
|
||||
* Copyright (C) 1994, 1995, 1997 TooLs GmbH.
|
||||
* All rights reserved.
|
||||
* Original code by Paul Popelka (paulp@uts.amdahl.com) (see below).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by TooLs GmbH.
|
||||
* 4. The name of TooLs GmbH may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*
|
||||
* Written by Paul Popelka (paulp@uts.amdahl.com)
|
||||
*
|
||||
* You can do anything you want with this software, just don't say you wrote
|
||||
* it, and don't remove this notice.
|
||||
*
|
||||
* This software is provided "as is".
|
||||
*
|
||||
* The author supplies this software to be publicly redistributed on the
|
||||
* understanding that the author is not responsible for the correct
|
||||
* functioning of this software in any circumstances and is not liable for
|
||||
* any damages caused by this software.
|
||||
*
|
||||
* October 1992
|
||||
*/
|
||||
|
||||
/*
|
||||
* This is the pc filesystem specific portion of the vnode structure.
|
||||
*
|
||||
* To describe a file uniquely the de_dirclust, de_diroffset, and
|
||||
* de_StartCluster fields are used.
|
||||
*
|
||||
* de_dirclust contains the cluster number of the directory cluster
|
||||
* containing the entry for a file or directory.
|
||||
* de_diroffset is the index into the cluster for the entry describing
|
||||
* a file or directory.
|
||||
* de_StartCluster is the number of the first cluster of the file or directory.
|
||||
*
|
||||
* Now to describe the quirks of the pc filesystem.
|
||||
* - Clusters 0 and 1 are reserved.
|
||||
* - The first allocatable cluster is 2.
|
||||
* - The root directory is of fixed size and all blocks that make it up
|
||||
* are contiguous.
|
||||
* - Cluster 0 refers to the root directory when it is found in the
|
||||
* startcluster field of a directory entry that points to another directory.
|
||||
* - Cluster 0 implies a 0 length file when found in the start cluster field
|
||||
* of a directory entry that points to a file.
|
||||
* - You can't use the cluster number 0 to derive the address of the root
|
||||
* directory.
|
||||
* - Multiple directory entries can point to a directory. The entry in the
|
||||
* parent directory points to a child directory. Any directories in the
|
||||
* child directory contain a ".." entry that points back to the parent.
|
||||
* The child directory itself contains a "." entry that points to itself.
|
||||
* - The root directory does not contain a "." or ".." entry.
|
||||
* - Directory entries for directories are never changed once they are created
|
||||
* (except when removed). The size stays 0, and the last modification time
|
||||
* is never changed. This is because so many directory entries can point to
|
||||
* the physical clusters that make up a directory. It would lead to an
|
||||
* update nightmare.
|
||||
* - The length field in a directory entry pointing to a directory contains 0
|
||||
* (always). The only way to find the end of a directory is to follow the
|
||||
* cluster chain until the "last cluster" marker is found.
|
||||
*
|
||||
* My extensions to make this house of cards work. These apply only to the in
|
||||
* memory copy of the directory entry.
|
||||
* - A reference count for each denode will be kept since dos doesn't keep such
|
||||
* things.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Internal pseudo-offset for (nonexistent) directory entry for the root
|
||||
* dir in the root dir
|
||||
*/
|
||||
#define MSDOSFSROOT_OFS 0x1fffffff
|
||||
|
||||
/*
|
||||
* The fat cache structure. fc_fsrcn is the filesystem relative cluster
|
||||
* number that corresponds to the file relative cluster number in this
|
||||
* structure (fc_frcn).
|
||||
*/
|
||||
struct fatcache {
|
||||
u_long fc_frcn; /* file relative cluster number */
|
||||
u_long fc_fsrcn; /* filesystem relative cluster number */
|
||||
};
|
||||
|
||||
/*
|
||||
* The fat entry cache as it stands helps make extending files a "quick"
|
||||
* operation by avoiding having to scan the fat to discover the last
|
||||
* cluster of the file. The cache also helps sequential reads by
|
||||
* remembering the last cluster read from the file. This also prevents us
|
||||
* from having to rescan the fat to find the next cluster to read. This
|
||||
* cache is probably pretty worthless if a file is opened by multiple
|
||||
* processes.
|
||||
*/
|
||||
#define FC_SIZE 2 /* number of entries in the cache */
|
||||
#define FC_LASTMAP 0 /* entry the last call to pcbmap() resolved
|
||||
* to */
|
||||
#define FC_LASTFC 1 /* entry for the last cluster in the file */
|
||||
|
||||
#define FCE_EMPTY 0xffffffff /* doesn't represent an actual cluster # */
|
||||
|
||||
/*
|
||||
* Set a slot in the fat cache.
|
||||
*/
|
||||
#define fc_setcache(dep, slot, frcn, fsrcn) \
|
||||
(dep)->de_fc[slot].fc_frcn = frcn; \
|
||||
(dep)->de_fc[slot].fc_fsrcn = fsrcn;
|
||||
|
||||
/*
|
||||
* This is the in memory variant of a dos directory entry. It is usually
|
||||
* contained within a vnode.
|
||||
*/
|
||||
struct denode {
|
||||
struct denode *de_next; /* Hash chain forward */
|
||||
struct denode **de_prev; /* Hash chain back */
|
||||
struct vnode *de_vnode; /* addr of vnode we are part of */
|
||||
struct vnode *de_devvp; /* vnode of blk dev we live on */
|
||||
u_long de_flag; /* flag bits */
|
||||
dev_t de_dev; /* device where direntry lives */
|
||||
u_long de_dirclust; /* cluster of the directory file containing this entry */
|
||||
u_long de_diroffset; /* offset of this entry in the directory cluster */
|
||||
u_long de_fndoffset; /* offset of found dir entry */
|
||||
int de_fndcnt; /* number of slots before de_fndoffset */
|
||||
long de_refcnt; /* reference count */
|
||||
struct msdosfsmount *de_pmp; /* addr of our mount struct */
|
||||
u_char de_Name[12]; /* name, from DOS directory entry */
|
||||
u_char de_Attributes; /* attributes, from directory entry */
|
||||
u_char de_LowerCase; /* NT VFAT lower case flags */
|
||||
u_char de_CHun; /* Hundredth of second of CTime*/
|
||||
u_short de_CTime; /* creation time */
|
||||
u_short de_CDate; /* creation date */
|
||||
u_short de_ADate; /* access date */
|
||||
u_short de_MTime; /* modification time */
|
||||
u_short de_MDate; /* modification date */
|
||||
u_long de_StartCluster; /* starting cluster of file */
|
||||
u_long de_FileSize; /* size of file in bytes */
|
||||
struct fatcache de_fc[FC_SIZE]; /* fat cache */
|
||||
u_quad_t de_modrev; /* Revision level for lease. */
|
||||
};
|
||||
|
||||
/*
|
||||
* Values for the de_flag field of the denode.
|
||||
*/
|
||||
#define DE_UPDATE 0x0004 /* Modification time update request */
|
||||
#define DE_CREATE 0x0008 /* Creation time update */
|
||||
#define DE_ACCESS 0x0010 /* Access time update */
|
||||
#define DE_MODIFIED 0x0020 /* Denode has been modified */
|
||||
#define DE_RENAME 0x0040 /* Denode is in the process of being renamed */
|
||||
|
||||
|
||||
/*
|
||||
* Transfer directory entries between internal and external form.
|
||||
* dep is a struct denode * (internal form),
|
||||
* dp is a struct direntry * (external form).
|
||||
*/
|
||||
#define DE_INTERNALIZE32(dep, dp) \
|
||||
((dep)->de_StartCluster |= getushort((dp)->deHighClust) << 16)
|
||||
#define DE_INTERNALIZE(dep, dp) \
|
||||
(bcopy((dp)->deName, (dep)->de_Name, 11), \
|
||||
(dep)->de_Attributes = (dp)->deAttributes, \
|
||||
(dep)->de_LowerCase = (dp)->deLowerCase, \
|
||||
(dep)->de_CHun = (dp)->deCHundredth, \
|
||||
(dep)->de_CTime = getushort((dp)->deCTime), \
|
||||
(dep)->de_CDate = getushort((dp)->deCDate), \
|
||||
(dep)->de_ADate = getushort((dp)->deADate), \
|
||||
(dep)->de_MTime = getushort((dp)->deMTime), \
|
||||
(dep)->de_MDate = getushort((dp)->deMDate), \
|
||||
(dep)->de_StartCluster = getushort((dp)->deStartCluster), \
|
||||
(dep)->de_FileSize = getulong((dp)->deFileSize), \
|
||||
(FAT32((dep)->de_pmp) ? DE_INTERNALIZE32((dep), (dp)) : 0))
|
||||
|
||||
#define DE_EXTERNALIZE(dp, dep) \
|
||||
(bcopy((dep)->de_Name, (dp)->deName, 11), \
|
||||
(dp)->deAttributes = (dep)->de_Attributes, \
|
||||
(dp)->deLowerCase = (dep)->de_LowerCase, \
|
||||
(dp)->deCHundredth = (dep)->de_CHun, \
|
||||
putushort((dp)->deCTime, (dep)->de_CTime), \
|
||||
putushort((dp)->deCDate, (dep)->de_CDate), \
|
||||
putushort((dp)->deADate, (dep)->de_ADate), \
|
||||
putushort((dp)->deMTime, (dep)->de_MTime), \
|
||||
putushort((dp)->deMDate, (dep)->de_MDate), \
|
||||
putushort((dp)->deStartCluster, (dep)->de_StartCluster), \
|
||||
putulong((dp)->deFileSize, \
|
||||
((dep)->de_Attributes & ATTR_DIRECTORY) ? 0 : (dep)->de_FileSize), \
|
||||
putushort((dp)->deHighClust, (dep)->de_StartCluster >> 16))
|
||||
|
||||
#define de_forw de_chain[0]
|
||||
#define de_back de_chain[1]
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
#define VTODE(vp) ((struct denode *)(vp)->v_data)
|
||||
#define DETOV(de) ((de)->de_vnode)
|
||||
|
||||
#define DETIMES(dep, acc, mod, cre) do { \
|
||||
if ((dep)->de_flag & DE_UPDATE) { \
|
||||
(dep)->de_flag |= DE_MODIFIED; \
|
||||
unix2dostime((mod), &(dep)->de_MDate, &(dep)->de_MTime, \
|
||||
NULL); \
|
||||
(dep)->de_Attributes |= ATTR_ARCHIVE; \
|
||||
} \
|
||||
if ((dep)->de_pmp->pm_flags & MSDOSFSMNT_NOWIN95) { \
|
||||
(dep)->de_flag &= ~(DE_UPDATE | DE_CREATE | DE_ACCESS); \
|
||||
break; \
|
||||
} \
|
||||
if ((dep)->de_flag & DE_ACCESS) { \
|
||||
u_int16_t adate; \
|
||||
\
|
||||
unix2dostime((acc), &adate, NULL, NULL); \
|
||||
if (adate != (dep)->de_ADate) { \
|
||||
(dep)->de_flag |= DE_MODIFIED; \
|
||||
(dep)->de_ADate = adate; \
|
||||
} \
|
||||
} \
|
||||
if ((dep)->de_flag & DE_CREATE) { \
|
||||
unix2dostime((cre), &(dep)->de_CDate, &(dep)->de_CTime, \
|
||||
&(dep)->de_CHun); \
|
||||
(dep)->de_flag |= DE_MODIFIED; \
|
||||
} \
|
||||
(dep)->de_flag &= ~(DE_UPDATE | DE_CREATE | DE_ACCESS); \
|
||||
} while (0);
|
||||
|
||||
/*
|
||||
* This overlays the fid structure (see mount.h)
|
||||
*/
|
||||
struct defid {
|
||||
u_short defid_len; /* length of structure */
|
||||
u_short defid_pad; /* force long alignment */
|
||||
|
||||
u_long defid_dirclust; /* cluster this dir entry came from */
|
||||
u_long defid_dirofs; /* offset of entry within the cluster */
|
||||
#if 0
|
||||
u_long defid_gen; /* generation number */
|
||||
#endif
|
||||
};
|
||||
|
||||
extern vop_t **msdosfs_vnodeop_p;
|
||||
|
||||
int msdosfs_lookup __P((struct vop_cachedlookup_args *));
|
||||
int msdosfs_inactive __P((struct vop_inactive_args *));
|
||||
int msdosfs_reclaim __P((struct vop_reclaim_args *));
|
||||
|
||||
/*
|
||||
* Internal service routine prototypes.
|
||||
*/
|
||||
int deget __P((struct msdosfsmount *, u_long, u_long, struct denode **));
|
||||
int uniqdosname __P((struct denode *, struct componentname *, u_char *));
|
||||
int findwin95 __P((struct denode *));
|
||||
|
||||
int readep __P((struct msdosfsmount *pmp, u_long dirclu, u_long dirofs, struct buf **bpp, struct direntry **epp));
|
||||
int readde __P((struct denode *dep, struct buf **bpp, struct direntry **epp));
|
||||
int deextend __P((struct denode *dep, u_long length, struct ucred *cred));
|
||||
int fillinusemap __P((struct msdosfsmount *pmp));
|
||||
void reinsert __P((struct denode *dep));
|
||||
int dosdirempty __P((struct denode *dep));
|
||||
int createde __P((struct denode *dep, struct denode *ddep, struct denode **depp, struct componentname *cnp));
|
||||
int deupdat __P((struct denode *dep, int waitfor));
|
||||
int removede __P((struct denode *pdep, struct denode *dep));
|
||||
int detrunc __P((struct denode *dep, u_long length, int flags, struct ucred *cred, struct proc *p));
|
||||
int doscheckpath __P(( struct denode *source, struct denode *target));
|
||||
#endif /* _KERNEL */
|
@ -1,143 +0,0 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $NetBSD: direntry.h,v 1.14 1997/11/17 15:36:32 ws Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
|
||||
* Copyright (C) 1994, 1995, 1997 TooLs GmbH.
|
||||
* All rights reserved.
|
||||
* Original code by Paul Popelka (paulp@uts.amdahl.com) (see below).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by TooLs GmbH.
|
||||
* 4. The name of TooLs GmbH may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*
|
||||
* Written by Paul Popelka (paulp@uts.amdahl.com)
|
||||
*
|
||||
* You can do anything you want with this software, just don't say you wrote
|
||||
* it, and don't remove this notice.
|
||||
*
|
||||
* This software is provided "as is".
|
||||
*
|
||||
* The author supplies this software to be publicly redistributed on the
|
||||
* understanding that the author is not responsible for the correct
|
||||
* functioning of this software in any circumstances and is not liable for
|
||||
* any damages caused by this software.
|
||||
*
|
||||
* October 1992
|
||||
*/
|
||||
|
||||
/*
|
||||
* Structure of a dos directory entry.
|
||||
*/
|
||||
struct direntry {
|
||||
u_int8_t deName[8]; /* filename, blank filled */
|
||||
#define SLOT_EMPTY 0x00 /* slot has never been used */
|
||||
#define SLOT_E5 0x05 /* the real value is 0xe5 */
|
||||
#define SLOT_DELETED 0xe5 /* file in this slot deleted */
|
||||
u_int8_t deExtension[3]; /* extension, blank filled */
|
||||
u_int8_t deAttributes; /* file attributes */
|
||||
#define ATTR_NORMAL 0x00 /* normal file */
|
||||
#define ATTR_READONLY 0x01 /* file is readonly */
|
||||
#define ATTR_HIDDEN 0x02 /* file is hidden */
|
||||
#define ATTR_SYSTEM 0x04 /* file is a system file */
|
||||
#define ATTR_VOLUME 0x08 /* entry is a volume label */
|
||||
#define ATTR_DIRECTORY 0x10 /* entry is a directory name */
|
||||
#define ATTR_ARCHIVE 0x20 /* file is new or modified */
|
||||
u_int8_t deLowerCase; /* NT VFAT lower case flags */
|
||||
#define LCASE_BASE 0x08 /* filename base in lower case */
|
||||
#define LCASE_EXT 0x10 /* filename extension in lower case */
|
||||
u_int8_t deCHundredth; /* hundredth of seconds in CTime */
|
||||
u_int8_t deCTime[2]; /* create time */
|
||||
u_int8_t deCDate[2]; /* create date */
|
||||
u_int8_t deADate[2]; /* access date */
|
||||
u_int8_t deHighClust[2]; /* high bytes of cluster number */
|
||||
u_int8_t deMTime[2]; /* last update time */
|
||||
u_int8_t deMDate[2]; /* last update date */
|
||||
u_int8_t deStartCluster[2]; /* starting cluster of file */
|
||||
u_int8_t deFileSize[4]; /* size of file in bytes */
|
||||
};
|
||||
|
||||
/*
|
||||
* Structure of a Win95 long name directory entry
|
||||
*/
|
||||
struct winentry {
|
||||
u_int8_t weCnt;
|
||||
#define WIN_LAST 0x40
|
||||
#define WIN_CNT 0x3f
|
||||
u_int8_t wePart1[10];
|
||||
u_int8_t weAttributes;
|
||||
#define ATTR_WIN95 0x0f
|
||||
u_int8_t weReserved1;
|
||||
u_int8_t weChksum;
|
||||
u_int8_t wePart2[12];
|
||||
u_int16_t weReserved2;
|
||||
u_int8_t wePart3[4];
|
||||
};
|
||||
#define WIN_CHARS 13 /* Number of chars per winentry */
|
||||
|
||||
/*
|
||||
* Maximum filename length in Win95
|
||||
* Note: Must be < sizeof(dirent.d_name)
|
||||
*/
|
||||
#define WIN_MAXLEN 255
|
||||
|
||||
/*
|
||||
* This is the format of the contents of the deTime field in the direntry
|
||||
* structure.
|
||||
* We don't use bitfields because we don't know how compilers for
|
||||
* arbitrary machines will lay them out.
|
||||
*/
|
||||
#define DT_2SECONDS_MASK 0x1F /* seconds divided by 2 */
|
||||
#define DT_2SECONDS_SHIFT 0
|
||||
#define DT_MINUTES_MASK 0x7E0 /* minutes */
|
||||
#define DT_MINUTES_SHIFT 5
|
||||
#define DT_HOURS_MASK 0xF800 /* hours */
|
||||
#define DT_HOURS_SHIFT 11
|
||||
|
||||
/*
|
||||
* This is the format of the contents of the deDate field in the direntry
|
||||
* structure.
|
||||
*/
|
||||
#define DD_DAY_MASK 0x1F /* day of month */
|
||||
#define DD_DAY_SHIFT 0
|
||||
#define DD_MONTH_MASK 0x1E0 /* month */
|
||||
#define DD_MONTH_SHIFT 5
|
||||
#define DD_YEAR_MASK 0xFE00 /* year - 1980 */
|
||||
#define DD_YEAR_SHIFT 9
|
||||
|
||||
#ifdef _KERNEL
|
||||
struct dirent;
|
||||
void unix2dostime __P((struct timespec *tsp, u_int16_t *ddp,
|
||||
u_int16_t *dtp, u_int8_t *dhp));
|
||||
void dos2unixtime __P((u_int dd, u_int dt, u_int dh, struct timespec *tsp));
|
||||
int dos2unixfn __P((u_char dn[11], u_char *un, int lower, int d2u_loaded, u_int8_t *d2u, int ul_loaded, u_int8_t *ul));
|
||||
int unix2dosfn __P((const u_char *un, u_char dn[12], int unlen, u_int gen, int u2d_loaded, u_int8_t *u2d, int lu_loaded, u_int8_t *lu));
|
||||
int unix2winfn __P((const u_char *un, int unlen, struct winentry *wep, int cnt, int chksum, int table_loaded, u_int16_t *u2w));
|
||||
int winChkName __P((const u_char *un, int unlen, struct winentry *wep, int chksum, int u2w_loaded, u_int16_t *u2w, int ul_loaded, u_int8_t *ul));
|
||||
int win2unixfn __P((struct winentry *wep, struct dirent *dp, int chksum, int table_loaded, u_int16_t *u2w));
|
||||
u_int8_t winChksum __P((u_int8_t *name));
|
||||
int winSlotCnt __P((const u_char *un, int unlen));
|
||||
int winLenFixup __P((const u_char *un, int unlen));
|
||||
#endif /* _KERNEL */
|
@ -1,108 +0,0 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $NetBSD: fat.h,v 1.12 1997/11/17 15:36:36 ws Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (C) 1994, 1997 Wolfgang Solfrank.
|
||||
* Copyright (C) 1994, 1997 TooLs GmbH.
|
||||
* All rights reserved.
|
||||
* Original code by Paul Popelka (paulp@uts.amdahl.com) (see below).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by TooLs GmbH.
|
||||
* 4. The name of TooLs GmbH may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*
|
||||
* Written by Paul Popelka (paulp@uts.amdahl.com)
|
||||
*
|
||||
* You can do anything you want with this software, just don't say you wrote
|
||||
* it, and don't remove this notice.
|
||||
*
|
||||
* This software is provided "as is".
|
||||
*
|
||||
* The author supplies this software to be publicly redistributed on the
|
||||
* understanding that the author is not responsible for the correct
|
||||
* functioning of this software in any circumstances and is not liable for
|
||||
* any damages caused by this software.
|
||||
*
|
||||
* October 1992
|
||||
*/
|
||||
|
||||
/*
|
||||
* Some useful cluster numbers.
|
||||
*/
|
||||
#define MSDOSFSROOT 0 /* cluster 0 means the root dir */
|
||||
#define CLUST_FREE 0 /* cluster 0 also means a free cluster */
|
||||
#define MSDOSFSFREE CLUST_FREE
|
||||
#define CLUST_FIRST 2 /* first legal cluster number */
|
||||
#define CLUST_RSRVD 0xfffffff6 /* reserved cluster range */
|
||||
#define CLUST_BAD 0xfffffff7 /* a cluster with a defect */
|
||||
#define CLUST_EOFS 0xfffffff8 /* start of eof cluster range */
|
||||
#define CLUST_EOFE 0xffffffff /* end of eof cluster range */
|
||||
|
||||
#define FAT12_MASK 0x00000fff /* mask for 12 bit cluster numbers */
|
||||
#define FAT16_MASK 0x0000ffff /* mask for 16 bit cluster numbers */
|
||||
#define FAT32_MASK 0x0fffffff /* mask for FAT32 cluster numbers */
|
||||
|
||||
/*
|
||||
* MSDOSFS:
|
||||
* Return true if filesystem uses 12 bit fats. Microsoft Programmer's
|
||||
* Reference says if the maximum cluster number in a filesystem is greater
|
||||
* than 4078 ((CLUST_RSRVS - CLUST_FIRST) & FAT12_MASK) then we've got a
|
||||
* 16 bit fat filesystem. While mounting, the result of this test is stored
|
||||
* in pm_fatentrysize.
|
||||
* GEMDOS-flavour (atari):
|
||||
* If the filesystem is on floppy we've got a 12 bit fat filesystem, otherwise
|
||||
* 16 bit. We check the d_type field in the disklabel struct while mounting
|
||||
* and store the result in the pm_fatentrysize. Note that this kind of
|
||||
* detection gets flakey when mounting a vnd-device.
|
||||
*/
|
||||
#define FAT12(pmp) (pmp->pm_fatmask == FAT12_MASK)
|
||||
#define FAT16(pmp) (pmp->pm_fatmask == FAT16_MASK)
|
||||
#define FAT32(pmp) (pmp->pm_fatmask == FAT32_MASK)
|
||||
|
||||
#define MSDOSFSEOF(pmp, cn) ((((cn) | ~(pmp)->pm_fatmask) & CLUST_EOFS) == CLUST_EOFS)
|
||||
|
||||
#ifdef _KERNEL
|
||||
/*
|
||||
* These are the values for the function argument to the function
|
||||
* fatentry().
|
||||
*/
|
||||
#define FAT_GET 0x0001 /* get a fat entry */
|
||||
#define FAT_SET 0x0002 /* set a fat entry */
|
||||
#define FAT_GET_AND_SET (FAT_GET | FAT_SET)
|
||||
|
||||
/*
|
||||
* Flags to extendfile:
|
||||
*/
|
||||
#define DE_CLEAR 1 /* Zero out the blocks allocated */
|
||||
|
||||
int pcbmap __P((struct denode *dep, u_long findcn, daddr_t *bnp, u_long *cnp, int* sp));
|
||||
int clusterfree __P((struct msdosfsmount *pmp, u_long cn, u_long *oldcnp));
|
||||
int clusteralloc __P((struct msdosfsmount *pmp, u_long start, u_long count, u_long fillwith, u_long *retcluster, u_long *got));
|
||||
int fatentry __P((int function, struct msdosfsmount *pmp, u_long cluster, u_long *oldcontents, u_long newcontents));
|
||||
int freeclusterchain __P((struct msdosfsmount *pmp, u_long startchain));
|
||||
int extendfile __P((struct denode *dep, u_long count, struct buf **bpp, u_long *ncp, int flags));
|
||||
void fc_purge __P((struct denode *dep, u_int frcn));
|
||||
|
||||
#endif /* _KERNEL */
|
File diff suppressed because it is too large
Load Diff
@ -1,724 +0,0 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $NetBSD: msdosfs_denode.c,v 1.28 1998/02/10 14:10:00 mrg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
|
||||
* Copyright (C) 1994, 1995, 1997 TooLs GmbH.
|
||||
* All rights reserved.
|
||||
* Original code by Paul Popelka (paulp@uts.amdahl.com) (see below).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by TooLs GmbH.
|
||||
* 4. The name of TooLs GmbH may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*
|
||||
* Written by Paul Popelka (paulp@uts.amdahl.com)
|
||||
*
|
||||
* You can do anything you want with this software, just don't say you wrote
|
||||
* it, and don't remove this notice.
|
||||
*
|
||||
* This software is provided "as is".
|
||||
*
|
||||
* The author supplies this software to be publicly redistributed on the
|
||||
* understanding that the author is not responsible for the correct
|
||||
* functioning of this software in any circumstances and is not liable for
|
||||
* any damages caused by this software.
|
||||
*
|
||||
* October 1992
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/bio.h>
|
||||
#include <sys/buf.h>
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/mutex.h>
|
||||
|
||||
#include <vm/vm.h>
|
||||
#include <vm/vm_extern.h>
|
||||
|
||||
#include <msdosfs/bpb.h>
|
||||
#include <msdosfs/msdosfsmount.h>
|
||||
#include <msdosfs/direntry.h>
|
||||
#include <msdosfs/denode.h>
|
||||
#include <msdosfs/fat.h>
|
||||
|
||||
static MALLOC_DEFINE(M_MSDOSFSNODE, "MSDOSFS node", "MSDOSFS vnode private part");
|
||||
|
||||
static struct denode **dehashtbl;
|
||||
static u_long dehash; /* size of hash table - 1 */
|
||||
#define DEHASH(dev, dcl, doff) (dehashtbl[(minor(dev) + (dcl) + (doff) / \
|
||||
sizeof(struct direntry)) & dehash])
|
||||
static struct mtx dehash_mtx;
|
||||
|
||||
union _qcvt {
|
||||
quad_t qcvt;
|
||||
long val[2];
|
||||
};
|
||||
#define SETHIGH(q, h) { \
|
||||
union _qcvt tmp; \
|
||||
tmp.qcvt = (q); \
|
||||
tmp.val[_QUAD_HIGHWORD] = (h); \
|
||||
(q) = tmp.qcvt; \
|
||||
}
|
||||
#define SETLOW(q, l) { \
|
||||
union _qcvt tmp; \
|
||||
tmp.qcvt = (q); \
|
||||
tmp.val[_QUAD_LOWWORD] = (l); \
|
||||
(q) = tmp.qcvt; \
|
||||
}
|
||||
|
||||
static struct denode *
|
||||
msdosfs_hashget __P((dev_t dev, u_long dirclust,
|
||||
u_long diroff));
|
||||
static void msdosfs_hashins __P((struct denode *dep));
|
||||
static void msdosfs_hashrem __P((struct denode *dep));
|
||||
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
msdosfs_init(vfsp)
|
||||
struct vfsconf *vfsp;
|
||||
{
|
||||
dehashtbl = hashinit(desiredvnodes/2, M_MSDOSFSMNT, &dehash);
|
||||
mtx_init(&dehash_mtx, "msdosfs dehash", MTX_DEF);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
msdosfs_uninit(vfsp)
|
||||
struct vfsconf *vfsp;
|
||||
{
|
||||
|
||||
if (dehashtbl)
|
||||
free(dehashtbl, M_MSDOSFSMNT);
|
||||
mtx_destroy(&dehash_mtx);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static struct denode *
|
||||
msdosfs_hashget(dev, dirclust, diroff)
|
||||
dev_t dev;
|
||||
u_long dirclust;
|
||||
u_long diroff;
|
||||
{
|
||||
struct proc *p = curproc; /* XXX */
|
||||
struct denode *dep;
|
||||
struct vnode *vp;
|
||||
|
||||
loop:
|
||||
mtx_lock(&dehash_mtx);
|
||||
for (dep = DEHASH(dev, dirclust, diroff); dep; dep = dep->de_next) {
|
||||
if (dirclust == dep->de_dirclust
|
||||
&& diroff == dep->de_diroffset
|
||||
&& dev == dep->de_dev
|
||||
&& dep->de_refcnt != 0) {
|
||||
vp = DETOV(dep);
|
||||
mtx_lock(&vp->v_interlock);
|
||||
mtx_unlock(&dehash_mtx);
|
||||
if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p))
|
||||
goto loop;
|
||||
return (dep);
|
||||
}
|
||||
}
|
||||
mtx_unlock(&dehash_mtx);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
msdosfs_hashins(dep)
|
||||
struct denode *dep;
|
||||
{
|
||||
struct denode **depp, *deq;
|
||||
|
||||
mtx_lock(&dehash_mtx);
|
||||
depp = &DEHASH(dep->de_dev, dep->de_dirclust, dep->de_diroffset);
|
||||
deq = *depp;
|
||||
if (deq)
|
||||
deq->de_prev = &dep->de_next;
|
||||
dep->de_next = deq;
|
||||
dep->de_prev = depp;
|
||||
*depp = dep;
|
||||
mtx_unlock(&dehash_mtx);
|
||||
}
|
||||
|
||||
static void
|
||||
msdosfs_hashrem(dep)
|
||||
struct denode *dep;
|
||||
{
|
||||
struct denode *deq;
|
||||
|
||||
mtx_lock(&dehash_mtx);
|
||||
deq = dep->de_next;
|
||||
if (deq)
|
||||
deq->de_prev = dep->de_prev;
|
||||
*dep->de_prev = deq;
|
||||
#ifdef DIAGNOSTIC
|
||||
dep->de_next = NULL;
|
||||
dep->de_prev = NULL;
|
||||
#endif
|
||||
mtx_unlock(&dehash_mtx);
|
||||
}
|
||||
|
||||
/*
|
||||
* If deget() succeeds it returns with the gotten denode locked().
|
||||
*
|
||||
* pmp - address of msdosfsmount structure of the filesystem containing
|
||||
* the denode of interest. The pm_dev field and the address of
|
||||
* the msdosfsmount structure are used.
|
||||
* dirclust - which cluster bp contains, if dirclust is 0 (root directory)
|
||||
* diroffset is relative to the beginning of the root directory,
|
||||
* otherwise it is cluster relative.
|
||||
* diroffset - offset past begin of cluster of denode we want
|
||||
* depp - returns the address of the gotten denode.
|
||||
*/
|
||||
int
|
||||
deget(pmp, dirclust, diroffset, depp)
|
||||
struct msdosfsmount *pmp; /* so we know the maj/min number */
|
||||
u_long dirclust; /* cluster this dir entry came from */
|
||||
u_long diroffset; /* index of entry within the cluster */
|
||||
struct denode **depp; /* returns the addr of the gotten denode */
|
||||
{
|
||||
int error;
|
||||
dev_t dev = pmp->pm_dev;
|
||||
struct mount *mntp = pmp->pm_mountp;
|
||||
struct direntry *direntptr;
|
||||
struct denode *ldep;
|
||||
struct vnode *nvp;
|
||||
struct buf *bp;
|
||||
struct proc *p = curproc; /* XXX */
|
||||
struct timeval tv;
|
||||
|
||||
#ifdef MSDOSFS_DEBUG
|
||||
printf("deget(pmp %p, dirclust %lu, diroffset %lx, depp %p)\n",
|
||||
pmp, dirclust, diroffset, depp);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* On FAT32 filesystems, root is a (more or less) normal
|
||||
* directory
|
||||
*/
|
||||
if (FAT32(pmp) && dirclust == MSDOSFSROOT)
|
||||
dirclust = pmp->pm_rootdirblk;
|
||||
|
||||
/*
|
||||
* See if the denode is in the denode cache. Use the location of
|
||||
* the directory entry to compute the hash value. For subdir use
|
||||
* address of "." entry. For root dir (if not FAT32) use cluster
|
||||
* MSDOSFSROOT, offset MSDOSFSROOT_OFS
|
||||
*
|
||||
* NOTE: The check for de_refcnt > 0 below insures the denode being
|
||||
* examined does not represent an unlinked but still open file.
|
||||
* These files are not to be accessible even when the directory
|
||||
* entry that represented the file happens to be reused while the
|
||||
* deleted file is still open.
|
||||
*/
|
||||
ldep = msdosfs_hashget(dev, dirclust, diroffset);
|
||||
if (ldep) {
|
||||
*depp = ldep;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Do the MALLOC before the getnewvnode since doing so afterward
|
||||
* might cause a bogus v_data pointer to get dereferenced
|
||||
* elsewhere if MALLOC should block.
|
||||
*/
|
||||
MALLOC(ldep, struct denode *, sizeof(struct denode), M_MSDOSFSNODE, M_WAITOK);
|
||||
|
||||
/*
|
||||
* Directory entry was not in cache, have to create a vnode and
|
||||
* copy it from the passed disk buffer.
|
||||
*/
|
||||
/* getnewvnode() does a VREF() on the vnode */
|
||||
error = getnewvnode(VT_MSDOSFS, mntp, msdosfs_vnodeop_p, &nvp);
|
||||
if (error) {
|
||||
*depp = NULL;
|
||||
FREE(ldep, M_MSDOSFSNODE);
|
||||
return error;
|
||||
}
|
||||
bzero((caddr_t)ldep, sizeof *ldep);
|
||||
lockinit(&nvp->v_lock, PINOD, "denode", 0, 0);
|
||||
nvp->v_vnlock = &nvp->v_lock;
|
||||
nvp->v_data = ldep;
|
||||
ldep->de_vnode = nvp;
|
||||
ldep->de_flag = 0;
|
||||
ldep->de_devvp = 0;
|
||||
ldep->de_dev = dev;
|
||||
ldep->de_dirclust = dirclust;
|
||||
ldep->de_diroffset = diroffset;
|
||||
fc_purge(ldep, 0); /* init the fat cache for this denode */
|
||||
|
||||
/*
|
||||
* Lock the denode so that it can't be accessed until we've read
|
||||
* it in and have done what we need to it. Do this here instead
|
||||
* of at the start of msdosfs_hashins() so that reinsert() can
|
||||
* call msdosfs_hashins() with a locked denode.
|
||||
*/
|
||||
if (VOP_LOCK(nvp, LK_EXCLUSIVE, p) != 0)
|
||||
panic("deget: unexpected lock failure");
|
||||
|
||||
/*
|
||||
* Insert the denode into the hash queue.
|
||||
*/
|
||||
msdosfs_hashins(ldep);
|
||||
|
||||
ldep->de_pmp = pmp;
|
||||
ldep->de_refcnt = 1;
|
||||
/*
|
||||
* Copy the directory entry into the denode area of the vnode.
|
||||
*/
|
||||
if ((dirclust == MSDOSFSROOT
|
||||
|| (FAT32(pmp) && dirclust == pmp->pm_rootdirblk))
|
||||
&& diroffset == MSDOSFSROOT_OFS) {
|
||||
/*
|
||||
* Directory entry for the root directory. There isn't one,
|
||||
* so we manufacture one. We should probably rummage
|
||||
* through the root directory and find a label entry (if it
|
||||
* exists), and then use the time and date from that entry
|
||||
* as the time and date for the root denode.
|
||||
*/
|
||||
nvp->v_flag |= VROOT; /* should be further down XXX */
|
||||
|
||||
ldep->de_Attributes = ATTR_DIRECTORY;
|
||||
ldep->de_LowerCase = 0;
|
||||
if (FAT32(pmp))
|
||||
ldep->de_StartCluster = pmp->pm_rootdirblk;
|
||||
/* de_FileSize will be filled in further down */
|
||||
else {
|
||||
ldep->de_StartCluster = MSDOSFSROOT;
|
||||
ldep->de_FileSize = pmp->pm_rootdirsize * DEV_BSIZE;
|
||||
}
|
||||
/*
|
||||
* fill in time and date so that dos2unixtime() doesn't
|
||||
* spit up when called from msdosfs_getattr() with root
|
||||
* denode
|
||||
*/
|
||||
ldep->de_CHun = 0;
|
||||
ldep->de_CTime = 0x0000; /* 00:00:00 */
|
||||
ldep->de_CDate = (0 << DD_YEAR_SHIFT) | (1 << DD_MONTH_SHIFT)
|
||||
| (1 << DD_DAY_SHIFT);
|
||||
/* Jan 1, 1980 */
|
||||
ldep->de_ADate = ldep->de_CDate;
|
||||
ldep->de_MTime = ldep->de_CTime;
|
||||
ldep->de_MDate = ldep->de_CDate;
|
||||
/* leave the other fields as garbage */
|
||||
} else {
|
||||
error = readep(pmp, dirclust, diroffset, &bp, &direntptr);
|
||||
if (error) {
|
||||
/*
|
||||
* The denode does not contain anything useful, so
|
||||
* it would be wrong to leave it on its hash chain.
|
||||
* Arrange for vput() to just forget about it.
|
||||
*/
|
||||
ldep->de_Name[0] = SLOT_DELETED;
|
||||
|
||||
vput(nvp);
|
||||
*depp = NULL;
|
||||
return (error);
|
||||
}
|
||||
DE_INTERNALIZE(ldep, direntptr);
|
||||
brelse(bp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Fill in a few fields of the vnode and finish filling in the
|
||||
* denode. Then return the address of the found denode.
|
||||
*/
|
||||
if (ldep->de_Attributes & ATTR_DIRECTORY) {
|
||||
/*
|
||||
* Since DOS directory entries that describe directories
|
||||
* have 0 in the filesize field, we take this opportunity
|
||||
* to find out the length of the directory and plug it into
|
||||
* the denode structure.
|
||||
*/
|
||||
u_long size;
|
||||
|
||||
nvp->v_type = VDIR;
|
||||
if (ldep->de_StartCluster != MSDOSFSROOT) {
|
||||
error = pcbmap(ldep, 0xffff, 0, &size, 0);
|
||||
if (error == E2BIG) {
|
||||
ldep->de_FileSize = de_cn2off(pmp, size);
|
||||
error = 0;
|
||||
} else
|
||||
printf("deget(): pcbmap returned %d\n", error);
|
||||
}
|
||||
} else
|
||||
nvp->v_type = VREG;
|
||||
getmicrouptime(&tv);
|
||||
SETHIGH(ldep->de_modrev, tv.tv_sec);
|
||||
SETLOW(ldep->de_modrev, tv.tv_usec * 4294);
|
||||
ldep->de_devvp = pmp->pm_devvp;
|
||||
VREF(ldep->de_devvp);
|
||||
*depp = ldep;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
deupdat(dep, waitfor)
|
||||
struct denode *dep;
|
||||
int waitfor;
|
||||
{
|
||||
int error;
|
||||
struct buf *bp;
|
||||
struct direntry *dirp;
|
||||
struct timespec ts;
|
||||
|
||||
if (DETOV(dep)->v_mount->mnt_flag & MNT_RDONLY)
|
||||
return (0);
|
||||
getnanotime(&ts);
|
||||
DETIMES(dep, &ts, &ts, &ts);
|
||||
if ((dep->de_flag & DE_MODIFIED) == 0)
|
||||
return (0);
|
||||
dep->de_flag &= ~DE_MODIFIED;
|
||||
if (dep->de_Attributes & ATTR_DIRECTORY)
|
||||
return (0);
|
||||
if (dep->de_refcnt <= 0)
|
||||
return (0);
|
||||
error = readde(dep, &bp, &dirp);
|
||||
if (error)
|
||||
return (error);
|
||||
DE_EXTERNALIZE(dirp, dep);
|
||||
if (waitfor)
|
||||
return (bwrite(bp));
|
||||
else {
|
||||
bdwrite(bp);
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Truncate the file described by dep to the length specified by length.
|
||||
*/
|
||||
int
|
||||
detrunc(dep, length, flags, cred, p)
|
||||
struct denode *dep;
|
||||
u_long length;
|
||||
int flags;
|
||||
struct ucred *cred;
|
||||
struct proc *p;
|
||||
{
|
||||
int error;
|
||||
int allerror;
|
||||
u_long eofentry;
|
||||
u_long chaintofree;
|
||||
daddr_t bn;
|
||||
int boff;
|
||||
int isadir = dep->de_Attributes & ATTR_DIRECTORY;
|
||||
struct buf *bp;
|
||||
struct msdosfsmount *pmp = dep->de_pmp;
|
||||
|
||||
#ifdef MSDOSFS_DEBUG
|
||||
printf("detrunc(): file %s, length %lu, flags %x\n", dep->de_Name, length, flags);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Disallow attempts to truncate the root directory since it is of
|
||||
* fixed size. That's just the way dos filesystems are. We use
|
||||
* the VROOT bit in the vnode because checking for the directory
|
||||
* bit and a startcluster of 0 in the denode is not adequate to
|
||||
* recognize the root directory at this point in a file or
|
||||
* directory's life.
|
||||
*/
|
||||
if ((DETOV(dep)->v_flag & VROOT) && !FAT32(pmp)) {
|
||||
printf("detrunc(): can't truncate root directory, clust %ld, offset %ld\n",
|
||||
dep->de_dirclust, dep->de_diroffset);
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
|
||||
if (dep->de_FileSize < length) {
|
||||
vnode_pager_setsize(DETOV(dep), length);
|
||||
return deextend(dep, length, cred);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the desired length is 0 then remember the starting cluster of
|
||||
* the file and set the StartCluster field in the directory entry
|
||||
* to 0. If the desired length is not zero, then get the number of
|
||||
* the last cluster in the shortened file. Then get the number of
|
||||
* the first cluster in the part of the file that is to be freed.
|
||||
* Then set the next cluster pointer in the last cluster of the
|
||||
* file to CLUST_EOFE.
|
||||
*/
|
||||
if (length == 0) {
|
||||
chaintofree = dep->de_StartCluster;
|
||||
dep->de_StartCluster = 0;
|
||||
eofentry = ~0;
|
||||
} else {
|
||||
error = pcbmap(dep, de_clcount(pmp, length) - 1, 0,
|
||||
&eofentry, 0);
|
||||
if (error) {
|
||||
#ifdef MSDOSFS_DEBUG
|
||||
printf("detrunc(): pcbmap fails %d\n", error);
|
||||
#endif
|
||||
return (error);
|
||||
}
|
||||
}
|
||||
|
||||
fc_purge(dep, de_clcount(pmp, length));
|
||||
|
||||
/*
|
||||
* If the new length is not a multiple of the cluster size then we
|
||||
* must zero the tail end of the new last cluster in case it
|
||||
* becomes part of the file again because of a seek.
|
||||
*/
|
||||
if ((boff = length & pmp->pm_crbomask) != 0) {
|
||||
if (isadir) {
|
||||
bn = cntobn(pmp, eofentry);
|
||||
error = bread(pmp->pm_devvp, bn, pmp->pm_bpcluster,
|
||||
NOCRED, &bp);
|
||||
} else {
|
||||
bn = de_blk(pmp, length);
|
||||
error = bread(DETOV(dep), bn, pmp->pm_bpcluster,
|
||||
NOCRED, &bp);
|
||||
}
|
||||
if (error) {
|
||||
brelse(bp);
|
||||
#ifdef MSDOSFS_DEBUG
|
||||
printf("detrunc(): bread fails %d\n", error);
|
||||
#endif
|
||||
return (error);
|
||||
}
|
||||
/*
|
||||
* is this the right place for it?
|
||||
*/
|
||||
bzero(bp->b_data + boff, pmp->pm_bpcluster - boff);
|
||||
if (flags & IO_SYNC)
|
||||
bwrite(bp);
|
||||
else
|
||||
bdwrite(bp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write out the updated directory entry. Even if the update fails
|
||||
* we free the trailing clusters.
|
||||
*/
|
||||
dep->de_FileSize = length;
|
||||
if (!isadir)
|
||||
dep->de_flag |= DE_UPDATE|DE_MODIFIED;
|
||||
allerror = vtruncbuf(DETOV(dep), cred, p, length, pmp->pm_bpcluster);
|
||||
#ifdef MSDOSFS_DEBUG
|
||||
if (allerror)
|
||||
printf("detrunc(): vtruncbuf error %d\n", allerror);
|
||||
#endif
|
||||
error = deupdat(dep, 1);
|
||||
if (error && (allerror == 0))
|
||||
allerror = error;
|
||||
#ifdef MSDOSFS_DEBUG
|
||||
printf("detrunc(): allerror %d, eofentry %lu\n",
|
||||
allerror, eofentry);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If we need to break the cluster chain for the file then do it
|
||||
* now.
|
||||
*/
|
||||
if (eofentry != ~0) {
|
||||
error = fatentry(FAT_GET_AND_SET, pmp, eofentry,
|
||||
&chaintofree, CLUST_EOFE);
|
||||
if (error) {
|
||||
#ifdef MSDOSFS_DEBUG
|
||||
printf("detrunc(): fatentry errors %d\n", error);
|
||||
#endif
|
||||
return (error);
|
||||
}
|
||||
fc_setcache(dep, FC_LASTFC, de_cluster(pmp, length - 1),
|
||||
eofentry);
|
||||
}
|
||||
|
||||
/*
|
||||
* Now free the clusters removed from the file because of the
|
||||
* truncation.
|
||||
*/
|
||||
if (chaintofree != 0 && !MSDOSFSEOF(pmp, chaintofree))
|
||||
freeclusterchain(pmp, chaintofree);
|
||||
|
||||
return (allerror);
|
||||
}
|
||||
|
||||
/*
|
||||
* Extend the file described by dep to length specified by length.
|
||||
*/
|
||||
int
|
||||
deextend(dep, length, cred)
|
||||
struct denode *dep;
|
||||
u_long length;
|
||||
struct ucred *cred;
|
||||
{
|
||||
struct msdosfsmount *pmp = dep->de_pmp;
|
||||
u_long count;
|
||||
int error;
|
||||
|
||||
/*
|
||||
* The root of a DOS filesystem cannot be extended.
|
||||
*/
|
||||
if ((DETOV(dep)->v_flag & VROOT) && !FAT32(pmp))
|
||||
return (EINVAL);
|
||||
|
||||
/*
|
||||
* Directories cannot be extended.
|
||||
*/
|
||||
if (dep->de_Attributes & ATTR_DIRECTORY)
|
||||
return (EISDIR);
|
||||
|
||||
if (length <= dep->de_FileSize)
|
||||
panic("deextend: file too large");
|
||||
|
||||
/*
|
||||
* Compute the number of clusters to allocate.
|
||||
*/
|
||||
count = de_clcount(pmp, length) - de_clcount(pmp, dep->de_FileSize);
|
||||
if (count > 0) {
|
||||
if (count > pmp->pm_freeclustercount)
|
||||
return (ENOSPC);
|
||||
error = extendfile(dep, count, NULL, NULL, DE_CLEAR);
|
||||
if (error) {
|
||||
/* truncate the added clusters away again */
|
||||
(void) detrunc(dep, dep->de_FileSize, 0, cred, NULL);
|
||||
return (error);
|
||||
}
|
||||
}
|
||||
dep->de_FileSize = length;
|
||||
dep->de_flag |= DE_UPDATE|DE_MODIFIED;
|
||||
return (deupdat(dep, 1));
|
||||
}
|
||||
|
||||
/*
|
||||
* Move a denode to its correct hash queue after the file it represents has
|
||||
* been moved to a new directory.
|
||||
*/
|
||||
void
|
||||
reinsert(dep)
|
||||
struct denode *dep;
|
||||
{
|
||||
/*
|
||||
* Fix up the denode cache. If the denode is for a directory,
|
||||
* there is nothing to do since the hash is based on the starting
|
||||
* cluster of the directory file and that hasn't changed. If for a
|
||||
* file the hash is based on the location of the directory entry,
|
||||
* so we must remove it from the cache and re-enter it with the
|
||||
* hash based on the new location of the directory entry.
|
||||
*/
|
||||
if (dep->de_Attributes & ATTR_DIRECTORY)
|
||||
return;
|
||||
msdosfs_hashrem(dep);
|
||||
msdosfs_hashins(dep);
|
||||
}
|
||||
|
||||
int
|
||||
msdosfs_reclaim(ap)
|
||||
struct vop_reclaim_args /* {
|
||||
struct vnode *a_vp;
|
||||
} */ *ap;
|
||||
{
|
||||
struct vnode *vp = ap->a_vp;
|
||||
struct denode *dep = VTODE(vp);
|
||||
|
||||
#ifdef MSDOSFS_DEBUG
|
||||
printf("msdosfs_reclaim(): dep %p, file %s, refcnt %ld\n",
|
||||
dep, dep->de_Name, dep->de_refcnt);
|
||||
#endif
|
||||
|
||||
if (prtactive && vp->v_usecount != 0)
|
||||
vprint("msdosfs_reclaim(): pushing active", vp);
|
||||
/*
|
||||
* Remove the denode from its hash chain.
|
||||
*/
|
||||
msdosfs_hashrem(dep);
|
||||
/*
|
||||
* Purge old data structures associated with the denode.
|
||||
*/
|
||||
cache_purge(vp);
|
||||
if (dep->de_devvp) {
|
||||
vrele(dep->de_devvp);
|
||||
dep->de_devvp = 0;
|
||||
}
|
||||
#if 0 /* XXX */
|
||||
dep->de_flag = 0;
|
||||
#endif
|
||||
lockdestroy(&vp->v_lock);
|
||||
FREE(dep, M_MSDOSFSNODE);
|
||||
vp->v_data = NULL;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
msdosfs_inactive(ap)
|
||||
struct vop_inactive_args /* {
|
||||
struct vnode *a_vp;
|
||||
struct proc *a_p;
|
||||
} */ *ap;
|
||||
{
|
||||
struct vnode *vp = ap->a_vp;
|
||||
struct denode *dep = VTODE(vp);
|
||||
struct proc *p = ap->a_p;
|
||||
int error = 0;
|
||||
|
||||
#ifdef MSDOSFS_DEBUG
|
||||
printf("msdosfs_inactive(): dep %p, de_Name[0] %x\n", dep, dep->de_Name[0]);
|
||||
#endif
|
||||
|
||||
if (prtactive && vp->v_usecount != 0)
|
||||
vprint("msdosfs_inactive(): pushing active", vp);
|
||||
|
||||
/*
|
||||
* Ignore denodes related to stale file handles.
|
||||
*/
|
||||
if (dep->de_Name[0] == SLOT_DELETED)
|
||||
goto out;
|
||||
|
||||
/*
|
||||
* If the file has been deleted and it is on a read/write
|
||||
* filesystem, then truncate the file, and mark the directory slot
|
||||
* as empty. (This may not be necessary for the dos filesystem.)
|
||||
*/
|
||||
#ifdef MSDOSFS_DEBUG
|
||||
printf("msdosfs_inactive(): dep %p, refcnt %ld, mntflag %x, MNT_RDONLY %x\n",
|
||||
dep, dep->de_refcnt, vp->v_mount->mnt_flag, MNT_RDONLY);
|
||||
#endif
|
||||
if (dep->de_refcnt <= 0 && (vp->v_mount->mnt_flag & MNT_RDONLY) == 0) {
|
||||
error = detrunc(dep, (u_long) 0, 0, NOCRED, p);
|
||||
dep->de_flag |= DE_UPDATE;
|
||||
dep->de_Name[0] = SLOT_DELETED;
|
||||
}
|
||||
deupdat(dep, 0);
|
||||
|
||||
out:
|
||||
VOP_UNLOCK(vp, 0, p);
|
||||
/*
|
||||
* If we are done with the denode, reclaim it
|
||||
* so that it can be reused immediately.
|
||||
*/
|
||||
#ifdef MSDOSFS_DEBUG
|
||||
printf("msdosfs_inactive(): v_usecount %d, de_Name[0] %x\n", vp->v_usecount,
|
||||
dep->de_Name[0]);
|
||||
#endif
|
||||
if (dep->de_Name[0] == SLOT_DELETED)
|
||||
vrecycle(vp, NULL, p);
|
||||
return (error);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,964 +0,0 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $NetBSD: msdosfs_vfsops.c,v 1.51 1997/11/17 15:36:58 ws Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
|
||||
* Copyright (C) 1994, 1995, 1997 TooLs GmbH.
|
||||
* All rights reserved.
|
||||
* Original code by Paul Popelka (paulp@uts.amdahl.com) (see below).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by TooLs GmbH.
|
||||
* 4. The name of TooLs GmbH may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*
|
||||
* Written by Paul Popelka (paulp@uts.amdahl.com)
|
||||
*
|
||||
* You can do anything you want with this software, just don't say you wrote
|
||||
* it, and don't remove this notice.
|
||||
*
|
||||
* This software is provided "as is".
|
||||
*
|
||||
* The author supplies this software to be publicly redistributed on the
|
||||
* understanding that the author is not responsible for the correct
|
||||
* functioning of this software in any circumstances and is not liable for
|
||||
* any damages caused by this software.
|
||||
*
|
||||
* October 1992
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/conf.h>
|
||||
#include <sys/namei.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/bio.h>
|
||||
#include <sys/buf.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/stat.h> /* defines ALLPERMS */
|
||||
#include <sys/mutex.h>
|
||||
|
||||
#include <msdosfs/bpb.h>
|
||||
#include <msdosfs/bootsect.h>
|
||||
#include <msdosfs/direntry.h>
|
||||
#include <msdosfs/denode.h>
|
||||
#include <msdosfs/msdosfsmount.h>
|
||||
#include <msdosfs/fat.h>
|
||||
|
||||
#define MSDOSFS_DFLTBSIZE 4096
|
||||
|
||||
#if 1 /*def PC98*/
|
||||
/*
|
||||
* XXX - The boot signature formatted by NEC PC-98 DOS looks like a
|
||||
* garbage or a random value :-{
|
||||
* If you want to use that broken-signatured media, define the
|
||||
* following symbol even though PC/AT.
|
||||
* (ex. mount PC-98 DOS formatted FD on PC/AT)
|
||||
*/
|
||||
#define MSDOSFS_NOCHECKSIG
|
||||
#endif
|
||||
|
||||
MALLOC_DEFINE(M_MSDOSFSMNT, "MSDOSFS mount", "MSDOSFS mount structure");
|
||||
static MALLOC_DEFINE(M_MSDOSFSFAT, "MSDOSFS FAT", "MSDOSFS file allocation table");
|
||||
|
||||
static int update_mp __P((struct mount *mp, struct msdosfs_args *argp));
|
||||
static int mountmsdosfs __P((struct vnode *devvp, struct mount *mp,
|
||||
struct proc *p, struct msdosfs_args *argp));
|
||||
static int msdosfs_fhtovp __P((struct mount *, struct fid *,
|
||||
struct vnode **));
|
||||
static int msdosfs_mount __P((struct mount *, char *, caddr_t,
|
||||
struct nameidata *, struct proc *));
|
||||
static int msdosfs_root __P((struct mount *, struct vnode **));
|
||||
static int msdosfs_statfs __P((struct mount *, struct statfs *,
|
||||
struct proc *));
|
||||
static int msdosfs_sync __P((struct mount *, int, struct ucred *,
|
||||
struct proc *));
|
||||
static int msdosfs_unmount __P((struct mount *, int, struct proc *));
|
||||
static int msdosfs_vptofh __P((struct vnode *, struct fid *));
|
||||
|
||||
static int
|
||||
update_mp(mp, argp)
|
||||
struct mount *mp;
|
||||
struct msdosfs_args *argp;
|
||||
{
|
||||
struct msdosfsmount *pmp = VFSTOMSDOSFS(mp);
|
||||
int error;
|
||||
|
||||
pmp->pm_gid = argp->gid;
|
||||
pmp->pm_uid = argp->uid;
|
||||
pmp->pm_mask = argp->mask & ALLPERMS;
|
||||
pmp->pm_flags |= argp->flags & MSDOSFSMNT_MNTOPT;
|
||||
if (pmp->pm_flags & MSDOSFSMNT_U2WTABLE) {
|
||||
bcopy(argp->u2w, pmp->pm_u2w, sizeof(pmp->pm_u2w));
|
||||
bcopy(argp->d2u, pmp->pm_d2u, sizeof(pmp->pm_d2u));
|
||||
bcopy(argp->u2d, pmp->pm_u2d, sizeof(pmp->pm_u2d));
|
||||
}
|
||||
if (pmp->pm_flags & MSDOSFSMNT_ULTABLE) {
|
||||
bcopy(argp->ul, pmp->pm_ul, sizeof(pmp->pm_ul));
|
||||
bcopy(argp->lu, pmp->pm_lu, sizeof(pmp->pm_lu));
|
||||
}
|
||||
|
||||
#ifndef __FreeBSD__
|
||||
/*
|
||||
* GEMDOS knows nothing (yet) about win95
|
||||
*/
|
||||
if (pmp->pm_flags & MSDOSFSMNT_GEMDOSFS)
|
||||
pmp->pm_flags |= MSDOSFSMNT_NOWIN95;
|
||||
#endif
|
||||
|
||||
if (pmp->pm_flags & MSDOSFSMNT_NOWIN95)
|
||||
pmp->pm_flags |= MSDOSFSMNT_SHORTNAME;
|
||||
else if (!(pmp->pm_flags &
|
||||
(MSDOSFSMNT_SHORTNAME | MSDOSFSMNT_LONGNAME))) {
|
||||
struct vnode *rootvp;
|
||||
|
||||
/*
|
||||
* Try to divine whether to support Win'95 long filenames
|
||||
*/
|
||||
if (FAT32(pmp))
|
||||
pmp->pm_flags |= MSDOSFSMNT_LONGNAME;
|
||||
else {
|
||||
if ((error = msdosfs_root(mp, &rootvp)) != 0)
|
||||
return error;
|
||||
pmp->pm_flags |= findwin95(VTODE(rootvp))
|
||||
? MSDOSFSMNT_LONGNAME
|
||||
: MSDOSFSMNT_SHORTNAME;
|
||||
vput(rootvp);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef __FreeBSD__
|
||||
int
|
||||
msdosfs_mountroot()
|
||||
{
|
||||
register struct mount *mp;
|
||||
struct proc *p = curproc; /* 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;
|
||||
LIST_INIT(&mp->mnt_vnodelist);
|
||||
|
||||
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, p);
|
||||
free(mp, M_MOUNT);
|
||||
return (error);
|
||||
}
|
||||
|
||||
if ((error = vfs_lock(mp)) != 0) {
|
||||
(void)msdosfs_unmount(mp, 0, p);
|
||||
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, p);
|
||||
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
|
||||
* special file to treat as a filesystem.
|
||||
*/
|
||||
static int
|
||||
msdosfs_mount(mp, path, data, ndp, p)
|
||||
struct mount *mp;
|
||||
char *path;
|
||||
caddr_t data;
|
||||
struct nameidata *ndp;
|
||||
struct proc *p;
|
||||
{
|
||||
struct vnode *devvp; /* vnode for blk device to mount */
|
||||
struct msdosfs_args args; /* will hold data from mount request */
|
||||
/* msdosfs specific mount control block */
|
||||
struct msdosfsmount *pmp = NULL;
|
||||
size_t size;
|
||||
int error, flags;
|
||||
mode_t accessmode;
|
||||
|
||||
error = copyin(data, (caddr_t)&args, sizeof(struct msdosfs_args));
|
||||
if (error)
|
||||
return (error);
|
||||
if (args.magic != MSDOSFS_ARGSMAGIC)
|
||||
args.flags = 0;
|
||||
/*
|
||||
* If updating, check whether changing from read-only to
|
||||
* read/write; if there is no device name, that's all we do.
|
||||
*/
|
||||
if (mp->mnt_flag & MNT_UPDATE) {
|
||||
pmp = VFSTOMSDOSFS(mp);
|
||||
error = 0;
|
||||
if (!(pmp->pm_flags & MSDOSFSMNT_RONLY) && (mp->mnt_flag & MNT_RDONLY)) {
|
||||
flags = WRITECLOSE;
|
||||
if (mp->mnt_flag & MNT_FORCE)
|
||||
flags |= FORCECLOSE;
|
||||
error = vflush(mp, 0, flags);
|
||||
}
|
||||
if (!error && (mp->mnt_flag & MNT_RELOAD))
|
||||
/* not yet implemented */
|
||||
error = EOPNOTSUPP;
|
||||
if (error)
|
||||
return (error);
|
||||
if ((pmp->pm_flags & MSDOSFSMNT_RONLY) && (mp->mnt_kern_flag & MNTK_WANTRDWR)) {
|
||||
/*
|
||||
* If upgrade to read-write by non-root, then verify
|
||||
* that user has necessary permissions on the device.
|
||||
*/
|
||||
if (p->p_ucred->cr_uid != 0) {
|
||||
devvp = pmp->pm_devvp;
|
||||
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);
|
||||
error = VOP_ACCESS(devvp, VREAD | VWRITE,
|
||||
p->p_ucred, p);
|
||||
if (error) {
|
||||
VOP_UNLOCK(devvp, 0, p);
|
||||
return (error);
|
||||
}
|
||||
VOP_UNLOCK(devvp, 0, p);
|
||||
}
|
||||
pmp->pm_flags &= ~MSDOSFSMNT_RONLY;
|
||||
}
|
||||
if (args.fspec == 0) {
|
||||
#ifdef __notyet__ /* doesn't work correctly with current mountd XXX */
|
||||
if (args.flags & MSDOSFSMNT_MNTOPT) {
|
||||
pmp->pm_flags &= ~MSDOSFSMNT_MNTOPT;
|
||||
pmp->pm_flags |= args.flags & MSDOSFSMNT_MNTOPT;
|
||||
if (pmp->pm_flags & MSDOSFSMNT_NOWIN95)
|
||||
pmp->pm_flags |= MSDOSFSMNT_SHORTNAME;
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* Process export requests.
|
||||
*/
|
||||
return (vfs_export(mp, &args.export));
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Not an update, or updating the name: look up the name
|
||||
* and verify that it refers to a sensible block device.
|
||||
*/
|
||||
NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, p);
|
||||
error = namei(ndp);
|
||||
if (error)
|
||||
return (error);
|
||||
devvp = ndp->ni_vp;
|
||||
NDFREE(ndp, NDF_ONLY_PNBUF);
|
||||
|
||||
if (!vn_isdisk(devvp, &error)) {
|
||||
vrele(devvp);
|
||||
return (error);
|
||||
}
|
||||
/*
|
||||
* If mount by non-root, then verify that user has necessary
|
||||
* permissions on the device.
|
||||
*/
|
||||
if (p->p_ucred->cr_uid != 0) {
|
||||
accessmode = VREAD;
|
||||
if ((mp->mnt_flag & MNT_RDONLY) == 0)
|
||||
accessmode |= VWRITE;
|
||||
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);
|
||||
error = VOP_ACCESS(devvp, accessmode, p->p_ucred, p);
|
||||
if (error) {
|
||||
vput(devvp);
|
||||
return (error);
|
||||
}
|
||||
VOP_UNLOCK(devvp, 0, p);
|
||||
}
|
||||
if ((mp->mnt_flag & MNT_UPDATE) == 0) {
|
||||
error = mountmsdosfs(devvp, mp, p, &args);
|
||||
#ifdef MSDOSFS_DEBUG /* only needed for the printf below */
|
||||
pmp = VFSTOMSDOSFS(mp);
|
||||
#endif
|
||||
} else {
|
||||
if (devvp != pmp->pm_devvp)
|
||||
error = EINVAL; /* XXX needs translation */
|
||||
else
|
||||
vrele(devvp);
|
||||
}
|
||||
if (error) {
|
||||
vrele(devvp);
|
||||
return (error);
|
||||
}
|
||||
|
||||
error = update_mp(mp, &args);
|
||||
if (error) {
|
||||
msdosfs_unmount(mp, MNT_FORCE, p);
|
||||
return error;
|
||||
}
|
||||
(void) copyinstr(args.fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1,
|
||||
&size);
|
||||
bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
|
||||
(void) msdosfs_statfs(mp, &mp->mnt_stat, p);
|
||||
#ifdef MSDOSFS_DEBUG
|
||||
printf("msdosfs_mount(): mp %p, pmp %p, inusemap %p\n", mp, pmp, pmp->pm_inusemap);
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
mountmsdosfs(devvp, mp, p, argp)
|
||||
struct vnode *devvp;
|
||||
struct mount *mp;
|
||||
struct proc *p;
|
||||
struct msdosfs_args *argp;
|
||||
{
|
||||
struct msdosfsmount *pmp;
|
||||
struct buf *bp;
|
||||
dev_t dev = devvp->v_rdev;
|
||||
#ifndef __FreeBSD__
|
||||
struct partinfo dpart;
|
||||
int bsize = 0, dtype = 0, tmp;
|
||||
#endif
|
||||
union bootsector *bsp;
|
||||
struct byte_bpb33 *b33;
|
||||
struct byte_bpb50 *b50;
|
||||
struct byte_bpb710 *b710;
|
||||
u_int8_t SecPerClust;
|
||||
u_long clusters;
|
||||
int ronly, error;
|
||||
|
||||
/*
|
||||
* Disallow multiple mounts of the same device.
|
||||
* Disallow mounting of a device that is currently in use
|
||||
* (except for root, which might share swap device for miniroot).
|
||||
* Flush out any old buffers remaining from a previous use.
|
||||
*/
|
||||
error = vfs_mountedon(devvp);
|
||||
if (error)
|
||||
return (error);
|
||||
if (vcount(devvp) > 1 && devvp != rootvp)
|
||||
return (EBUSY);
|
||||
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);
|
||||
error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0);
|
||||
VOP_UNLOCK(devvp, 0, p);
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
ronly = (mp->mnt_flag & MNT_RDONLY) != 0;
|
||||
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);
|
||||
error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, p);
|
||||
VOP_UNLOCK(devvp, 0, p);
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
bp = NULL; /* both used in error_exit */
|
||||
pmp = NULL;
|
||||
|
||||
#ifndef __FreeBSD__
|
||||
if (argp->flags & MSDOSFSMNT_GEMDOSFS) {
|
||||
/*
|
||||
* We need the disklabel to calculate the size of a FAT entry
|
||||
* later on. Also make sure the partition contains a filesystem
|
||||
* of type FS_MSDOS. This doesn't work for floppies, so we have
|
||||
* to check for them too.
|
||||
*
|
||||
* At least some parts of the msdos fs driver seem to assume
|
||||
* that the size of a disk block will always be 512 bytes.
|
||||
* Let's check it...
|
||||
*/
|
||||
error = VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart,
|
||||
FREAD, NOCRED, p);
|
||||
if (error)
|
||||
goto error_exit;
|
||||
tmp = dpart.part->p_fstype;
|
||||
dtype = dpart.disklab->d_type;
|
||||
bsize = dpart.disklab->d_secsize;
|
||||
if (bsize != 512 || (dtype!=DTYPE_FLOPPY && tmp!=FS_MSDOS)) {
|
||||
error = EINVAL;
|
||||
goto error_exit;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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...
|
||||
*/
|
||||
error = bread(devvp, 0, 2048, NOCRED, &bp);
|
||||
if (error)
|
||||
goto error_exit;
|
||||
bp->b_flags |= B_AGE;
|
||||
bsp = (union bootsector *)bp->b_data;
|
||||
b33 = (struct byte_bpb33 *)bsp->bs33.bsBPB;
|
||||
b50 = (struct byte_bpb50 *)bsp->bs50.bsBPB;
|
||||
b710 = (struct byte_bpb710 *)bsp->bs710.bsPBP;
|
||||
|
||||
#ifndef __FreeBSD__
|
||||
if (!(argp->flags & MSDOSFSMNT_GEMDOSFS)) {
|
||||
#endif
|
||||
#ifndef MSDOSFS_NOCHECKSIG
|
||||
if (bsp->bs50.bsBootSectSig0 != BOOTSIG0
|
||||
|| bsp->bs50.bsBootSectSig1 != BOOTSIG1) {
|
||||
error = EINVAL;
|
||||
goto error_exit;
|
||||
}
|
||||
#endif
|
||||
#ifndef __FreeBSD__
|
||||
}
|
||||
#endif
|
||||
|
||||
pmp = malloc(sizeof *pmp, M_MSDOSFSMNT, M_WAITOK | M_ZERO);
|
||||
pmp->pm_mountp = mp;
|
||||
|
||||
/*
|
||||
* Compute several useful quantities from the bpb in the
|
||||
* bootsector. Copy in the dos 5 variant of the bpb then fix up
|
||||
* the fields that are different between dos 5 and dos 3.3.
|
||||
*/
|
||||
SecPerClust = b50->bpbSecPerClust;
|
||||
pmp->pm_BytesPerSec = getushort(b50->bpbBytesPerSec);
|
||||
pmp->pm_ResSectors = getushort(b50->bpbResSectors);
|
||||
pmp->pm_FATs = b50->bpbFATs;
|
||||
pmp->pm_RootDirEnts = getushort(b50->bpbRootDirEnts);
|
||||
pmp->pm_Sectors = getushort(b50->bpbSectors);
|
||||
pmp->pm_FATsecs = getushort(b50->bpbFATsecs);
|
||||
pmp->pm_SecPerTrack = getushort(b50->bpbSecPerTrack);
|
||||
pmp->pm_Heads = getushort(b50->bpbHeads);
|
||||
pmp->pm_Media = b50->bpbMedia;
|
||||
|
||||
/* calculate the ratio of sector size to DEV_BSIZE */
|
||||
pmp->pm_BlkPerSec = pmp->pm_BytesPerSec / DEV_BSIZE;
|
||||
|
||||
#ifndef __FreeBSD__
|
||||
if (!(argp->flags & MSDOSFSMNT_GEMDOSFS)) {
|
||||
#endif
|
||||
/* XXX - We should probably check more values here */
|
||||
if (!pmp->pm_BytesPerSec || !SecPerClust
|
||||
|| !pmp->pm_Heads || pmp->pm_Heads > 255
|
||||
#ifdef PC98
|
||||
|| !pmp->pm_SecPerTrack || pmp->pm_SecPerTrack > 255) {
|
||||
#else
|
||||
|| !pmp->pm_SecPerTrack || pmp->pm_SecPerTrack > 63) {
|
||||
#endif
|
||||
error = EINVAL;
|
||||
goto error_exit;
|
||||
}
|
||||
#ifndef __FreeBSD__
|
||||
}
|
||||
#endif
|
||||
|
||||
if (pmp->pm_Sectors == 0) {
|
||||
pmp->pm_HiddenSects = getulong(b50->bpbHiddenSecs);
|
||||
pmp->pm_HugeSectors = getulong(b50->bpbHugeSectors);
|
||||
} else {
|
||||
pmp->pm_HiddenSects = getushort(b33->bpbHiddenSecs);
|
||||
pmp->pm_HugeSectors = pmp->pm_Sectors;
|
||||
}
|
||||
if (pmp->pm_HugeSectors > 0xffffffff /
|
||||
(pmp->pm_BytesPerSec / sizeof(struct direntry)) + 1) {
|
||||
/*
|
||||
* We cannot deal currently with this size of disk
|
||||
* due to fileid limitations (see msdosfs_getattr and
|
||||
* msdosfs_readdir)
|
||||
*/
|
||||
error = EINVAL;
|
||||
printf("mountmsdosfs(): disk too big, sorry\n");
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
if (pmp->pm_RootDirEnts == 0) {
|
||||
if (bsp->bs710.bsBootSectSig2 != BOOTSIG2
|
||||
|| bsp->bs710.bsBootSectSig3 != BOOTSIG3
|
||||
|| pmp->pm_Sectors
|
||||
|| pmp->pm_FATsecs
|
||||
|| getushort(b710->bpbFSVers)) {
|
||||
error = EINVAL;
|
||||
printf("mountmsdosfs(): bad FAT32 filesystem\n");
|
||||
goto error_exit;
|
||||
}
|
||||
pmp->pm_fatmask = FAT32_MASK;
|
||||
pmp->pm_fatmult = 4;
|
||||
pmp->pm_fatdiv = 1;
|
||||
pmp->pm_FATsecs = getulong(b710->bpbBigFATsecs);
|
||||
if (getushort(b710->bpbExtFlags) & FATMIRROR)
|
||||
pmp->pm_curfat = getushort(b710->bpbExtFlags) & FATNUM;
|
||||
else
|
||||
pmp->pm_flags |= MSDOSFS_FATMIRROR;
|
||||
} else
|
||||
pmp->pm_flags |= MSDOSFS_FATMIRROR;
|
||||
|
||||
/*
|
||||
* Check a few values (could do some more):
|
||||
* - logical sector size: power of 2, >= block size
|
||||
* - sectors per cluster: power of 2, >= 1
|
||||
* - number of sectors: >= 1, <= size of partition
|
||||
*/
|
||||
if ( (SecPerClust == 0)
|
||||
|| (SecPerClust & (SecPerClust - 1))
|
||||
|| (pmp->pm_BytesPerSec < DEV_BSIZE)
|
||||
|| (pmp->pm_BytesPerSec & (pmp->pm_BytesPerSec - 1))
|
||||
|| (pmp->pm_HugeSectors == 0)
|
||||
) {
|
||||
error = EINVAL;
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
pmp->pm_HugeSectors *= pmp->pm_BlkPerSec;
|
||||
pmp->pm_HiddenSects *= pmp->pm_BlkPerSec; /* XXX not used? */
|
||||
pmp->pm_FATsecs *= pmp->pm_BlkPerSec;
|
||||
SecPerClust *= pmp->pm_BlkPerSec;
|
||||
|
||||
pmp->pm_fatblk = pmp->pm_ResSectors * pmp->pm_BlkPerSec;
|
||||
|
||||
if (FAT32(pmp)) {
|
||||
pmp->pm_rootdirblk = getulong(b710->bpbRootClust);
|
||||
pmp->pm_firstcluster = pmp->pm_fatblk
|
||||
+ (pmp->pm_FATs * pmp->pm_FATsecs);
|
||||
pmp->pm_fsinfo = getushort(b710->bpbFSInfo) * pmp->pm_BlkPerSec;
|
||||
} else {
|
||||
pmp->pm_rootdirblk = pmp->pm_fatblk +
|
||||
(pmp->pm_FATs * pmp->pm_FATsecs);
|
||||
pmp->pm_rootdirsize = (pmp->pm_RootDirEnts * sizeof(struct direntry)
|
||||
+ DEV_BSIZE - 1)
|
||||
/ DEV_BSIZE; /* in blocks */
|
||||
pmp->pm_firstcluster = pmp->pm_rootdirblk + pmp->pm_rootdirsize;
|
||||
}
|
||||
|
||||
pmp->pm_maxcluster = (pmp->pm_HugeSectors - pmp->pm_firstcluster) /
|
||||
SecPerClust + 1;
|
||||
pmp->pm_fatsize = pmp->pm_FATsecs * DEV_BSIZE; /* XXX not used? */
|
||||
|
||||
#ifndef __FreeBSD__
|
||||
if (argp->flags & MSDOSFSMNT_GEMDOSFS) {
|
||||
if ((pmp->pm_maxcluster <= (0xff0 - 2))
|
||||
&& ((dtype == DTYPE_FLOPPY) || ((dtype == DTYPE_VNODE)
|
||||
&& ((pmp->pm_Heads == 1) || (pmp->pm_Heads == 2))))
|
||||
) {
|
||||
pmp->pm_fatmask = FAT12_MASK;
|
||||
pmp->pm_fatmult = 3;
|
||||
pmp->pm_fatdiv = 2;
|
||||
} else {
|
||||
pmp->pm_fatmask = FAT16_MASK;
|
||||
pmp->pm_fatmult = 2;
|
||||
pmp->pm_fatdiv = 1;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
if (pmp->pm_fatmask == 0) {
|
||||
if (pmp->pm_maxcluster
|
||||
<= ((CLUST_RSRVD - CLUST_FIRST) & FAT12_MASK)) {
|
||||
/*
|
||||
* This will usually be a floppy disk. This size makes
|
||||
* sure that one fat entry will not be split across
|
||||
* multiple blocks.
|
||||
*/
|
||||
pmp->pm_fatmask = FAT12_MASK;
|
||||
pmp->pm_fatmult = 3;
|
||||
pmp->pm_fatdiv = 2;
|
||||
} else {
|
||||
pmp->pm_fatmask = FAT16_MASK;
|
||||
pmp->pm_fatmult = 2;
|
||||
pmp->pm_fatdiv = 1;
|
||||
}
|
||||
}
|
||||
|
||||
clusters = (pmp->pm_fatsize / pmp->pm_fatmult) * pmp->pm_fatdiv;
|
||||
if (pmp->pm_maxcluster >= clusters) {
|
||||
printf("Warning: number of clusters (%ld) exceeds FAT "
|
||||
"capacity (%ld)\n", pmp->pm_maxcluster + 1, clusters);
|
||||
pmp->pm_maxcluster = clusters - 1;
|
||||
}
|
||||
|
||||
|
||||
if (FAT12(pmp))
|
||||
pmp->pm_fatblocksize = 3 * pmp->pm_BytesPerSec;
|
||||
else
|
||||
pmp->pm_fatblocksize = MSDOSFS_DFLTBSIZE;
|
||||
|
||||
pmp->pm_fatblocksec = pmp->pm_fatblocksize / DEV_BSIZE;
|
||||
pmp->pm_bnshift = ffs(DEV_BSIZE) - 1;
|
||||
|
||||
/*
|
||||
* Compute mask and shift value for isolating cluster relative byte
|
||||
* offsets and cluster numbers from a file offset.
|
||||
*/
|
||||
pmp->pm_bpcluster = SecPerClust * DEV_BSIZE;
|
||||
pmp->pm_crbomask = pmp->pm_bpcluster - 1;
|
||||
pmp->pm_cnshift = ffs(pmp->pm_bpcluster) - 1;
|
||||
|
||||
/*
|
||||
* Check for valid cluster size
|
||||
* must be a power of 2
|
||||
*/
|
||||
if (pmp->pm_bpcluster ^ (1 << pmp->pm_cnshift)) {
|
||||
error = EINVAL;
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
/*
|
||||
* Release the bootsector buffer.
|
||||
*/
|
||||
brelse(bp);
|
||||
bp = NULL;
|
||||
|
||||
/*
|
||||
* Check FSInfo.
|
||||
*/
|
||||
if (pmp->pm_fsinfo) {
|
||||
struct fsinfo *fp;
|
||||
|
||||
if ((error = bread(devvp, pmp->pm_fsinfo, fsi_size(pmp),
|
||||
NOCRED, &bp)) != 0)
|
||||
goto error_exit;
|
||||
fp = (struct fsinfo *)bp->b_data;
|
||||
if (!bcmp(fp->fsisig1, "RRaA", 4)
|
||||
&& !bcmp(fp->fsisig2, "rrAa", 4)
|
||||
&& !bcmp(fp->fsisig3, "\0\0\125\252", 4)
|
||||
&& !bcmp(fp->fsisig4, "\0\0\125\252", 4))
|
||||
pmp->pm_nxtfree = getulong(fp->fsinxtfree);
|
||||
else
|
||||
pmp->pm_fsinfo = 0;
|
||||
brelse(bp);
|
||||
bp = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check and validate (or perhaps invalidate?) the fsinfo structure? XXX
|
||||
*/
|
||||
|
||||
/*
|
||||
* Allocate memory for the bitmap of allocated clusters, and then
|
||||
* fill it in.
|
||||
*/
|
||||
pmp->pm_inusemap = malloc(((pmp->pm_maxcluster + N_INUSEBITS - 1)
|
||||
/ N_INUSEBITS)
|
||||
* sizeof(*pmp->pm_inusemap),
|
||||
M_MSDOSFSFAT, M_WAITOK);
|
||||
|
||||
/*
|
||||
* fillinusemap() needs pm_devvp.
|
||||
*/
|
||||
pmp->pm_dev = dev;
|
||||
pmp->pm_devvp = devvp;
|
||||
|
||||
/*
|
||||
* Have the inuse map filled in.
|
||||
*/
|
||||
if ((error = fillinusemap(pmp)) != 0)
|
||||
goto error_exit;
|
||||
|
||||
/*
|
||||
* If they want fat updates to be synchronous then let them suffer
|
||||
* the performance degradation in exchange for the on disk copy of
|
||||
* the fat being correct just about all the time. I suppose this
|
||||
* would be a good thing to turn on if the kernel is still flakey.
|
||||
*/
|
||||
if (mp->mnt_flag & MNT_SYNCHRONOUS)
|
||||
pmp->pm_flags |= MSDOSFSMNT_WAITONFAT;
|
||||
|
||||
/*
|
||||
* Finish up.
|
||||
*/
|
||||
if (ronly)
|
||||
pmp->pm_flags |= MSDOSFSMNT_RONLY;
|
||||
else
|
||||
pmp->pm_fmod = 1;
|
||||
mp->mnt_data = (qaddr_t) pmp;
|
||||
mp->mnt_stat.f_fsid.val[0] = dev2udev(dev);
|
||||
mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum;
|
||||
mp->mnt_flag |= MNT_LOCAL;
|
||||
devvp->v_rdev->si_mountpoint = mp;
|
||||
|
||||
return 0;
|
||||
|
||||
error_exit:
|
||||
if (bp)
|
||||
brelse(bp);
|
||||
(void) VOP_CLOSE(devvp, ronly ? FREAD : FREAD | FWRITE, NOCRED, p);
|
||||
if (pmp) {
|
||||
if (pmp->pm_inusemap)
|
||||
free(pmp->pm_inusemap, M_MSDOSFSFAT);
|
||||
free(pmp, M_MSDOSFSMNT);
|
||||
mp->mnt_data = (qaddr_t)0;
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* Unmount the filesystem described by mp.
|
||||
*/
|
||||
static int
|
||||
msdosfs_unmount(mp, mntflags, p)
|
||||
struct mount *mp;
|
||||
int mntflags;
|
||||
struct proc *p;
|
||||
{
|
||||
struct msdosfsmount *pmp;
|
||||
int error, flags;
|
||||
|
||||
flags = 0;
|
||||
if (mntflags & MNT_FORCE)
|
||||
flags |= FORCECLOSE;
|
||||
error = vflush(mp, 0, flags);
|
||||
if (error)
|
||||
return error;
|
||||
pmp = VFSTOMSDOSFS(mp);
|
||||
pmp->pm_devvp->v_rdev->si_mountpoint = NULL;
|
||||
#ifdef MSDOSFS_DEBUG
|
||||
{
|
||||
struct vnode *vp = pmp->pm_devvp;
|
||||
|
||||
printf("msdosfs_umount(): just before calling VOP_CLOSE()\n");
|
||||
printf("flag %08lx, usecount %d, writecount %d, holdcnt %ld\n",
|
||||
vp->v_flag, vp->v_usecount, vp->v_writecount, vp->v_holdcnt);
|
||||
printf("id %lu, mount %p, op %p\n",
|
||||
vp->v_id, vp->v_mount, vp->v_op);
|
||||
printf("freef %p, freeb %p, mount %p\n",
|
||||
TAILQ_NEXT(vp, v_freelist), vp->v_freelist.tqe_prev,
|
||||
vp->v_mount);
|
||||
printf("cleanblkhd %p, dirtyblkhd %p, numoutput %ld, type %d\n",
|
||||
TAILQ_FIRST(&vp->v_cleanblkhd),
|
||||
TAILQ_FIRST(&vp->v_dirtyblkhd),
|
||||
vp->v_numoutput, vp->v_type);
|
||||
printf("union %p, tag %d, data[0] %08x, data[1] %08x\n",
|
||||
vp->v_socket, vp->v_tag,
|
||||
((u_int *)vp->v_data)[0],
|
||||
((u_int *)vp->v_data)[1]);
|
||||
}
|
||||
#endif
|
||||
error = VOP_CLOSE(pmp->pm_devvp,
|
||||
(pmp->pm_flags&MSDOSFSMNT_RONLY) ? FREAD : FREAD | FWRITE,
|
||||
NOCRED, p);
|
||||
vrele(pmp->pm_devvp);
|
||||
free(pmp->pm_inusemap, M_MSDOSFSFAT);
|
||||
free(pmp, M_MSDOSFSMNT);
|
||||
mp->mnt_data = (qaddr_t)0;
|
||||
mp->mnt_flag &= ~MNT_LOCAL;
|
||||
return (error);
|
||||
}
|
||||
|
||||
static int
|
||||
msdosfs_root(mp, vpp)
|
||||
struct mount *mp;
|
||||
struct vnode **vpp;
|
||||
{
|
||||
struct msdosfsmount *pmp = VFSTOMSDOSFS(mp);
|
||||
struct denode *ndep;
|
||||
int error;
|
||||
|
||||
#ifdef MSDOSFS_DEBUG
|
||||
printf("msdosfs_root(); mp %p, pmp %p\n", mp, pmp);
|
||||
#endif
|
||||
error = deget(pmp, MSDOSFSROOT, MSDOSFSROOT_OFS, &ndep);
|
||||
if (error)
|
||||
return (error);
|
||||
*vpp = DETOV(ndep);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
msdosfs_statfs(mp, sbp, p)
|
||||
struct mount *mp;
|
||||
struct statfs *sbp;
|
||||
struct proc *p;
|
||||
{
|
||||
struct msdosfsmount *pmp;
|
||||
|
||||
pmp = VFSTOMSDOSFS(mp);
|
||||
sbp->f_bsize = pmp->pm_bpcluster;
|
||||
sbp->f_iosize = pmp->pm_bpcluster;
|
||||
sbp->f_blocks = pmp->pm_maxcluster + 1;
|
||||
sbp->f_bfree = pmp->pm_freeclustercount;
|
||||
sbp->f_bavail = pmp->pm_freeclustercount;
|
||||
sbp->f_files = pmp->pm_RootDirEnts; /* XXX */
|
||||
sbp->f_ffree = 0; /* what to put in here? */
|
||||
if (sbp != &mp->mnt_stat) {
|
||||
sbp->f_type = mp->mnt_vfc->vfc_typenum;
|
||||
bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN);
|
||||
bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN);
|
||||
}
|
||||
strncpy(sbp->f_fstypename, mp->mnt_vfc->vfc_name, MFSNAMELEN);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
msdosfs_sync(mp, waitfor, cred, p)
|
||||
struct mount *mp;
|
||||
int waitfor;
|
||||
struct ucred *cred;
|
||||
struct proc *p;
|
||||
{
|
||||
struct vnode *vp, *nvp;
|
||||
struct denode *dep;
|
||||
struct msdosfsmount *pmp = VFSTOMSDOSFS(mp);
|
||||
int error, allerror = 0;
|
||||
|
||||
/*
|
||||
* If we ever switch to not updating all of the fats all the time,
|
||||
* this would be the place to update them from the first one.
|
||||
*/
|
||||
if (pmp->pm_fmod != 0) {
|
||||
if (pmp->pm_flags & MSDOSFSMNT_RONLY)
|
||||
panic("msdosfs_sync: rofs mod");
|
||||
else {
|
||||
/* update fats here */
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Write back each (modified) denode.
|
||||
*/
|
||||
mtx_lock(&mntvnode_mtx);
|
||||
loop:
|
||||
for (vp = LIST_FIRST(&mp->mnt_vnodelist); vp != NULL; vp = nvp) {
|
||||
/*
|
||||
* If the vnode that we are about to sync is no longer
|
||||
* associated with this mount point, start over.
|
||||
*/
|
||||
if (vp->v_mount != mp)
|
||||
goto loop;
|
||||
|
||||
mtx_lock(&vp->v_interlock);
|
||||
nvp = LIST_NEXT(vp, v_mntvnodes);
|
||||
dep = VTODE(vp);
|
||||
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))) {
|
||||
mtx_unlock(&vp->v_interlock);
|
||||
continue;
|
||||
}
|
||||
mtx_unlock(&mntvnode_mtx);
|
||||
error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT | LK_INTERLOCK, p);
|
||||
if (error) {
|
||||
mtx_lock(&mntvnode_mtx);
|
||||
if (error == ENOENT)
|
||||
goto loop;
|
||||
continue;
|
||||
}
|
||||
error = VOP_FSYNC(vp, cred, waitfor, p);
|
||||
if (error)
|
||||
allerror = error;
|
||||
VOP_UNLOCK(vp, 0, p);
|
||||
vrele(vp);
|
||||
mtx_lock(&mntvnode_mtx);
|
||||
}
|
||||
mtx_unlock(&mntvnode_mtx);
|
||||
|
||||
/*
|
||||
* Flush filesystem control info.
|
||||
*/
|
||||
if (waitfor != MNT_LAZY) {
|
||||
vn_lock(pmp->pm_devvp, LK_EXCLUSIVE | LK_RETRY, p);
|
||||
error = VOP_FSYNC(pmp->pm_devvp, cred, waitfor, p);
|
||||
if (error)
|
||||
allerror = error;
|
||||
VOP_UNLOCK(pmp->pm_devvp, 0, p);
|
||||
}
|
||||
return (allerror);
|
||||
}
|
||||
|
||||
static int
|
||||
msdosfs_fhtovp(mp, fhp, vpp)
|
||||
struct mount *mp;
|
||||
struct fid *fhp;
|
||||
struct vnode **vpp;
|
||||
{
|
||||
struct msdosfsmount *pmp = VFSTOMSDOSFS(mp);
|
||||
struct defid *defhp = (struct defid *) fhp;
|
||||
struct denode *dep;
|
||||
int error;
|
||||
|
||||
error = deget(pmp, defhp->defid_dirclust, defhp->defid_dirofs, &dep);
|
||||
if (error) {
|
||||
*vpp = NULLVP;
|
||||
return (error);
|
||||
}
|
||||
*vpp = DETOV(dep);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
msdosfs_vptofh(vp, fhp)
|
||||
struct vnode *vp;
|
||||
struct fid *fhp;
|
||||
{
|
||||
struct denode *dep;
|
||||
struct defid *defhp;
|
||||
|
||||
dep = VTODE(vp);
|
||||
defhp = (struct defid *)fhp;
|
||||
defhp->defid_len = sizeof(struct defid);
|
||||
defhp->defid_dirclust = dep->de_dirclust;
|
||||
defhp->defid_dirofs = dep->de_diroffset;
|
||||
/* defhp->defid_gen = dep->de_gen; */
|
||||
return (0);
|
||||
}
|
||||
|
||||
static struct vfsops msdosfs_vfsops = {
|
||||
msdosfs_mount,
|
||||
vfs_stdstart,
|
||||
msdosfs_unmount,
|
||||
msdosfs_root,
|
||||
vfs_stdquotactl,
|
||||
msdosfs_statfs,
|
||||
msdosfs_sync,
|
||||
vfs_stdvget,
|
||||
msdosfs_fhtovp,
|
||||
vfs_stdcheckexp,
|
||||
msdosfs_vptofh,
|
||||
msdosfs_init,
|
||||
msdosfs_uninit,
|
||||
vfs_stdextattrctl,
|
||||
};
|
||||
|
||||
VFS_SET(msdosfs_vfsops, msdos, 0);
|
File diff suppressed because it is too large
Load Diff
@ -1,245 +0,0 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $NetBSD: msdosfsmount.h,v 1.17 1997/11/17 15:37:07 ws Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
|
||||
* Copyright (C) 1994, 1995, 1997 TooLs GmbH.
|
||||
* All rights reserved.
|
||||
* Original code by Paul Popelka (paulp@uts.amdahl.com) (see below).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by TooLs GmbH.
|
||||
* 4. The name of TooLs GmbH may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*
|
||||
* Written by Paul Popelka (paulp@uts.amdahl.com)
|
||||
*
|
||||
* You can do anything you want with this software, just don't say you wrote
|
||||
* it, and don't remove this notice.
|
||||
*
|
||||
* This software is provided "as is".
|
||||
*
|
||||
* The author supplies this software to be publicly redistributed on the
|
||||
* understanding that the author is not responsible for the correct
|
||||
* functioning of this software in any circumstances and is not liable for
|
||||
* any damages caused by this software.
|
||||
*
|
||||
* October 1992
|
||||
*/
|
||||
|
||||
#ifndef _MSDOSFS_MSDOSFSMOUNT_H_
|
||||
#define _MSDOSFS_MSDOSFSMOUNT_H_
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
#ifdef MALLOC_DECLARE
|
||||
MALLOC_DECLARE(M_MSDOSFSMNT);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Layout of the mount control block for a msdos file system.
|
||||
*/
|
||||
struct msdosfsmount {
|
||||
struct mount *pm_mountp;/* vfs mount struct for this fs */
|
||||
dev_t pm_dev; /* block special device mounted */
|
||||
uid_t pm_uid; /* uid to set as owner of the files */
|
||||
gid_t pm_gid; /* gid to set as owner of the files */
|
||||
mode_t pm_mask; /* mask to and with file protection bits */
|
||||
struct vnode *pm_devvp; /* vnode for block device mntd */
|
||||
struct bpb50 pm_bpb; /* BIOS parameter blk for this fs */
|
||||
u_long pm_BlkPerSec; /* How many DEV_BSIZE blocks fit inside a physical sector */
|
||||
u_long pm_FATsecs; /* actual number of fat sectors */
|
||||
u_long pm_fatblk; /* block # of first FAT */
|
||||
u_long pm_rootdirblk; /* block # (cluster # for FAT32) of root directory number */
|
||||
u_long pm_rootdirsize; /* size in blocks (not clusters) */
|
||||
u_long pm_firstcluster; /* block number of first cluster */
|
||||
u_long pm_maxcluster; /* maximum cluster number */
|
||||
u_long pm_freeclustercount; /* number of free clusters */
|
||||
u_long pm_cnshift; /* shift file offset right this amount to get a cluster number */
|
||||
u_long pm_crbomask; /* and a file offset with this mask to get cluster rel offset */
|
||||
u_long pm_bnshift; /* shift file offset right this amount to get a block number */
|
||||
u_long pm_bpcluster; /* bytes per cluster */
|
||||
u_long pm_fmod; /* ~0 if fs is modified, this can rollover to 0 */
|
||||
u_long pm_fatblocksize; /* size of fat blocks in bytes */
|
||||
u_long pm_fatblocksec; /* size of fat blocks in sectors */
|
||||
u_long pm_fatsize; /* size of fat in bytes */
|
||||
u_int32_t pm_fatmask; /* mask to use for fat numbers */
|
||||
u_long pm_fsinfo; /* fsinfo block number */
|
||||
u_long pm_nxtfree; /* next free cluster in fsinfo block */
|
||||
u_int pm_fatmult; /* these 2 values are used in fat */
|
||||
u_int pm_fatdiv; /* offset computation */
|
||||
u_int pm_curfat; /* current fat for FAT32 (0 otherwise) */
|
||||
u_int *pm_inusemap; /* ptr to bitmap of in-use clusters */
|
||||
u_int pm_flags; /* see below */
|
||||
u_int16_t pm_u2w[128]; /* Local->Unicode table */
|
||||
u_int8_t pm_ul[128]; /* Local upper->lower table */
|
||||
u_int8_t pm_lu[128]; /* Local lower->upper table */
|
||||
u_int8_t pm_d2u[128]; /* DOS->local table */
|
||||
u_int8_t pm_u2d[128]; /* Local->DOS table */
|
||||
};
|
||||
/* Byte offset in FAT on filesystem pmp, cluster cn */
|
||||
#define FATOFS(pmp, cn) ((cn) * (pmp)->pm_fatmult / (pmp)->pm_fatdiv)
|
||||
|
||||
|
||||
#define VFSTOMSDOSFS(mp) ((struct msdosfsmount *)mp->mnt_data)
|
||||
|
||||
/* Number of bits in one pm_inusemap item: */
|
||||
#define N_INUSEBITS (8 * sizeof(u_int))
|
||||
|
||||
/*
|
||||
* Shorthand for fields in the bpb contained in the msdosfsmount structure.
|
||||
*/
|
||||
#define pm_BytesPerSec pm_bpb.bpbBytesPerSec
|
||||
#define pm_ResSectors pm_bpb.bpbResSectors
|
||||
#define pm_FATs pm_bpb.bpbFATs
|
||||
#define pm_RootDirEnts pm_bpb.bpbRootDirEnts
|
||||
#define pm_Sectors pm_bpb.bpbSectors
|
||||
#define pm_Media pm_bpb.bpbMedia
|
||||
#define pm_SecPerTrack pm_bpb.bpbSecPerTrack
|
||||
#define pm_Heads pm_bpb.bpbHeads
|
||||
#define pm_HiddenSects pm_bpb.bpbHiddenSecs
|
||||
#define pm_HugeSectors pm_bpb.bpbHugeSectors
|
||||
|
||||
/*
|
||||
* Convert pointer to buffer -> pointer to direntry
|
||||
*/
|
||||
#define bptoep(pmp, bp, dirofs) \
|
||||
((struct direntry *)(((bp)->b_data) \
|
||||
+ ((dirofs) & (pmp)->pm_crbomask)))
|
||||
|
||||
/*
|
||||
* Convert block number to cluster number
|
||||
*/
|
||||
#define de_bn2cn(pmp, bn) \
|
||||
((bn) >> ((pmp)->pm_cnshift - (pmp)->pm_bnshift))
|
||||
|
||||
/*
|
||||
* Convert cluster number to block number
|
||||
*/
|
||||
#define de_cn2bn(pmp, cn) \
|
||||
((cn) << ((pmp)->pm_cnshift - (pmp)->pm_bnshift))
|
||||
|
||||
/*
|
||||
* Convert file offset to cluster number
|
||||
*/
|
||||
#define de_cluster(pmp, off) \
|
||||
((off) >> (pmp)->pm_cnshift)
|
||||
|
||||
/*
|
||||
* Clusters required to hold size bytes
|
||||
*/
|
||||
#define de_clcount(pmp, size) \
|
||||
(((size) + (pmp)->pm_bpcluster - 1) >> (pmp)->pm_cnshift)
|
||||
|
||||
/*
|
||||
* Convert file offset to block number
|
||||
*/
|
||||
#define de_blk(pmp, off) \
|
||||
(de_cn2bn(pmp, de_cluster((pmp), (off))))
|
||||
|
||||
/*
|
||||
* Convert cluster number to file offset
|
||||
*/
|
||||
#define de_cn2off(pmp, cn) \
|
||||
((cn) << (pmp)->pm_cnshift)
|
||||
|
||||
/*
|
||||
* Convert block number to file offset
|
||||
*/
|
||||
#define de_bn2off(pmp, bn) \
|
||||
((bn) << (pmp)->pm_bnshift)
|
||||
/*
|
||||
* Map a cluster number into a filesystem relative block number.
|
||||
*/
|
||||
#define cntobn(pmp, cn) \
|
||||
(de_cn2bn((pmp), (cn)-CLUST_FIRST) + (pmp)->pm_firstcluster)
|
||||
|
||||
/*
|
||||
* Calculate block number for directory entry in root dir, offset dirofs
|
||||
*/
|
||||
#define roottobn(pmp, dirofs) \
|
||||
(de_blk((pmp), (dirofs)) + (pmp)->pm_rootdirblk)
|
||||
|
||||
/*
|
||||
* Calculate block number for directory entry at cluster dirclu, offset
|
||||
* dirofs
|
||||
*/
|
||||
#define detobn(pmp, dirclu, dirofs) \
|
||||
((dirclu) == MSDOSFSROOT \
|
||||
? roottobn((pmp), (dirofs)) \
|
||||
: cntobn((pmp), (dirclu)))
|
||||
|
||||
/*
|
||||
* Calculate fsinfo block size
|
||||
*/
|
||||
#define fsi_size(pmp) \
|
||||
(1024 << ((pmp)->pm_BlkPerSec >> 2))
|
||||
|
||||
int msdosfs_init __P((struct vfsconf *vfsp));
|
||||
int msdosfs_uninit __P((struct vfsconf *vfsp));
|
||||
int msdosfs_mountroot __P((void));
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
/*
|
||||
* Arguments to mount MSDOS filesystems.
|
||||
*/
|
||||
struct msdosfs_args {
|
||||
char *fspec; /* blocks special holding the fs to mount */
|
||||
struct export_args export; /* network export information */
|
||||
uid_t uid; /* uid that owns msdosfs files */
|
||||
gid_t gid; /* gid that owns msdosfs files */
|
||||
mode_t mask; /* mask to be applied for msdosfs perms */
|
||||
int flags; /* see below */
|
||||
int magic; /* version number */
|
||||
u_int16_t u2w[128]; /* Local->Unicode table */
|
||||
u_int8_t ul[128]; /* Local upper->lower table */
|
||||
u_int8_t lu[128]; /* Local lower->upper table */
|
||||
u_int8_t d2u[128]; /* DOS->local table */
|
||||
u_int8_t u2d[128]; /* Local->DOS table */
|
||||
};
|
||||
|
||||
/*
|
||||
* Msdosfs mount options:
|
||||
*/
|
||||
#define MSDOSFSMNT_SHORTNAME 1 /* Force old DOS short names only */
|
||||
#define MSDOSFSMNT_LONGNAME 2 /* Force Win'95 long names */
|
||||
#define MSDOSFSMNT_NOWIN95 4 /* Completely ignore Win95 entries */
|
||||
#ifndef __FreeBSD__
|
||||
#define MSDOSFSMNT_GEMDOSFS 8 /* This is a gemdos-flavour */
|
||||
#endif
|
||||
#define MSDOSFSMNT_U2WTABLE 0x10 /* Local->Unicode and local<->DOS */
|
||||
/* tables loaded */
|
||||
#define MSDOSFSMNT_ULTABLE 0x20 /* Local upper<->lower table loaded */
|
||||
/* All flags above: */
|
||||
#define MSDOSFSMNT_MNTOPT \
|
||||
(MSDOSFSMNT_SHORTNAME|MSDOSFSMNT_LONGNAME|MSDOSFSMNT_NOWIN95 \
|
||||
/*|MSDOSFSMNT_GEMDOSFS*/|MSDOSFSMNT_U2WTABLE|MSDOSFSMNT_ULTABLE)
|
||||
#define MSDOSFSMNT_RONLY 0x80000000 /* mounted read-only */
|
||||
#define MSDOSFSMNT_WAITONFAT 0x40000000 /* mounted synchronous */
|
||||
#define MSDOSFS_FATMIRROR 0x20000000 /* FAT is mirrored */
|
||||
|
||||
#define MSDOSFS_ARGSMAGIC 0xe4eff300
|
||||
|
||||
#endif /* !_MSDOSFS_MSDOSFSMOUNT_H_ */
|
@ -43,13 +43,13 @@
|
||||
|
||||
#define _KERNEL
|
||||
#include <sys/mount.h>
|
||||
#include <msdosfs/bpb.h>
|
||||
#include <msdosfs/msdosfsmount.h>
|
||||
#include <fs/msdosfs/bpb.h>
|
||||
#include <fs/msdosfs/msdosfsmount.h>
|
||||
#undef _KERNEL
|
||||
|
||||
#include <msdosfs/denode.h>
|
||||
#include <msdosfs/direntry.h>
|
||||
#include <msdosfs/fat.h>
|
||||
#include <fs/msdosfs/denode.h>
|
||||
#include <fs/msdosfs/direntry.h>
|
||||
#include <fs/msdosfs/fat.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <kvm.h>
|
||||
|
@ -1572,7 +1572,10 @@
|
||||
/* #undef HAVE_MOUNT_H */
|
||||
|
||||
/* Define if you have the <msdosfs/msdosfsmount.h> header file. */
|
||||
#define HAVE_MSDOSFS_MSDOSFSMOUNT_H 1
|
||||
/* #undef HAVE_MSDOSFS_MSDOSFSMOUNT_H */
|
||||
|
||||
/* Define if you have the <fs/msdosfs/msdosfsmount.h> header file. */
|
||||
#define HAVE_FS_MSDOSFS_MSDOSFSMOUNT_H 1
|
||||
|
||||
/* Define if you have the <ndbm.h> header file. */
|
||||
#define HAVE_NDBM_H 1
|
||||
|
@ -63,7 +63,7 @@ static const char rcsid[] =
|
||||
#include <nfs/nfsproto.h>
|
||||
#include <nfs/nfs.h>
|
||||
#include <ufs/ufs/ufsmount.h>
|
||||
#include <msdosfs/msdosfsmount.h>
|
||||
#include <fs/msdosfs/msdosfsmount.h>
|
||||
#include <ntfs/ntfsmount.h>
|
||||
#include <isofs/cd9660/cd9660_mount.h> /* XXX need isofs in include */
|
||||
|
||||
|
@ -45,7 +45,7 @@
|
||||
#define MSDOSFS
|
||||
#include <sys/mount.h>
|
||||
#include <ufs/ufs/ufsmount.h>
|
||||
#include <msdosfs/msdosfsmount.h>
|
||||
#include <fs/msdosfs/msdosfsmount.h>
|
||||
#undef MSDOSFS
|
||||
#include <sys/stat.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
@ -46,7 +46,7 @@
|
||||
#include <grp.h>
|
||||
#define MSDOSFS
|
||||
#include <sys/mount.h>
|
||||
#include <msdosfs/msdosfsmount.h>
|
||||
#include <fs/msdosfs/msdosfsmount.h>
|
||||
#undef MSDOSFS
|
||||
|
||||
static Boolean DOSMounted;
|
||||
|
@ -49,7 +49,7 @@
|
||||
|
||||
#define MSDOSFS
|
||||
#include <sys/mount.h>
|
||||
#include <msdosfs/msdosfsmount.h>
|
||||
#include <fs/msdosfs/msdosfsmount.h>
|
||||
#undef MSDOSFS
|
||||
|
||||
#include <ufs/ufs/ufsmount.h>
|
||||
|
@ -45,7 +45,7 @@
|
||||
#define MSDOSFS
|
||||
#include <sys/mount.h>
|
||||
#include <ufs/ufs/ufsmount.h>
|
||||
#include <msdosfs/msdosfsmount.h>
|
||||
#include <fs/msdosfs/msdosfsmount.h>
|
||||
#undef MSDOSFS
|
||||
#include <sys/stat.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
Loading…
Reference in New Issue
Block a user