1 structure Quotas
:> QUOTAS
=
5 val proc
= Unix
.execute ("/bin/sh", ["-c", "/usr/bin/vos listvol -long deleuze"])
6 val inf
= Unix
.textInstreamOf proc
8 fun eatUntilBlankLine () =
9 case TextIO.inputLine inf
of
12 | SOME _
=> eatUntilBlankLine ()
14 val suffix
= "." ^ uname
17 case TextIO.inputLine inf
of
20 case String.tokens
Char.isSpace line
of
21 [vol
, _
, _
, kbs
, _
, _
] =>
22 if String.isSuffix suffix vol
then
24 val _
= TextIO.inputLine inf
25 val _
= TextIO.inputLine inf
27 case TextIO.inputLine inf
of
32 case String.tokens
Char.isSpace line
of
33 [_
, quota
, _
] => quota
34 | _
=> raise Fail
"Bad quota string"
38 used
= valOf (Int.fromString kbs
),
39 quota
= valOf (Int.fromString quota
)}
44 (eatUntilBlankLine ();
48 val _
= TextIO.inputLine inf
51 before ignore (Unix
.reap proc
)
56 raise Fail
"Username too short"
58 String.concat
[String.substring (s
, 0, 1), "/",
59 String.substring (s
, 0, 2), "/",
64 val (befor
, after
) = Substring
.splitl (fn ch
=> ch
<> #
".") (Substring
.full vol
)
66 (Substring
.string befor
,
67 Substring
.string (Substring
.slice (after
, 1, NONE
)))
72 val (kind
, uname
) = splitVol vol
75 "user" => "/afs/hcoop.net/user/" ^ goofy uname
76 |
"db" => "/afs/hcoop.net/.databases/" ^ goofy uname
77 |
"mail" => "/afs/hcoop.net/user/" ^ goofy uname ^
"/Maildir"
78 | _
=> raise Fail ("Don't know how to find mount point for volume " ^ vol
)