xref: /aosp_15_r20/external/mtools/scripts/mcheck (revision d5c9a868b113e0ec0db2f27bc2ce8a253e77c4b0)
1*d5c9a868SElliott Hughes#!/bin/sh
2*d5c9a868SElliott Hughes# Copyright 1994 David C. Niemi
3*d5c9a868SElliott Hughes# Copyright 1994,1997,2001,2002 Alain Knaff.
4*d5c9a868SElliott Hughes# This file is part of mtools.
5*d5c9a868SElliott Hughes#
6*d5c9a868SElliott Hughes# Mtools is free software: you can redistribute it and/or modify
7*d5c9a868SElliott Hughes# it under the terms of the GNU General Public License as published by
8*d5c9a868SElliott Hughes# the Free Software Foundation, either version 3 of the License, or
9*d5c9a868SElliott Hughes# (at your option) any later version.
10*d5c9a868SElliott Hughes#
11*d5c9a868SElliott Hughes# Mtools is distributed in the hope that it will be useful,
12*d5c9a868SElliott Hughes# but WITHOUT ANY WARRANTY; without even the implied warranty of
13*d5c9a868SElliott Hughes# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*d5c9a868SElliott Hughes# GNU General Public License for more details.
15*d5c9a868SElliott Hughes#
16*d5c9a868SElliott Hughes# You should have received a copy of the GNU General Public License
17*d5c9a868SElliott Hughes# along with Mtools.  If not, see <http://www.gnu.org/licenses/>.
18*d5c9a868SElliott Hughes#
19*d5c9a868SElliott Hughes# mcheck [ <DOS drive letter> ]
20*d5c9a868SElliott Hughes#
21*d5c9a868SElliott Hughes# Read every file on an MS-DOS formatted disk to make sure they're good.
22*d5c9a868SElliott Hughes#
23*d5c9a868SElliott Hughes# Requires: mdir and mread utilities from mtools in user's path.
24*d5c9a868SElliott Hughes#
25*d5c9a868SElliott Hughes# 1994/02/19	DCN	Created
26*d5c9a868SElliott Hughes# 1994/??/??	ALK	Added case statement for results of mdir
27*d5c9a868SElliott Hughes# 1994/09/24	DCN	Cleanup (5 minutes on top of the 30 seconds creating it)
28*d5c9a868SElliott Hughes# 1994/12/01	DCN	Better comments, notices to stderr
29*d5c9a868SElliott Hughes#
30*d5c9a868SElliott Hughes# Copyright (C) 1994 David C. Niemi ([email protected])
31*d5c9a868SElliott Hughes# The author requires that any copies or derived works include this
32*d5c9a868SElliott Hughes# copyright notice; no other restrictions are placed on its use.
33*d5c9a868SElliott Hughes#
34*d5c9a868SElliott Hughes
35*d5c9a868SElliott Hughesset -e
36*d5c9a868SElliott Hughesset -u
37*d5c9a868SElliott Hughes
38*d5c9a868SElliott HughesDRIVE=${1:-'A:'}
39*d5c9a868SElliott Hughesmdir ${DRIVE}'*'
40*d5c9a868SElliott Hughescase $? in
41*d5c9a868SElliott Hughes2)
42*d5c9a868SElliott Hughes	echo "No files on disk." >&2
43*d5c9a868SElliott Hughes	exit 0
44*d5c9a868SElliott Hughes	;;
45*d5c9a868SElliott Hughes1)
46*d5c9a868SElliott Hughes	exit 1
47*d5c9a868SElliott Hughes	;;
48*d5c9a868SElliott Hughes0)
49*d5c9a868SElliott Hughes	;;
50*d5c9a868SElliott Hughesesac
51*d5c9a868SElliott Hughes
52*d5c9a868SElliott Hughesecho >&2; echo "Verifying files on drive ${DRIVE}..." >&2
53*d5c9a868SElliott Hughesif mtype -/ ${DRIVE}\* > /dev/null; then
54*d5c9a868SElliott Hughes	echo "Disk in drive ${DRIVE} is OK." >&2
55*d5c9a868SElliott Hughes	exit 0
56*d5c9a868SElliott Hugheselse
57*d5c9a868SElliott Hughes	echo "Disk in drive ${DRIVE} has errors." >&2
58*d5c9a868SElliott Hughes	exit 1
59*d5c9a868SElliott Hughesfi
60*d5c9a868SElliott Hughes
61*d5c9a868SElliott Hughes## NOTREACHED ##
62