Revision: 6fcebb5f03
Author: for...@vitanuova.com
Date: Fri Feb 5 03:01:55 2010
Log: 20100205-1101
http://code.google.com/p/inferno-npe/source/detail?r=6fcebb5f03
Revision: d174be9302
Author: for...@vitanuova.com
Date: Fri Feb 5 03:09:14 2010
Log: 20100205-1109
http://code.google.com/p/inferno-npe/source/detail?r=d174be9302
Revision: c12249bfc8
Author: for...@vitanuova.com
Date: Fri Feb 5 06:51:46 2010
Log: 20100205-1451
http://code.google.com/p/inferno-npe/source/detail?r=c12249bfc8
Revision: dc810d52e2
Author: for...@vitanuova.com
Date: Fri Feb 5 07:15:14 2010
Log: 20100205-1515
http://code.google.com/p/inferno-npe/source/detail?r=dc810d52e2
Revision: 424f5c46a5
Author: for...@vitanuova.com
Date: Fri Feb 5 07:56:39 2010
Log: 20100205-1556
http://code.google.com/p/inferno-npe/source/detail?r=424f5c46a5
Revision: eeb9eeeb80
Author: Venkatesh Srinivas <m...@acm.jhu.edu>
Date: Sun Feb 7 07:49:54 2010
Log: Merge with inferno-os 20100205.
http://code.google.com/p/inferno-npe/source/detail?r=eeb9eeeb80
Revision: f8439c0f49
Author: Venkatesh Srinivas <m...@acm.jhu.edu>
Date: Sun Feb 7 08:18:30 2010
Log: Fix DragonFly lib9.h; previous merge resolution for this file was
inco...
http://code.google.com/p/inferno-npe/source/detail?r=f8439c0f49
==============================================================================
Revision: 6fcebb5f03
Author: for...@vitanuova.com
Date: Fri Feb 5 03:01:55 2010
Log: 20100205-1101
http://code.google.com/p/inferno-npe/source/detail?r=6fcebb5f03
Modified:
/CHANGES
/appl/cmd/auth/secstore.b
/appl/lib/secstore.b
/dis/lib/secstore.dis
/doc/port.ms
/doc/port.pdf
/include/version.h
/man/1/bind
/man/1/cpu
/man/1/grid-register
/man/1/grid-session
/man/1/listen
/man/1/ls
/man/1/ns
/man/1/secstore
/man/1/sh-file2chan
/man/1/telnet
/man/10/devattach
/man/10/odbc
/man/10/styx
/man/2/drawmux
/man/2/registries
/man/2/secstore
/man/2/security-login
/man/2/srv
/man/2/styx
/man/2/styxconv
/man/2/styxflush
/man/2/styxpersist
/man/2/styxservers
/man/2/sys-0intro
/man/2/sys-bind
/man/2/sys-export
/man/2/sys-fauth
/man/2/sys-file2chan
/man/2/sys-fversion
/man/2/sys-iounit
/man/2/sys-pipe
/man/2/virgil
/man/3/0intro
/man/3/ip
/man/3/logfs
/man/3/mnt
/man/3/plap
/man/3/tls
/man/4/0intro
/man/4/dossrv
/man/4/export
/man/4/ftpfs
/man/4/grid-cpu
/man/4/iostats
/man/4/kfs
/man/4/mntgen
/man/4/registry
/man/6/image
/man/8/collabsrv
/man/8/cs
/man/8/httpd
/man/8/ping
/man/8/rdbgsrv
/man/8/styxchat
/man/8/styxmon
/man/8/svc
/module/secstore.m
=======================================
--- /CHANGES Wed Feb 3 12:48:47 2010
+++ /CHANGES Fri Feb 5 03:01:55 2010
@@ -1,7 +1,10 @@
+20100205
+ update man pages to replace most references to Styx by 9P
+ update man pages to replace references to sys-dial(2) by dial(2)
20100203
- appl/lib/cfg.b treat \r as white space (issue 69, 70)
+ appl/lib/cfg.b treat \r as white space [issue 69, issue 70]
add u64int to lib9.h files that needed it
- add sha2.c sha256block.c sha512block.c to libsec/port and include/libsec.h
+ add sha2.c sha256block.c sha512block.c to libsec/port and
include/libsec.h [issue 185, mechiel]
add new sha functions to module/keyring.m and libinterp/keyring.c
20100115
appl/cmd/tarfs.b man/4/tarfs changes to permission handling from mechiel
[issue 220]
=======================================
--- /appl/cmd/auth/secstore.b Tue Mar 4 05:50:55 2008
+++ /appl/cmd/auth/secstore.b Fri Feb 5 03:01:55 2010
@@ -29,7 +29,7 @@
Maxfilesize: con 128*1024;
stderr: ref Sys->FD;
-conn: ref Sys->Connection;
+conn: ref Dial->Connection;
seckey: array of byte;
filekey: array of byte;
file: array of byte;
@@ -100,7 +100,7 @@
if(nf > 1)
pin = hd tl flds;
}
- conn: ref Sys->Connection;
+ conn: ref Dial->Connection;
Auth:
for(;;){
if(!iflag)
@@ -229,7 +229,7 @@
sys->fprint(stderr, "%c %q\n", op, n);
}
-getfile(conn: ref Sys->Connection, fname: string, key: array of byte):
array of byte
+getfile(conn: ref Dial->Connection, fname: string, key: array of byte):
array of byte
{
f := secstore->getfile(conn, fname, 0);
if(f == nil)
=======================================
--- /appl/lib/secstore.b Fri Dec 22 09:07:39 2006
+++ /appl/lib/secstore.b Fri Feb 5 03:01:55 2010
@@ -7,6 +7,9 @@
include "sys.m";
sys: Sys;
+include "dial.m";
+ dialler: Dial;
+
include "keyring.m";
kr: Keyring;
DigestState, IPint: import kr;
@@ -27,6 +30,7 @@
kr = load Keyring Keyring->PATH;
ssl = load SSL SSL->PATH;
base64 = load Encoding Encoding->BASE64PATH;
+ dialler = load Dial Dial->PATH;
initPAKparams();
}
@@ -38,7 +42,7 @@
return 1;
}
-connect(addr: string, user: string, pwhash: array of byte): (ref
Sys->Connection, string, string)
+connect(addr: string, user: string, pwhash: array of byte): (ref
Dial->Connection, string, string)
{
conn := dial(addr);
if(conn == nil){
@@ -53,12 +57,12 @@
return (conn, sname, diag);
}
-dial(netaddr: string): ref Sys->Connection
+dial(netaddr: string): ref Dial->Connection
{
if(netaddr == nil)
netaddr = "net!$auth!secstore";
- (ok, conn) := sys->dial(netaddr, nil);
- if(ok < 0)
+ conn := dialler->dial(netaddr, nil);
+ if(conn == nil)
return nil;
(err, sslconn) := ssl->connect(conn.dfd);
if(err != nil)
@@ -66,7 +70,7 @@
return sslconn;
}
-auth(conn: ref Sys->Connection, user: string, pwhash: array of byte):
(string, string)
+auth(conn: ref Dial->Connection, user: string, pwhash: array of byte):
(string, string)
{
sname := PAKclient(conn, user, pwhash);
if(sname == nil)
@@ -96,7 +100,7 @@
return string buf[0:n] == "!account exists";
}
-sendpin(conn: ref Sys->Connection, pin: string): int
+sendpin(conn: ref Dial->Connection, pin: string): int
{
if(sys->fprint(conn.dfd, "STA%s", pin) < 0)
return -1;
@@ -109,7 +113,7 @@
return 0;
}
-files(conn: ref Sys->Connection): list of (string, int, string, string,
array of byte)
+files(conn: ref Dial->Connection): list of (string, int, string, string,
array of byte)
{
file := getfile(conn, ".", 0);
if(file == nil)
@@ -136,7 +140,7 @@
return l;
}
-getfile(conn: ref Sys->Connection, name: string, maxsize: int): array of
byte
+getfile(conn: ref Dial->Connection, name: string, maxsize: int): array of
byte
{
fd := conn.dfd;
if(maxsize <= 0)
@@ -171,7 +175,7 @@
return file;
}
-remove(conn: ref Sys->Connection, name: string): int
+remove(conn: ref Dial->Connection, name: string): int
{
if(sys->fprint(conn.dfd, "RM %s\n", name) < 0)
return -1;
@@ -179,7 +183,7 @@
return 0;
}
-bye(conn: ref Sys->Connection)
+bye(conn: ref Dial->Connection)
{
if(conn != nil){
if(conn.dfd != nil)
@@ -270,7 +274,7 @@
sys->werrstr(s);
}
-setsecret(conn: ref Sys->Connection, sigma: array of byte, direction:
int): string
+setsecret(conn: ref Dial->Connection, sigma: array of byte, direction:
int): string
{
secretin := array[Keyring->SHA1dlen] of byte;
secretout := array[Keyring->SHA1dlen] of byte;
@@ -399,14 +403,14 @@
# On output, session secret has been set in conn
# (unless return code is negative, which means failure).
#
-PAKclient(conn: ref Sys->Connection, C: string, pwhash: array of byte):
string
+PAKclient(conn: ref Dial->Connection, C: string, pwhash: array of byte):
string
{
dfd := conn.dfd;
(hexHi, H, nil) := PAK_Hi(C, pwhash);
# random 1<=x<=q-1; send C, m=g**x H
- x := mod(IPint.random(240, 240), pak.q);
+ x := mod(IPint.random(240), pak.q);
if(x.eq(IPint.inttoip(0)))
x = IPint.inttoip(1);
m := mod(pak.g.expmod(x, pak.p).mul(H), pak.p);
=======================================
--- /dis/lib/secstore.dis Fri Dec 22 12:52:35 2006
+++ /dis/lib/secstore.dis Fri Feb 5 03:01:55 2010
Binary file, no diff available.
=======================================
--- /doc/port.ms Fri Oct 24 08:42:31 2008
+++ /doc/port.ms Fri Feb 5 03:01:55 2010
@@ -25,7 +25,7 @@
.I make ,
can be found in
.I "Maintaining Files on Plan 9 with Mk"
-by Hume and Flandera,
+by Hume and Flandrena,
reprinted in this volume.
The source for
.CW mk
@@ -453,7 +453,7 @@
.CW etherscc.c
and
.CW devuart.c ).
-The IrDA has been used for Styx transport between a FADS board
+The IrDA has been used for 9P transport between a FADS board
and an IBM Thinkpad 560.
The file
.CW screen.c
=======================================
--- /doc/port.pdf Fri Oct 24 08:42:31 2008
+++ /doc/port.pdf Fri Feb 5 03:01:55 2010
Binary file, no diff available.
=======================================
--- /include/version.h Wed Feb 3 06:42:08 2010
+++ /include/version.h Fri Feb 5 03:01:55 2010
@@ -1,1 +1,1 @@
-#define VERSION "Fourth Edition (20100203)"
+#define VERSION "Fourth Edition (20100205)"
=======================================
--- /man/1/bind Tue Dec 15 13:40:20 2009
+++ /man/1/bind Fri Feb 5 03:01:55 2010
@@ -89,13 +89,14 @@
as a file server.
This argument should then conform to the conventions
described in
-.IR sys-dial (2).
+.IR dial (2).
Otherwise
.I source
should be the name of a file that when opened gives a connection
-to a file server, something serving the Styx protocol
+to a file server, something serving the 9P protocol
described in
-.IR intro (5).
+.IR intro (5),
+formerly called `Styx'.
The optional
.I spec
argument to
@@ -262,7 +263,7 @@
For
.I mount
only,
-the file server serves the original version of the Styx protocol, and
+the file server serves the 1995 version of Inferno's Styx protocol, and
.I mount
inserts a process that translates to the current version.
.SH SOURCE
@@ -273,10 +274,10 @@
.B /appl/cmd/unmount.b
.SH SEE ALSO
.IR sh (1),
+.IR dial (2),
.IR keyring-auth (2),
.IR security-auth (2),
.IR sys-intro (2),
.IR sys-bind (2),
-.IR sys-dial (2),
.IR intro (3),
.IR getauthinfo (8)
=======================================
--- /man/1/cpu Fri Dec 22 12:52:35 2006
+++ /man/1/cpu Fri Feb 5 03:01:55 2010
@@ -49,7 +49,7 @@
.SH SOURCE
.B /appl/cmd/cpu.b
.SH SEE ALSO
-.IR sys-dial (2),
+.IR dial (2),
.IR keyring-auth (2),
.IR security-auth (2)
.SH BUGS
=======================================
--- /man/1/grid-register Mon Oct 27 11:02:37 2008
+++ /man/1/grid-register Fri Feb 5 03:01:55 2010
@@ -11,12 +11,12 @@
.SH DESCRIPTION
.I Register
-takes a program which serves a Styx (see
-.IR intro (5))
-namespace on
-.I stdin
-and registers it with a known
-.IR registry (4).
+takes a program that serves a namespace using the 9P protocol on its
standard input
+and registers it with a known
+.IR registery (4).
+(See
+.IR intro (5)
+for a description of the protocol.)
It then marshals the service by listening for incoming connections and
exporting the namespace across them.
.I Register
prints out various status messages to
=======================================
--- /man/1/grid-session Mon Oct 27 11:02:37 2008
+++ /man/1/grid-session Fri Feb 5 03:01:55 2010
@@ -17,9 +17,11 @@
.IR session
presents a heirarchical view of currently registered resources (such as
.IR grid-ns (1))
-which export a Styx (see
-.IR intro (5))
-namespace. The top level displays the type of resource e.g.
+that serve name spaces using 9P.
+(See
+.IR intro (5)
+for a description of the protocol.)
+The top level displays the type of resource, for instance
.BR 'CPU resource' ,
whilst the second level shows the name of each individual resource.
Descending futher down the tree will reveal the attributes of the selected
resource. To mount a resource and see the namespace it exports, click mouse
button 3 on the resource name. The view will switch to a split pane view
displaying the resource namespace with directories listed on the left and
all files in the current directory displayed on the right.
.PP
=======================================
--- /man/1/listen Fri Dec 22 12:52:35 2006
+++ /man/1/listen Fri Feb 5 03:01:55 2010
@@ -59,7 +59,7 @@
(as accepted by
.B announce
in
-.IR sys-dial (2))
+.IR dial (2))
and then invokes
.IR sh (1)
to run the associated
@@ -97,7 +97,7 @@
.B net
set to the name of the corresponding network directory
(see
-.IR sys-dial (2)),
+.IR dial (2)),
before listening for incoming calls.
This can be used to change, or find out the characteristics
of an announced port (for instance to find out
@@ -231,7 +231,7 @@
has been started by
.IR styxlisten .
.SH "SEE ALSO"
-.IR svc (8),
-.IR sys-dial (2),
+.IR dial (2),
+.IR ssl (3),
.IR auth (6),
-.IR ssl (3)
+.IR svc (8)
=======================================
--- /man/1/ls Fri Jun 1 09:04:53 2007
+++ /man/1/ls Fri Feb 5 03:01:55 2010
@@ -61,7 +61,7 @@
respectively.
.IP 2.
The device type (this is the `#' device letter for local devices
-or `M' for files mounted over a Styx connection).
+or `M' for files mounted over a 9P connection).
.IP 3.
The device instance number (this distinguishes between
separately mounted instances of the same device).
=======================================
--- /man/1/ns Fri Dec 22 12:52:35 2006
+++ /man/1/ns Fri Feb 5 03:01:55 2010
@@ -27,7 +27,7 @@
.PP
Mounts of file services on a network show the network address as
given to
-.IR sys-dial (2)
+.IR dial (2)
instead of the name of the data file for the connection; the
.B -r
option causes
@@ -40,4 +40,3 @@
.IR prog (3),
.IR namespace (4),
.IR namespace (6)
-
=======================================
--- /man/1/secstore Fri Dec 22 12:52:35 2006
+++ /man/1/secstore Fri Feb 5 03:01:55 2010
@@ -98,7 +98,7 @@
Connect to the server at the given network
.IR address ,
as defined by
-.IR sys-dial (2),
+.IR dial (2),
and translated by
.IR cs (8).
The default is
=======================================
--- /man/1/sh-file2chan Fri Dec 22 12:52:35 2006
+++ /man/1/sh-file2chan Fri Feb 5 03:01:55 2010
@@ -235,7 +235,9 @@
.EE
It is, however, very limited, as binary data stored in the file
will be corrupted, and the size of the file is limited to the amount
-of data that can be transmitted in a single Styx message (8192 bytes).
+of data that can be transmitted in a single write
+(see
+.IR sys-read (2)).
.PP
The following code implements a single-threaded logfile
which can support multiple concurrent writers:
=======================================
--- /man/1/telnet Fri Dec 22 12:52:35 2006
+++ /man/1/telnet Fri Feb 5 03:01:55 2010
@@ -9,7 +9,7 @@
uses the Telnet protocol to talk to a remote
.IR machine ,
addressed using any form acceptable to
-.IR sys-dial (2):
+.IR dial (2):
.IB net ! host ! port
in general.
The default
=======================================
--- /man/10/devattach Fri Jun 26 08:57:37 2009
+++ /man/10/devattach Fri Feb 5 03:01:55 2010
@@ -203,7 +203,7 @@
.BR up->genbuf .)
If channel
.I c
-corresponds to a file descriptor on which Styx is served,
+corresponds to a file descriptor on which 9P is served,
.I devdir
sets both the flag bit
.B QTMOUNT
@@ -214,9 +214,7 @@
in
.IB dp ->mode
(see
-.I export
-in
-.IR sys-dial (2)
+.IR sys-export (2)
and
.I mount
in
@@ -470,7 +468,7 @@
.BR Qid.path ).
If
.I c
-is a communications channel connecting a Styx server to a current mount
point,
+is a communications channel connecting a 9P server to a current mount
point,
the
.B DMMOUNT
bit is set in the resulting
=======================================
--- /man/10/odbc Fri Dec 22 12:52:35 2006
+++ /man/10/odbc Fri Feb 5 03:01:55 2010
@@ -7,11 +7,13 @@
.B -d
] [
.BI -p " port"
+] [
+.BI -u " user"
]
.SH DESCRIPTION
.I Odbc
is a file server that runs under Windows and
-exports a Styx namespace
+exports a 9P namespace
(see
.IR intro (5)).
An Inferno process that mounts the namespace
@@ -26,6 +28,15 @@
The
.B -p
option gives the port number to listen on for connections. The default is
6700.
+.PP
+By default, the user
+.B inferno
+owns the files in the name space.
+The
+.B -u
+option makes
+.I user
+own the files instead.
.SS Name space
.I Odbc
presents the following name space:
=======================================
--- /man/10/styx Fri Dec 22 12:52:35 2006
+++ /man/10/styx Fri Feb 5 03:01:55 2010
@@ -40,7 +40,8 @@
These
routines convert messages in the machine-independent format of
the Inferno file protocol,
-Styx (which is equivalent to the Plan 9 protocol 9P2000),
+described by
+.IR intro (5),
to and from a more convenient form,
an
.B Fcall
@@ -129,7 +130,7 @@
This structure is defined in
.BR <styx.h> .
See section 5
-for a full description of Styx messages and their encoding.
+for a full description of 9P messages and their encoding.
For all message types, the
.B type
field of an
@@ -149,7 +150,7 @@
given in comments.
.PP
.I ConvM2S
-takes a Styx message at
+takes a 9P message at
.I ap
of length
.IR nap ,
@@ -197,7 +198,7 @@
The constant
.B IOHDRSZ
is a suitable amount of buffer to reserve for storing
-the Styx header;
+the 9P header;
the data portion of a
.B Twrite
or
@@ -295,7 +296,7 @@
and
.I buf
should include the second two-byte (16-bit) length field that precedes the
entry when
-formatted in a Styx message (see
+formatted in a 9P message (see
.IR stat (5));
in other words,
.I nbuf
=======================================
--- /man/2/drawmux Fri Dec 22 12:52:35 2006
+++ /man/2/drawmux Fri Feb 5 03:01:55 2010
@@ -52,7 +52,7 @@
The remote viewer must then use
.B Sys->export
(see
-.IR sys-dial (2))
+.IR sys-export (2))
to export its
.BR /dev/draw ,
which
=======================================
--- /man/2/registries Fri Dec 22 12:52:35 2006
+++ /man/2/registries Fri Feb 5 03:01:55 2010
@@ -108,7 +108,7 @@
.TP
.B addr
A string that represents where the service can be reached: it is often a
-.IR sys-dial (2)
+.IR dial (2)
address string, but might be a name in the name space; the interpretation
is internal to
.BR Registries .
.TP
@@ -148,7 +148,7 @@
.TP
.B fd
A file descriptor that can be read and written to exchange data with the
service.
-The meaning of the data depends on the service (eg, it might be a Styx
connection
+The meaning of the data depends on the service (eg, it might be a 9P
connection
or a SOAP implementation).
Typically an attribute of the service description hints at the protocol.
.TP
@@ -222,7 +222,7 @@
if
.I svc
is nil, the default is to try
-.IR sys-dial (2)
+.IR dial (2)
to
.BR net!$registry!registry ,
the symbolic name of the default registry for the current host.
=======================================
--- /man/2/secstore Fri Dec 22 12:52:35 2006
+++ /man/2/secstore Fri Feb 5 03:01:55 2010
@@ -3,6 +3,7 @@
secstore \- fetch data from Plan 9's secure storage service
.SH SYNOPSIS
.EX
+include "dial.m";
include "secstore.m";
secstore := load Secstore Secstore->PATH;
@@ -12,19 +13,19 @@
privacy: fn(): int;
cansecstore: fn(addr: string, user: string): int;
mkseckey: fn(pass: string): array of byte;
-dial: fn(addr: string): ref Sys->Connection;
-auth: fn(conn: ref Sys->Connection, user: string, seckey: array of
byte):
+dial: fn(addr: string): ref Dial->Connection;
+auth: fn(conn: ref Dial->Connection, user: string, seckey: array of
byte):
(string, string);
connect: fn(addr: string, user: string, seckey: array of byte):
- (ref Sys->Connection, string, string);
-sendpin: fn(conn: ref Sys->Connection, pin: string): int;
-files: fn(conn: ref Sys->Connection):
+ (ref Dial->Connection, string, string);
+sendpin: fn(conn: ref Dial->Connection, pin: string): int;
+files: fn(conn: ref Dial->Connection):
list of (string, int, string, string, array of byte);
-getfile: fn(conn: ref Sys->Connection, name: string,
+getfile: fn(conn: ref Dial->Connection, name: string,
maxsize: int): array of byte;
-.\"putfile: fn(conn: ref Sys->Connection, name: string, data: array of
byte,): int;
-remove: fn(conn: ref Sys->Connection, file: string): int;
-bye: fn(conn: ref Sys->Connection);
+.\"putfile: fn(conn: ref Dial->Connection, name: string, data: array of
byte,): int;
+remove: fn(conn: ref Dial->Connection, file: string): int;
+bye: fn(conn: ref Dial->Connection);
mkfilekey: fn(pass: string): array of byte;
decrypt: fn(data: array of byte, filekey: array of byte): array of byte;
@@ -43,16 +44,16 @@
file containing the initial keys for an instance of
.IR factotum (4).
The module's functions hold the file descriptors for the connection in a
-.BR Sys->Connection
+.BR Dial->Connection
value,
as returned by
-.IR sys-dial (2).
+.IR dial (2).
The
.I addr
parameter that gives the network address of the
.I secstore
service is also as defined in
-.IR sys-dial (2).
+.IR dial (2).
A nil value defaults to
.BR "net!$auth!secstore" ,
for translation in the usual way by
@@ -94,9 +95,9 @@
at network address
.I addr
(as defined by
-.IR sys-dial (2))
-and returns a reference to the resulting
-.BR Sys->Connection .
+.IR dial (2))
+and returns a reference to the resulting
+.BR Dial->Connection .
It returns nil on an error and sets the error string.
.PP
.B Auth
@@ -106,7 +107,7 @@
The parameter
.I conn
refers to the
-.B Sys->Connection
+.B Dial->Connection
value representing the connection.
.I User
names a user registered with the service.
=======================================
--- /man/2/security-login Fri Dec 22 12:52:35 2006
+++ /man/2/security-login Fri Feb 5 03:01:55 2010
@@ -44,7 +44,7 @@
.PP
.B Login
connects, using
-.IR sys-dial (2),
+.IR dial (2),
to the signer at network address
.IR addr ,
which is any form accepted by
=======================================
--- /man/2/srv Fri Dec 22 12:52:35 2006
+++ /man/2/srv Fri Feb 5 03:01:55 2010
@@ -34,7 +34,7 @@
.IR dns (6)
if available.
Other Inferno applications normally give network addresses to the
functions of
-.IR sys-dial (2),
+.IR dial (2),
and they are then translated automatically, using the services of
.IR cs (8).
.PP
=======================================
--- /man/2/styx Fri Dec 22 12:52:35 2006
+++ /man/2/styx Fri Feb 5 03:01:55 2010
@@ -1,6 +1,6 @@
.TH STYX 2
.SH NAME
-Styx: Rmsg, Tmsg, dir2text, istmsg, packdir, packdirsize, readmsg,
qid2text, unpackdir \- interface to Styx file protocol
+Styx: Rmsg, Tmsg, dir2text, istmsg, packdir, packdirsize, readmsg,
qid2text, unpackdir \- interface to 9P (Styx) file protocol
.SH SYNOPSIS
.EX
include "styx.m";
@@ -118,13 +118,14 @@
.EE
.SH DESCRIPTION
.B Styx
-provides a Limbo interface to send and receive messages of the Styx file
service protocol,
-described by Section 5 of this manual (a thorough reading of which
-is advised before using this module).
+provides a Limbo interface to send and receive messages of the 9P file
service protocol,
+described by Section 5 of this manual, a thorough reading of which
+is advised before using this module.
+(The protocol was previously called `Styx' in Inferno, hence the module's
name.)
.B Init
must be called before using any other function in the module.
.PP
-A Styx client transmits requests to a server as `T-messages'
+A 9P client transmits requests to a server as `T-messages'
and receives replies in matching `R-messages'.
A T-message is here represented by values of the type
.BR Tmsg ,
@@ -232,7 +233,7 @@
for tracing or debugging.
.TP
.IB t .mtype()
-Return the Styx message type of the message.
+Return the 9P message type of the message.
.PP
An R-message is represented by
.BR Rmsg .
=======================================
--- /man/2/styxconv Fri Dec 4 12:41:24 2009
+++ /man/2/styxconv Fri Feb 5 03:01:55 2010
@@ -1,6 +1,6 @@
.TH STYXCONV 2
.SH NAME
-styxconv \- convert between old and new Styx
+styxconv \- convert between old 1995 Styx and current Styx (9P)
.SH SYNOPSIS
.EX
include "styxconv.m";
@@ -12,9 +12,10 @@
.EE
.SH DESCRIPTION
.B Styxconv
-converts between the previous version of the Styx protocol,
+converts between the obsolete 1995 version of the Styx protocol,
as used for instance in Inferno's Third Edition and earlier,
-and the current version of the protocol,
+and the current file service protocol,
+previously also called `Styx' but
based on 9P2000 and defined by
.IR intro (5).
.PP
@@ -25,10 +26,10 @@
.B styxconv
takes two file descriptors:
.I client
-should be a connection to a styx client requiring
+should be a connection to a client requiring
one version of the protocol;
.I server
-should be a connection to a styx server serving
+should be a connection to a server serving
the other version of the protocol.
There are two conversion modules:
.B PATHNEW2OLD
@@ -74,4 +75,4 @@
.IR sys-pipe (2),
.IR intro (5)
.SH BUGS
-There is no provision for 9p2000 authentication.
+There is no provision for 9P2000 authentication.
=======================================
--- /man/2/styxflush Thu Dec 27 04:25:32 2007
+++ /man/2/styxflush Fri Feb 5 03:01:55 2010
@@ -1,6 +1,6 @@
.TH STYXFLUSH 2
.SH NAME
-styxflush \- handler for styx flush protocol
+styxflush \- handler for 9P (Styx) flush protocol
.SH SYNOPSIS
.EX
include "sys.m";
@@ -16,17 +16,17 @@
Einterrupted: con "interrupted";
.EE
.SH DESCRIPTION
-Getting the semantics of the Styx
+Getting the semantics of the 9P
.IR flush (5)
protocol correct when handling requests concurrently
is surprisingly hard to do.
.I Styxflush
-is designed to help get it right. It deals with Styx
-messages for a single styx session \- if a server needs to
+is designed to help get it right. It deals with 9P
+messages for a single 9P session \- if a server needs to
deal with multiple sessions, then multiple instances of
.I styxflush
should be loaded. It assumes there is a loop in a central process
-which both reads T-messages and sends their R-message replies.
+that both reads T-messages and sends their R-message replies.
.I Styxflush
handles the flushing of requests that are being run
outside the central process.
=======================================
--- /man/2/styxpersist Fri Dec 22 12:52:35 2006
+++ /man/2/styxpersist Fri Feb 5 03:01:55 2010
@@ -1,20 +1,20 @@
.TH STYXPERSIST 2
.SH NAME
-styxpersist \- persistent Styx connection
+styxpersist \- persistent 9P (Styx) connection
.SH SYNOPSIS
.EX
include "sys.m";
include "styxpersist.m";
styxpersist := load Styxpersist Styxpersist->PATH;
-init: fn(clientfd: ref Sys->FD, usefac: int, keyspec: string)
- : (chan of chan of ref Sys->FD, string);
+init: fn(clientfd: ref Sys->FD, usefac: int, keyspec: string):
+ (chan of chan of ref Sys->FD, string);
.EE
.SH DESCRIPTION
.I Styxpersist
-tries to maintain a persistent Styx connection for its client.
+tries to maintain a persistent 9P (Styx) connection for its client.
.B Init
-starts a process to serve Styx for the client on
+starts a process to serve 9P for the client on
.IR clientfd .
If
.I usefac
@@ -77,4 +77,4 @@
may be unable to re-authenticate.
.SH "SEE ALSO"
.IR mount (1),
-.IR sys-dial (2)
+.IR dial (2)
=======================================
--- /man/2/styxservers Mon Mar 19 04:53:59 2007
+++ /man/2/styxservers Fri Feb 5 03:01:55 2010
@@ -1,7 +1,7 @@
.TH STYXSERVERS 2
.SH NAME
styxservers \-
-Styx server implementation assistance
+9P (Styx) server implementation assistance
.SH SYNOPSIS
.EX
include "sys.m";
@@ -14,7 +14,7 @@
Styxserver: adt {
fd: ref Sys->FD; # file server end of connection
t: ref Navigator; # name space navigator for this server
- msize: int; # negotiated Styx message size
+ msize: int; # negotiated 9P message size
new: fn(fd: ref Sys->FD, t: ref Navigator, rootpath: big)
:(chan of ref Tmsg, ref Styxserver);
@@ -103,7 +103,7 @@
openmode: fn(o: int): int;
.EE
.SH DESCRIPTION
-When writing a Styx file server, there are some
+When writing a file server, there are some
commonly performed tasks that are
fiddly or tedious to implement each time.
.B Styxservers
@@ -119,7 +119,7 @@
Familiarity with Section 5 of the manual which defines the protocol
(see
.IR intro (5)),
-and with the representation of Styx messages in Limbo
+and with the representation of 9P messages in Limbo
(see
.IR styx (2)),
is a prerequisite for use of this module.
@@ -322,7 +322,7 @@
which can be used to access that navigator; and
the file descriptor
.IB srv .fd
-that is the file server's end of the connection to the Styx client.
+that is the file server's end of the connection to the 9P client.
Both values are initially provided by the file serving application,
but can be accessed through the
.B Styxserver
@@ -345,7 +345,7 @@
.RI ( c ", " srv ),
and spawns a new process, which uses
.IR styx (2)
-to read and parse Styx messages read
+to read and parse 9P messages read
from
.IR fd ,
and send them down
@@ -892,14 +892,14 @@
If
.I on
is true (non-zero),
-will trace Styx requests and replies, on standard error.
+will trace 9P requests and replies, on standard error.
This option must be set before creating a
.BR Styxserver ,
to ensure that it preserves its standard error descriptor.
.SS Constants
.B Styxservers
defines a number of constants applicable to the writing
-of Styx servers, including:
+of 9P servers, including:
.TP
.BR Einuse\fP,\fP\ Ebadfid\fP,\fP\ Eopen\fP,\fP\ Enotfound\fP,\fP\
Enotdir\fP,\fP\ Eperm\fP,\fP\ Ebadarg\fP,\fP\ Eexists
These provide standard strings for commonly used error conditions,
=======================================
--- /man/2/sys-0intro Wed Oct 22 14:17:47 2008
+++ /man/2/sys-0intro Fri Feb 5 03:01:55 2010
@@ -210,8 +210,8 @@
Record locking in the underlying file system is not supported by Inferno.
Processes can coordinate their file operations by other mechanisms.
.PP
-Atomicity is guaranteed for byte counts smaller than the
-.I Styx
+Atomicity is guaranteed for byte counts no larger than the
+.I 9P
message size;
see
.IR read (5).
=======================================
--- /man/2/sys-bind Fri Dec 22 12:52:35 2006
+++ /man/2/sys-bind Fri Feb 5 03:01:55 2010
@@ -54,7 +54,7 @@
argument to
.B mount
is a file descriptor of an open pipe or network connection
-to a file server ready to receive Styx messages.
+to a file server ready to receive 9P messages.
The
.I old
file must be a directory.
=======================================
--- /man/2/sys-export Tue Jun 16 13:24:43 2009
+++ /man/2/sys-export Fri Feb 5 03:01:55 2010
@@ -11,7 +11,7 @@
.SH DESCRIPTION
.B Export
receives and replies
-to Styx requests from a client on a connection represented by
+to 9P requests from a client on a connection represented by
.IR fd ,
for file operations on the part of the current file name space
rooted at
@@ -40,7 +40,7 @@
returned by
.B listen
(see
-.IR sys-dial (2)).
+.IR dial (2)).
Before calling
.BR export ,
the connection on
=======================================
--- /man/2/sys-fauth Fri Dec 22 12:52:35 2006
+++ /man/2/sys-fauth Fri Feb 5 03:01:55 2010
@@ -11,7 +11,7 @@
.SH DESCRIPTION
.B Fauth
provides a means for the current user to authenticate to access
-resources available through the Styx connection represented by
+resources available through the 9P connection represented by
.IR fd .
The return value is a file descriptor, conventionally called
.IR afd ,
=======================================
--- /man/2/sys-file2chan Sun Nov 1 13:50:21 2009
+++ /man/2/sys-file2chan Fri Feb 5 03:01:55 2010
@@ -49,7 +49,7 @@
.B Tread
and
.B Twrite
-Styx messages received by the system on the server's behalf; see
+9P messages received by the system on the server's behalf; see
.IR intro (5).
.PP
When the client invokes the
=======================================
--- /man/2/sys-fversion Fri Dec 22 12:52:35 2006
+++ /man/2/sys-fversion Fri Feb 5 03:01:55 2010
@@ -1,6 +1,6 @@
.TH SYS-FVERSION 2
.SH NAME
-fversion \- initialize Styx connection and negotiate version
+fversion \- initialize 9P connection and negotiate version
.SH SYNOPSIS
.EX
include "sys.m";
@@ -10,13 +10,13 @@
.EE
.SH DESCRIPTION
.B Fversion
-initialises the Styx connection represented by
+initialises the 9P connection represented by
.I fd
and negotiates the maximum message size and the version of the protocol to
be used.
.PP
The
.I bufsize
-determines the size of the I/O buffer used to stage Styx requests to the
server,
+determines the size of the I/O buffer used to stage 9P requests to the
server,
subject to the constraints of the server itself.
The
.I version
=======================================
--- /man/2/sys-iounit Fri Dec 22 12:52:35 2006
+++ /man/2/sys-iounit Fri Feb 5 03:01:55 2010
@@ -9,7 +9,7 @@
iounit: fn(fd: ref FD): int;
.EE
.SH DESCRIPTION
-Reads and writes of files are transmitted using the Styx protocol (see
+Reads and writes of files are transmitted using the 9P protocol (see
.IR intro (5))
and in general, operations involving large amounts of data must be
broken into smaller pieces by the operating system.
=======================================
--- /man/2/sys-pipe Fri Dec 22 12:52:35 2006
+++ /man/2/sys-pipe Fri Feb 5 03:01:55 2010
@@ -33,12 +33,12 @@
Pipes are still useful, however,
to connect applications that do not (or cannot) share such channels,
or when a system interface requires a file descriptor.
-For instance, a process that serves the Styx protocol can
+For instance, a process that serves the 9P protocol can
pass the file descriptor for one end of a pipe to
.B Sys->mount
(see
.IR sys-bind (2)),
-and read and write Styx messages on the other end of the pipe.
+and read and write 9P messages on the other end of the pipe.
.SH DIAGNOSTICS
Returns 0 on success; -1 on failure.
.SH "SEE ALSO"
=======================================
--- /man/2/virgil Fri Dec 22 12:52:35 2006
+++ /man/2/virgil Fri Feb 5 03:01:55 2010
@@ -39,7 +39,7 @@
.SH SOURCE
.B /appl/lib/virgil.b
.SH SEE ALSO
-.IR sys-dial (2),
+.IR dial (2),
.IR cs (8),
.IR register (8),
.IR virgild (8)
=======================================
--- /man/3/0intro Fri Dec 22 12:52:35 2006
+++ /man/3/0intro Fri Feb 5 03:01:55 2010
@@ -29,7 +29,7 @@
.PP
A kernel device driver is a
.I server
-in the sense of the Inferno File Protocol, Styx (see Section 5),
+in the sense of the Inferno File Protocol, 9P (see Section 5),
but with the messages implemented by local
rather than remote procedure calls.
Also, several of the messages
=======================================
--- /man/3/ip Thu May 10 02:01:15 2007
+++ /man/3/ip Fri Feb 5 03:01:55 2010
@@ -243,7 +243,7 @@
and
.BR listen
functions described in
-.IR sys-dial (2)
+.IR dial (2)
perform the necessary I/O to establish and
manipulate network connections.
.SS TCP protocol
@@ -747,7 +747,7 @@
.IB device !0x806
(ARP).
See
-.IR sys-dial (2)
+.IR dial (2)
for the interpretation of such addresses.
The interface runs until a process does an explicit
.BR unbind .
@@ -807,7 +807,7 @@
a connection will be opened using
.B dial
(see
-.IR sys-dial (2)).
+.IR dial (2)).
Otherwise the name will be opened as-is;
usually it is the name of a serial device
(eg,
@@ -921,6 +921,6 @@
.br
.B /os/ip/*medium.c
.SH "SEE ALSO"
-.IR sys-dial (2)
+.IR dial (2)
.\" joinmulti and leavemulti are unimplemented
.\" many media are only partly implemented
=======================================
--- /man/3/logfs Fri Dec 22 12:52:35 2006
+++ /man/3/logfs Fri Feb 5 03:01:55 2010
@@ -44,7 +44,7 @@
.PP
The file system maintains two storage regions on the same medium:
a log-structured hierarchical file system that implements all the
-functionality communicable by the Styx protocol
+functionality communicable by the 9P protocol
(see
.IR intro (5)),
and a boot
@@ -106,7 +106,7 @@
.BI /dev/logfs name
and
.BI /dev/logfs name\f5boot\fI.
-The former serves the Styx protocol giving access to the hierarchical file
system;
+The former serves the 9P protocol giving access to the hierarchical file
system;
the latter is a fixed size file that represents the boot partition.
.TP
.BI [fsys " name\f5] format \fIbootsize"
=======================================
--- /man/3/mnt Fri Dec 22 12:52:35 2006
+++ /man/3/mnt Fri Feb 5 03:01:55 2010
@@ -1,6 +1,6 @@
.TH MNT 3
.SH NAME
-mnt \- attach to Styx servers
+mnt \- attach to 9P servers
.SH SYNOPSIS
.nf
.B #M
@@ -15,12 +15,12 @@
see
.IR sys-bind (2))
to connect the name space of a process to
-the service provided by a Styx server over a communications channel.
+the service provided by a 9P server over a communications channel.
After the
.BR mount ,
file operations in that portion of the name space will
be converted by the mount driver into the appropriate
-Styx messages to the server, and its Styx replies returned
+9P messages to the server, and its 9P replies returned
as the status of the system calls.
.PP
Any authentication must precede
@@ -40,8 +40,8 @@
the mount driver multiplexes the access of the various users and their
processes to the service.
.PP
-File-oriented system calls are converted by the kernel into messages in
the Styx protocol.
-Within the kernel, Styx is implemented by procedure calls to the
+File-oriented system calls are converted by the kernel into messages in
the 9P protocol.
+Within the kernel, 9P is implemented by procedure calls to the
various kernel device drivers, as described in
.IR intro (10)
and
@@ -61,7 +61,7 @@
may be translated
into more than one
message,
-since there is a maximum data size for a Styx message.
+since there is a maximum data size for a 9P message.
The system call
will return when the specified number of bytes have been transferred
or a short reply is returned.
=======================================
--- /man/3/plap Fri Dec 22 12:52:35 2006
+++ /man/3/plap Fri Feb 5 03:01:55 2010
@@ -126,7 +126,7 @@
and
.B listen
of
-.IR sys-dial (2)
+.IR dial (2)
to do the work needed to establish and manipulate network connections.
.SH SOURCE
.B /os/pc/devplap.c
=======================================
--- /man/3/tls Fri Dec 22 12:52:35 2006
+++ /man/3/tls Fri Feb 5 03:01:55 2010
@@ -267,7 +267,7 @@
.BR 'sha1' .
.SH "SEE ALSO"
.IR listen (1),
-.IR sys-dial (2),
+.IR dial (2),
.IR ssl (3)
\".IR pushtls (2)
.SH SOURCE
=======================================
--- /man/4/0intro Fri Dec 22 12:52:35 2006
+++ /man/4/0intro Fri Feb 5 03:01:55 2010
@@ -2,7 +2,7 @@
.SH NAME
intro \- introduction to file servers
.SH DESCRIPTION
-This section describes programs that serve Styx
+This section describes programs that serve 9P
(see
.IR intro (5)),
and can therefore
=======================================
--- /man/4/dossrv Fri Dec 22 12:52:35 2006
+++ /man/4/dossrv Fri Feb 5 03:01:55 2010
@@ -27,7 +27,7 @@
The options are:
.TP
.B -v
-print a debugging trace, including Styx messages, on standard error
+print a debugging trace, including 9P messages, on standard error
.TP
.B -F
display FAT information
=======================================
--- /man/4/export Mon Oct 27 12:38:47 2008
+++ /man/4/export Fri Feb 5 03:01:55 2010
@@ -13,12 +13,10 @@
.SH DESCRIPTION
.I Export
calls
-.B Sys->export
-(see
-.IR sys-dial (2))
-to serve a name space rooted at
+.IR sys-export (2)
+to serve the name space rooted at
.I dir
-over a connection to a Styx client.
+over a connection to a 9P (Styx) client.
.I Export
opens the connection on the given
.IR file ,
@@ -35,7 +33,7 @@
will be visible to clients.
.PP
.I Export
-starts serving Styx immediately; it assumes that the connection
+starts serving 9P immediately; it assumes that the connection
has been authenticated if required.
.I Export
is typically called via
@@ -53,5 +51,6 @@
.SH SEE ALSO
.IR cpu (1),
.IR listen (1),
-.IR sys-dial (2),
+.IR dial (2),
+.IR sys-export (2),
.IR intro (5)
=======================================
--- /man/4/ftpfs Tue Mar 27 05:56:17 2007
+++ /man/4/ftpfs Fri Feb 5 03:01:55 2010
@@ -23,7 +23,7 @@
.BR /n/ftp )
in the current name space,
for access by ordinary Inferno file operations.
-In other words, it is a protocol translator between FTP and Styx.
+In other words, it is a protocol translator between FTP and 9P.
The connection is shut down by unmounting the mount point;
see
.IR bind (1).
=======================================
--- /man/4/grid-cpu Thu Feb 19 05:30:52 2009
+++ /man/4/grid-cpu Fri Feb 5 03:01:55 2010
@@ -53,7 +53,7 @@
.B /dis
and
.B /dev
-from a resource exporting a Styx (see
+from a resource exporting a 9P (see
.IR intro(5))
namespace at address
.B tcp!200.1.5.53!7003
=======================================
***Additional files exist in this changeset.***
==============================================================================
Revision: d174be9302
Author: for...@vitanuova.com
Date: Fri Feb 5 03:09:14 2010
Log: 20100205-1109
http://code.google.com/p/inferno-npe/source/detail?r=d174be9302
Modified:
/appl/lib/secstore.b
/dis/lib/secstore.dis
=======================================
--- /appl/lib/secstore.b Fri Feb 5 03:01:55 2010
+++ /appl/lib/secstore.b Fri Feb 5 03:09:14 2010
@@ -410,7 +410,7 @@
(hexHi, H, nil) := PAK_Hi(C, pwhash);
# random 1<=x<=q-1; send C, m=g**x H
- x := mod(IPint.random(240), pak.q);
+ x := mod(IPint.random(240, 240), pak.q);
if(x.eq(IPint.inttoip(0)))
x = IPint.inttoip(1);
m := mod(pak.g.expmod(x, pak.p).mul(H), pak.p);
=======================================
--- /dis/lib/secstore.dis Fri Feb 5 03:01:55 2010
+++ /dis/lib/secstore.dis Fri Feb 5 03:09:14 2010
Binary file, no diff available.
==============================================================================
Revision: c12249bfc8
Author: for...@vitanuova.com
Date: Fri Feb 5 06:51:46 2010
Log: 20100205-1451
http://code.google.com/p/inferno-npe/source/detail?r=c12249bfc8
Added:
/DragonFly/386/bin/.dreg
/DragonFly/386/include/fpuctl.h
/DragonFly/386/include/lib9.h
/DragonFly/386/lib/.dreg
/emu/DragonFly/README
/emu/DragonFly/asm-386.S
/emu/DragonFly/audio.c
/emu/DragonFly/cmd.c
/emu/DragonFly/deveia.c
/emu/DragonFly/devfs.c
/emu/DragonFly/emu
/emu/DragonFly/emu-g
/emu/DragonFly/ipif.c
/emu/DragonFly/mkfile
/emu/DragonFly/os.c
/lib9/getcallerpc-DragonFly-386.S
/libmath/FPcontrol-DragonFly.c
/mkfiles/mkfile-DragonFly-386
/mkfiles/mkhost-DragonFly
Modified:
/CHANGES
=======================================
--- /dev/null
+++ /DragonFly/386/include/fpuctl.h Fri Feb 5 06:51:46 2010
@@ -0,0 +1,76 @@
+/*
+ * Linux 386 fpu support
+ * Mimic Plan9 floating point support
+ */
+
+static void
+setfcr(ulong fcr)
+{
+ __asm__( "xorb $0x3f, %%al\n\t"
+ "pushw %%ax\n\t"
+ "fwait\n\t"
+ "fldcw (%%esp)\n\t"
+ "popw %%ax\n\t"
+ : /* no output */
+ : "al" (fcr)
+ );
+}
+
+static ulong
+getfcr(void)
+{
+ ulong fcr = 0;
+
+ __asm__( "pushl %%eax\n\t"
+ "fwait\n\t"
+ "fstcw (%%esp)\n\t"
+ "popl %%eax\n\t"
+ "xorb $0x3f, %%al\n\t"
+ : "=a" (fcr)
+ : "eax" (fcr)
+ );
+ return fcr;
+}
+
+static ulong
+getfsr(void)
+{
+ ulong fsr = -1;
+
+ __asm__( "fwait\n\t"
+ "fstsw (%%eax)\n\t"
+ "movl (%%eax), %%eax\n\t"
+ "andl $0xffff, %%eax\n\t"
+ : "=a" (fsr)
+ : "eax" (&fsr)
+ );
+ return fsr;
+}
+
+static void
+setfsr(ulong fsr)
+{
+ __asm__("fclex\n\t");
+}
+
+/* FCR */
+#define FPINEX (1<<5)
+#define FPUNFL ((1<<4)|(1<<1))
+#define FPOVFL (1<<3)
+#define FPZDIV (1<<2)
+#define FPINVAL (1<<0)
+#define FPRNR (0<<10)
+#define FPRZ (3<<10)
+#define FPRPINF (2<<10)
+#define FPRNINF (1<<10)
+#define FPRMASK (3<<10)
+#define FPPEXT (3<<8)
+#define FPPSGL (0<<8)
+#define FPPDBL (2<<8)
+#define FPPMASK (3<<8)
+/* FSR */
+#define FPAINEX FPINEX
+#define FPAOVFL FPOVFL
+#define FPAUNFL FPUNFL
+#define FPAZDIV FPZDIV
+#define FPAINVAL FPINVAL
=======================================
--- /dev/null
+++ /DragonFly/386/include/lib9.h Fri Feb 5 06:51:46 2010
@@ -0,0 +1,492 @@
+/* define _BSD_SOURCE to use ISO C, POSIX, and 4.3BSD things. */
+#ifndef _BSD_SOURCE
+#define _BSD_SOURCE
+#endif
+/* these aren't really needed because FreeBSD does the right thing and
makes off_t 64 bits, full stop */
+#define _LARGEFILE64_SOURCE 1
+#define _FILE_OFFSET_BITS 64
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include "math.h"
+#include <fcntl.h>
+#include <setjmp.h>
+#include <float.h>
+#include <time.h>
+
+#define getwd infgetwd
+
+#undef isnan
+#define round infround
+#define fmax inffmax
+#define log2 inflog2
+
+#ifndef EMU
+typedef struct Proc Proc;
+#endif
+
+/*
+ * math module dtoa
+ */
+#define __LITTLE_ENDIAN
+
+#define nil ((void*)0)
+
+typedef unsigned char uchar;
+typedef signed char schar;
+typedef unsigned long ulong;
+typedef unsigned short Rune;
+typedef long long int vlong;
+typedef unsigned long long int uvlong;
+typedef unsigned int u32int;
+typedef uvlong u64int;
+typedef unsigned int mpdigit; /* for /sys/include/mp.h */
+typedef unsigned short u16int;
+typedef unsigned char u8int;
+typedef unsigned long uintptr;
+
+#define USED(x) if(x){}else{}
+#define SET(x)
+
+#undef nelem
+#define nelem(x) (sizeof(x)/sizeof((x)[0]))
+#undef offsetof
+#define offsetof(s, m) (ulong)(&(((s*)0)->m))
+#undef assert
+#define assert(x) if(x){}else _assert("x")
+
+/*
+ * most mem and string routines are declared by ANSI/POSIX files above
+ */
+
+extern char* strecpy(char*, char*, char*);
+extern char* strdup(const char*);
+extern int cistrncmp(char*, char*, int);
+extern int cistrcmp(char*, char*);
+extern char* cistrstr(char*, char*);
+extern int tokenize(char*, char**, int);
+
+enum
+{
+ UTFmax = 3, /* maximum bytes per rune */
+ Runesync = 0x80, /* cannot represent part of a UTF sequence (<) */
+ Runeself = 0x80, /* rune and UTF sequences are the same (<) */
+ Runeerror = 0x80 /* decoding error in UTF */
+};
+
+/*
+ * rune routines
+ */
+extern int runetochar(char*, Rune*);
+extern int chartorune(Rune*, char*);
+extern int runelen(long);
+extern int runenlen(Rune*, int);
+extern int fullrune(char*, int);
+extern int utflen(char*);
+extern int utfnlen(char*, long);
+extern char* utfrune(char*, long);
+extern char* utfrrune(char*, long);
+extern char* utfutf(char*, char*);
+extern char* utfecpy(char*, char*, char*);
+
+extern Rune* runestrcat(Rune*, Rune*);
+extern Rune* runestrchr(Rune*, Rune);
+extern int runestrcmp(Rune*, Rune*);
+extern Rune* runestrcpy(Rune*, Rune*);
+extern Rune* runestrncpy(Rune*, Rune*, long);
+extern Rune* runestrecpy(Rune*, Rune*, Rune*);
+extern Rune* runestrdup(Rune*);
+extern Rune* runestrncat(Rune*, Rune*, long);
+extern int runestrncmp(Rune*, Rune*, long);
+extern Rune* runestrrchr(Rune*, Rune);
+extern long runestrlen(Rune*);
+extern Rune* runestrstr(Rune*, Rune*);
+
+extern Rune tolowerrune(Rune);
+extern Rune totitlerune(Rune);
+extern Rune toupperrune(Rune);
+extern int isalpharune(Rune);
+extern int islowerrune(Rune);
+extern int isspacerune(Rune);
+extern int istitlerune(Rune);
+extern int isupperrune(Rune);
+
+/*
+ * malloc
+ */
+extern void* malloc(size_t);
+extern void* mallocz(ulong, int);
+extern void free(void*);
+extern ulong msize(void*);
+extern void* calloc(size_t, size_t);
+extern void* realloc(void*, size_t);
+extern void setmalloctag(void*, ulong);
+extern void setrealloctag(void*, ulong);
+extern ulong getmalloctag(void*);
+extern ulong getrealloctag(void*);
+extern void* malloctopoolblock(void*);
+
+/*
+ * print routines
+ */
+typedef struct Fmt Fmt;
+struct Fmt{
+ uchar runes; /* output buffer is runes or chars? */
+ void *start; /* of buffer */
+ void *to; /* current place in the buffer */
+ void *stop; /* end of the buffer; overwritten if flush fails */
+ int (*flush)(Fmt *); /* called when to == stop */
+ void *farg; /* to make flush a closure */
+ int nfmt; /* num chars formatted so far */
+ va_list args; /* args passed to dofmt */
+ int r; /* % format Rune */
+ int width;
+ int prec;
+ ulong flags;
+};
+
+enum{
+ FmtWidth = 1,
+ FmtLeft = FmtWidth << 1,
+ FmtPrec = FmtLeft << 1,
+ FmtSharp = FmtPrec << 1,
+ FmtSpace = FmtSharp << 1,
+ FmtSign = FmtSpace << 1,
+ FmtZero = FmtSign << 1,
+ FmtUnsigned = FmtZero << 1,
+ FmtShort = FmtUnsigned << 1,
+ FmtLong = FmtShort << 1,
+ FmtVLong = FmtLong << 1,
+ FmtComma = FmtVLong << 1,
+ FmtByte = FmtComma << 1,
+
+ FmtFlag = FmtByte << 1
+};
+
+extern int print(char*, ...);
+extern char* seprint(char*, char*, char*, ...);
+extern char* vseprint(char*, char*, char*, va_list);
+extern int snprint(char*, int, char*, ...);
+extern int vsnprint(char*, int, char*, va_list);
+extern char* smprint(char*, ...);
+extern char* vsmprint(char*, va_list);
+extern int sprint(char*, char*, ...);
+extern int fprint(int, char*, ...);
+extern int vfprint(int, char*, va_list);
+
+extern int runesprint(Rune*, char*, ...);
+extern int runesnprint(Rune*, int, char*, ...);
+extern int runevsnprint(Rune*, int, char*, va_list);
+extern Rune* runeseprint(Rune*, Rune*, char*, ...);
+extern Rune* runevseprint(Rune*, Rune*, char*, va_list);
+extern Rune* runesmprint(char*, ...);
+extern Rune* runevsmprint(char*, va_list);
+
+extern int fmtfdinit(Fmt*, int, char*, int);
+extern int fmtfdflush(Fmt*);
+extern int fmtstrinit(Fmt*);
+extern char* fmtstrflush(Fmt*);
+extern int runefmtstrinit(Fmt*);
+extern Rune* runefmtstrflush(Fmt*);
+
+extern int fmtinstall(int, int (*)(Fmt*));
+extern int dofmt(Fmt*, char*);
+extern int dorfmt(Fmt*, Rune*);
+extern int fmtprint(Fmt*, char*, ...);
+extern int fmtvprint(Fmt*, char*, va_list);
+extern int fmtrune(Fmt*, int);
+extern int fmtstrcpy(Fmt*, char*);
+extern int fmtrunestrcpy(Fmt*, Rune*);
+/*
+ * error string for %r
+ * supplied on per os basis, not part of fmt library
+ */
+extern int errfmt(Fmt *f);
+
+/*
+ * quoted strings
+ */
+extern char *unquotestrdup(char*);
+extern Rune *unquoterunestrdup(Rune*);
+extern char *quotestrdup(char*);
+extern Rune *quoterunestrdup(Rune*);
+extern int quotestrfmt(Fmt*);
+extern int quoterunestrfmt(Fmt*);
+extern void quotefmtinstall(void);
+extern int (*doquote)(int);
+
+/*
+ * random number
+ */
+extern int nrand(int);
+extern ulong truerand(void);
+extern ulong ntruerand(ulong);
+
+/*
+ * math
+ */
+extern int isNaN(double);
+extern int isInf(double, int);
+extern double pow(double, double);
+
+/*
+ * Time-of-day
+ */
+
+typedef struct Tm Tm;
+struct Tm {
+ int sec;
+ int min;
+ int hour;
+ int mday;
+ int mon;
+ int year;
+ int wday;
+ int yday;
+ char zone[4];
+ int tzoff;
+};
+extern vlong osnsec(void);
+#define nsec osnsec
+
+/*
+ * one-of-a-kind
+ */
+extern void _assert(char*);
+extern double charstod(int(*)(void*), void*);
+extern char* cleanname(char*);
+extern double frexp(double, int*);
+extern ulong getcallerpc(void*);
+extern int getfields(char*, char**, int, int, char*);
+extern char* getuser(void);
+extern char* getwd(char*, int);
+extern double ipow10(int);
+extern double ldexp(double, int);
+extern double modf(double, double*);
+#define pow10 infpow10
+extern double pow10(int);
+extern vlong strtoll(const char*, char**, int);
+extern uvlong strtoull(const char*, char**, int);
+extern void sysfatal(char*, ...);
+extern int dec64(uchar*, int, char*, int);
+extern int enc64(char*, int, uchar*, int);
+extern int dec32(uchar*, int, char*, int);
+extern int enc32(char*, int, uchar*, int);
+extern int dec16(uchar*, int, char*, int);
+extern int enc16(char*, int, uchar*, int);
+extern int encodefmt(Fmt*);
+
+/*
+ * synchronization
+ */
+typedef
+struct Lock {
+ int val;
+ int pid;
+} Lock;
+
+extern int _tas(int*);
+
+extern void lock(Lock*);
+extern void unlock(Lock*);
+extern int canlock(Lock*);
+
+typedef struct QLock QLock;
+struct QLock
+{
+ Lock use; /* to access Qlock structure */
+ Proc *head; /* next process waiting for object */
+ Proc *tail; /* last process waiting for object */
+ int locked; /* flag */
+};
+
+extern void qlock(QLock*);
+extern void qunlock(QLock*);
+extern int canqlock(QLock*);
+extern void _qlockinit(ulong (*)(ulong, ulong)); /* called only by the
thread library */
+
+typedef
+struct RWLock
+{
+ Lock l; /* Lock modify lock */
+ QLock x; /* Mutual exclusion lock */
+ QLock k; /* Lock for waiting writers */
+ int readers; /* Count of readers in lock */
+} RWLock;
+
+extern int canrlock(RWLock*);
+extern int canwlock(RWLock*);
+extern void rlock(RWLock*);
+extern void runlock(RWLock*);
+extern void wlock(RWLock*);
+extern void wunlock(RWLock*);
+
+/*
+ * network dialing
+ */
+#define NETPATHLEN 40
+
+/*
+ * system calls
+ *
+ */
+#define STATMAX 65535U /* max length of machine-independent stat structure
*/
+#define DIRMAX (sizeof(Dir)+STATMAX) /* max length of Dir structure */
+#define ERRMAX 128 /* max length of error string */
+
+#define MORDER 0x0003 /* mask for bits defining order of mounting */
+#define MREPL 0x0000 /* mount replaces object */
+#define MBEFORE 0x0001 /* mount goes before others in union directory */
+#define MAFTER 0x0002 /* mount goes after others in union directory */
+#define MCREATE 0x0004 /* permit creation in mounted directory */
+#define MCACHE 0x0010 /* cache some data */
+#define MMASK 0x0017 /* all bits on */
+
+#define OREAD 0 /* open for read */
+#define OWRITE 1 /* write */
+#define ORDWR 2 /* read and write */
+#define OEXEC 3 /* execute, == read but check execute permission */
+#define OTRUNC 16 /* or'ed in (except for exec), truncate file first */
+#define OCEXEC 32 /* or'ed in, close on exec */
+#define ORCLOSE 64 /* or'ed in, remove on close */
+#define OEXCL 0x1000 /* or'ed in, exclusive use (create only) */
+
+#define AEXIST 0 /* accessible: exists */
+#define AEXEC 1 /* execute access */
+#define AWRITE 2 /* write access */
+#define AREAD 4 /* read access */
+
+/* bits in Qid.type */
+#define QTDIR 0x80 /* type bit for directories */
+#define QTAPPEND 0x40 /* type bit for append only files */
+#define QTEXCL 0x20 /* type bit for exclusive use files */
+#define QTMOUNT 0x10 /* type bit for mounted channel */
+#define QTAUTH 0x08 /* type bit for authentication file */
+#define QTFILE 0x00 /* plain file */
+
+/* bits in Dir.mode */
+#define DMDIR 0x80000000 /* mode bit for directories */
+#define DMAPPEND 0x40000000 /* mode bit for append only files */
+#define DMEXCL 0x20000000 /* mode bit for exclusive use files */
+#define DMMOUNT 0x10000000 /* mode bit for mounted channel */
+#define DMAUTH 0x08000000 /* mode bit for authentication file */
+#define DMREAD 0x4 /* mode bit for read permission */
+#define DMWRITE 0x2 /* mode bit for write permission */
+#define DMEXEC 0x1 /* mode bit for execute permission */
+
+typedef
+struct Qid
+{
+ uvlong path;
+ ulong vers;
+ uchar type;
+} Qid;
+
+typedef
+struct Dir {
+ /* system-modified data */
+ ushort type; /* server type */
+ uint dev; /* server subtype */
+ /* file data */
+ Qid qid; /* unique id from server */
+ ulong mode; /* permissions */
+ ulong atime; /* last read time */
+ ulong mtime; /* last write time */
+ vlong length; /* file length */
+ char *name; /* last element of path */
+ char *uid; /* owner name */
+ char *gid; /* group name */
+ char *muid; /* last modifier name */
+} Dir;
+
+extern Dir* dirstat(char*);
+extern Dir* dirfstat(int);
+extern int dirwstat(char*, Dir*);
+extern int dirfwstat(int, Dir*);
+extern long dirread(int, Dir**);
+extern void nulldir(Dir*);
+extern long dirreadall(int, Dir**);
+
+typedef
+struct Waitmsg
+{
+ int pid; /* of loved one */
+ ulong time[3]; /* of loved one & descendants */
+ char *msg;
+} Waitmsg;
+
+extern void _exits(char*);
+
+extern void exits(char*);
+extern int create(char*, int, int);
+extern int errstr(char*, uint);
+
+extern void perror(const char*);
+extern long readn(int, void*, long);
+extern int remove(const char*);
+extern void rerrstr(char*, uint);
+extern vlong seek(int, vlong, int);
+extern int segflush(void*, ulong);
+extern void werrstr(char*, ...);
+
+extern char *argv0;
+#define ARGBEGIN for((argv0||(argv0=*argv)),argv++,argc--;\
+ argv[0] && argv[0][0]=='-' && argv[0][1];\
+ argc--, argv++) {\
+ char *_args, *_argt;\
+ Rune _argc;\
+ _args = &argv[0][1];\
+ if(_args[0]=='-' && _args[1]==0){\
+ argc--; argv++; break;\
+ }\
+ _argc = 0;\
+ while(*_args && (_args += chartorune(&_argc, _args)))\
+ switch(_argc)
+#define ARGEND SET(_argt);USED(_argt);USED(_argc);
USED(_args);}USED(argv); USED(argc);
+#define ARGF() (_argt=_args, _args="",\
+ (*_argt? _argt: argv[1]? (argc--, *++argv): 0))
+#define EARGF(x) (_argt=_args, _args="",\
+ (*_argt? _argt: argv[1]? (argc--, *++argv): ((x), abort(), (char*)0)))
+
+#define ARGC() _argc
+
+/*
+ * Extensions for Inferno to basic libc.h
+ */
+
+#define setbinmode()
+
+/*
+ * Extensions for emu kernel emulation
+ */
+#ifdef EMU
+
+/*
+ * This structure must agree with FPsave and FPrestore asm routines
+ */
+typedef struct FPU FPU;
+struct FPU
+{
+ uchar env[28];
+};
+
+#define KSTACK (32 * 1024)
+
+static __inline Proc *getup(void) {
+ Proc *p;
+ __asm__( "movl %%esp, %%eax\n\t"
+ : "=a" (p)
+ );
+ return *(Proc **)((unsigned long)p & ~(KSTACK - 1));
+};
+
+#define up (getup())
+
+typedef sigjmp_buf osjmpbuf;
+#define ossetjmp(buf) sigsetjmp(buf, 1)
+
+#endif
=======================================
--- /dev/null
+++ /emu/DragonFly/README Fri Feb 5 06:51:46 2010
@@ -0,0 +1,1 @@
+DragonFly BSD changes contributed by fgudin and extrudedaluminiu (see
issue 181 at inferno-os.googlecode.com)
=======================================
--- /dev/null
+++ /emu/DragonFly/asm-386.S Fri Feb 5 06:51:46 2010
@@ -0,0 +1,107 @@
+ .file "asm-DragonFly-386.S"
+#include <sys/syscall.h>
+
+/*
+ * executeonnewstack(void *tos, void (*tramp)(void *arg), void *arg)
+ */
+
+ .type ournewstack,@function
+ .global executeonnewstack
+executeonnewstack:
+ pushl %ebp
+ movl %esp, %ebp
+ pushl %esi
+
+ movl 8(%ebp), %esi /* get tos */
+ subl $4, %esi
+ movl 16(%ebp), %eax
+ movl %eax, (%esi) /* stash arg on new stack */
+ subl $4, %esi
+ movl 12(%ebp), %eax
+ movl %eax, (%esi) /* stash tramp on new stack */
+ mov %esi, %esp /* swap stacks pronto */
+ popl %eax /* recover the tramp address */
+ call *%eax /* and jump to it (ho ho) */
+
+ /* if we return here, tramp didn't do it's job */
+
+ addl $8, %esp /* clean up for pose value */
+
+ leal SYS_exit, %eax
+ int $0x80
+
+/*
+ * unlockandexit(int *key)
+ *
+ * NB: the return status may be rubbish if the stack is reused
+ * between the unlock and the system call, but this should
+ * not matter since no task is waiting for the result
+ */
+
+ .type unlockandexit,@function
+ .global unlockandexit
+unlockandexit:
+ pushl %ebp
+ movl %esp, %ebp
+
+ movl 8(%ebp), %esi /* get the key address */
+ pushl $0 /* exit status 0 */
+ movl $0, %eax /* unlock the stack allocator */
+ movl %eax, (%esi)
+ leal SYS_exit, %eax /* call exit */
+ int $0x80
+
+/*
+ * umult(ulong m1, ulong m2, ulong *hi)
+ */
+
+ .type umult,@function
+ .global umult
+umult:
+ pushl %ebp
+ movl %esp, %ebp
+ pushl %ebx
+
+ movl 8(%ebp), %eax
+ movl 12(%ebp), %ebx
+ mull %ebx
+ movl 16(%ebp), %ebx
+ movl %edx, (%ebx)
+
+ popl %ebx
+ popl %ebp
+ ret
+
+ .type FPsave,@function
+ .global FPsave
+FPsave:
+ pushl %ebp
+ movl %esp, %ebp
+ movl 8(%ebp), %eax
+ fstenv (%eax)
+ popl %ebp
+ ret
+
+ .type FPrestore,@function
+ .global FPrestore
+FPrestore:
+ pushl %ebp
+ movl %esp, %ebp
+ movl 8(%ebp), %eax
+ fldenv (%eax)
+ popl %ebp
+ ret
+
+ .type getcallerpc,@function
+ .global getcallerpc
+getcallerpc:
+ movl 4(%ebp), %eax
+ ret
+
+ .type _tas,@function
+ .globl _tas
+_tas:
+ movl $1, %eax
+ movl 4(%esp), %ecx
+ xchgl %eax, 0(%ecx)
+ ret
=======================================
--- /dev/null
+++ /emu/DragonFly/audio.c Fri Feb 5 06:51:46 2010
@@ -0,0 +1,547 @@
+#include "dat.h"
+#include "fns.h"
+#include "error.h"
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sys/filio.h>
+#include "audio.h"
+#include <sys/soundcard.h>
+
+#define Audio_Mic_Val SOUND_MIXER_MIC
+#define Audio_Linein_Val SOUND_MIXER_LINE
+
+#define Audio_Speaker_Val SOUND_MIXER_SPEAKER
+#define Audio_Headphone_Val SOUND_MIXER_PHONEOUT
+#define Audio_Lineout_Val SOUND_MIXER_VOLUME
+
+#define Audio_Pcm_Val AFMT_S16_LE
+#define Audio_Ulaw_Val AFMT_MU_LAW
+#define Audio_Alaw_Val AFMT_A_LAW
+
+#include "audio-tbls.c"
+
+#define min(a,b) ((a) < (b) ? (a) : (b))
+static int debug;
+
+#define AUDIO_FILE_STRING "/dev/dsp"
+
+enum {
+ A_Pause,
+ A_UnPause
+};
+
+enum {
+ A_In,
+ A_Out
+};
+
+static QLock inlock;
+static QLock outlock;
+
+static int audio_file = -1; /* file in/out */
+static int audio_file_in = -1; /* copy of above when opened O_READ/O_RDWR
*/
+static int audio_file_out = -1; /* copy of above when opened
O_WRITE/O_RDWR */
+
+static int audio_swap_flag = 0; /* endian swap */
+
+static int audio_in_pause = A_UnPause;
+
+static Audio_t av;
+static int mixerleftvol[32];
+static int mixerrightvol[32];
+
+static int audio_enforce(Audio_t*);
+static int audio_open(void);
+static int audio_pause_in(int, int);
+static int audio_flush(int, int);
+static int audio_pause_out(int);
+static int audio_set_blocking(int);
+static int audio_set_info(int, Audio_d*, int);
+static void audio_swap_endian(char*, int);
+
+void
+audio_file_init(void)
+{
+ int i;
+ static ushort flag = 1;
+
+ audio_swap_flag = *((uchar*)&flag) == 0; /* big-endian? */
+ audio_info_init(&av);
+ for (i = 0; i < 32; i++)
+ mixerleftvol[i] = mixerrightvol[i] = 100;
+}
+
+void
+audio_ctl_init(void)
+{
+}
+
+void
+audio_file_open(Chan *c, int omode)
+{
+ char ebuf[ERRMAX];
+
+ if (debug)
+ print("audio_file_open(0x%.8lux, %d)\n", c, omode);
+ switch(omode){
+ case OREAD:
+ qlock(&inlock);
+ if(waserror()){
+ qunlock(&inlock);
+ nexterror();
+ }
+
+ if(audio_file_in >= 0)
+ error(Einuse);
+ if (audio_file < 0)
+ audio_file = audio_open();
+ audio_file_in = audio_file;
+ poperror();
+ qunlock(&inlock);
+ break;
+ case OWRITE:
+ qlock(&outlock);
+ if(waserror()){
+ qunlock(&outlock);
+ nexterror();
+ }
+ if(audio_file_out >= 0)
+ error(Einuse);
+ if (audio_file < 0)
+ audio_file = audio_open();
+ audio_file_out = audio_file;
+ poperror();
+ qunlock(&outlock);
+ break;
+ case ORDWR:
+ qlock(&inlock);
+ qlock(&outlock);
+ if(waserror()){
+ qunlock(&outlock);
+ qunlock(&inlock);
+ nexterror();
+ }
+ if(audio_file_in >= 0 || audio_file_out >= 0)
+ error(Einuse);
+ if (audio_file < 0)
+ audio_file = audio_open();
+ audio_file_in = audio_file_out = audio_file;
+ poperror();
+ qunlock(&outlock);
+ qunlock(&inlock);
+ break;
+ }
+ if (debug)
+ print("audio_file_open: success\nin %d out %d both %d\n",
+ audio_file_out, audio_file_in, audio_file);
+}
+
+void
+audio_ctl_open(Chan *c, int omode)
+{
+ USED(c);
+ USED(omode);
+}
+
+void
+audio_file_close(Chan *c)
+{
+ switch(c->mode){
+ case OREAD:
+ qlock(&inlock);
+ qlock(&outlock);
+ if (audio_file_out < 0) {
+ close(audio_file);
+ audio_file = -1;
+ }
+ qunlock(&outlock);
+ audio_file_in = -1;
+ qunlock(&inlock);
+ break;
+ case OWRITE:
+ qlock(&inlock);
+ qlock(&outlock);
+ if (audio_file_in < 0) {
+ close(audio_file);
+ audio_file = -1;
+ }
+ audio_file_out = -1;
+ qunlock(&outlock);
+ qunlock(&inlock);
+ break;
+ case ORDWR:
+ qlock(&inlock);
+ qlock(&outlock);
+ close(audio_file);
+ audio_file_in = audio_file_out = audio_file = -1;
+ qunlock(&outlock);
+ qunlock(&inlock);
+ break;
+ }
+}
+
+void
+audio_ctl_close(Chan *c)
+{
+}
+
+long
+audio_file_read(Chan *c, void *va, long count, vlong offset)
+{
+ struct timespec time;
+ long ba, status, chunk, total;
+ char *pva = (char *) va;
+
+ qlock(&inlock);
+ if(waserror()){
+ qunlock(&inlock);
+ nexterror();
+ }
+
+ if(audio_file_in < 0)
+ error(Eperm);
+
+ /* check block alignment */
+ ba = av.in.bits * av.in.chan / Bits_Per_Byte;
+
+ if(count % ba)
+ error(Ebadarg);
+
+ if(!audio_pause_in(audio_file_in, A_UnPause))
+ error(Eio);
+
+ total = 0;
+ while(total < count) {
+ chunk = count - total;
+ osenter();
+ status = read(audio_file_in, pva + total, chunk);
+ osleave();
+ if(status < 0)
+ error(Eio);
+ total += status;
+ }
+
+ if(total != count)
+ error(Eio);
+
+ if(audio_swap_flag && av.out.bits == 16)
+ audio_swap_endian(pva, count);
+
+ poperror();
+ qunlock(&inlock);
+
+ return count;
+}
+
+long
+audio_file_write(Chan *c, void *va, long count, vlong offset)
+{
+ struct timespec time;
+ long status = -1;
+ long ba, total, chunk, bufsz;
+
+ if (debug > 1)
+ print("audio_file_write(0x%.8lux, 0x%.8lux, %ld, %uld)\n",
+ c, va, count, offset);
+
+ qlock(&outlock);
+ if(waserror()){
+ qunlock(&outlock);
+ nexterror();
+ }
+
+ if(audio_file_out < 0)
+ error(Eperm);
+
+ /* check block alignment */
+ ba = av.out.bits * av.out.chan / Bits_Per_Byte;
+
+ if(count % ba)
+ error(Ebadarg);
+
+ if(audio_swap_flag && av.out.bits == 16)
+ audio_swap_endian(va, count);
+
+ total = 0;
+ bufsz = av.out.buf * Audio_Max_Buf / Audio_Max_Val;
+
+ if(bufsz == 0)
+ error(Ebadarg);
+
+ while(total < count) {
+ chunk = min(bufsz, count - total);
+ osenter();
+ status = write(audio_file_out, va, chunk);
+ osleave();
+ if(status <= 0)
+ error(Eio);
+ total += status;
+ }
+
+ poperror();
+ qunlock(&outlock);
+
+ return count;
+}
+
+static int
+audio_open(void)
+{
+ int fd;
+
+ /* open non-blocking in case someone already has it open */
+ /* otherwise we would block until they close! */
+ fd = open(AUDIO_FILE_STRING, O_RDWR|O_NONBLOCK);
+ if(fd < 0)
+ oserror();
+
+ /* change device to be blocking */
+ if(!audio_set_blocking(fd)) {
+ if (debug)
+ print("audio_open: failed to set blocking\n");
+ close(fd);
+ error("cannot set blocking mode");
+ }
+
+ if (debug)
+ print("audio_open: blocking set\n");
+
+ /* set audio info */
+ av.in.flags = ~0;
+ av.out.flags = 0;
+
+ if(! audio_set_info(fd, &av.in, A_In)) {
+ close(fd);
+ error(Ebadarg);
+ }
+
+ av.in.flags = 0;
+
+ /* tada, we're open, blocking, paused and flushed */
+ return fd;
+}
+
+long
+audio_ctl_write(Chan *c, void *va, long count, vlong offset)
+{
+ int fd;
+ int ff;
+ Audio_t tmpav = av;
+
+ tmpav.in.flags = 0;
+ tmpav.out.flags = 0;
+
+ if (!audioparse(va, count, &tmpav))
+ error(Ebadarg);
+
+ if (!audio_enforce(&tmpav))
+ error(Ebadarg);
+
+ qlock(&inlock);
+ if (waserror()) {
+ qunlock(&inlock);
+ nexterror();
+ }
+
+ if (audio_file_in >= 0 && (tmpav.in.flags & AUDIO_MOD_FLAG)) {
+ if (!audio_pause_in(audio_file_in, A_Pause))
+ error(Ebadarg);
+ if (!audio_flush(audio_file_in, A_In))
+ error(Ebadarg);
+ if (!audio_set_info(audio_file_in, &tmpav.in, A_In))
+ error(Ebadarg);
+ }
+ poperror();
+ qunlock(&inlock);
+
+ qlock(&outlock);
+ if (waserror()) {
+ qunlock(&outlock);
+ nexterror();
+ }
+ if (audio_file_out >= 0 && (tmpav.out.flags & AUDIO_MOD_FLAG)){
+ if (!audio_pause_out(audio_file_out))
+ error(Ebadarg);
+ if (!audio_set_info(audio_file_out, &tmpav.out, A_Out))
+ error(Ebadarg);
+ }
+ poperror();
+ qunlock(&outlock);
+
+ tmpav.in.flags = 0;
+ tmpav.out.flags = 0;
+
+ av = tmpav;
+
+ return count;
+}
+
+
+
+static int
+audio_set_blocking(int fd)
+{
+ int val;
+
+ if((val = fcntl(fd, F_GETFL, 0)) == -1)
+ return 0;
+
+ val &= ~O_NONBLOCK;
+
+ if(fcntl(fd, F_SETFL, val) < 0)
+ return 0;
+
+ return 1;
+}
+
+static int
+doioctl(int fd, int ctl, int *info)
+{
+ int status;
+ osenter();
+ status = ioctl(fd, ctl, info); /* qlock and load general stuff */
+ osleave();
+ if (status < 0)
+ print("doioctl(0x%.8lux, 0x%.8lux) failed %d\n", ctl, *info, errno);
+ return status;
+}
+
+static int
+choosefmt(Audio_d *i)
+{
+ int newbits, newenc;
+
+ newbits = i->bits;
+ newenc = i->enc;
+ switch (newenc) {
+ case Audio_Alaw_Val:
+ if (newbits == 8)
+ return AFMT_A_LAW;
+ break;
+ case Audio_Ulaw_Val:
+ if (newbits == 8)
+ return AFMT_MU_LAW;
+ break;
+ case Audio_Pcm_Val:
+ if (newbits == 8)
+ return AFMT_U8;
+ else if (newbits == 16)
+ return AFMT_S16_LE;
+ break;
+ }
+ return -1;
+}
+
+static int
+audio_set_info(int fd, Audio_d *i, int d)
+{
+ int status;
+ int unequal_stereo = 0;
+
+ if(fd < 0)
+ return 0;
+
+ /* fmt */
+ if(i->flags & (AUDIO_BITS_FLAG || AUDIO_ENC_FLAG)) {
+ int oldfmt, newfmt;
+ oldfmt = AFMT_QUERY;
+ if (doioctl(fd, SNDCTL_DSP_SETFMT, &oldfmt) < 0)
+ return 0;
+ if (debug)
+ print("audio_set_info: current format 0x%.8lux\n", oldfmt);
+ newfmt = choosefmt(i);
+ if (debug)
+ print("audio_set_info: new format 0x%.8lux\n", newfmt);
+ if (newfmt == -1 || newfmt != oldfmt && doioctl(fd, SNDCTL_DSP_SETFMT,
&newfmt) < 0)
+ return 0;
+ }
+
+ /* channels */
+ if(i->flags & AUDIO_CHAN_FLAG) {
+ int channels = i->chan;
+ if (debug)
+ print("audio_set_info: new channels %d\n", channels);
+ if (doioctl(fd, SNDCTL_DSP_CHANNELS, &channels) < 0
+ || channels != i->chan)
+ return 0;
+ }
+
+ /* sample rate */
+ if(i->flags & AUDIO_RATE_FLAG) {
+ int speed = i->rate;
+ if (debug)
+ print("audio_set_info: new speed %d\n", speed);
+ if (doioctl(fd, SNDCTL_DSP_SPEED, &speed) < 0 || speed != i->rate)
+ return 0;
+ }
+
+ /* dev volume */
+ if(i->flags & (AUDIO_LEFT_FLAG | AUDIO_VOL_FLAG | AUDIO_RIGHT_FLAG)) {
+ int val;
+ if (i->flags & (AUDIO_LEFT_FLAG | AUDIO_VOL_FLAG))
+ mixerleftvol[i->dev] = (i->left * 100) / Audio_Max_Val;
+ if (i->flags & (AUDIO_RIGHT_FLAG | AUDIO_VOL_FLAG))
+ mixerrightvol[i->dev] = (i->right * 100) / Audio_Max_Val;
+ val = mixerleftvol[i->dev] | (mixerrightvol[i->dev] << 8);
+ doioctl(fd, MIXER_WRITE(i->dev), &val);
+ }
+
+ if (i->flags & AUDIO_DEV_FLAG) {
+ }
+
+ return 1;
+}
+
+void
+audio_swap_endian(char *p, int n)
+{
+ int b;
+
+ while (n > 1) {
+ b = p[0];
+ p[0] = p[1];
+ p[1] = b;
+ p += 2;
+ n -= 2;
+ }
+}
+
+static int
+audio_pause_out(int fd)
+{
+ USED(fd);
+ return 1;
+}
+
+static int
+audio_pause_in(int fd, int f)
+{
+ USED(fd);
+ USED(f);
+ return 1;
+}
+
+static int
+audio_flush(int fd, int d)
+{
+ int x;
+ return doioctl(fd, SNDCTL_DSP_SYNC, &x) >= 0;
+}
+
+static int
+audio_enforce(Audio_t *t)
+{
+ if((t->in.enc == Audio_Ulaw_Val || t->in.enc == Audio_Alaw_Val) &&
+ (t->in.rate != 8000 || t->in.chan != 1))
+ return 0;
+ if((t->out.enc == Audio_Ulaw_Val || t->out.enc == Audio_Alaw_Val) &&
+ (t->out.rate != 8000 || t->out.chan != 1))
+ return 0;
+ return 1;
+}
+
+Audio_t*
+getaudiodev(void)
+{
+ return &av;
+}
=======================================
--- /dev/null
+++ /emu/DragonFly/cmd.c Fri Feb 5 06:51:46 2010
@@ -0,0 +1,213 @@
+#include <sys/types.h>
+#include <signal.h>
+#include <pwd.h>
+#include <sys/resource.h>
+#include <sys/wait.h>
+#include <fcntl.h>
+
+#include "dat.h"
+#include "fns.h"
+#include "error.h"
+
+enum
+{
+ Debug = 0
+};
+
+/*
+ * os-specific devcmd support.
+ * this version should be reasonably portable across Unix systems.
+ */
+typedef struct Targ Targ;
+struct Targ
+{
+ int fd[3]; /* fd[0] is standard input, fd[1] is standard output, fd[2] is
standard error */
+ char** args;
+ char* dir;
+ int pid;
+ int wfd; /* child writes errors that occur after the fork or on exec */
+ int uid;
+ int gid;
+};
+
+extern int gidnobody;
+extern int uidnobody;
+
+static int
+childproc(Targ *t)
+{
+ int i, nfd;
+
+ if(Debug)
+ print("devcmd: '%s'", t->args[0]);
+
+ nfd = getdtablesize();
+ for(i = 0; i < nfd; i++)
+ if(i != t->fd[0] && i != t->fd[1] && i != t->fd[2] && i != t->wfd)
+ close(i);
+
+ dup2(t->fd[0], 0);
+ dup2(t->fd[1], 1);
+ dup2(t->fd[2], 2);
+ close(t->fd[0]);
+ close(t->fd[1]);
+ close(t->fd[2]);
+
+ /* should have an auth file to do host-specific authorisation? */
+ if(t->gid != -1){
+ if(setgid(t->gid) < 0 && getegid() == 0){
+ fprint(t->wfd, "can't set gid %d: %s", t->gid, strerror(errno));
+ _exit(1);
+ }
+ }
+
+ if(t->uid != -1){
+ if(setuid(t->uid) < 0 && geteuid() == 0){
+ fprint(t->wfd, "can't set uid %d: %s", t->uid, strerror(errno));
+ _exit(1);
+ }
+ }
+
+ if(t->dir != nil && chdir(t->dir) < 0){
+ fprint(t->wfd, "can't chdir to %s: %s", t->dir, strerror(errno));
+ _exit(1);
+ }
+
+ signal(SIGPIPE, SIG_DFL);
+
+ execvp(t->args[0], t->args);
+ if(Debug)
+ print("execvp: %s\n",strerror(errno));
+ fprint(t->wfd, "exec failed: %s", strerror(errno));
+
+ _exit(1);
+}
+
+void*
+oscmd(char **args, int nice, char *dir, int *fd)
+{
+ Targ *t;
+ int r, fd0[2], fd1[2], fd2[2], wfd[2], n, pid;
+
+ t = mallocz(sizeof(*t), 1);
+ if(t == nil)
+ return nil;
+
+ fd0[0] = fd0[1] = -1;
+ fd1[0] = fd1[1] = -1;
+ fd2[0] = fd2[1] = -1;
+ wfd[0] = wfd[1] = -1;
+ if(pipe(fd0) < 0 || pipe(fd1) < 0 || pipe(fd2) < 0 || pipe(wfd) < 0)
+ goto Error;
+ if(fcntl(wfd[1], F_SETFD, FD_CLOEXEC) < 0) /* close on exec to give end
of file on success */
+ goto Error;
+
+ t->fd[0] = fd0[0];
+ t->fd[1] = fd1[1];
+ t->fd[2] = fd2[1];
+ t->wfd = wfd[1];
+ t->args = args;
+ t->dir = dir;
+ t->gid = up->env->gid;
+ if(t->gid == -1)
+ t->gid = gidnobody;
+ t->uid = up->env->uid;
+ if(t->uid == -1)
+ t->uid = uidnobody;
+
+ signal(SIGCHLD, SIG_DFL);
+ switch(pid = fork()) {
+ case -1:
+ goto Error;
+ case 0:
+ setpgid(0, getpid());
+ if(nice)
+ oslopri();
+ childproc(t);
+ _exit(1);
+ default:
+ t->pid = pid;
+ if(Debug)
+ print("cmd pid %d\n", t->pid);
+ break;
+ }
+
+ close(fd0[0]);
+ close(fd1[1]);
+ close(fd2[1]);
+ close(wfd[1]);
+
+ n = read(wfd[0], up->genbuf, sizeof(up->genbuf)-1);
+ close(wfd[0]);
+ if(n > 0){
+ close(fd0[1]);
+ close(fd1[0]);
+ close(fd2[0]);
+ free(t);
+ up->genbuf[n] = 0;
+ if(Debug)
+ print("oscmd: bad exec: %q\n", up->genbuf);
+ error(up->genbuf);
+ return nil;
+ }
+
+ fd[0] = fd0[1];
+ fd[1] = fd1[0];
+ fd[2] = fd2[0];
+ return t;
+
+Error:
+ r = errno;
+ if(Debug)
+ print("oscmd: %q\n",strerror(r));
+ close(fd0[0]);
+ close(fd0[1]);
+ close(fd1[0]);
+ close(fd1[1]);
+ close(fd2[0]);
+ close(fd2[1]);
+ close(wfd[0]);
+ close(wfd[1]);
+ error(strerror(r));
+ return nil;
+}
+
+int
+oscmdkill(void *a)
+{
+ Targ *t = a;
+
+ if(Debug)
+ print("kill: %d\n", t->pid);
+ return kill(-t->pid, SIGTERM);
+}
+
+int
+oscmdwait(void *a, char *buf, int n)
+{
+ Targ *t = a;
+ int s;
+
+ if(waitpid(t->pid, &s, 0) == -1){
+ if(Debug)
+ print("wait error: %d [in %d] %q\n", t->pid, getpid(), strerror(errno));
+ return -1;
+ }
+ if(WIFEXITED(s)){
+ if(WEXITSTATUS(s) == 0)
+ return snprint(buf, n, "%d 0 0 0 ''", t->pid);
+ return snprint(buf, n, "%d 0 0 0 'exit: %d'", t->pid, WEXITSTATUS(s));
+ }
+ if(WIFSIGNALED(s)){
+ if(WTERMSIG(s) == SIGTERM || WTERMSIG(s) == SIGKILL)
+ return snprint(buf, n, "%d 0 0 0 killed", t->pid);
+ return snprint(buf, n, "%d 0 0 0 'signal: %d'", t->pid, WTERMSIG(s));
+ }
+ return snprint(buf, n, "%d 0 0 0 'odd status: 0x%x'", t->pid, s);
+}
+
+void
+oscmdfree(void *a)
+{
+ free(a);
+}
=======================================
--- /dev/null
+++ /emu/DragonFly/deveia.c Fri Feb 5 06:51:46 2010
@@ -0,0 +1,39 @@
+/*
+ * FreeBSD serial port definitions
+ */
+
+static char *sysdev[] = {
+ "/dev/cuaa0",
+ "/dev/cuaa1",
+ "/dev/cuaa2",
+ "/dev/cuaa3",
+};
+
+#include <sys/ioctl.h>
+#include "deveia-posix.c"
+#include "deveia-bsd.c"
+
+
+static struct tcdef_t bps[] = {
+ {0, B0},
+ {50, B50},
+ {75, B75},
+ {110, B110},
+ {134, B134},
+ {150, B150},
+ {200, B200},
+ {300, B300},
+ {600, B600},
+ {1200, B1200},
+ {1800, B1800},
+ {2400, B2400},
+ {4800, B4800},
+ {9600, B9600},
+ {19200, B19200},
+ {38400, B38400},
+ {57600, B57600},
+ {115200, B115200},
+ {230400, B230400},
+ {-1, -1}
+};
+
=======================================
--- /dev/null
+++ /emu/DragonFly/devfs.c Fri Feb 5 06:51:46 2010
@@ -0,0 +1,1 @@
+#include "devfs-posix.c"
=======================================
--- /dev/null
+++ /emu/DragonFly/emu Fri Feb 5 06:51:46 2010
@@ -0,0 +1,109 @@
+dev
+ root
+ cons
+ env
+ mnt
+ pipe
+ prog
+ prof
+ srv
+ dup
+ ssl
+ cap
+ fs
+ cmd cmd
+ indir
+
+ draw win-x11a
+ pointer
+ snarf
+
+ ip ipif ipaux
+ eia
+ audio audio
+ mem
+
+lib
+ interp
+ tk
+ freetype
+ math
+ draw
+
+ memlayer
+ memdraw
+ keyring
+ sec
+ mp
+
+ 9
+
+link
+
+mod
+ sys
+ draw
+
+ tk
+ math
+ srv srv
+ keyring
+ loader
+ freetype
+
+port
+ alloc
+ cache
+ chan
+ dev
+ devtab
+
+ dial
+ dis
+ discall
+ env
+ error
+ errstr
+ exception
+ exportfs
+ inferno
+ latin1
+ main
+ parse
+ pgrp
+ print
+ proc
+ qio
+ random
+ sysfile
+ uqid
+
+code
+
+init
+ emuinit
+
+root
+ /dev /
+ /fd /
+ /prog /
+ /prof /
+ /net /
+ /net.alt /
+ /chan /
+ /nvfs /
+ /env /
+# /chan
+# /dev
+# /dis
+# /env
+# /n
+# /net
+# /nvfs /
+# /prog
+# /icons
+# /osinit.dis
+# /dis/emuinit.dis
+# /dis/lib/auth.dis
+# /dis/lib/ssl.dis
+# /n/local /
=======================================
--- /dev/null
+++ /emu/DragonFly/emu-g Fri Feb 5 06:51:46 2010
@@ -0,0 +1,95 @@
+dev
+ root
+ cons
+ env
+ mnt
+ pipe
+ prog
+ srv
+ dup
+ ssl
+ cap
+ fs
+ cmd cmd
+ indir
+
+ ip ipif ipaux
+ eia
+ mem
+
+lib
+ interp
+ math
+ keyring
+ sec
+ mp
+
+ 9
+
+link
+
+mod
+ sys
+ math
+ srv srv
+ keyring
+ loader
+
+port
+ alloc
+ cache
+ chan
+ dev
+ devtab
+
+ dial
+ dis
+ discall
+ env
+ error
+ errstr
+ exception
+ exportfs
+ inferno
+ latin1
+ main
+ parse
+ pgrp
+ print
+ proc
+ qio
+ random
+ sysfile
+ uqid
+
+code
+ void setpointer(int x, int y) { USED(x); USED(y); }
+ ulong strtochan(char *s) { USED(s); return ~0; }
+
+init
+ emuinit
+
+root
+ /dev /
+ /fd /
+ /prog /
+ /prof /
+ /net /
+ /net.alt /
+ /chan /
+ /nvfs /
+ /env /
+# /chan
+# /dev
+# /dis
+# /env
+# /n
+# /net
+# /nvfs /
+# /prog
+# /icons
+# /osinit.dis
+# /dis/emuinit.dis
+# /dis/lib/auth.dis
+# /dis/lib/ssl.dis
+# /n/local /
=======================================
--- /dev/null
+++ /emu/DragonFly/ipif.c Fri Feb 5 06:51:46 2010
@@ -0,0 +1,354 @@
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/socket.h>
+#include <net/if.h>
+#include <net/if_arp.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <netdb.h>
+#include "dat.h"
+#include "fns.h"
+#include "ip.h"
+#include "error.h"
+#include <sys/ioctl.h>
+
+int
+so_socket(int type)
+{
+ int fd, one;
+
+ switch(type) {
+ default:
+ error("bad protocol type");
+ case S_TCP:
+ type = SOCK_STREAM;
+ break;
+ case S_UDP:
+ type = SOCK_DGRAM;
+ break;
+ }
+
+ fd = socket(AF_INET, type, 0);
+ if(fd < 0)
+ oserror();
+ if(type == SOCK_DGRAM){
+ one = 1;
+ setsockopt(fd, SOL_SOCKET, SO_BROADCAST, (char*)&one, sizeof (one));
+ }else{
+ one = 1;
+ setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *)&one, sizeof(one));
+ }
+ return fd;
+}
+
+int
+so_send(int sock, void *va, int len, void *hdr, int hdrlen)
+{
+ int r;
+ struct sockaddr sa;
+ struct sockaddr_in *sin;
+ char *h = hdr;
+
+
+ osenter();
+ if(hdr == 0)
+ r = write(sock, va, len);
+ else {
+ memset(&sa, 0, sizeof(sa));
+ sin = (struct sockaddr_in*)&sa;
+ sin->sin_family = AF_INET;
+ switch(hdrlen){
+ case OUdphdrlenv4:
+ memmove(&sin->sin_addr, h, 4);
+ memmove(&sin->sin_port, h+8, 2);
+ break;
+ case OUdphdrlen:
+ v6tov4((uchar*)&sin->sin_addr, h);
+ memmove(&sin->sin_port, h+2*IPaddrlen, 2); /* rport */
+ break;
+ default:
+ v6tov4((uchar*)&sin->sin_addr, h);
+ memmove(&sin->sin_port, h+3*IPaddrlen, 2);
+ break;
+ }
+ r = sendto(sock, va, len, 0, &sa, sizeof(sa));
+ }
+ osleave();
+ return r;
+}
+
+int
+so_recv(int sock, void *va, int len, void *hdr, int hdrlen)
+{
+ int r, l;
+ struct sockaddr sa;
+ struct sockaddr_in *sin;
+ char h[Udphdrlen];
+
+
+ osenter();
+ if(hdr == 0)
+ r = read(sock, va, len);
+ else {
+ sin = (struct sockaddr_in*)&sa;
+ l = sizeof(sa);
+ r = recvfrom(sock, va, len, 0, &sa, &l);
+ if(r >= 0) {
+ memset(h, 0, sizeof(h));
+ switch(hdrlen){
+ case OUdphdrlenv4:
+ memmove(h, &sin->sin_addr, 4);
+ memmove(h+2*IPv4addrlen, &sin->sin_port, 2);
+ break;
+ case OUdphdrlen:
+ v4tov6(h, (uchar*)&sin->sin_addr);
+ memmove(h+2*IPaddrlen, &sin->sin_port, 2);
+ break;
+ default:
+ v4tov6(h, (uchar*)&sin->sin_addr);
+ memmove(h+3*IPaddrlen, &sin->sin_port, 2);
+ break;
+ }
+
+ /* alas there's no way to get the local addr/port correctly. Pretend.
*/
+ getsockname(sock, &sa, &l);
+ switch(hdrlen){
+ case OUdphdrlenv4:
+ memmove(h+IPv4addrlen, &sin->sin_addr, IPv4addrlen);
+ memmove(h+2*IPv4addrlen+2, &sin->sin_port, 2);
+ break;
+ case OUdphdrlen:
+ v4tov6(h+IPaddrlen, (uchar*)&sin->sin_addr);
+ memmove(h+2*IPaddrlen+2, &sin->sin_port, 2);
+ break;
+ default:
+ v4tov6(h+IPaddrlen, (uchar*)&sin->sin_addr);
+ v4tov6(h+2*IPaddrlen, (uchar*)&sin->sin_addr); /* ifcaddr */
+ memmove(h+3*IPaddrlen+2, &sin->sin_port, 2);
+ break;
+ }
+ memmove(hdr, h, hdrlen);
+ }
+ }
+ osleave();
+ return r;
+}
+
+void
+so_close(int sock)
+{
+ close(sock);
+}
+
+void
+so_connect(int fd, unsigned long raddr, unsigned short rport)
+{
+ int r;
+ struct sockaddr sa;
+ struct sockaddr_in *sin;
+
+ memset(&sa, 0, sizeof(sa));
+ sin = (struct sockaddr_in*)&sa;
+ sin->sin_family = AF_INET;
+ hnputs(&sin->sin_port, rport);
+ hnputl(&sin->sin_addr.s_addr, raddr);
+
+ osenter();
+ r = connect(fd, &sa, sizeof(sa));
+ osleave();
+ if(r < 0)
+ oserror();
+}
+
+void
+so_getsockname(int fd, unsigned long *laddr, unsigned short *lport)
+{
+ int len;
+ struct sockaddr sa;
+ struct sockaddr_in *sin;
+
+
+ len = sizeof(sa);
+ if(getsockname(fd, &sa, &len) < 0)
+ oserror();
+
+ sin = (struct sockaddr_in*)&sa;
+ if(sin->sin_family != AF_INET || len != sizeof(*sin))
+ error("not AF_INET");
+
+ *laddr = nhgetl(&sin->sin_addr.s_addr);
+ *lport = nhgets(&sin->sin_port);
+}
+
+void
+so_listen(int fd)
+{
+ int r;
+
+ osenter();
+ r = listen(fd, 256);
+ osleave();
+ if(r < 0)
+ oserror();
+}
+
+int
+so_accept(int fd, unsigned long *raddr, unsigned short *rport)
+{
+ int nfd, len;
+ struct sockaddr sa;
+ struct sockaddr_in *sin;
+
+ sin = (struct sockaddr_in*)&sa;
+
+ len = sizeof(sa);
+ osenter();
+ nfd = accept(fd, &sa, &len);
+ osleave();
+ if(nfd < 0)
+ oserror();
+
+ if(sin->sin_family != AF_INET || len != sizeof(*sin))
+ error("not AF_INET");
+
+ *raddr = nhgetl(&sin->sin_addr.s_addr);
+ *rport = nhgets(&sin->sin_port);
+ return nfd;
+}
+
+void
+so_bind(int fd, int su, unsigned long addr, unsigned short port)
+{
+ int i, one;
+ struct sockaddr sa;
+ struct sockaddr_in *sin;
+
+ sin = (struct sockaddr_in*)&sa;
+
+ one = 1;
+ if(setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char*)&one, sizeof(one)) <
0) {
+ oserrstr(up->genbuf, sizeof(up->genbuf));
+ print("setsockopt: %s", up->genbuf);
+ }
+
+ if(su) {
+ for(i = 600; i < 1024; i++) {
+ memset(&sa, 0, sizeof(sa));
+ sin->sin_family = AF_INET;
+ hnputl(&sin->sin_addr.s_addr, addr);
+ hnputs(&sin->sin_port, i);
+
+ if(bind(fd, &sa, sizeof(sa)) >= 0)
+ return;
+ }
+ oserror();
+ }
+
+ memset(&sa, 0, sizeof(sa));
+ sin->sin_family = AF_INET;
+ hnputl(&sin->sin_addr.s_addr, addr);
+ hnputs(&sin->sin_port, port);
+
+ if(bind(fd, &sa, sizeof(sa)) < 0)
+ oserror();
+}
+
+int
+so_gethostbyname(char *host, char**hostv, int n)
+{
+ int i;
+ char buf[32];
+ uchar *p;
+ struct hostent *hp;
+
+ hp = gethostbyname(host);
+ if(hp == 0)
+ return 0;
+
+ for(i = 0; hp->h_addr_list[i] && i < n; i++) {
+ p = hp->h_addr_list[i];
+ snprint(buf, sizeof(buf), "%ud.%ud.%ud.%ud", p[0], p[1], p[2], p[3]);
+ hostv[i] = strdup(buf);
+ if(hostv[i] == 0)
+ break;
+ }
+ return i;
+}
+
+int
+so_gethostbyaddr(char *addr, char **hostv, int n)
+{
+ int i;
+ struct hostent *hp;
+ unsigned long straddr;
+
+ straddr = inet_addr(addr);
+ if(straddr == -1)
+ return 0;
+
+ hp = gethostbyaddr((char *)&straddr, sizeof(straddr), AF_INET);
+ if(hp == 0)
+ return 0;
+
+ hostv[0] = strdup(hp->h_name);
+ if(hostv[0] == 0)
+ return 0;
+ for(i = 1; hp->h_aliases[i-1] && i < n; i++) {
+ hostv[i] = strdup(hp->h_aliases[i-1]);
+ if(hostv[i] == 0)
+ break;
+ }
+ return i;
+}
+
+int
+so_getservbyname(char *service, char *net, char *port)
+{
+ ushort p;
+ struct servent *s;
+
+ s = getservbyname(service, net);
+ if(s == 0)
+ return -1;
+ p = s->s_port;
+ sprint(port, "%d", nhgets(&p));
+ return 0;
+}
+
+int
+so_hangup(int fd, int nolinger)
+{
+ int r;
+ static struct linger l = {1, 0};
+
+ osenter();
+ if(nolinger)
+ setsockopt(fd, SOL_SOCKET, SO_LINGER, (char*)&l, sizeof(l));
+ r = shutdown(fd, 2);
+ if(r >= 0)
+ r = close(fd);
+ osleave();
+ return r;
+}
+
+void
+arpadd(char *ipaddr, char *eaddr, int n)
+{
+ error("arp not implemented");
+}
+
+int
+so_mustbind(int restricted, int port)
+{
+ return restricted || port != 0;
+}
+
+void
+so_keepalive(int fd, int ms)
+{
+ int on;
+
+ USED(ms);
+ on = 1;
+ setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (char*)&on, sizeof(on));
+}
=======================================
--- /dev/null
+++ /emu/DragonFly/mkfile Fri Feb 5 06:51:46 2010
@@ -0,0 +1,46 @@
+SYSTARG=DragonFly
+OBJTYPE=386
+<../../mkconfig
+SYSTARG=DragonFly
+OBJTYPE=386
+
+#Configurable parameters
+
+CONF=emu #default configuration
+CONFLIST=emu
+CLEANCONFLIST=
+
+INSTALLDIR=$ROOT/$SYSTARG/$OBJTYPE/bin #path of directory where kernel is
installed
+
+#end configurable parameters
+
+<$ROOT/mkfiles/mkfile-$SYSTARG-$OBJTYPE #set vars based on target system
+
+<| $SHELLNAME ../port/mkdevlist $CONF #sets $IP, $DEVS, $PORT, $LIBS
+
+OBJ=\
+ asm-$OBJTYPE.$O\
+ os.$O\
+ $CONF.root.$O\
+ lock.$O\
+ $DEVS\
+ $PORT\
+
+HFILES=\
+
+CFLAGS='-DROOT="'$ROOT'"' -DEMU -I. -I../port
-I$ROOT/$SYSTARG/$OBJTYPE/include -I$ROOT/include -I$ROOT/libinterp
$CTHREADFLAGS $CFLAGS $EMUOPTIONS
+SYSLIBS= -lm
+KERNDATE=`{$NDATE}
+
+default:V: $O.$CONF
+
+<../port/portmkfile
+
+$O.$CONF: $OBJ $CONF.c $CONF.root.h $LIBFILES
+ $CC $CFLAGS '-DKERNDATE='$KERNDATE $CONF.c
+ $LD $LDFLAGS -o $target $OBJ $CONF.$O $LIBFILES $SYSLIBS
+
+install:V: $O.$CONF
+ cp $O.$CONF $INSTALLDIR/$CONF
+
+devfs.$O: ../port/devfs-posix.c
=======================================
--- /dev/null
+++ /emu/DragonFly/os.c Fri Feb 5 06:51:46 2010
@@ -0,0 +1,533 @@
+#include "dat.h"
+#include "fns.h"
+#include "error.h"
+#undef getwd
+#include <signal.h>
+#include <sys/socket.h>
+#include <time.h>
+#include <sys/time.h>
+#include <termios.h>
+#include <sched.h>
+#include <pwd.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/resource.h>
+#include <fpuctl.h>
+
+enum
+{
+ DELETE = 0x7F,
+ NSTACKSPERALLOC = 16,
+ X11STACK= 256*1024
+};
+char *hosttype = "DragonFly";
+
+extern void unlockandexit(int*);
+extern void executeonnewstack(void*, void (*f)(void*), void*);
+static void *stackalloc(Proc *p, void **tos);
+static void stackfreeandexit(void *stack);
+
+extern int dflag;
+
+void
+pexit(char *msg, int t)
+{
+ Osenv *e;
+ Proc *p;
+ void *kstack;
+
+ lock(&procs.l);
+ p = up;
+ if(p->prev)
+ p->prev->next = p->next;
+ else
+ procs.head = p->next;
+
+ if(up->next)
+ p->next->prev = p->prev;
+ else
+ procs.tail = p->prev;
+ unlock(&procs.l);
+
+ if(0)
+ print("pexit: %s: %s\n", up->text, msg);
+
+ e = up->env;
+ if(e != nil) {
+ closefgrp(e->fgrp);
+ closepgrp(e->pgrp);
+ closeegrp(e->egrp);
+ closesigs(e->sigs);
+ }
+ kstack = p->kstack;
+ free(p->prog);
+ free(p);
+ if(kstack != nil)
+ stackfreeandexit(kstack);
+}
+
+void
+trapBUS(int signo, siginfo_t *info, void *context)
+{
+ if(info)
+ print("trapBUS: signo: %d code: %d addr: %lx\n",
+ info->si_signo, info->si_code, info->si_addr);
+ else
+ print("trapBUS: no info\n");
+ disfault(nil, "Bus error");
+}
+
+static void
+trapUSR1(int signo)
+{
+ int intwait;
+
+ USED(signo);
+
+ intwait = up->intwait;
+ up->intwait = 0; /* clear it to let proc continue in osleave */
+
+ if(up->type != Interp) /* Used to unblock pending I/O */
+ return;
+ if(intwait == 0) /* Not posted so its a sync error */
+ disfault(nil, Eintr); /* Should never happen */
+}
+
+static void
+trapUSR2(int signo)
+{
+ USED(signo);
+ /* we've done our work of interrupting sigsuspend */
+}
+
+static void
+trapILL(int signo)
+{
+ disfault(nil, "Illegal instruction");
+}
+
+static void
+trapSEGV(int signo)
+{
+ disfault(nil, "Segmentation violation");
+}
+
+static void
+trapFPE(int signo)
+{
+ USED(signo);
+ print("FPU status=0x$.4lux", getfsr());
+ disfault(nil, "Floating point exception");
+}
+
+static sigset_t initmask;
+
+static void
+setsigs(void)
+{
+ struct sigaction act;
+ sigset_t mask;
+
+ memset(&act, 0 , sizeof(act));
+ sigemptyset(&initmask);
+
+ signal(SIGPIPE, SIG_IGN); /* prevent signal when devcmd child exits */
+ if(signal(SIGTERM, SIG_IGN) != SIG_IGN)
+ signal(SIGTERM, cleanexit);
+
+ act.sa_handler = trapUSR1;
+ act.sa_mask = initmask;
+ sigaction(SIGUSR1, &act, nil);
+
+ act.sa_handler = trapUSR2;
+ sigaction(SIGUSR2, &act, nil);
+ sigemptyset(&mask);
+ sigaddset(&mask, SIGUSR2);
+ sigaddset(&initmask, SIGUSR2);
+ sigprocmask(SIG_BLOCK, &mask, NULL);
+
+ /*
+ * prevent Zombies forming when any process terminates
+ */
+ act.sa_sigaction = 0;
+ act.sa_flags |= SA_NOCLDWAIT;
+ if(sigaction(SIGCHLD, &act, nil))
+ panic("sigaction SIGCHLD");
+
+ if(sflag == 0) {
+ act.sa_sigaction = trapBUS;
+ act.sa_flags |= SA_SIGINFO;
+ if(sigaction(SIGBUS, &act, nil))
+ panic("sigaction SIGBUS");
+ act.sa_handler = trapILL;
+ if(sigaction(SIGILL, &act, nil))
+ panic("sigaction SIGBUS");
+ act.sa_handler = trapSEGV;
+ if(sigaction(SIGSEGV, &act, nil))
+ panic("sigaction SIGSEGV");
+ act.sa_handler = trapFPE;
+ if(sigaction(SIGFPE, &act, nil))
+ panic("sigaction SIGFPE");
+ if(sigaddset(&initmask, SIGINT) == -1)
+ panic("sigaddset");
+ }
+ if(sigprocmask(SIG_BLOCK, &initmask, nil)!= 0)
+ panic("sigprocmask");
+}
+
+static int
+tramp(void *arg)
+{
+ Proc *p;
+
+ p = arg;
+ p->pid = p->sigid = getpid();
+ sigprocmask(SIG_BLOCK, &initmask, nil); /* in 5.3, rfork_thread doesn't
copy from parent, contrary to docs? */
+ (*p->func)(p->arg);
+ pexit("{Tramp}", 0);
+ _exit(0);
+}
+
+int
+kproc(char *name, void (*func)(void*), void *arg, int flags)
+{
+ Proc *p;
+ Pgrp *pg;
+ Fgrp *fg;
+ Egrp *eg;
+ int pid;
+ void *tos;
+
+ p = newproc();
+
+ if(flags & KPDUPPG) {
+ pg = up->env->pgrp;
+ incref(&pg->r);
+ p->env->pgrp = pg;
+ }
+ if(flags & KPDUPFDG) {
+ fg = up->env->fgrp;
+ incref(&fg->r);
+ p->env->fgrp = fg;
+ }
+ if(flags & KPDUPENVG) {
+ eg = up->env->egrp;
+ incref(&eg->r);
+ p->env->egrp = eg;
+ }
+
+ p->env->uid = up->env->uid;
+ p->env->gid = up->env->gid;
+ kstrdup(&p->env->user, up->env->user);
+
+ strcpy(p->text, name);
+
+ p->func = func;
+ p->arg = arg;
+
+ lock(&procs.l);
+ if(procs.tail != nil) {
+ p->prev = procs.tail;
+ procs.tail->next = p;
+ }
+ else {
+ procs.head = p;
+ p->prev = nil;
+ }
+ procs.tail = p;
+ unlock(&procs.l);
+
+ if(flags & KPX11){
+ p->kstack = nil; /* never freed; also up not defined */
+ tos = (char*)mallocz(X11STACK, 0) + X11STACK - sizeof(void*);
+ }else
+ p->kstack = stackalloc(p, &tos);
+ pid = rfork_thread(RFPROC|RFMEM|RFNOWAIT, tos, tramp, p);
+ if(pid < 0)
+ panic("ourfork");
+
+ return pid;
+
+}
+
+void
+oshostintr(Proc *p)
+{
+ kill(p->sigid, SIGUSR1);
+}
+
+void
+osblock(void)
+{
+ sigset_t mask;
+
+ sigprocmask(SIG_SETMASK, NULL, &mask);
+ sigdelset(&mask, SIGUSR2);
+ sigsuspend(&mask);
+}
+
+void
+osready(Proc *p)
+{
+ if(kill(p->sigid, SIGUSR2) < 0)
+ fprint(2, "emu: osready failed: pid %d: %s\n", p->sigid,
strerror(errno));
+}
+
+void
+oslongjmp(void *regs, osjmpbuf env, int val)
+{
+ USED(regs);
+ siglongjmp(env, val);
+}
+
+struct termios tinit;
+
+static void
+termset(void)
+{
+ struct termios t;
+
+ tcgetattr(0, &t);
+ tinit = t;
+ t.c_lflag &= ~(ICANON|ECHO|ISIG);
+ t.c_cc[VMIN] = 1;
+ t.c_cc[VTIME] = 0;
+ tcsetattr(0, TCSANOW, &t);
+}
+
+static void
+termrestore(void)
+{
+ tcsetattr(0, TCSANOW, &tinit);
+}
+
+void
+cleanexit(int x)
+{
+ USED(x);
+
+ if(up->intwait) {
+ up->intwait = 0;
+ return;
+ }
+
+ if(dflag == 0)
+ termrestore();
+
+ kill(0, SIGKILL);
+ exit(0);
+}
+
+void
+osreboot(char *file, char **argv)
+{
+ if(dflag == 0)
+ termrestore();
+ execvp(file, argv);
+ panic("reboot failure");
+}
+
+int gidnobody= -1, uidnobody= -1;
+
+void
+getnobody()
+{
+ struct passwd *pwd;
+
+ if(pwd = getpwnam("nobody")) {
+ uidnobody = pwd->pw_uid;
+ gidnobody = pwd->pw_gid;
+ }
+}
+
+void
+libinit(char *imod)
+{
+ struct passwd *pw;
+ Proc *p;
+ void *tos;
+ char sys[64];
+
+ setsid();
+
+ gethostname(sys, sizeof(sys));
+ kstrdup(&ossysname, sys);
+ getnobody();
+
+ if(dflag == 0)
+ termset();
+
+ setsigs();
+
+ p = newproc();
+ p->kstack = stackalloc(p, &tos);
+
+ pw = getpwuid(getuid());
+ if(pw != nil)
+ kstrdup(&eve, pw->pw_name);
+ else
+ print("cannot getpwuid\n");
+
+ p->env->uid = getuid();
+ p->env->gid = getgid();
+
+ executeonnewstack(tos, emuinit, imod);
+}
+
+int
+readkbd(void)
+{
+ int n;
+ char buf[1];
+
+ n = read(0, buf, sizeof(buf));
+ if(n < 0)
+ print("keyboard close (n=%d, %s)\n", n, strerror(errno));
+ if(n <= 0)
+ pexit("keyboard thread", 0);
+
+ switch(buf[0]) {
+ case '\r':
+ buf[0] = '\n';
+ break;
+ case DELETE:
+ cleanexit(0);
+ break;
+ }
+ return buf[0];
+}
+
+/*
+ * Return an abitrary millisecond clock time
+ */
+long
+osmillisec(void)
+{
+ static long sec0 = 0, usec0;
+ struct timeval t;
+
+ if(gettimeofday(&t,(struct timezone*)0)<0)
+ return 0;
+ if(sec0==0) {
+ sec0 = t.tv_sec;
+ usec0 = t.tv_usec;
+ }
+ return (t.tv_sec-sec0)*1000+(t.tv_usec-usec0+500)/1000;
+}
+
+int
+limbosleep(ulong milsec)
+{
+ return osmillisleep(milsec);
+}
+
+/*
+ * Return the time since the epoch in nanoseconds and microseconds
+ * The epoch is defined at 1 Jan 1970
+ */
+vlong
+osnsec(void)
+{
+ struct timeval t;
+
+ gettimeofday(&t, nil);
+ return (vlong)t.tv_sec*1000000000L + t.tv_usec*1000;
+}
+
+vlong
+osusectime(void)
+{
+ struct timeval t;
+
+ gettimeofday(&t, nil);
+ return (vlong)t.tv_sec * 1000000 + t.tv_usec;
+}
+
+int
+osmillisleep(ulong milsec)
+{
+ struct timespec time;
+
+ time.tv_sec = milsec / 1000;
+ time.tv_nsec = (milsec % 1000) * 1000000;
+ nanosleep(&time, 0);
+ return 0;
+}
+
+void
+osyield(void)
+{
+ sched_yield();
+}
+
+void
+ospause(void)
+{
+ for(;;)
+ pause();
+}
+
+void
+oslopri(void)
+{
+ setpriority(PRIO_PROCESS, 0, getpriority(PRIO_PROCESS,0)+4);
+}
+
+static struct {
+ Lock l;
+ void *free;
+} stacklist;
+
+static void
+_stackfree(void *stack)
+{
+ *((void **)stack) = stacklist.free;
+ stacklist.free = stack;
+}
+
+static void
+stackfreeandexit(void *stack)
+{
+ lock(&stacklist.l);
+ _stackfree(stack);
+ unlockandexit(&stacklist.l.val);
+}
+
+static void *
+stackalloc(Proc *p, void **tos)
+{
+ void *rv;
+ lock(&stacklist.l);
+ if (stacklist.free == 0) {
+ int x;
+ /*
+ * obtain some more by using sbrk()
+ */
+ void *more = sbrk(KSTACK * (NSTACKSPERALLOC + 1));
+ if (more == 0)
+ panic("stackalloc: no more stacks");
+ /*
+ * align to KSTACK
+ */
+ more = (void *)((((unsigned long)more) + (KSTACK - 1)) & ~(KSTACK - 1));
+ /*
+ * free all the new stacks onto the freelist
+ */
+ for (x = 0; x < NSTACKSPERALLOC; x++)
+ _stackfree((char *)more + KSTACK * x);
+ }
+ rv = stacklist.free;
+ stacklist.free = *(void **)rv;
+ unlock(&stacklist.l);
+ *tos = rv + KSTACK - sizeof(void*);
+ *(Proc **)rv = p;
+ return rv;
+}
+
+int
+segflush(void *a, ulong n)
+{
+ USED(a);
+ USED(n);
+ return 0;
+}
=======================================
--- /dev/null
+++ /lib9/getcallerpc-DragonFly-386.S Fri Feb 5 06:51:46 2010
@@ -0,0 +1,7 @@
+ .file "getcallerpc-DragonFly-386.S"
+
+ .type getcallerpc,@function
+ .global getcallerpc
+getcallerpc:
+ movl 4(%ebp), %eax
+ ret
=======================================
--- /dev/null
+++ /libmath/FPcontrol-DragonFly.c Fri Feb 5 06:51:46 2010
@@ -0,0 +1,78 @@
+#include "lib9.h"
+#include "fpuctl.h"
+#include "mathi.h"
+
+void
+FPinit(void)
+{
+ setfsr(0); /* Clear pending exceptions */
+ setfcr(FPPDBL|FPRNR|FPINVAL|FPZDIV|FPUNFL|FPOVFL);
+}
+
+ulong
+getFPstatus(void)
+{
+ ulong fsr = 0, fsr9 = getfsr();
+ /* on specific machines, could be table lookup */
+ if(fsr9&FPAINEX) fsr |= INEX;
+ if(fsr9&FPAOVFL) fsr |= OVFL;
+ if(fsr9&FPAUNFL) fsr |= UNFL;
+ if(fsr9&FPAZDIV) fsr |= ZDIV;
+ if(fsr9&FPAINVAL) fsr |= INVAL;
+ return fsr;
+}
+
+ulong
+FPstatus(ulong fsr, ulong mask)
+{
+ ulong fsr9 = 0;
+ ulong old = getFPstatus();
+ fsr = (fsr&mask) | (old&~mask);
+ if(fsr&INEX) fsr9 |= FPAINEX;
+ if(fsr&OVFL) fsr9 |= FPAOVFL;
+ if(fsr&UNFL) fsr9 |= FPAUNFL;
+ if(fsr&ZDIV) fsr9 |= FPAZDIV;
+ if(fsr&INVAL) fsr9 |= FPAINVAL;
+ setfsr(fsr9);
+ return(old&mask);
+}
+
+ulong
+getFPcontrol(void)
+{
+ ulong fcr = 0, fcr9 = getfcr();
+ switch(fcr9&FPRMASK){
+ case FPRNR: fcr = RND_NR; break;
+ case FPRNINF: fcr = RND_NINF; break;
+ case FPRPINF: fcr = RND_PINF; break;
+ case FPRZ: fcr = RND_Z; break;
+ }
+ if(fcr9&FPINEX) fcr |= INEX;
+ if(fcr9&FPOVFL) fcr |= OVFL;
+ if(fcr9&FPUNFL) fcr |= UNFL;
+ if(fcr9&FPZDIV) fcr |= ZDIV;
+ if(fcr9&FPINVAL) fcr |= INVAL;
+ return fcr;
+}
+
+ulong
+FPcontrol(ulong fcr, ulong mask)
+{
+ ulong fcr9 = FPPDBL;
+ ulong old = getFPcontrol();
+ fcr = (fcr&mask) | (old&~mask);
+ if(fcr&INEX) fcr9 |= FPINEX;
+ if(fcr&OVFL) fcr9 |= FPOVFL;
+ if(fcr&UNFL) fcr9 |= FPUNFL;
+ if(fcr&ZDIV) fcr9 |= FPZDIV;
+ if(fcr&INVAL) fcr9 |= FPINVAL;
+ switch(fcr&RND_MASK){
+ case RND_NR: fcr9 |= FPRNR; break;
+ case RND_NINF: fcr9 |= FPRNINF; break;
+ case RND_PINF: fcr9 |= FPRPINF; break;
+ case RND_Z: fcr9 |= FPRZ; break;
+ }
+ setfcr(fcr9);
+ return(old&mask);
+}
+
=======================================
--- /dev/null
+++ /mkfiles/mkfile-DragonFly-386 Fri Feb 5 06:51:46 2010
@@ -0,0 +1,32 @@
+TARGMODEL= Posix
+TARGSHTYPE= sh
+CPUS= 386
+
+O= o
+OS= o
+
+AR= ar
+ARFLAGS= ruvs
+
+AS= cc -c
+ASFLAGS=
+
+CC= cc -c
+CFLAGS= -g\
+ -O\
+ -Wno-deprecated-declarations -Wuninitialized -Wunused -Wreturn-type
-Wimplicit\
+ -I$ROOT/DragonFly/386/include\
+ -I$ROOT/include\
+ -I/usr/local/include\
+ -I/usr/X11R6/include\
+
+ANSICPP=
+LD= cc
+LDFLAGS= -L/usr/openwin/lib\
+ -L/usr/local/lib\
+ -L/usr/X11R6/lib\
+
+SYSLIBS=
+
+YACC= iyacc
+YFLAGS= -d
=======================================
--- /dev/null
+++ /mkfiles/mkhost-DragonFly Fri Feb 5 06:51:46 2010
@@ -0,0 +1,19 @@
+
+# Variables for host system type = Unixware
+
+SHELLTYPE= sh
+SHELLNAME= /bin/sh
+HOSTMODEL= Posix
+OSTARG= os
+
+DATA2S= data2s
+NDATE= ndate
+KSIZE= ksize
+AWK= awk
+CP= cp
+ECHO= echo
+FALSE= false
+MKDIR= mkdir -p
+RM= rm -f
+RMDIR= rmdir
+TRUE= true
=======================================
--- /CHANGES Fri Feb 5 03:01:55 2010
+++ /CHANGES Fri Feb 5 06:51:46 2010
@@ -1,6 +1,7 @@
20100205
update man pages to replace most references to Styx by 9P
update man pages to replace references to sys-dial(2) by dial(2)
+ add DragonFly files (from fgudin and extrudedaluminiu, issue 181);
possibly should automatically keep aligned with FreeBSD
20100203
appl/lib/cfg.b treat \r as white space [issue 69, issue 70]
add u64int to lib9.h files that needed it
==============================================================================
Revision: dc810d52e2
Author: for...@vitanuova.com
Date: Fri Feb 5 07:15:14 2010
Log: 20100205-1515
http://code.google.com/p/inferno-npe/source/detail?r=dc810d52e2
Modified:
/CHANGES
/emu/DragonFly/os.c
/emu/FreeBSD/os.c
/emu/Linux/os.c
/emu/OpenBSD/os.c
=======================================
--- /CHANGES Fri Feb 5 06:51:46 2010
+++ /CHANGES Fri Feb 5 07:15:14 2010
@@ -2,6 +2,7 @@
update man pages to replace most references to Styx by 9P
update man pages to replace references to sys-dial(2) by dial(2)
add DragonFly files (from fgudin and extrudedaluminiu, issue 181);
possibly should automatically keep aligned with FreeBSD
+ fpe handling in OpenBSD and FreeBSD [mechiel, issue 190]
20100203
appl/lib/cfg.b treat \r as white space [issue 69, issue 70]
add u64int to lib9.h files that needed it
=======================================
--- /emu/DragonFly/os.c Fri Feb 5 06:51:46 2010
+++ /emu/DragonFly/os.c Fri Feb 5 07:15:14 2010
@@ -115,9 +115,10 @@
static void
trapFPE(int signo)
{
+ char buf[64];
USED(signo);
- print("FPU status=0x$.4lux", getfsr());
- disfault(nil, "Floating point exception");
+ snprint(buf, sizeof(buf), "sys: fp: exception status=%.4lux", getfsr());
+ disfault(nil, buf);
}
static sigset_t initmask;
=======================================
--- /emu/FreeBSD/os.c Sun Jul 19 09:10:21 2009
+++ /emu/FreeBSD/os.c Fri Feb 5 07:15:14 2010
@@ -12,6 +12,7 @@
#include <errno.h>
#include <unistd.h>
#include <sys/resource.h>
+#include <fpuctl.h>
enum
{
@@ -110,6 +111,16 @@
{
disfault(nil, "Segmentation violation");
}
+
+static void
+trapFPE(int signo)
+{
+
+ char buf[64];
+ USED(signo);
+ snprint(buf, sizeof(buf), "sys: fp: exception status=%.4lux", getfsr());
+ disfault(nil, buf);
+}
static sigset_t initmask;
@@ -156,6 +167,9 @@
act.sa_handler = trapSEGV;
if(sigaction(SIGSEGV, &act, nil))
panic("sigaction SIGSEGV");
+ act.sa_handler = trapFPE;
+ if(sigaction(SIGFPE, &act, nil))
+ panic("sigaction SIGFPE");
if(sigaddset(&initmask, SIGINT) == -1)
panic("sigaddset");
}
=======================================
--- /emu/Linux/os.c Thu Apr 2 05:47:45 2009
+++ /emu/Linux/os.c Fri Feb 5 07:15:14 2010
@@ -11,6 +11,7 @@
#include "dat.h"
#include "fns.h"
#include "error.h"
+#include <fpuctl.h>
/* glibc 2.3.3-NTPL messes up getpid() by trying to cache the result, so
we'll do it ourselves */
#include <sys/syscall.h>
@@ -188,13 +189,13 @@
disfault(nil, "Segmentation violation");
}
-#include <fpuctl.h>
static void
trapFPE(int signo)
{
+ char buf[64];
USED(signo);
- print("FPU status=0x%.4lux", getfsr());
- disfault(nil, "Floating exception");
+ snprint(buf, sizeof(buf), "sys: fp: exception status=%.4lux", getfsr());
+ disfault(nil, buf);
}
static void
=======================================
--- /emu/OpenBSD/os.c Thu May 22 15:49:44 2008
+++ /emu/OpenBSD/os.c Fri Feb 5 07:15:14 2010
@@ -15,6 +15,7 @@
#include <pwd.h>
#include <errno.h>
#include <unistd.h>
+#include <fpuctl.h>
enum
{
@@ -115,6 +116,15 @@
{
disfault(nil, "Segmentation violation");
}
+
+static void
+trapFPE(int signo)
+{
+ char buf[64];
+ USED(signo);
+ snprint(buf, sizeof(buf), "sys: fp: exception status=%.4lux", getfsr());
+ disfault(nil, buf);
+}
static sigset_t initmask;
@@ -161,6 +171,9 @@
act.sa_handler = trapSEGV;
if(sigaction(SIGSEGV, &act, nil))
panic("sigaction SIGSEGV");
+ act.sa_handler = trapFPE;
+ if(sigaction(SIGFPE, &act, nil))
+ panic("sigaction SIGFPE");
if(sigaddset(&initmask, SIGINT) == -1)
panic("sigaddset");
}
==============================================================================
Revision: 424f5c46a5
Author: for...@vitanuova.com
Date: Fri Feb 5 07:56:39 2010
Log: 20100205-1556
http://code.google.com/p/inferno-npe/source/detail?r=424f5c46a5
Modified:
/CHANGES
/appl/cmd/vacfs.b
/dis/vacfs.dis
=======================================
--- /CHANGES Fri Feb 5 07:15:14 2010
+++ /CHANGES Fri Feb 5 07:56:39 2010
@@ -3,6 +3,7 @@
update man pages to replace references to sys-dial(2) by dial(2)
add DragonFly files (from fgudin and extrudedaluminiu, issue 181);
possibly should automatically keep aligned with FreeBSD
fpe handling in OpenBSD and FreeBSD [mechiel, issue 190]
+ appl/cmd/vacfs.b apply fix from mechiel [issue 204]
20100203
appl/lib/cfg.b treat \r as white space [issue 69, issue 70]
add u64int to lib9.h files that needed it
=======================================
--- /appl/cmd/vacfs.b Thu May 21 13:02:52 2009
+++ /appl/cmd/vacfs.b Fri Feb 5 07:56:39 2010
@@ -54,7 +54,7 @@
Qdir: adt {
qid: int;
- cqids: list of (big, int);
+ cqids: list of (string, int); # name, qid
};
elems := array[512] of list of ref Elem;
@@ -63,21 +63,21 @@
qidscores: list of (string, int);
-childget(qid: int, vqid: big): ref Elem
+childget(qid: int, name: string): ref Elem
{
for(l := qids[qid % len qids]; l != nil; l = tl l) {
if((hd l).qid != qid)
continue;
for(m := (hd l).cqids; m != nil; m = tl m) {
- (vq, cq) := hd m;
- if(vq == vqid)
+ (cname, cq) := hd m;
+ if(name == cname)
return get(cq);
}
}
return nil;
}
-childput(qid: int, vqid: big): int
+childput(qid: int, name: string): int
{
qd: ref Qdir;
for(l := qids[qid % len qids]; l != nil; l = tl l)
@@ -89,7 +89,7 @@
qd = ref Qdir(qid, nil);
qids[qid % len qids] = qd::nil;
}
- qd.cqids = (vqid, ++lastqid)::qd.cqids;
+ qd.cqids = (name, ++lastqid)::qd.cqids;
return lastqid;
}
@@ -154,9 +154,9 @@
de := ed.vd.walk(name);
if(de == nil)
return (nil, sprint("%r"));
- ne := childget(ed.qid, de.qid);
+ ne := childget(ed.qid, de.elem);
if(ne == nil) {
- nqid := childput(ed.qid, de.qid);
+ nqid := childput(ed.qid, de.elem);
ne = Elem.new(nqid, ed.vd, de, ed.qid);
if(ne == nil)
return (nil, sprint("%r"));
@@ -379,6 +379,7 @@
if(n.offset == 0) {
ed.vd.rewind();
ed.offset = 0;
+ ed.nprev = 0;
ed.prev = array[0] of ref Sys->Dir;
}
skip := n.offset-ed.offset;
@@ -401,14 +402,15 @@
}
if(de == nil)
break;
- ne := childget(ed.qid, de.qid);
+ ne := childget(ed.qid, de.elem);
if(ne == nil) {
- nqid := childput(ed.qid, de.qid);
+ nqid := childput(ed.qid, de.elem);
ne = Elem.new(nqid, ed.vd, de, ed.qid);
if(ne == nil) {
n.reply <-= (nil, sprint("%r"));
continue loop;
}
+ set(ne);
}
d := ne.stat();
ed.prev[ed.nprev++] = d;
=======================================
--- /dis/vacfs.dis Thu May 21 13:02:52 2009
+++ /dis/vacfs.dis Fri Feb 5 07:56:39 2010
Binary file, no diff available.
==============================================================================
Revision: eeb9eeeb80
Author: Venkatesh Srinivas <m...@acm.jhu.edu>
Date: Sun Feb 7 07:49:54 2010
Log: Merge with inferno-os 20100205.
http://code.google.com/p/inferno-npe/source/detail?r=eeb9eeeb80
Modified:
/CHANGES
/DragonFly/386/include/lib9.h
/doc/port.pdf
/emu/DragonFly/mkfile
/emu/DragonFly/os.c
/emu/FreeBSD/os.c
/emu/Linux/os.c
/emu/OpenBSD/os.c
/include/version.h
/man/2/sys-0intro
/man/4/export
/mkfiles/mkfile-DragonFly-386
=======================================
--- /CHANGES Wed Feb 3 13:28:15 2010
+++ /CHANGES Sun Feb 7 07:49:54 2010
@@ -1,7 +1,13 @@
+20100205
+ update man pages to replace most references to Styx by 9P
+ update man pages to replace references to sys-dial(2) by dial(2)
+ add DragonFly files (from fgudin and extrudedaluminiu, issue 181);
possibly should automatically keep aligned with FreeBSD
+ fpe handling in OpenBSD and FreeBSD [mechiel, issue 190]
+ appl/cmd/vacfs.b apply fix from mechiel [issue 204]
20100203
- appl/lib/cfg.b treat \r as white space (issue 69, 70)
+ appl/lib/cfg.b treat \r as white space [issue 69, issue 70]
add u64int to lib9.h files that needed it
- add sha2.c sha256block.c sha512block.c to libsec/port and include/libsec.h
+ add sha2.c sha256block.c sha512block.c to libsec/port and
include/libsec.h [issue 185, mechiel]
add new sha functions to module/keyring.m and libinterp/keyring.c
20100115
appl/cmd/tarfs.b man/4/tarfs changes to permission handling from mechiel
[issue 220]
=======================================
--- /DragonFly/386/include/lib9.h Wed Feb 3 13:29:43 2010
+++ /DragonFly/386/include/lib9.h Sun Feb 7 07:49:54 2010
@@ -1,3 +1,4 @@
+<<<<<<< /var/tmp/inferno-npe/DragonFly/386/include/lib9.h
/* define _BSD_SOURCE to use ISO C, POSIX, and 4.3BSD things. */
#ifndef _BSD_SOURCE
#define _BSD_SOURCE
@@ -491,3 +492,497 @@
#define ossetjmp(buf) sigsetjmp(buf, 1)
#endif
+=======
+/* define _BSD_SOURCE to use ISO C, POSIX, and 4.3BSD things. */
+#ifndef _BSD_SOURCE
+#define _BSD_SOURCE
+#endif
+/* these aren't really needed because FreeBSD does the right thing and
makes off_t 64 bits, full stop */
+#define _LARGEFILE64_SOURCE 1
+#define _FILE_OFFSET_BITS 64
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include "math.h"
+#include <fcntl.h>
+#include <setjmp.h>
+#include <float.h>
+#include <time.h>
+
+#define getwd infgetwd
+
+#undef isnan
+#define round infround
+#define fmax inffmax
+#define log2 inflog2
+
+#ifndef EMU
+typedef struct Proc Proc;
+#endif
+
+/*
+ * math module dtoa
+ */
+#define __LITTLE_ENDIAN
+
+#define nil ((void*)0)
+
+typedef unsigned char uchar;
+typedef signed char schar;
+typedef unsigned long ulong;
+typedef unsigned short Rune;
+typedef long long int vlong;
+typedef unsigned long long int uvlong;
+typedef unsigned int u32int;
+typedef uvlong u64int;
+typedef unsigned int mpdigit; /* for /sys/include/mp.h */
+typedef unsigned short u16int;
+typedef unsigned char u8int;
+typedef unsigned long uintptr;
+
+#define USED(x) if(x){}else{}
+#define SET(x)
+
+#undef nelem
+#define nelem(x) (sizeof(x)/sizeof((x)[0]))
+#undef offsetof
+#define offsetof(s, m) (ulong)(&(((s*)0)->m))
+#undef assert
+#define assert(x) if(x){}else _assert("x")
+
+/*
+ * most mem and string routines are declared by ANSI/POSIX files above
+ */
+
+extern char* strecpy(char*, char*, char*);
+extern char* strdup(const char*);
+extern int cistrncmp(char*, char*, int);
+extern int cistrcmp(char*, char*);
+extern char* cistrstr(char*, char*);
+extern int tokenize(char*, char**, int);
+
+enum
+{
+ UTFmax = 3, /* maximum bytes per rune */
+ Runesync = 0x80, /* cannot represent part of a UTF sequence (<) */
+ Runeself = 0x80, /* rune and UTF sequences are the same (<) */
+ Runeerror = 0x80 /* decoding error in UTF */
+};
+
+/*
+ * rune routines
+ */
+extern int runetochar(char*, Rune*);
+extern int chartorune(Rune*, char*);
+extern int runelen(long);
+extern int runenlen(Rune*, int);
+extern int fullrune(char*, int);
+extern int utflen(char*);
+extern int utfnlen(char*, long);
+extern char* utfrune(char*, long);
+extern char* utfrrune(char*, long);
+extern char* utfutf(char*, char*);
+extern char* utfecpy(char*, char*, char*);
+
+extern Rune* runestrcat(Rune*, Rune*);
+extern Rune* runestrchr(Rune*, Rune);
+extern int runestrcmp(Rune*, Rune*);
+extern Rune* runestrcpy(Rune*, Rune*);
+extern Rune* runestrncpy(Rune*, Rune*, long);
+extern Rune* runestrecpy(Rune*, Rune*, Rune*);
+extern Rune* runestrdup(Rune*);
+extern Rune* runestrncat(Rune*, Rune*, long);
+extern int runestrncmp(Rune*, Rune*, long);
+extern Rune* runestrrchr(Rune*, Rune);
+extern long runestrlen(Rune*);
+extern Rune* runestrstr(Rune*, Rune*);
+
+extern Rune tolowerrune(Rune);
+extern Rune totitlerune(Rune);
+extern Rune toupperrune(Rune);
+extern int isalpharune(Rune);
+extern int islowerrune(Rune);
+extern int isspacerune(Rune);
+extern int istitlerune(Rune);
+extern int isupperrune(Rune);
+
+/*
+ * malloc
+ */
+extern void* malloc(size_t);
+extern void* mallocz(ulong, int);
+extern void free(void*);
+extern ulong msize(void*);
+extern void* calloc(size_t, size_t);
+extern void* realloc(void*, size_t);
+extern void setmalloctag(void*, ulong);
+extern void setrealloctag(void*, ulong);
+extern ulong getmalloctag(void*);
+extern ulong getrealloctag(void*);
+extern void* malloctopoolblock(void*);
+
+/*
+ * print routines
+ */
+typedef struct Fmt Fmt;
+struct Fmt{
+ uchar runes; /* output buffer is runes or chars? */
+ void *start; /* of buffer */
+ void *to; /* current place in the buffer */
+ void *stop; /* end of the buffer; overwritten if flush fails */
+ int (*flush)(Fmt *); /* called when to == stop */
+ void *farg; /* to make flush a closure */
+ int nfmt; /* num chars formatted so far */
+ va_list args; /* args passed to dofmt */
+ int r; /* % format Rune */
+ int width;
+ int prec;
+ ulong flags;
+};
+
+enum{
+ FmtWidth = 1,
+ FmtLeft = FmtWidth << 1,
+ FmtPrec = FmtLeft << 1,
+ FmtSharp = FmtPrec << 1,
+ FmtSpace = FmtSharp << 1,
+ FmtSign = FmtSpace << 1,
+ FmtZero = FmtSign << 1,
+ FmtUnsigned = FmtZero << 1,
+ FmtShort = FmtUnsigned << 1,
+ FmtLong = FmtShort << 1,
+ FmtVLong = FmtLong << 1,
+ FmtComma = FmtVLong << 1,
+ FmtByte = FmtComma << 1,
+
+ FmtFlag = FmtByte << 1
+};
+
+extern int print(char*, ...);
+extern char* seprint(char*, char*, char*, ...);
+extern char* vseprint(char*, char*, char*, va_list);
+extern int snprint(char*, int, char*, ...);
+extern int vsnprint(char*, int, char*, va_list);
+extern char* smprint(char*, ...);
+extern char* vsmprint(char*, va_list);
+extern int sprint(char*, char*, ...);
+extern int fprint(int, char*, ...);
+extern int vfprint(int, char*, va_list);
+
+extern int runesprint(Rune*, char*, ...);
+extern int runesnprint(Rune*, int, char*, ...);
+extern int runevsnprint(Rune*, int, char*, va_list);
+extern Rune* runeseprint(Rune*, Rune*, char*, ...);
+extern Rune* runevseprint(Rune*, Rune*, char*, va_list);
+extern Rune* runesmprint(char*, ...);
+extern Rune* runevsmprint(char*, va_list);
+
+extern int fmtfdinit(Fmt*, int, char*, int);
+extern int fmtfdflush(Fmt*);
+extern int fmtstrinit(Fmt*);
+extern char* fmtstrflush(Fmt*);
+extern int runefmtstrinit(Fmt*);
+extern Rune* runefmtstrflush(Fmt*);
+
+extern int fmtinstall(int, int (*)(Fmt*));
+extern int dofmt(Fmt*, char*);
+extern int dorfmt(Fmt*, Rune*);
+extern int fmtprint(Fmt*, char*, ...);
+extern int fmtvprint(Fmt*, char*, va_list);
+extern int fmtrune(Fmt*, int);
+extern int fmtstrcpy(Fmt*, char*);
+extern int fmtrunestrcpy(Fmt*, Rune*);
+/*
+ * error string for %r
+ * supplied on per os basis, not part of fmt library
+ */
+extern int errfmt(Fmt *f);
+
+/*
+ * quoted strings
+ */
+extern char *unquotestrdup(char*);
+extern Rune *unquoterunestrdup(Rune*);
+extern char *quotestrdup(char*);
+extern Rune *quoterunestrdup(Rune*);
+extern int quotestrfmt(Fmt*);
+extern int quoterunestrfmt(Fmt*);
+extern void quotefmtinstall(void);
+extern int (*doquote)(int);
+
+/*
+ * random number
+ */
+extern int nrand(int);
+extern ulong truerand(void);
+extern ulong ntruerand(ulong);
+
+/*
+ * math
+ */
+extern int isNaN(double);
+extern int isInf(double, int);
+extern double pow(double, double);
+
+/*
+ * Time-of-day
+ */
+
+typedef struct Tm Tm;
+struct Tm {
+ int sec;
+ int min;
+ int hour;
+ int mday;
+ int mon;
+ int year;
+ int wday;
+ int yday;
+ char zone[4];
+ int tzoff;
+};
+extern vlong osnsec(void);
+#define nsec osnsec
+
+/*
+ * one-of-a-kind
+ */
+extern void _assert(char*);
+extern double charstod(int(*)(void*), void*);
+extern char* cleanname(char*);
+extern double frexp(double, int*);
+extern ulong getcallerpc(void*);
+extern int getfields(char*, char**, int, int, char*);
+extern char* getuser(void);
+extern char* getwd(char*, int);
+extern double ipow10(int);
+extern double ldexp(double, int);
+extern double modf(double, double*);
+#define pow10 infpow10
+extern double pow10(int);
+extern vlong strtoll(const char*, char**, int);
+extern uvlong strtoull(const char*, char**, int);
+extern void sysfatal(char*, ...);
+extern int dec64(uchar*, int, char*, int);
+extern int enc64(char*, int, uchar*, int);
+extern int dec32(uchar*, int, char*, int);
+extern int enc32(char*, int, uchar*, int);
+extern int dec16(uchar*, int, char*, int);
+extern int enc16(char*, int, uchar*, int);
+extern int encodefmt(Fmt*);
+
+/*
+ * synchronization
+ */
+typedef
+struct Lock {
+ int val;
+ int pid;
+} Lock;
+
+extern int _tas(int*);
+
+extern void lock(Lock*);
+extern void unlock(Lock*);
+extern int canlock(Lock*);
+
+typedef struct QLock QLock;
+struct QLock
+{
+ Lock use; /* to access Qlock structure */
+ Proc *head; /* next process waiting for object */
+ Proc *tail; /* last process waiting for object */
+ int locked; /* flag */
+};
+
+extern void qlock(QLock*);
+extern void qunlock(QLock*);
+extern int canqlock(QLock*);
+extern void _qlockinit(ulong (*)(ulong, ulong)); /* called only by the
thread library */
+
+typedef
+struct RWLock
+{
+ Lock l; /* Lock modify lock */
+ QLock x; /* Mutual exclusion lock */
+ QLock k; /* Lock for waiting writers */
+ int readers; /* Count of readers in lock */
+} RWLock;
+
+extern int canrlock(RWLock*);
+extern int canwlock(RWLock*);
+extern void rlock(RWLock*);
+extern void runlock(RWLock*);
+extern void wlock(RWLock*);
+extern void wunlock(RWLock*);
+
+/*
+ * network dialing
+ */
+#define NETPATHLEN 40
+
+/*
+ * system calls
+ *
+ */
+#define STATMAX 65535U /* max length of machine-independent stat structure
*/
+#define DIRMAX (sizeof(Dir)+STATMAX) /* max length of Dir structure */
+#define ERRMAX 128 /* max length of error string */
+
+#define MORDER 0x0003 /* mask for bits defining order of mounting */
+#define MREPL 0x0000 /* mount replaces object */
+#define MBEFORE 0x0001 /* mount goes before others in union directory */
+#define MAFTER 0x0002 /* mount goes after others in union directory */
+#define MCREATE 0x0004 /* permit creation in mounted directory */
+#define MCACHE 0x0010 /* cache some data */
+#define MMASK 0x0017 /* all bits on */
+
+#define OREAD 0 /* open for read */
+#define OWRITE 1 /* write */
+#define ORDWR 2 /* read and write */
+#define OEXEC 3 /* execute, == read but check execute permission */
+#define OTRUNC 16 /* or'ed in (except for exec), truncate file first */
+#define OCEXEC 32 /* or'ed in, close on exec */
+#define ORCLOSE 64 /* or'ed in, remove on close */
+#define OEXCL 0x1000 /* or'ed in, exclusive use (create only) */
+
+#define AEXIST 0 /* accessible: exists */
+#define AEXEC 1 /* execute access */
+#define AWRITE 2 /* write access */
+#define AREAD 4 /* read access */
+
+/* bits in Qid.type */
+#define QTDIR 0x80 /* type bit for directories */
+#define QTAPPEND 0x40 /* type bit for append only files */
+#define QTEXCL 0x20 /* type bit for exclusive use files */
+#define QTMOUNT 0x10 /* type bit for mounted channel */
+#define QTAUTH 0x08 /* type bit for authentication file */
+#define QTFILE 0x00 /* plain file */
+
+/* bits in Dir.mode */
+#define DMDIR 0x80000000 /* mode bit for directories */
+#define DMAPPEND 0x40000000 /* mode bit for append only files */
+#define DMEXCL 0x20000000 /* mode bit for exclusive use files */
+#define DMMOUNT 0x10000000 /* mode bit for mounted channel */
+#define DMAUTH 0x08000000 /* mode bit for authentication file */
+#define DMREAD 0x4 /* mode bit for read permission */
+#define DMWRITE 0x2 /* mode bit for write permission */
+#define DMEXEC 0x1 /* mode bit for execute permission */
+
+typedef
+struct Qid
+{
+ uvlong path;
+ ulong vers;
+ uchar type;
+} Qid;
+
+typedef
+struct Dir {
+ /* system-modified data */
+ ushort type; /* server type */
+ uint dev; /* server subtype */
+ /* file data */
+ Qid qid; /* unique id from server */
+ ulong mode; /* permissions */
+ ulong atime; /* last read time */
+ ulong mtime; /* last write time */
+ vlong length; /* file length */
+ char *name; /* last element of path */
+ char *uid; /* owner name */
+ char *gid; /* group name */
+ char *muid; /* last modifier name */
+} Dir;
+
+extern Dir* dirstat(char*);
+extern Dir* dirfstat(int);
+extern int dirwstat(char*, Dir*);
+extern int dirfwstat(int, Dir*);
+extern long dirread(int, Dir**);
+extern void nulldir(Dir*);
+extern long dirreadall(int, Dir**);
+
+typedef
+struct Waitmsg
+{
+ int pid; /* of loved one */
+ ulong time[3]; /* of loved one & descendants */
+ char *msg;
+} Waitmsg;
+
+extern void _exits(char*);
+
+extern void exits(char*);
+extern int create(char*, int, int);
+extern int errstr(char*, uint);
+
+extern void perror(const char*);
+extern long readn(int, void*, long);
+extern int remove(const char*);
+extern void rerrstr(char*, uint);
+extern vlong seek(int, vlong, int);
+extern int segflush(void*, ulong);
+extern void werrstr(char*, ...);
+
+extern char *argv0;
+#define ARGBEGIN for((argv0||(argv0=*argv)),argv++,argc--;\
+ argv[0] && argv[0][0]=='-' && argv[0][1];\
+ argc--, argv++) {\
+ char *_args, *_argt;\
+ Rune _argc;\
+ _args = &argv[0][1];\
+ if(_args[0]=='-' && _args[1]==0){\
+ argc--; argv++; break;\
+ }\
+ _argc = 0;\
+ while(*_args && (_args += chartorune(&_argc, _args)))\
+ switch(_argc)
+#define ARGEND SET(_argt);USED(_argt);USED(_argc);
USED(_args);}USED(argv); USED(argc);
+#define ARGF() (_argt=_args, _args="",\
+ (*_argt? _argt: argv[1]? (argc--, *++argv): 0))
+#define EARGF(x) (_argt=_args, _args="",\
+ (*_argt? _argt: argv[1]? (argc--, *++argv): ((x), abort(), (char*)0)))
+
+#define ARGC() _argc
+
+/*
+ * Extensions for Inferno to basic libc.h
+ */
+
+#define setbinmode()
+
+/*
+ * Extensions for emu kernel emulation
+ */
+#ifdef EMU
+
+/*
+ * This structure must agree with FPsave and FPrestore asm routines
+ */
+typedef struct FPU FPU;
+struct FPU
+{
+ uchar env[28];
+};
+
+#define KSTACK (32 * 1024)
+
+static __inline Proc *getup(void) {
+ Proc *p;
+ __asm__( "movl %%esp, %%eax\n\t"
+ : "=a" (p)
+ );
+ return *(Proc **)((unsigned long)p & ~(KSTACK - 1));
+};
+
+#define up (getup())
+
+typedef sigjmp_buf osjmpbuf;
+#define ossetjmp(buf) sigsetjmp(buf, 1)
+
+#endif
+>>>>>>> /tmp/lib9.h~other.FoUskE
=======================================
--- /doc/port.pdf Fri Nov 13 05:07:00 2009
+++ /doc/port.pdf Sun Feb 7 07:49:54 2010
Binary file, no diff available.
=======================================
--- /emu/DragonFly/mkfile Thu Jan 14 14:19:51 2010
+++ /emu/DragonFly/mkfile Sun Feb 7 07:49:54 2010
@@ -6,7 +6,7 @@
#Configurable parameters
-CONF=emu-g #default configuration
+CONF=emu #default configuration
CONFLIST=emu emu-g
CLEANCONFLIST=
@@ -20,7 +20,7 @@
OBJ=\
asm-$OBJTYPE.$O\
- os-$OBJTYPE.$O\
+ os-$OBJTYPE.$O\
os.$O\
$CONF.root.$O\
lock.$O\
=======================================
--- /emu/DragonFly/os.c Mon Feb 1 04:40:39 2010
+++ /emu/DragonFly/os.c Sun Feb 7 07:49:54 2010
@@ -12,6 +12,7 @@
#include <errno.h>
#include <unistd.h>
#include <sys/resource.h>
+#include <fpuctl.h>
enum
{
@@ -64,6 +65,17 @@
if(kstack != nil)
stackfreeandexit(kstack);
}
+
+void
+trapBUS(int signo, siginfo_t *info, void *context)
+{
+ if(info)
+ print("trapBUS: signo: %d code: %d addr: %lx\n",
+ info->si_signo, info->si_code, info->si_addr);
+ else
+ print("trapBUS: no info\n");
+ disfault(nil, "Bus error");
+}
static void
trapUSR1(int signo)
@@ -87,53 +99,26 @@
USED(signo);
/* we've done our work of interrupting sigsuspend */
}
-
static void
-diserr(char *msg, siginfo_t *si)
-{
- char buf[128];
-
- if(si != nil) {
- snprint(buf, sizeof buf, "%s, addr=%p", msg, si->si_addr);
- disfault(nil, buf);
- } else
- disfault(nil, msg);
+trapILL(int signo)
+{
+ disfault(nil, "Illegal instruction");
}
static void
-trapBUS(int signo, siginfo_t *si, void *context)
-{
- USED(signo);
- USED(context);
- diserr("Bus error", si);
+trapSEGV(int signo)
+{
+ disfault(nil, "Segmentation violation");
}
static void
-trapILL(int signo, siginfo_t *si, void *context)
-{
+trapFPE(int signo)
+{
+ char buf[64];
USED(signo);
- USED(context);
- diserr("Illegal instruction", si);
-}
-
-static void
-trapSEGV(int signo, siginfo_t *si, void *context)
-{
- USED(signo);
- USED(context);
- diserr("Segmentation violation", si);
-}
-
-#include <fpuctl.h>
-void
-trapFPE(int signo, siginfo_t *si, void *context)
-{
- USED(signo);
- USED(context);
-
- print("FPU status=0x%.4lux\n", getfsr());
- diserr("Floating point exception", si);
+ snprint(buf, sizeof(buf), "sys: fp: exception status=%.4lux", getfsr());
+ disfault(nil, buf);
}
static sigset_t initmask;
@@ -171,17 +156,17 @@
panic("sigaction SIGCHLD");
if(sflag == 0) {
- act.sa_flags |= SA_SIGINFO;
act.sa_sigaction = trapBUS;
+ act.sa_flags |= SA_SIGINFO;
if(sigaction(SIGBUS, &act, nil))
panic("sigaction SIGBUS");
- act.sa_sigaction = trapILL;
+ act.sa_handler = trapILL;
if(sigaction(SIGILL, &act, nil))
- panic("sigaction SIGILL");
- act.sa_sigaction = trapSEGV;
+ panic("sigaction SIGBUS");
+ act.sa_handler = trapSEGV;
if(sigaction(SIGSEGV, &act, nil))
panic("sigaction SIGSEGV");
- act.sa_sigaction = trapFPE;
+ act.sa_handler = trapFPE;
if(sigaction(SIGFPE, &act, nil))
panic("sigaction SIGFPE");
if(sigaddset(&initmask, SIGINT) == -1)
=======================================
--- /emu/FreeBSD/os.c Mon Feb 1 04:40:39 2010
+++ /emu/FreeBSD/os.c Sun Feb 7 07:49:54 2010
@@ -12,6 +12,7 @@
#include <errno.h>
#include <unistd.h>
#include <sys/resource.h>
+#include <fpuctl.h>
enum
{
@@ -64,6 +65,17 @@
if(kstack != nil)
stackfreeandexit(kstack);
}
+
+void
+trapBUS(int signo, siginfo_t *info, void *context)
+{
+ if(info)
+ print("trapBUS: signo: %d code: %d addr: %lx\n",
+ info->si_signo, info->si_code, info->si_addr);
+ else
+ print("trapBUS: no info\n");
+ disfault(nil, "Bus error");
+}
static void
trapUSR1(int signo)
@@ -89,50 +101,25 @@
}
static void
-diserr(char *msg, siginfo_t *si)
-{
- char buf[128];
-
- if(si != nil) {
- snprint(buf, sizeof buf, "%s, addr=%p", msg, si->si_addr);
- disfault(nil, buf);
- } else
- disfault(nil, msg);
+trapILL(int signo)
+{
+ disfault(nil, "Illegal instruction");
}
static void
-trapBUS(int signo, siginfo_t *si, void *context)
-{
- USED(signo);
- USED(context);
- diserr("Bus error", si);
+trapSEGV(int signo)
+{
+ disfault(nil, "Segmentation violation");
}
static void
-trapILL(int signo, siginfo_t *si, void *context)
-{
- USED(signo);
- USED(context);
- diserr("Illegal instruction", si);
-}
-
-static void
-trapSEGV(int signo, siginfo_t *si, void *context)
-{
+trapFPE(int signo)
+{
+
+ char buf[64];
USED(signo);
- USED(context);
- diserr("Segmentation violation", si);
-}
-
-#include <fpuctl.h>
-void
-trapFPE(int signo, siginfo_t *si, void *context)
-{
- USED(signo);
- USED(context);
-
- print("FPU status=0x%.4lux\n", getfsr());
- diserr("Floating point exception", si);
+ snprint(buf, sizeof(buf), "sys: fp: exception status=%.4lux", getfsr());
+ disfault(nil, buf);
}
static sigset_t initmask;
@@ -170,17 +157,17 @@
panic("sigaction SIGCHLD");
if(sflag == 0) {
- act.sa_flags |= SA_SIGINFO;
act.sa_sigaction = trapBUS;
+ act.sa_flags |= SA_SIGINFO;
if(sigaction(SIGBUS, &act, nil))
panic("sigaction SIGBUS");
- act.sa_sigaction = trapILL;
+ act.sa_handler = trapILL;
if(sigaction(SIGILL, &act, nil))
- panic("sigaction SIGILL");
- act.sa_sigaction = trapSEGV;
+ panic("sigaction SIGBUS");
+ act.sa_handler = trapSEGV;
if(sigaction(SIGSEGV, &act, nil))
panic("sigaction SIGSEGV");
- act.sa_sigaction = trapFPE;
+ act.sa_handler = trapFPE;
if(sigaction(SIGFPE, &act, nil))
panic("sigaction SIGFPE");
if(sigaddset(&initmask, SIGINT) == -1)
=======================================
--- /emu/Linux/os.c Mon Feb 1 04:40:39 2010
+++ /emu/Linux/os.c Sun Feb 7 07:49:54 2010
@@ -11,6 +11,7 @@
#include "dat.h"
#include "fns.h"
#include "error.h"
+#include <fpuctl.h>
/* glibc 2.3.3-NTPL messes up getpid() by trying to cache the result, so
we'll do it ourselves */
#include <sys/syscall.h>
@@ -150,82 +151,82 @@
return 0;
}
+/*
+ * TO DO:
+ * To get pc on trap, use sigaction instead of signal and
+ * examine its siginfo structure
+ */
+
+/*
static void
-trapUSR1(int signo)
-{
- int intwait;
-
- USED(signo);
-
- intwait = up->intwait;
- up->intwait = 0; /* clear it to let proc continue in osleave */
-
- if(up->type != Interp) /* Used to unblock pending I/O */
- return;
-
- if(intwait == 0) /* Not posted so it's a sync error */
- disfault(nil, Eintr); /* Should never happen */
-}
-
-/* called to wake up kproc blocked on a syscall */
-void
-oshostintr(Proc *p)
-{
- kill(p->sigid, SIGUSR1);
-}
+diserr(char *s, int pc)
+{
+ char buf[ERRMAX];
+
+ snprint(buf, sizeof(buf), "%s: pc=0x%lux", s, pc);
+ disfault(nil, buf);
+}
+*/
static void
-trapUSR2(int signo)
+trapILL(int signo)
{
USED(signo);
- /* we've done our work of interrupting sigsuspend */
+ disfault(nil, "Illegal instruction");
}
static void
-diserr(char *msg, siginfo_t *si)
-{
- char buf[128];
-
- if(si != nil) {
- snprint(buf, sizeof buf, "%s, addr=%p", msg, si->si_addr);
- disfault(nil, buf);
- } else
- disfault(nil, msg);
+trapBUS(int signo)
+{
+ USED(signo);
+ disfault(nil, "Bus error");
}
static void
-trapBUS(int signo, siginfo_t *si, void *context)
+trapSEGV(int signo)
{
USED(signo);
- USED(context);
- diserr("Bus error", si);
+ disfault(nil, "Segmentation violation");
}
static void
-trapILL(int signo, siginfo_t *si, void *context)
-{
+trapFPE(int signo)
+{
+ char buf[64];
USED(signo);
- USED(context);
- diserr("Illegal instruction", si);
+ snprint(buf, sizeof(buf), "sys: fp: exception status=%.4lux", getfsr());
+ disfault(nil, buf);
}
static void
-trapSEGV(int signo, siginfo_t *si, void *context)
-{
+trapUSR1(int signo)
+{
+ int intwait;
+
USED(signo);
- USED(context);
- diserr("Segmentation violation", si);
+
+ intwait = up->intwait;
+ up->intwait = 0; /* clear it to let proc continue in osleave */
+
+ if(up->type != Interp) /* Used to unblock pending I/O */
+ return;
+
+ if(intwait == 0) /* Not posted so it's a sync error */
+ disfault(nil, Eintr); /* Should never happen */
}
-#include <fpuctl.h>
+/* called to wake up kproc blocked on a syscall */
void
-trapFPE(int signo, siginfo_t *si, void *context)
-{
- USED(signo);
- USED(context);
-
- print("FPU status=0x%.4lux\n", getfsr());
- diserr("Floating point exception", si);
+oshostintr(Proc *p)
+{
+ kill(p->sigid, SIGUSR1);
+}
+
+static void
+trapUSR2(int signo)
+{
+ USED(signo);
+ /* we've done our work of interrupting sigsuspend */
}
void
@@ -291,6 +292,10 @@
void
osreboot(char *file, char **argv)
{
+ if(dflag == 0)
+ termrestore();
+ execvp(file, argv);
+ error("reboot failure");
}
void
@@ -343,19 +348,14 @@
signal(SIGINT, cleanexit);
if(sflag == 0) {
- act.sa_flags |= SA_SIGINFO;
- act.sa_sigaction = trapBUS;
- if(sigaction(SIGBUS, &act, nil))
- panic("sigaction SIGBUS");
- act.sa_sigaction = trapILL;
- if(sigaction(SIGILL, &act, nil))
- panic("sigaction SIGILL");
- act.sa_sigaction = trapSEGV;
- if(sigaction(SIGSEGV, &act, nil))
- panic("sigaction SIGSEGV");
- act.sa_sigaction = trapFPE;
- if(sigaction(SIGFPE, &act, nil))
- panic("sigaction SIGFPE");
+ act.sa_handler = trapBUS;
+ sigaction(SIGBUS, &act, nil);
+ act.sa_handler = trapILL;
+ sigaction(SIGILL, &act, nil);
+ act.sa_handler = trapSEGV;
+ sigaction(SIGSEGV, &act, nil);
+ act.sa_handler = trapFPE;
+ sigaction(SIGFPE, &act, nil);
}
p = newproc();
=======================================
--- /emu/OpenBSD/os.c Mon Feb 1 04:40:39 2010
+++ /emu/OpenBSD/os.c Sun Feb 7 07:49:54 2010
@@ -15,6 +15,7 @@
#include <pwd.h>
#include <errno.h>
#include <unistd.h>
+#include <fpuctl.h>
enum
{
@@ -69,6 +70,17 @@
if(kstack != nil)
stackfreeandexit(kstack);
}
+
+void
+trapBUS(int signo, siginfo_t *info, void *context)
+{
+ if(info)
+ print("trapBUS: signo: %d code: %d addr: %lx\n",
+ info->si_signo, info->si_code, info->si_addr);
+ else
+ print("trapBUS: no info\n");
+ disfault(nil, "Bus error");
+}
static void
trapUSR1(int signo)
@@ -94,50 +106,24 @@
}
static void
-diserr(char *msg, siginfo_t *si)
-{
- char buf[128];
-
- if(si != nil) {
- snprint(buf, sizeof buf, "%s, addr=%p", msg, si->si_addr);
- disfault(nil, buf);
- } else
- disfault(nil, msg);
+trapILL(int signo)
+{
+ disfault(nil, "Illegal instruction");
}
static void
-trapBUS(int signo, siginfo_t *si, void *context)
-{
- USED(signo);
- USED(context);
- diserr("Bus error", si);
+trapSEGV(int signo)
+{
+ disfault(nil, "Segmentation violation");
}
static void
-trapILL(int signo, siginfo_t *si, void *context)
-{
+trapFPE(int signo)
+{
+ char buf[64];
USED(signo);
- USED(context);
- diserr("Illegal instruction", si);
-}
-
-static void
-trapSEGV(int signo, siginfo_t *si, void *context)
-{
- USED(signo);
- USED(context);
- diserr("Segmentation violation", si);
-}
-
-#include <fpuctl.h>
-void
-trapFPE(int signo, siginfo_t *si, void *context)
-{
- USED(signo);
- USED(context);
-
- print("FPU status=0x%.4lux\n", getfsr());
- diserr("Floating point exception", si);
+ snprint(buf, sizeof(buf), "sys: fp: exception status=%.4lux", getfsr());
+ disfault(nil, buf);
}
static sigset_t initmask;
@@ -175,17 +161,17 @@
panic("sigaction SIGCHLD");
if(sflag == 0) {
- act.sa_flags |= SA_SIGINFO;
act.sa_sigaction = trapBUS;
+ act.sa_flags |= SA_SIGINFO;
if(sigaction(SIGBUS, &act, nil))
panic("sigaction SIGBUS");
- act.sa_sigaction = trapILL;
+ act.sa_handler = trapILL;
if(sigaction(SIGILL, &act, nil))
- panic("sigaction SIGILL");
- act.sa_sigaction = trapSEGV;
+ panic("sigaction SIGBUS");
+ act.sa_handler = trapSEGV;
if(sigaction(SIGSEGV, &act, nil))
panic("sigaction SIGSEGV");
- act.sa_sigaction = trapFPE;
+ act.sa_handler = trapFPE;
if(sigaction(SIGFPE, &act, nil))
panic("sigaction SIGFPE");
if(sigaddset(&initmask, SIGINT) == -1)
=======================================
--- /include/version.h Wed Feb 3 13:28:15 2010
+++ /include/version.h Sun Feb 7 07:49:54 2010
@@ -1,1 +1,1 @@
-#define VERSION "Fourth Edition (20100203)"
+#define VERSION "Fourth Edition (20100205)"
=======================================
--- /man/2/sys-0intro Fri Nov 13 05:07:00 2009
+++ /man/2/sys-0intro Sun Feb 7 07:49:54 2010
@@ -210,8 +210,8 @@
Record locking in the underlying file system is not supported by Inferno.
Processes can coordinate their file operations by other mechanisms.
.PP
-Atomicity is guaranteed for byte counts smaller than the
-.I Styx
+Atomicity is guaranteed for byte counts no larger than the
+.I 9P
message size;
see
.IR read (5).
=======================================
--- /man/4/export Fri Nov 13 05:07:00 2009
+++ /man/4/export Sun Feb 7 07:49:54 2010
@@ -13,12 +13,10 @@
.SH DESCRIPTION
.I Export
calls
-.B Sys->export
-(see
-.IR sys-dial (2))
-to serve a name space rooted at
+.IR sys-export (2)
+to serve the name space rooted at
.I dir
-over a connection to a Styx client.
+over a connection to a 9P (Styx) client.
.I Export
opens the connection on the given
.IR file ,
@@ -35,7 +33,7 @@
will be visible to clients.
.PP
.I Export
-starts serving Styx immediately; it assumes that the connection
+starts serving 9P immediately; it assumes that the connection
has been authenticated if required.
.I Export
is typically called via
@@ -53,5 +51,6 @@
.SH SEE ALSO
.IR cpu (1),
.IR listen (1),
-.IR sys-dial (2),
+.IR dial (2),
+.IR sys-export (2),
.IR intro (5)
=======================================
--- /mkfiles/mkfile-DragonFly-386 Wed Jan 13 15:30:03 2010
+++ /mkfiles/mkfile-DragonFly-386 Sun Feb 7 07:49:54 2010
@@ -18,13 +18,15 @@
-I$ROOT/DragonFly/386/include\
-I$ROOT/include\
-I/usr/local/include\
- -I/usr/pkg/include\
+ -I/usr/X11R6/include\
+ -I/usr/pkg/include\
-DDragonFly_386
ANSICPP=
LD= cc
LDFLAGS= -L/usr/openwin/lib\
-L/usr/local/lib\
+ -L/usr/X11R6/lib\
-L/usr/pkg/lib\
SYSLIBS=
==============================================================================
Revision: f8439c0f49
Author: Venkatesh Srinivas <m...@acm.jhu.edu>
Date: Sun Feb 7 08:18:30 2010
Log: Fix DragonFly lib9.h; previous merge resolution for this file was
incorrect.
http://code.google.com/p/inferno-npe/source/detail?r=f8439c0f49
Modified:
/DragonFly/386/include/lib9.h
=======================================
--- /DragonFly/386/include/lib9.h Sun Feb 7 07:49:54 2010
+++ /DragonFly/386/include/lib9.h Sun Feb 7 08:18:30 2010
@@ -1,4 +1,3 @@
-<<<<<<< /var/tmp/inferno-npe/DragonFly/386/include/lib9.h
/* define _BSD_SOURCE to use ISO C, POSIX, and 4.3BSD things. */
#ifndef _BSD_SOURCE
#define _BSD_SOURCE
@@ -45,7 +44,6 @@
typedef unsigned long long int uvlong;
typedef unsigned int u32int;
typedef uvlong u64int;
-
typedef unsigned int mpdigit; /* for /sys/include/mp.h */
typedef unsigned short u16int;
typedef unsigned char u8int;
@@ -492,497 +490,3 @@
#define ossetjmp(buf) sigsetjmp(buf, 1)
#endif
-=======
-/* define _BSD_SOURCE to use ISO C, POSIX, and 4.3BSD things. */
-#ifndef _BSD_SOURCE
-#define _BSD_SOURCE
-#endif
-/* these aren't really needed because FreeBSD does the right thing and
makes off_t 64 bits, full stop */
-#define _LARGEFILE64_SOURCE 1
-#define _FILE_OFFSET_BITS 64
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-#include "math.h"
-#include <fcntl.h>
-#include <setjmp.h>
-#include <float.h>
-#include <time.h>
-
-#define getwd infgetwd
-
-#undef isnan
-#define round infround
-#define fmax inffmax
-#define log2 inflog2
-
-#ifndef EMU
-typedef struct Proc Proc;
-#endif
-
-/*
- * math module dtoa
- */
-#define __LITTLE_ENDIAN
-
-#define nil ((void*)0)
-
-typedef unsigned char uchar;
-typedef signed char schar;
-typedef unsigned long ulong;
-typedef unsigned short Rune;
-typedef long long int vlong;
-typedef unsigned long long int uvlong;
-typedef unsigned int u32int;
-typedef uvlong u64int;
-typedef unsigned int mpdigit; /* for /sys/include/mp.h */
-typedef unsigned short u16int;
-typedef unsigned char u8int;
-typedef unsigned long uintptr;
-
-#define USED(x) if(x){}else{}
-#define SET(x)
-
-#undef nelem
-#define nelem(x) (sizeof(x)/sizeof((x)[0]))
-#undef offsetof
-#define offsetof(s, m) (ulong)(&(((s*)0)->m))
-#undef assert
-#define assert(x) if(x){}else _assert("x")
-
-/*
- * most mem and string routines are declared by ANSI/POSIX files above
- */
-
-extern char* strecpy(char*, char*, char*);
-extern char* strdup(const char*);
-extern int cistrncmp(char*, char*, int);
-extern int cistrcmp(char*, char*);
-extern char* cistrstr(char*, char*);
-extern int tokenize(char*, char**, int);
-
-enum
-{
- UTFmax = 3, /* maximum bytes per rune */
- Runesync = 0x80, /* cannot represent part of a UTF sequence (<) */
- Runeself = 0x80, /* rune and UTF sequences are the same (<) */
- Runeerror = 0x80 /* decoding error in UTF */
-};
-
-/*
- * rune routines
- */
-extern int runetochar(char*, Rune*);
-extern int chartorune(Rune*, char*);
-extern int runelen(long);
-extern int runenlen(Rune*, int);
-extern int fullrune(char*, int);
-extern int utflen(char*);
-extern int utfnlen(char*, long);
-extern char* utfrune(char*, long);
-extern char* utfrrune(char*, long);
-extern char* utfutf(char*, char*);
-extern char* utfecpy(char*, char*, char*);
-
-extern Rune* runestrcat(Rune*, Rune*);
-extern Rune* runestrchr(Rune*, Rune);
-extern int runestrcmp(Rune*, Rune*);
-extern Rune* runestrcpy(Rune*, Rune*);
-extern Rune* runestrncpy(Rune*, Rune*, long);
-extern Rune* runestrecpy(Rune*, Rune*, Rune*);
-extern Rune* runestrdup(Rune*);
-extern Rune* runestrncat(Rune*, Rune*, long);
-extern int runestrncmp(Rune*, Rune*, long);
-extern Rune* runestrrchr(Rune*, Rune);
-extern long runestrlen(Rune*);
-extern Rune* runestrstr(Rune*, Rune*);
-
-extern Rune tolowerrune(Rune);
-extern Rune totitlerune(Rune);
-extern Rune toupperrune(Rune);
-extern int isalpharune(Rune);
-extern int islowerrune(Rune);
-extern int isspacerune(Rune);
-extern int istitlerune(Rune);
-extern int isupperrune(Rune);
-
-/*
- * malloc
- */
-extern void* malloc(size_t);
-extern void* mallocz(ulong, int);
-extern void free(void*);
-extern ulong msize(void*);
-extern void* calloc(size_t, size_t);
-extern void* realloc(void*, size_t);
-extern void setmalloctag(void*, ulong);
-extern void setrealloctag(void*, ulong);
-extern ulong getmalloctag(void*);
-extern ulong getrealloctag(void*);
-extern void* malloctopoolblock(void*);
-
-/*
- * print routines
- */
-typedef struct Fmt Fmt;
-struct Fmt{
- uchar runes; /* output buffer is runes or chars? */
- void *start; /* of buffer */
- void *to; /* current place in the buffer */
- void *stop; /* end of the buffer; overwritten if flush fails */
- int (*flush)(Fmt *); /* called when to == stop */
- void *farg; /* to make flush a closure */
- int nfmt; /* num chars formatted so far */
- va_list args; /* args passed to dofmt */
- int r; /* % format Rune */
- int width;
- int prec;
- ulong flags;
-};
-
-enum{
- FmtWidth = 1,
- FmtLeft = FmtWidth << 1,
- FmtPrec = FmtLeft << 1,
- FmtSharp = FmtPrec << 1,
- FmtSpace = FmtSharp << 1,
- FmtSign = FmtSpace << 1,
- FmtZero = FmtSign << 1,
- FmtUnsigned = FmtZero << 1,
- FmtShort = FmtUnsigned << 1,
- FmtLong = FmtShort << 1,
- FmtVLong = FmtLong << 1,
- FmtComma = FmtVLong << 1,
- FmtByte = FmtComma << 1,
-
- FmtFlag = FmtByte << 1
-};
-
-extern int print(char*, ...);
-extern char* seprint(char*, char*, char*, ...);
-extern char* vseprint(char*, char*, char*, va_list);
-extern int snprint(char*, int, char*, ...);
-extern int vsnprint(char*, int, char*, va_list);
-extern char* smprint(char*, ...);
-extern char* vsmprint(char*, va_list);
-extern int sprint(char*, char*, ...);
-extern int fprint(int, char*, ...);
-extern int vfprint(int, char*, va_list);
-
-extern int runesprint(Rune*, char*, ...);
-extern int runesnprint(Rune*, int, char*, ...);
-extern int runevsnprint(Rune*, int, char*, va_list);
-extern Rune* runeseprint(Rune*, Rune*, char*, ...);
-extern Rune* runevseprint(Rune*, Rune*, char*, va_list);
-extern Rune* runesmprint(char*, ...);
-extern Rune* runevsmprint(char*, va_list);
-
-extern int fmtfdinit(Fmt*, int, char*, int);
-extern int fmtfdflush(Fmt*);
-extern int fmtstrinit(Fmt*);
-extern char* fmtstrflush(Fmt*);
-extern int runefmtstrinit(Fmt*);
-extern Rune* runefmtstrflush(Fmt*);
-
-extern int fmtinstall(int, int (*)(Fmt*));
-extern int dofmt(Fmt*, char*);
-extern int dorfmt(Fmt*, Rune*);
-extern int fmtprint(Fmt*, char*, ...);
-extern int fmtvprint(Fmt*, char*, va_list);
-extern int fmtrune(Fmt*, int);
-extern int fmtstrcpy(Fmt*, char*);
-extern int fmtrunestrcpy(Fmt*, Rune*);
-/*
- * error string for %r
- * supplied on per os basis, not part of fmt library
- */
-extern int errfmt(Fmt *f);
-
-/*
- * quoted strings
- */
-extern char *unquotestrdup(char*);
-extern Rune *unquoterunestrdup(Rune*);
-extern char *quotestrdup(char*);
-extern Rune *quoterunestrdup(Rune*);
-extern int quotestrfmt(Fmt*);
-extern int quoterunestrfmt(Fmt*);
-extern void quotefmtinstall(void);
-extern int (*doquote)(int);
-
-/*
- * random number
- */
-extern int nrand(int);
-extern ulong truerand(void);
-extern ulong ntruerand(ulong);
-
-/*
- * math
- */
-extern int isNaN(double);
-extern int isInf(double, int);
-extern double pow(double, double);
-
-/*
- * Time-of-day
- */
-
-typedef struct Tm Tm;
-struct Tm {
- int sec;
- int min;
- int hour;
- int mday;
- int mon;
- int year;
- int wday;
- int yday;
- char zone[4];
- int tzoff;
-};
-extern vlong osnsec(void);
-#define nsec osnsec
-
-/*
- * one-of-a-kind
- */
-extern void _assert(char*);
-extern double charstod(int(*)(void*), void*);
-extern char* cleanname(char*);
-extern double frexp(double, int*);
-extern ulong getcallerpc(void*);
-extern int getfields(char*, char**, int, int, char*);
-extern char* getuser(void);
-extern char* getwd(char*, int);
-extern double ipow10(int);
-extern double ldexp(double, int);
-extern double modf(double, double*);
-#define pow10 infpow10
-extern double pow10(int);
-extern vlong strtoll(const char*, char**, int);
-extern uvlong strtoull(const char*, char**, int);
-extern void sysfatal(char*, ...);
-extern int dec64(uchar*, int, char*, int);
-extern int enc64(char*, int, uchar*, int);
-extern int dec32(uchar*, int, char*, int);
-extern int enc32(char*, int, uchar*, int);
-extern int dec16(uchar*, int, char*, int);
-extern int enc16(char*, int, uchar*, int);
-extern int encodefmt(Fmt*);
-
-/*
- * synchronization
- */
-typedef
-struct Lock {
- int val;
- int pid;
-} Lock;
-
-extern int _tas(int*);
-
-extern void lock(Lock*);
-extern void unlock(Lock*);
-extern int canlock(Lock*);
-
-typedef struct QLock QLock;
-struct QLock
-{
- Lock use; /* to access Qlock structure */
- Proc *head; /* next process waiting for object */
- Proc *tail; /* last process waiting for object */
- int locked; /* flag */
-};
-
-extern void qlock(QLock*);
-extern void qunlock(QLock*);
-extern int canqlock(QLock*);
-extern void _qlockinit(ulong (*)(ulong, ulong)); /* called only by the
thread library */
-
-typedef
-struct RWLock
-{
- Lock l; /* Lock modify lock */
- QLock x; /* Mutual exclusion lock */
- QLock k; /* Lock for waiting writers */
- int readers; /* Count of readers in lock */
-} RWLock;
-
-extern int canrlock(RWLock*);
-extern int canwlock(RWLock*);
-extern void rlock(RWLock*);
-extern void runlock(RWLock*);
-extern void wlock(RWLock*);
-extern void wunlock(RWLock*);
-
-/*
- * network dialing
- */
-#define NETPATHLEN 40
-
-/*
- * system calls
- *
- */
-#define STATMAX 65535U /* max length of machine-independent stat structure
*/
-#define DIRMAX (sizeof(Dir)+STATMAX) /* max length of Dir structure */
-#define ERRMAX 128 /* max length of error string */
-
-#define MORDER 0x0003 /* mask for bits defining order of mounting */
-#define MREPL 0x0000 /* mount replaces object */
-#define MBEFORE 0x0001 /* mount goes before others in union directory */
-#define MAFTER 0x0002 /* mount goes after others in union directory */
-#define MCREATE 0x0004 /* permit creation in mounted directory */
-#define MCACHE 0x0010 /* cache some data */
-#define MMASK 0x0017 /* all bits on */
-
-#define OREAD 0 /* open for read */
-#define OWRITE 1 /* write */
-#define ORDWR 2 /* read and write */
-#define OEXEC 3 /* execute, == read but check execute permission */
-#define OTRUNC 16 /* or'ed in (except for exec), truncate file first */
-#define OCEXEC 32 /* or'ed in, close on exec */
-#define ORCLOSE 64 /* or'ed in, remove on close */
-#define OEXCL 0x1000 /* or'ed in, exclusive use (create only) */
-
-#define AEXIST 0 /* accessible: exists */
-#define AEXEC 1 /* execute access */
-#define AWRITE 2 /* write access */
-#define AREAD 4 /* read access */
-
-/* bits in Qid.type */
-#define QTDIR 0x80 /* type bit for directories */
-#define QTAPPEND 0x40 /* type bit for append only files */
-#define QTEXCL 0x20 /* type bit for exclusive use files */
-#define QTMOUNT 0x10 /* type bit for mounted channel */
-#define QTAUTH 0x08 /* type bit for authentication file */
-#define QTFILE 0x00 /* plain file */
-
-/* bits in Dir.mode */
-#define DMDIR 0x80000000 /* mode bit for directories */
-#define DMAPPEND 0x40000000 /* mode bit for append only files */
-#define DMEXCL 0x20000000 /* mode bit for exclusive use files */
-#define DMMOUNT 0x10000000 /* mode bit for mounted channel */
-#define DMAUTH 0x08000000 /* mode bit for authentication file */
-#define DMREAD 0x4 /* mode bit for read permission */
-#define DMWRITE 0x2 /* mode bit for write permission */
-#define DMEXEC 0x1 /* mode bit for execute permission */
-
-typedef
-struct Qid
-{
- uvlong path;
- ulong vers;
- uchar type;
-} Qid;
-
-typedef
-struct Dir {
- /* system-modified data */
- ushort type; /* server type */
- uint dev; /* server subtype */
- /* file data */
- Qid qid; /* unique id from server */
- ulong mode; /* permissions */
- ulong atime; /* last read time */
- ulong mtime; /* last write time */
- vlong length; /* file length */
- char *name; /* last element of path */
- char *uid; /* owner name */
- char *gid; /* group name */
- char *muid; /* last modifier name */
-} Dir;
-
-extern Dir* dirstat(char*);
-extern Dir* dirfstat(int);
-extern int dirwstat(char*, Dir*);
-extern int dirfwstat(int, Dir*);
-extern long dirread(int, Dir**);
-extern void nulldir(Dir*);
-extern long dirreadall(int, Dir**);
-
-typedef
-struct Waitmsg
-{
- int pid; /* of loved one */
- ulong time[3]; /* of loved one & descendants */
- char *msg;
-} Waitmsg;
-
-extern void _exits(char*);
-
-extern void exits(char*);
-extern int create(char*, int, int);
-extern int errstr(char*, uint);
-
-extern void perror(const char*);
-extern long readn(int, void*, long);
-extern int remove(const char*);
-extern void rerrstr(char*, uint);
-extern vlong seek(int, vlong, int);
-extern int segflush(void*, ulong);
-extern void werrstr(char*, ...);
-
-extern char *argv0;
-#define ARGBEGIN for((argv0||(argv0=*argv)),argv++,argc--;\
- argv[0] && argv[0][0]=='-' && argv[0][1];\
- argc--, argv++) {\
- char *_args, *_argt;\
- Rune _argc;\
- _args = &argv[0][1];\
- if(_args[0]=='-' && _args[1]==0){\
- argc--; argv++; break;\
- }\
- _argc = 0;\
- while(*_args && (_args += chartorune(&_argc, _args)))\
- switch(_argc)
-#define ARGEND SET(_argt);USED(_argt);USED(_argc);
USED(_args);}USED(argv); USED(argc);
-#define ARGF() (_argt=_args, _args="",\
- (*_argt? _argt: argv[1]? (argc--, *++argv): 0))
-#define EARGF(x) (_argt=_args, _args="",\
- (*_argt? _argt: argv[1]? (argc--, *++argv): ((x), abort(), (char*)0)))
-
-#define ARGC() _argc
-
-/*
- * Extensions for Inferno to basic libc.h
- */
-
-#define setbinmode()
-
-/*
- * Extensions for emu kernel emulation
- */
-#ifdef EMU
-
-/*
- * This structure must agree with FPsave and FPrestore asm routines
- */
-typedef struct FPU FPU;
-struct FPU
-{
- uchar env[28];
-};
-
-#define KSTACK (32 * 1024)
-
-static __inline Proc *getup(void) {
- Proc *p;
- __asm__( "movl %%esp, %%eax\n\t"
- : "=a" (p)
- );
- return *(Proc **)((unsigned long)p & ~(KSTACK - 1));
-};
-
-#define up (getup())
-
-typedef sigjmp_buf osjmpbuf;
-#define ossetjmp(buf) sigsetjmp(buf, 1)
-
-#endif
->>>>>>> /tmp/lib9.h~other.FoUskE