11.1SjdolecekREM >Mountufs
21.1SjdolecekREM $NetBSD: MountUFS,v 1.1.1.1 2002/05/09 20:03:59 jdolecek Exp $
31.1SjdolecekREM
41.1SjdolecekREM Copyright (c) 1997 Mark Brinicombe
51.1SjdolecekREM All rights reserved
61.1SjdolecekREM
71.1SjdolecekREM Redistribution and use in source and binary forms, with or without
81.1SjdolecekREM modification, are permitted provided that the following conditions
91.1SjdolecekREM are met:
101.1SjdolecekREM 1. Redistributions of source code must retain the above copyright
111.1SjdolecekREM    notice, this list of conditions and the following disclaimer.
121.1SjdolecekREM 2. Redistributions in binary form must reproduce the above copyright
131.1SjdolecekREM    notice, this list of conditions and the following disclaimer in the
141.1SjdolecekREM    documentation and/or other materials provided with the distribution.
151.1SjdolecekREM 3. All advertising materials mentioning features or use of this software
161.1SjdolecekREM    must display the following acknowledgement:
171.1SjdolecekREM        This product includes software developed by Mark Brinicombe.
181.1SjdolecekREM 4. The name of the company nor the name of the author may be used to
191.1SjdolecekREM    endorse or promote products derived from this software without specific
201.1SjdolecekREM    prior written permission.
211.1SjdolecekREM
221.1SjdolecekREM THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
231.1SjdolecekREM IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
241.1SjdolecekREM OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
251.1SjdolecekREM IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
261.1SjdolecekREM INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
271.1SjdolecekREM BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
281.1SjdolecekREM OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
291.1SjdolecekREM ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
301.1SjdolecekREM OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
311.1SjdolecekREM THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
321.1SjdolecekREM DAMAGE.
331.1SjdolecekREM
341.1SjdolecekREM Created      : 26/01/97
351.1SjdolecekREM Last updated : 26/01/97
361.1SjdolecekREM
371.1SjdolecekREM Decodes filesystem and device arguments and mounts the correct
381.1SjdolecekREM FFS partition with unixfs
391.1SjdolecekREM
401.1Sjdolecek
411.1SjdolecekREM Get environment
421.1SjdolecekSYS "OS_GetEnv" TO env$
431.1Sjdolecek
441.1SjdolecekREM Skipprogram path etc.
451.1SjdolecekIF (INSTR(env$, "-quit")) THEN
461.1Sjdolecek  I% = INSTR(env$, """")
471.1Sjdolecek  I% = INSTR(env$, """", I% + 1)
481.1Sjdolecek  REPEAT
491.1Sjdolecek    I% += 1
501.1Sjdolecek  UNTIL MID$(env$, I%, 1) <> " "
511.1Sjdolecek  env$ = MID$(env$, I%)
521.1SjdolecekENDIF
531.1Sjdolecek
541.1SjdolecekREM Extract the first argument as the filesystem
551.1SjdolecekI% = INSTR(env$, " ")
561.1Sjdolecekfilesys$ = FNupper(LEFT$(env$, I% - 1))
571.1Sjdolecek
581.1SjdolecekREM Skip to the next argument
591.1SjdolecekREPEAT
601.1Sjdolecek  I% += 1
611.1SjdolecekUNTIL MID$(env$, I%, 1) <> " "
621.1Sjdolecekenv$ = MID$(env$, I%)
631.1Sjdolecek
641.1SjdolecekREM The drive is the next argument
651.1SjdolecekI% = INSTR(env$, " ")
661.1SjdolecekIF (I% = 0) THEN
671.1Sjdolecek  drive$ = env$
681.1Sjdolecek  part$  = "a"    : REM partition a
691.1SjdolecekELSE
701.1Sjdolecek  drive$ = LEFT$(env$, I% - 1)
711.1Sjdolecek  REM Skip to the next argument
721.1Sjdolecek  REPEAT
731.1Sjdolecek    I% += 1
741.1Sjdolecek  UNTIL MID$(env$, I%, 1) <> " "
751.1Sjdolecek  env$  = MID$(env$, I%)
761.1Sjdolecek  part$ = env$
771.1SjdolecekENDIF
781.1Sjdolecek
791.1Sjdolecekdrive% = VAL(drive$)
801.1Sjdolecekpart%  = ASC(FNupper(part$))-ASC("A")
811.1Sjdolecekunit%  = drive% - 4
821.1Sjdolecek
831.1SjdolecekREM Lookup the SWI Number for the DiscOp SWI
841.1Sjdolecekswi$ = filesys$ + "_DiscOp"
851.1SjdolecekSYS "OS_SWINumberFromString",, swi$ TO swi%
861.1Sjdolecek
871.1SjdolecekREM Assemble the unixfs_mount argument
881.1SjdolecekREM Assumes the filesystem is on the a partition
891.1Sjdolecekswi% = swi% AND NOT(&3F)
901.1Sjdolecekswi% += drive% * 8 + part%
911.1Sjdolecek
921.1SjdolecekREM Mount the filesystem
931.1SjdolecekOSCLI("<BtNetBSD$Dir>.native.unixfs_res")
941.1SjdolecekOSCLI("unixfs_mount " + STR$~(swi%))
951.1SjdolecekEND
961.1Sjdolecek
971.1SjdolecekREM Convert a string to upper case
981.1SjdolecekDEF FNupper(A$)
991.1SjdolecekR$ = ""
1001.1SjdolecekFOR A% = 1 TO LEN(A$)
1011.1Sjdolecek  R$ = R$ + CHR$(ASC(MID$(A$, A%, 1)) AND &DF)
1021.1SjdolecekNEXT
1031.1Sjdolecek
1041.1Sjdolecek= R$
105