/*
* 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,2001 by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* fsck_pcfs -- main routines.
*/
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <fcntl.h>
#include <strings.h>
#include <libintl.h>
#include <locale.h>
#include "pcfs_common.h"
#include "fsck_pcfs.h"
#include "pcfs_bpb.h"
/*
* {Output,Input}Image are the file names where we should write the
* checked fs image and from which we should read the initial fs.
* The image capability is designed for debugging purposes.
*/
/*
* By default be quick; skip verify reads.
* If the user wants more exhaustive checking,
* they should run with the -o v option.
*/
int ReadOnly = 0;
int IsFAT32 = 0;
int Verbose = 0;
extern ClusterContents TheRootDir;
/*
* Function definitions
*/
static void
{
if (!Quick)
}
static void
{
if (!IsFAT32)
}
static void
{
int saveError;
if (exitOnFailure == RETURN_ON_OPEN_FAILURE)
return;
exit(1);
}
}
static void
{
if (ReadOnly) {
*outFD = -1;
} else {
if (*inFD < 0) {
exit(2);
} else {
AlwaysYes = 0;
AlwaysNo = 1;
ReadOnly = 1;
*outFD = -1;
}
} else {
}
}
}
}
static void
{
if (Verbose)
if (InputImage == NULL) {
/*
* Destination exists, now find more about it.
*/
gettext("\n%s: device name must be a "
"character special device.\n"), actualDisk);
exit(2);
}
} else {
}
if (suffix) {
if ((PartitionOffset =
gettext("Unable to find logical drive %s\n"),
suffix);
exit(2);
} else if (Verbose) {
gettext("Partition starts at offset %lld\n"),
}
} else {
PartitionOffset = 0;
}
}
void
usage()
{
gettext("pcfs Usage: fsck -F pcfs [-o v|p|w] special-file\n"));
exit(1);
}
static
char *LegalOpts[] = {
#define VFLAG 0
"v",
"p",
"w",
"d",
"i",
"o",
};
static void
{
char *value;
int c;
while (*optsstr != '\0') {
case VFLAG:
Quick = 0;
break;
case PFLAG:
Preen++;
break;
case WFLAG:
WritableOnly++;
break;
case DFLAG:
Verbose++;
break;
case IFLAG:
missing_arg(LegalOpts[c]);
} else {
InputImage = value;
}
break;
case OFLAG:
missing_arg(LegalOpts[c]);
} else {
OutputImage = value;
}
break;
default:
break;
}
}
}
static void
sanityCheckOpts(void)
{
if (WritableOnly && ReadOnly) {
gettext("-w option may not be used with the -n "
"or -m options\n"));
exit(4);
}
}
static void
{
char *printName;
if (!IsFAT32) {
/* make sure we can at least read the root directory */
okayToMount = 0;
} else {
/* check the bit designed into FAT32 for this purpose */
}
if (okayToMount) {
exit(0);
} else {
gettext("pcfs fsck: sanity check: %s needs checking\n"),
exit(32);
}
}
void
mountSanityCheckFails(void)
{
if (Mflag) {
gettext("pcfs fsck: sanity check failed: "));
}
}
/*
* preenBail
* Routine that other routines can call if they would go into a
* state where they need user input. They can send an optional
* message string to be printed before the exit. Caller should
* send a NULL string if they don't have an exit message.
*/
void
{
/*
* If we are running in the 'preen' mode, we got here because
* we reached a situation that would require user intervention.
* We have no choice but to bail at this point.
*/
if (Preen) {
if (outString)
"INTERVENTION; RUN fsck MANUALLY.\n"));
exit(36);
}
}
int
{
char *string;
int c;
#if !defined(TEXT_DOMAIN)
#endif
(void) textdomain(TEXT_DOMAIN);
if (argc < 2)
usage();
switch (c) {
case 'F':
usage();
break;
case 'V': {
char *opt_text;
int opt_count;
opt_count++) {
if (opt_text)
(void) printf(" %s ",
opt_text);
}
(void) printf("\n");
exit(0);
}
break;
case 'N':
case 'n':
AlwaysYes = 0;
AlwaysNo = 1;
ReadOnly = 1;
break;
case 'Y':
case 'y':
AlwaysYes = 1;
AlwaysNo = 0;
break;
case 'm':
Mflag++;
ReadOnly = 1;
break;
case 'o':
break;
}
}
usage();
/*
* -m mountable fs check. This call will not return.
*/
if (Mflag)
/*
* Pass 1: Find any bad clusters and adjust the FAT and directory
* entries accordingly
*/
/*
* XXX - future passes?
* Ideas:
* Data relocation for bad clusters with partial read success?
* Syncing backup FAT copies with main copy?
* Syncing backup root sector for FAT32?
*/
/*
* No problems if we made it this far.
*/
return (0);
}