NetBSD/sys/msdosfs/fat.h

60 lines
2.2 KiB
C
Raw Normal View History

brought in fixed/renamed/matching MS-DOS FS code, from Jeff Polk <polk@bsdi.com>. His notes are as follows: ------------------------------------------------------------------------------ July 22, 1993 - Changed name of entire package from PCFS to MSDOSFS - Fixed bugs: root directory size in clusters instead of bytes growing directory didn't update in-core size link, symlink, mknod didn't free locked parent (deadlock) lookup returned real error on create and rename instead of EJUSTRETURN rename changed `.' entry in child instead of name entry in parent rename removed `.' entry in child instead of removing entry in parent when moving a directory from one dir to another createde() left new node locked when write of parent failed (deadlock) removede() decremented refcount even on error (rmdir's which failed due to write errors left in-core cache entries inconsistent) changed validation for filesystem to not check for the boot signature since some disks (e.g., mtools) aren't bootable directories are always show current time as modify time (needed for NFS export since DOS never updates dir mod times -- ctime is true create time). - Added support for cookies changes to the readdir() vnode interface (#ifdef __bsdi__) - Punted on the whole problem of inode generation numbers. This means that there's a chance of using a stale file handle to access a new file, but it doesn't appear to be the common case, and I don't see how to generate reasonable generation numbers without changing something on the disk (which is the way the SVR4 filesystem survival kit guys did it). I don't think it would be very safe to change the on-disk format. Jeff Polk (polk@BSDI.COM) ------------------------------------------------------------------------------
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
*
* $Id: fat.h,v 1.1 1993/08/13 11:35:33 cgd Exp $
*/
/*
* 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 */
/*
* Return true if filesystem uses 12 bit fats. Microsoft Programmer's
* Reference says if the maximum cluster number in a filesystem is greater
* than 4086 then we've got a 16 bit fat filesystem.
*/
#define FAT12(pmp) (pmp->pm_maxcluster <= 4086)
#define FAT16(pmp) (pmp->pm_maxcluster > 4086)
#define MSDOSFSEOF(cn) (((cn) & 0xfff8) == 0xfff8)
/*
* 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)
#if defined(KERNEL)
int pcbmap __P((struct denode * dep, u_long findcn, daddr_t * bnp, u_long * cnp));
int clusterfree __P((struct msdosfsmount * pmp, u_long cn, u_long * oldcnp));
int clusteralloc __P((struct msdosfsmount * pmp, u_long * retcluster, u_long fillwith));
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));
#endif /* defined(KERNEL) */