delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/01/11/15:31:54

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Date: Thu, 11 Jan 2001 22:01:36 +0200
Message-Id: <200101112001.WAA04639@linux.>
From: "Ehud Karni" <ehud AT unix DOT simonwiesel DOT co DOT il>
To: cygwin AT cygwin DOT com
Subject: Rebuild mount table - minor fix
In-reply-to: <20010111121455.B14961@redhat.com> (message from Christopher
Faylor on Thu, 11 Jan 2001 12:14:55 -0500)
Organization: Simon & Wiesel Insurance agency
Reply-to: ehud AT unix DOT simonwiesel DOT co DOT il
References: <8928D5E06A71D4118C13001083F9AD4FDE1B45 AT sandiego-ex1 DOT sandiego DOT akamai DOT com> <20010111121455 DOT B14961 AT redhat DOT com>
X-Mailer: Emacs 20.7.1 rmail (send-msg 1.104)
MIME-Version: 1.0

I'm sorry, but there was an error in the script I just posted.
(a leftover line that add extra u to the mount flags).
Seeing an email by cgf I enhanced my script to quote the Paths.
The script takes some times, so I added echos to stderr.
So here is the new script:

------------------------- mount-export.sh -------------------------

#! /bin/sh -e
# Export the current mount into a script to rebuild it
# the script is written into $1 (stdout if none/empty)
# ----------------------------------------------------

quote ()                                   # quote stdin to stdout
{                                          # change \ to \\, " to \"
   sed -e "s/\\\\/\\\\\\\\/g"  \
       -e "s/\\\"/\\\\\\\"/g"  \
       -e "s/\`/\\\\\\\`/g"              # re-escape \, ", ' and `
}
# ----------------------------------------------------------------------

dcd_ln ()                                  # decode 1 mount line
{                                          # given as argument

    WINP=`echo $1 | cut "-d " -f1 | quote` # Windows Path (unquoted)
    MNTP=`echo $1 | cut "-d " -f2 | quote` # Cygwin mount point
    U_S=`echo $1 | cut "-d " -f3`          # user / system
    BTX=`echo $1 | cut "-d " -f4`          # binmode / textmode , exec

    FLAGS="-f"
    case "$U_S" in
        "user" )   U_S=u   ;;              # user mount
        "system" ) U_S=s   ;;              # user mount
           *  )    echo "Error, type is $U_S, should be user/system !"
                   exit 1  ;;              # grave error
    esac

    case "$BTX" in
        *"exec" )  FLAGS="${FLAGS}x" ;;    # mounted with exec[ute]
    esac

    case "$BTX" in
        "bin"* )   BTX=b   ;;              # mounted in binary mode
        "text"* )  BTX=t   ;;              # mounted in text mode
           *  )    echo "Error, flags are $BTX, should be binmode/textmode !"
                   exit 1  ;;              # grave error
    esac
    FLAGS="$FLAGS$U_S$BTX"                 # flags for mount
}
# ----------------------------------------------------------------------

add_mounts ()                              # work on current mounts
{                                          # (output of mount command)
    read MLN                               # ignore 1st line
    read MLN                               # next line
    while [ "$MLN" != "" ]                 # stop on extra empty line
    do
        dcd_ln "$MLN"                      # break into components
        echo "mount $FLAGS \"$WINP\" \"$MNTP\""
                                           # write mount quoted command
        echo "Mount \"$WINP\" on \"$MNTP\" processed" >&2
        read MLN                           # next line
    done
}
# ----------------------------------------------------------------------


if [ "$1" != "" ] ; then
    exec 1>"$1"
fi

echo "#! /bin/sh -ex
# Rebuild the mount table, Original configuration from:"
HST=`hostname`
date -u "+# $HST at %Y-%m-%d %H:%M"
echo "# ----------------------------------------------------

# 1st remove all currently mount points & prefixes
umount --remove-all-mounts
umount --remove-cygdrive-prefix

# 2nd set Cygwin drive prefix"

PRFXLN=`mount --show-cygdrive-prefixes | tail -1`
dcd_ln "dummy $PRFXLN"                     # decode prefix
case "$BTX$U_S" in                         # special flags for prefix
    "bs" ) FLAGS="-bs" ;;                  # -bs
    "bu" ) FLAGS="-b"  ;;                  # -b
    "ts" ) FLAGS="-s"  ;;                  # -s
      *  ) FLAGS=""    ;;                  # none (tu)
esac
echo "mount $FLAGS --change-cygdrive-prefix \"$MNTP\""
echo "Prefix is \"$MNTP\" defined" >&2

echo -e "\n# restore mounts, one by one\n"

( mount ; echo ) | add_mounts              # write all mounts

echo "
############################## end of re-mount #############################"

############################## mount-export.sh ##############################


--
 @@@@@@ @@@ @@@@@@ @    @   Ehud Karni  Simon & Wiesel  Insurance agency
     @    @      @  @@  @   Tel: +972-3-6212-757    Fax: +972-3-6292-544
     @    @ @    @ @  @@    (USA)  Fax  and  voice  mail:  1-815-5509341
     @    @ @    @ @    @        Better     Safe     Than     Sorry
 http://www.simonwiesel.co.il    mailto:ehud AT unix DOT simonwiesel DOT co DOT il

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019