1REM >Mountufs 2REM $NetBSD: MountUFS,v 1.1.1.1 2002/05/09 20:03:59 jdolecek Exp $ 3REM 4REM Copyright (c) 1997 Mark Brinicombe 5REM All rights reserved 6REM 7REM Redistribution and use in source and binary forms, with or without 8REM modification, are permitted provided that the following conditions 9REM are met: 10REM 1. Redistributions of source code must retain the above copyright 11REM notice, this list of conditions and the following disclaimer. 12REM 2. Redistributions in binary form must reproduce the above copyright 13REM notice, this list of conditions and the following disclaimer in the 14REM documentation and/or other materials provided with the distribution. 15REM 3. All advertising materials mentioning features or use of this software 16REM must display the following acknowledgement: 17REM This product includes software developed by Mark Brinicombe. 18REM 4. The name of the company nor the name of the author may be used to 19REM endorse or promote products derived from this software without specific 20REM prior written permission. 21REM 22REM THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 23REM IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24REM OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25REM IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 26REM INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27REM BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 28REM OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 29REM ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30REM OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 31REM THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32REM DAMAGE. 33REM 34REM Created : 26/01/97 35REM Last updated : 26/01/97 36REM 37REM Decodes filesystem and device arguments and mounts the correct 38REM FFS partition with unixfs 39REM 40 41REM Get environment 42SYS "OS_GetEnv" TO env$ 43 44REM Skipprogram path etc. 45IF (INSTR(env$, "-quit")) THEN 46 I% = INSTR(env$, """") 47 I% = INSTR(env$, """", I% + 1) 48 REPEAT 49 I% += 1 50 UNTIL MID$(env$, I%, 1) <> " " 51 env$ = MID$(env$, I%) 52ENDIF 53 54REM Extract the first argument as the filesystem 55I% = INSTR(env$, " ") 56filesys$ = FNupper(LEFT$(env$, I% - 1)) 57 58REM Skip to the next argument 59REPEAT 60 I% += 1 61UNTIL MID$(env$, I%, 1) <> " " 62env$ = MID$(env$, I%) 63 64REM The drive is the next argument 65I% = INSTR(env$, " ") 66IF (I% = 0) THEN 67 drive$ = env$ 68 part$ = "a" : REM partition a 69ELSE 70 drive$ = LEFT$(env$, I% - 1) 71 REM Skip to the next argument 72 REPEAT 73 I% += 1 74 UNTIL MID$(env$, I%, 1) <> " " 75 env$ = MID$(env$, I%) 76 part$ = env$ 77ENDIF 78 79drive% = VAL(drive$) 80part% = ASC(FNupper(part$))-ASC("A") 81unit% = drive% - 4 82 83REM Lookup the SWI Number for the DiscOp SWI 84swi$ = filesys$ + "_DiscOp" 85SYS "OS_SWINumberFromString",, swi$ TO swi% 86 87REM Assemble the unixfs_mount argument 88REM Assumes the filesystem is on the a partition 89swi% = swi% AND NOT(&3F) 90swi% += drive% * 8 + part% 91 92REM Mount the filesystem 93OSCLI("<BtNetBSD$Dir>.native.unixfs_res") 94OSCLI("unixfs_mount " + STR$~(swi%)) 95END 96 97REM Convert a string to upper case 98DEF FNupper(A$) 99R$ = "" 100FOR A% = 1 TO LEN(A$) 101 R$ = R$ + CHR$(ASC(MID$(A$, A%, 1)) AND &DF) 102NEXT 103 104= R$ 105