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