/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1999 by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* fsck_pcfs -- routines for manipulating the FAT.
*/
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <libintl.h>
#include "pcfs_common.h"
#include "fsck_pcfs.h"
extern int32_t BytesPerCluster;
extern int32_t TotalClusters;
extern int32_t LastCluster;
extern off64_t FirstClusterOffset;
extern off64_t PartitionOffset;
extern bpb_t TheBIOSParameterBlock;
extern int ReadOnly;
extern int IsFAT32;
extern int Verbose;
static int FATRewriteNeeded = 0;
short FATEntrySize;
static off64_t
{
/*
* The FAT(s) immediately follows the reserved sectors.
*/
}
void
{
return;
exit(7);
}
exit(7);
}
if (Verbose)
gettext("Reading FAT\n"));
if (bytesRead < 0) {
} else {
gettext("Short read of FAT."));
}
exit(7);
}
/*
* XXX - might want to read the other copies of the FAT
*/
if (Verbose) {
gettext("Dump of FAT's first 32 bytes.\n"));
}
}
void
{
gettext("Internal error: No FAT to write\n"));
exit(11);
}
if (!FATRewriteNeeded) {
if (Verbose) {
gettext("No FAT changes need to be written.\n"));
}
return;
}
if (ReadOnly)
return;
if (Verbose)
exit(11);
}
if (bytesWritten < 0) {
} else {
gettext("Short write of FAT."));
}
exit(11);
}
FATRewriteNeeded = 0;
}
/*
* checkFAT32CleanBit()
* Return non-zero if the bit indicating proper Windows shutdown has
* been set.
*/
int
{
}
static uchar_t *
{
if (FATEntrySize == 32) {
} else if (FATEntrySize == 16) {
} else {
}
}
/*
* {read,write}FATentry
* For the 16 and 32 bit FATs these routines are relatively easy
* to follow.
*
* 12 bit FATs are kind of strange, though. The magic index for
* 12 bit FATS computed below, 1.5 * clusterNum, is a
* simplification that there are 8 bits in a byte, so you need
* 1.5 bytes per entry.
*
* It's easiest to think about FAT12 entries in pairs:
*
* ---------------------------------------------
* | mid1 | low1 | low2 | high1 | high2 | mid2 |
* ---------------------------------------------
*
* Each box in the diagram represents a nibble (4 bits) of a FAT
* entry. A FAT entry is made up of three nibbles. So if you
* look closely, you'll see that first byte of the pair of
* entries contains the low and middle nibbles of the first
* entry. The second byte has the low nibble of the second entry
* and the high nibble of the first entry. Those two bytes alone
* are enough to read the first entry. The second FAT entry is
* finished out by the last nibble pair.
*/
{
if (FATEntrySize == 32) {
} else if (FATEntrySize == 16) {
/*
* Convert 16 bit entry to 32 bit if we are
* into the reserved or higher values.
*/
if (value >= PCF_RESCLUSTER)
value |= 0xFFF0000;
} else {
value = 0;
if (currentCluster & 1) {
/*
* Odd numbered cluster
*/
} else {
}
/*
* Convert 12 bit entry to 32 bit if we are
* into the reserved or higher values.
*/
if (value >= PCF_12BCLUSTER)
value |= 0xFFFF000;
}
return (value);
}
void
{
FATRewriteNeeded = 1;
if (FATEntrySize == 32) {
} else if (FATEntrySize == 16) {
} else {
if (currentCluster & 1) {
/*
* Odd numbered cluster
*/
ep++;
} else {
}
}
}
/*
* reservedInFAT - Is this cluster marked in the reserved range?
* The range from PCF_RESCLUSTER32 to PCF_BADCLUSTER32 - 1,
* have been reserved by Microsoft. No cluster should be
* marked with these; they are effectively invalid cluster values.
*/
int
{
int32_t e;
e = readFATEntry(clusterNum);
return (e >= PCF_RESCLUSTER32 && e < PCF_BADCLUSTER32);
}
/*
* badInFAT - Is this cluster marked as bad? I.e., is it inaccessible?
*/
int
{
}
/*
* lastInFAT - Is this cluster marked as free? I.e., is it available
* for use?
*/
int
{
}
/*
* lastInFAT - Is this cluster the last in its cluster chain?
*/
int
{
}
/*
* markLastInFAT - Mark this cluster as the last in its cluster chain.
*/
void
{
}
void
{
}
void
{
}