source: Daodan/MinGW/msys/1.0/bin/umount@ 1063

Last change on this file since 1063 was 1046, checked in by alloc, 8 years ago

Daodan: Added Windows MinGW and build batch file

File size: 3.0 KB
Line 
1#!/bin/sh
2#
3# File: umount
4# $Id: umount,v 1.2 2010/03/24 21:28:30 keithmarshall Exp $
5#
6# =====================================================================
7#
8# Copyright (C) 2006, 2007, 2009 by Keith Marshall
9# mailto:keithmarshall@users.sourceforge.net
10#
11# This file is part of MSYS
12# http://www.mingw.org/msys.shtml
13#
14# 2009-04-06: First published implementation for MSYS-1.0.11
15#
16# MSYS is free software. It is provided "as is", in the hope that it
17# may be useful; there is NO WARRANTY OF ANY KIND, not even an implied
18# warranty of MERCHANTABILITY or FITNESS FOR ANY PARTICULAR PURPOSE.
19# At no time will the author accept liability for damages, however
20# caused, resulting from the use of this software.
21#
22# Permission is granted to copy and redistribute this software, either
23# as is, or in modified form, provided that:--
24#
25# 1) All such copies are distributed with the same rights
26# of redistribution.
27#
28# 2) The preceding disclaimer of warranty and liabality is
29# retained verbatim, in all copies.
30#
31# 3) Accreditation of the original author remains in place.
32#
33# 4) Modified copies are clearly identified as such, with
34# additional accreditation given to the authors of each
35# modified version.
36#
37# =====================================================================
38#
39# Exactly one argument is required...
40#
41 if test $# -eq 1
42 then
43#
44# Normally, it specifies the mount point to be released,
45# but it may also represent a mounted directory path name,
46# for which all bound mount points are to be filtered out
47# of the "mount table" file.
48#
49 MNTPATH=`echo "$1" | tr '\\\\' /`
50 TMPFILE=${TMPDIR-"/tmp"}/mnttab$$.tmp
51 MNTTAB=${MNTTAB-"/etc/fstab"}
52#
53 if cat "$MNTTAB" | tr '\\' / | awk '
54#
55# Copy the "mount table" to a temporary file, filtering
56# out all active mount point records which match MNTPATH,
57# (the specified argument); set exit status to:--
58# 0: if at least one mount point is matched;
59# 1: if no match is found.
60#
61 BEGIN { status = 1 }
62 { keep = $0 }
63 /^#/ { print; keep = "no"; $0 = "!'$MNTPATH'" }
64 $2 == "'$MNTPATH'" { keep = "no"; status = 0 }
65 { $2 = "!" } $0 == "'$MNTPATH' !" { keep = "no"; status = 0 }
66 keep != "no" { print keep }
67 END { exit status }' > "$TMPFILE"
68 then
69#
70# At least one mount point was selected to release...
71# Replace the active "mount table" file with the regenerated
72# copy, so completing the operation.
73#
74 cp "$TMPFILE" "$MNTTAB"
75 rm -f "$TMPFILE"
76#
77 else
78#
79# No active mount point matched the specified argument...
80# Discard the temporary file, complain, and bail out.
81#
82 rm -f "$TMPFILE"
83 echo >&2 "$0: '$1' is not mounted"
84 exit 1
85 fi
86#
87 else
88#
89# The command line did not specify exactly one argument...
90# Complain, and bail out.
91#
92 echo >&2 "$0: incorrect number of arguments"
93 echo >&2 "usage: umount <path>"
94 exit 2
95 fi
96#
97# On successful completion, ensure we set the exit status appropriately.
98#
99 exit 0
100#
101# $RCSfile: umount,v $: end of file
Note: See TracBrowser for help on using the repository browser.