v0.1; add -v flag to print version info and /version file for client to know the version as well
Iris Lightshard nilix@nilfm.cc
PGP Signature
-----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEkFh6dA+k/6CXFXU4O3+8IhROY5gFAmFstJ4ACgkQO3+8IhRO Y5h4jw//Rj+atS3F2S1Tn8SpgPMpQ4ULk6Yt54p1rfdEUg9BZoHZAXT+uWekWKqX 2MiHFhwImg+2AZPip6sCEnmK/FsZXm3AR386lqrwv6Owce9nA0zi7Se+7//D5b34 o9+DsbECxqHNezendWGJayHkG0dDPrnfnk+US3GJUtFdagvj2NudhrUtac7kmroK SgCrwp9fWbgyEWNJc7STNHft5rzuO0pIunuJYISMsprOqszXh+9AsOkR6A/fW09e Q8dvW2pcRB2Ma02mW01xJd3VVpx/nBSQHr5QXfgE/lFiyXrB8yqjgOfZ1o91rWec L/ErzP2vcVCQbw/khGfU/z7II9+LhHsHyrlrzEYl0j4mLE8SeLu7wRNDdrajuikn HhqNN5bWVF6npHPtAp+wAwE1sdofJfP2qDgQ+yyGGboebkJGHT4lJKfhFFZuO+jp Mx7hsSIpWQKUb1ohW7p1zGLUpmFjdYXe+6jEBLa6W02QKC8pspTzQ5b/YHBTHC5B AgYv5L2+Be5aoiBB6trWe27XjEpyAhCEBnpp+2jC1Pdm/Cl/cYMlocdW+JiR2e6N Eo3i8ptU4VcgWx8pIBSFg4GhYFHTtp9jLjEj0/kHpcKyXmlf1WpbLYXWlGttJB6I 1jWv2+5fH5NB5HoDfXte7Bz0khihbmMPMeUAauLXQqiINYqS3vA= =W2zB -----END PGP SIGNATURE-----
3 files changed,
22 insertions(+),
2 deletions(-)
M
README.md
→
README.md
@@ -8,7 +8,7 @@ ## design
This is the working structure of the 9p filesystem: -* `/ctl`: Read/write control file for inputing system commands. Reading the file shows the status of the last input command: 1 for success, 0 for failure; `logout` is a special case, and the status code will be -1 if it was succesful. the following are valid command syntax: + * `/ctl`: Read/write control file for inputing system commands. Reading the file shows the status of the last input command: 1 for success, 0 for failure; `logout` is a special case, and the status code will be -1 if it was succesful. the following are valid command syntax: * `login PW`: Authenticate with `xrxs` -- password is hashed against realm password hash. * `logout`: Gracefully remove yourself from the users table. * `load CART`: Load a cartridge.@@ -38,6 +38,8 @@
* `/random`: Read-only, get a random number from 0 to 99. * `/grandom`: Read-only, get a random number from 0 to 99 -- These are doled out on a per-realm basis, and the number stays the same until everyone in the realm has had a chance to read it. If you've already read it this round or aren't in a realm, it will be empty. + +* `/version`: Read-only, outputs the version of the `xrxs` server. ### realm format
M
server/aux.h
→
server/aux.h
@@ -11,6 +11,7 @@ UNIVERSE,
SCOPE, RANDOM, GRANDOM, + VERSION } FileType; typedef struct Aux {@@ -19,4 +20,4 @@ char* data;
int count; } Aux; -Aux* create_aux(FileType t);+Aux* create_aux(FileType t);
M
server/xrxs.c
→
server/xrxs.c
@@ -17,6 +17,8 @@ #include "universe.h"
#include "realm.h" #include "user.h" +char version[] = "0.1"; + int chatty9p = 0; static Tree* tree;@@ -524,6 +526,13 @@ readstr(r, buf);
respond(r, nil); } +void read_version(Req* r) { + char buf[16]; + sprintf(buf, "%s\n", version); + readstr(r, buf); + respond(r, nil); +} + void xrxs_read(Req* r) { Aux* a = r->fid->file->aux; switch (a->type) {@@ -559,6 +568,9 @@ break;
case GRANDOM: read_grandom(r); break; + case VERSION: + read_version(r); + break; default: respond(r, nil); break;@@ -610,12 +622,17 @@ for (i = 0; i < argc; i++) {
if (scmp(argv[i], "-d")) { chatty9p = 1; } + if (scmp(argv[i], "-v")) { + printf("xrxs v%s\n", version); + threadexits(0); + } } fs.foreground = 1; fs.tree = alloctree(nil, nil, DMDIR | 0777, fs_destroy_file); tree = fs.tree; + closefile(createfile(tree->root, "version", nil, 0400, create_aux(VERSION))); closefile( createfile(tree->root, "ctl", nil, DMAPPEND | 0600, create_aux(CTL))); closefile(createfile(tree->root, "carts", nil, 0400, create_aux(CARTS)));