diff options
-rw-r--r-- | lib/std/syswrap+plan9.myr | 29 | ||||
-rw-r--r-- | lib/sys/sys+plan9-x64.myr | 12 | ||||
-rwxr-xr-x | mbldwrap.sh | 4 |
3 files changed, 20 insertions, 25 deletions
diff --git a/lib/std/syswrap+plan9.myr b/lib/std/syswrap+plan9.myr index 4fd5c7c..8874224 100644 --- a/lib/std/syswrap+plan9.myr +++ b/lib/std/syswrap+plan9.myr @@ -6,6 +6,7 @@ use "errno" use "result" use "cstrconv" use "strfind" +use "getint" pkg std = type fd = sys.fd @@ -48,6 +49,7 @@ pkg std = const fmtime : (f : byte[:] -> result(time, errno)) const fsize : (f : byte[:] -> result(off, errno)) const fexists : (f : byte[:] -> bool) + const fisdir : (f : byte[:] -> bool) /* the important bits that uname provides */ const getsysinfo : (si : sysinfo# -> void) @@ -129,6 +131,16 @@ const fsize = {path -> `Ok (getle64(buf[Lengthoff:Lengthoff + 8]) castto(off)) } +extern const put : (fmt : byte[:], args : ... -> int64) +const fisdir = {path + var buf : byte[Stringsoff + 39] /* enough space for qid type */ + + if sys.stat(path, buf[:]) < Stringsoff + -> false + ;; + -> (getle32(buf[Modeoff:Modeoff + 4]) & sys.Dmdir) != 0 +} + const getsysinfo = {si si.system = getenvv("osname", "Plan9") si.release = "4" @@ -209,23 +221,6 @@ const statsz = {buf } */ -const getle32 = {buf - -> (buf[0] castto(int32)) \ - | ((buf[1] castto(int32)) << 8) \ - | ((buf[2] castto(int32)) << 16) \ - | ((buf[3] castto(int32)) << 24) -} - -const getle64 = {buf - -> (buf[0] castto(int64)) \ - | ((buf[1] castto(int64)) << 8) \ - | ((buf[2] castto(int64)) << 16) \ - | ((buf[3] castto(int64)) << 24) \ - | ((buf[4] castto(int64)) << 64) \ - | ((buf[5] castto(int64)) << 40) \ - | ((buf[6] castto(int64)) << 48) \ - | ((buf[7] castto(int64)) << 56) -} generic check = {e : @a::(integral, numeric) -> result(@b, errno) if e < 0 -> `Fail lasterr() diff --git a/lib/sys/sys+plan9-x64.myr b/lib/sys/sys+plan9-x64.myr index fe8e453..6e38d26 100644 --- a/lib/sys/sys+plan9-x64.myr +++ b/lib/sys/sys+plan9-x64.myr @@ -45,12 +45,12 @@ pkg sys = const Qttmp : int = 0x04 const Qtfile : int = 0x00 - const Dmdir : int = 0x8000000 - const Dmappend : int = 0x4000000 - const Dmexcl : int = 0x2000000 - const Dmmount : int = 0x1000000 - const Dmauth : int = 0x0800000 - const Dmtmp : int = 0x0400000 + const Dmdir : int = 0x80000000 + const Dmappend : int = 0x40000000 + const Dmexcl : int = 0x20000000 + const Dmmount : int = 0x10000000 + const Dmauth : int = 0x08000000 + const Dmtmp : int = 0x04000000 const Dmread : int = 0x4 const Dmwrite : int = 0x2 const Dmexec : int = 0x1 diff --git a/mbldwrap.sh b/mbldwrap.sh index 4c68388..9d94fd1 100755 --- a/mbldwrap.sh +++ b/mbldwrap.sh @@ -16,8 +16,8 @@ else fi if [ -f mbld/mbld ]; then - ./mbld/mbld -S $@ || mbld -S $@ || \ + ./mbld/mbld $@ || mbld $@ || \ (echo "Unable to run mbld $@; have you build successfully"; false) else - ./mbld/mbld -S || mbld -S || $BOOT + ./mbld/mbld || mbld || $BOOT fi |