1996-02-12 01:48:14 +03:00
|
|
|
/* $NetBSD: fat.h,v 1.10 1996/02/11 22:48:14 ws Exp $ */
|
1994-06-29 10:29:24 +04:00
|
|
|
|
1994-07-19 01:38:08 +04:00
|
|
|
/*-
|
|
|
|
* Copyright (C) 1994 Wolfgang Solfrank.
|
|
|
|
* Copyright (C) 1994 TooLs GmbH.
|
|
|
|
* All rights reserved.
|
1994-08-21 22:43:49 +04:00
|
|
|
* Original code by Paul Popelka (paulp@uts.amdahl.com) (see below).
|
1994-07-19 01:38:08 +04:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
1993-08-13 15:35:13 +04:00
|
|
|
/*
|
|
|
|
* 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_RSRVS 0xfff0 /* start of reserved cluster range */
|
|
|
|
#define CLUST_RSRVE 0xfff6 /* end of reserved cluster range */
|
|
|
|
#define CLUST_BAD 0xfff7 /* a cluster with a defect */
|
|
|
|
#define CLUST_EOFS 0xfff8 /* start of eof cluster range */
|
|
|
|
#define CLUST_EOFE 0xffff /* end of eof cluster range */
|
|
|
|
|
|
|
|
#define FAT12_MASK 0x0fff /* mask for 12 bit cluster numbers */
|
|
|
|
#define FAT16_MASK 0xffff /* mask for 16 bit cluster numbers */
|
|
|
|
|
|
|
|
/*
|
1996-01-19 17:28:05 +03:00
|
|
|
* MSDOSFS:
|
1993-08-13 15:35:13 +04:00
|
|
|
* Return true if filesystem uses 12 bit fats. Microsoft Programmer's
|
|
|
|
* Reference says if the maximum cluster number in a filesystem is greater
|
1996-02-12 01:48:14 +03:00
|
|
|
* 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.
|
1996-01-19 17:28:05 +03:00
|
|
|
* 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.
|
1993-08-13 15:35:13 +04:00
|
|
|
*/
|
1996-01-19 17:28:05 +03:00
|
|
|
#define FAT12(pmp) (pmp->pm_fatentrysize == 12)
|
|
|
|
#define FAT16(pmp) (pmp->pm_fatentrysize == 16)
|
1993-08-13 15:35:13 +04:00
|
|
|
|
|
|
|
#define MSDOSFSEOF(cn) (((cn) & 0xfff8) == 0xfff8)
|
|
|
|
|
1995-03-30 01:57:43 +04:00
|
|
|
#ifdef _KERNEL
|
1993-08-13 15:35:13 +04:00
|
|
|
/*
|
|
|
|
* 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)
|
|
|
|
|
1994-07-19 01:38:08 +04:00
|
|
|
/*
|
|
|
|
* Flags to extendfile:
|
|
|
|
*/
|
|
|
|
#define DE_CLEAR 1 /* Zero out the blocks allocated */
|
|
|
|
|
1995-09-09 23:38:00 +04:00
|
|
|
int pcbmap __P((struct denode *, u_long, daddr_t *, u_long *, int *));
|
1994-09-28 14:31:23 +03:00
|
|
|
int clusterfree __P((struct msdosfsmount *, u_long, u_long *));
|
|
|
|
int clusteralloc __P((struct msdosfsmount *, u_long, u_long, u_long, u_long *, u_long *));
|
|
|
|
int extendfile __P((struct denode *, u_long, struct buf **, u_long *, int));
|
|
|
|
int fatentry __P((int, struct msdosfsmount *, u_long, u_long *, u_long));
|
|
|
|
void fc_purge __P((struct denode *, u_int));
|
|
|
|
void fc_lookup __P((struct denode *, u_long, u_long *, u_long *));
|
|
|
|
int fillinusemap __P((struct msdosfsmount *));
|
|
|
|
int freeclusterchain __P((struct msdosfsmount *, u_long));
|
1995-03-30 01:57:43 +04:00
|
|
|
#endif /* _KERNEL */
|