Re: [9fans] [PATCH 2/3] Send vendor ndb attribute if available

2019-01-22 Thread k0ga
> all looks good. except that "swap" is kind of crazy name to mean
> the nfs server.

If you want we an change it to rootserver. If I am not wrong,
NetBSD uses "swap", OpenBSD uses "nextserver" and linux uses
"rootserver". As rootpath is an accepted attribute name (everyone
uses that name), maybe the best option is rootserver.




[9fans] [PATCH 1/3] Add swapip read in lookupip()

2019-01-22 Thread k0ga
Lookupip() was already reading rootpath, but it didn't read
the address of the swap server (called rootserver in some
systems). As they are very related it makes sense to read them
at the same time.

This patch also fixes a typo, where vendorclass was used instead of
vendor, resulting that vendor ndb attribute was never used. 

diff -r b1cb12e81f18 sys/src/cmd/ip/dhcpd/ndb.c
--- a/sys/src/cmd/ip/dhcpd/ndb.cSun Jan 20 12:55:31 2019 +0100
+++ b/sys/src/cmd/ip/dhcpd/ndb.cTue Jan 22 18:50:26 2019 +
@@ -116,10 +116,11 @@
*p++ = "@tftp2";
*p++ = "rootpath";
*p++ = "dhcp";
-   *p++ = "vendorclass";
+   *p++ = "vendor";
*p++ = "dom";
*p++ = "@fs";
*p++ = "@auth";
+   *p++ = "@swap";
}
if(hwattr != nil)
*p++ = hwattr;
@@ -153,6 +154,9 @@
if(strcmp(nt->attr, "ipgw") == 0)
setipaddr(iip->gwip, nt->val);
else
+   if(strcmp(nt->attr, "swap") == 0)
+   setipaddr(iip->swapip, nt->val);
+   else
if(strcmp(nt->attr, "dhcp") == 0){
if(iip->dhcpgroup[0] == 0)
strncpy(iip->dhcpgroup, nt->val, 
sizeof(iip->dhcpgroup)-1);




[9fans] [PATCH 3/3] Update ndb(6) and dhcpd(8)

2019-01-22 Thread k0ga


diff -r b1cb12e81f18 sys/man/6/ndb
--- a/sys/man/6/ndb Sun Jan 20 12:55:31 2019 +0100
+++ b/sys/man/6/ndb Tue Jan 22 18:54:46 2019 +
@@ -189,6 +189,12 @@
 .B /386/9bootpxe
 to boot a PC via PXE.
 .TP
+.B vendor
+Specific vendor attribute for dhcp and bootp
+.TP
+.B swap
+used by Unix machines for boot NFS server
+.TP
 .B tftp
 an TFTP server to use for PXE bootstrap
 .TP
diff -r b1cb12e81f18 sys/man/8/dhcpd
--- a/sys/man/8/dhcpd   Sun Jan 20 12:55:31 2019 +0100
+++ b/sys/man/8/dhcpd   Tue Jan 22 18:54:46 2019 +
@@ -162,6 +162,9 @@
 .TP
 .B swap
 used by Unix machines for boot NFS server
+.TP
+.B vendor
+Specific vendor attribute for dhcp and bootp
 .PD
 .PP
 .I Dhcpd




[9fans] [PATCH 1/3] Add swapip read in lookupip()

2019-01-22 Thread k0ga
Lookupip() was already reading rootpath, but it didn't read
the address of the swap server (called rootserver in some
systems). As they are very related it makes sense to read them
at the same time.

This patch also fixes a typo, where vendorclass was used instead of
vendor, resulting that vendor ndb attribute was never used. 

diff -r b1cb12e81f18 sys/src/cmd/ip/dhcpd/ndb.c
--- a/sys/src/cmd/ip/dhcpd/ndb.cSun Jan 20 12:55:31 2019 +0100
+++ b/sys/src/cmd/ip/dhcpd/ndb.cTue Jan 22 18:50:26 2019 +
@@ -116,10 +116,11 @@
*p++ = "@tftp2";
*p++ = "rootpath";
*p++ = "dhcp";
-   *p++ = "vendorclass";
+   *p++ = "vendor";
*p++ = "dom";
*p++ = "@fs";
*p++ = "@auth";
+   *p++ = "@swap";
}
if(hwattr != nil)
*p++ = hwattr;
@@ -153,6 +154,9 @@
if(strcmp(nt->attr, "ipgw") == 0)
setipaddr(iip->gwip, nt->val);
else
+   if(strcmp(nt->attr, "swap") == 0)
+   setipaddr(iip->swapip, nt->val);
+   else
if(strcmp(nt->attr, "dhcp") == 0){
if(iip->dhcpgroup[0] == 0)
strncpy(iip->dhcpgroup, nt->val, 
sizeof(iip->dhcpgroup)-1);




[9fans] [PATCH 2/3] Send vendor ndb attribute if available

2019-01-22 Thread k0ga
At this moment plan9 is using vendorinfo to communicate
some specific plan9 parameters, but there are some boards
that use this attribute to set specific values. This
patch allows netbooting of these boards using ndb attributes
instead of hard coded solutions in dhcpd(1). Vendor attribute
is used for that purpose because it is also used for the
same purpose in bootp.

diff -r b1cb12e81f18 sys/src/cmd/ip/dhcpd/dhcpd.c
--- a/sys/src/cmd/ip/dhcpd/dhcpd.c  Sun Jan 20 12:55:31 2019 +0100
+++ b/sys/src/cmd/ip/dhcpd/dhcpd.c  Tue Jan 22 18:06:01 2019 +
@@ -1277,8 +1277,7 @@
}
 
-   /* add plan9 specific options */
-   if(strncmp((char*)rp->vendorclass, "plan9_", 6) == 0
-   || strncmp((char*)rp->vendorclass, "p9-", 3) == 0){
+   if (*rp->vendorclass != '\0') {
/* point to temporary area */
op = rp->p;
omax = rp->max;
@@ -1286,15 +1285,21 @@
rp->p = vopts;
rp->max = vopts + sizeof(vopts) - 1;
 
-   /* emit old v4 addresses first to make sure that they fit */
-   addrsopt(rp, OP9fsv4, addrs, lookupserver("fs", addrs, 
nelem(addrs), t));
-   addrsopt(rp, OP9authv4, addrs, lookupserver("auth", addrs, 
nelem(addrs), t));
+   if (*rp->ii.vendor != '\0')
+   stringopt(rp, OBvendorinfo, rp->ii.vendor);
 
-   p9addrsopt(rp, OP9fs, addrs, lookupserver("fs", addrs, 
nelem(addrs), t));
-   p9addrsopt(rp, OP9auth, addrs, lookupserver("auth", addrs, 
nelem(addrs), t));
-   p9addrsopt(rp, OP9ipaddr, addrs, lookupserver("ip", addrs, 
nelem(addrs), t));
-   p9addrsopt(rp, OP9ipmask, addrs, lookupserver("ipmask", addrs, 
nelem(addrs), t));
-   p9addrsopt(rp, OP9ipgw, addrs, lookupserver("ipgw", addrs, 
nelem(addrs), t));
+   /* add plan9 specific options */
+   if (strncmp((char*)rp->vendorclass, "p9-", 3) == 0
+   ||  strncmp((char*)rp->vendorclass, "plan9_", 6) == 0){
+   /* emit old v4 addresses first to make sure that they 
fit */
+   addrsopt(rp, OP9fsv4, addrs, lookupserver("fs", addrs, 
nelem(addrs), t));
+   addrsopt(rp, OP9authv4, addrs, lookupserver("auth", 
addrs, nelem(addrs), t));
+
+   p9addrsopt(rp, OP9fs, addrs, lookupserver("fs", addrs, 
nelem(addrs), t));
+   p9addrsopt(rp, OP9auth, addrs, lookupserver("auth", 
addrs, nelem(addrs), t));
+   p9addrsopt(rp, OP9ipaddr, addrs, lookupserver("ip", 
addrs, nelem(addrs), t));
+   p9addrsopt(rp, OP9ipmask, addrs, lookupserver("ipmask", 
addrs, nelem(addrs), t));
+   p9addrsopt(rp, OP9ipgw, addrs, lookupserver("ipgw", 
addrs, nelem(addrs), t));
+   }
 
/* point back to packet, encapsulate vopts into packet */
j = rp->p - vopts;




Re: [9fans] r-pi usbotg error

2015-02-18 Thread k0ga
> I've had mixed results between keyboards. From what I have experienced 
> the keyboards that have usb hubs built into them drop, but the keyboards 
> without hubs (or with the hub wire unplugged) didn't drop connection. ymmv
> On 2/18/15 12:37 PM, Quintile wrote:


I have a similar problem. I have a usb kvm and I share the keyboard and
mouse between a PC and the r-pi. When I switch from the PC to
the r-pi there is usbotg error, but if I swtich again to the PC
and again to the r-pi then it works (it means I have to switch
twice each time I want to use the r-pi).

Regards,




Re: [9fans] atexit() & atexitdont()

2014-11-06 Thread k0ga

> perhaps a linked list would make sense, but atexits(2) doesn't say which order
> the functions will be run in.  and it doesn't seem like a great idea to 
> depend on
> atexits running things in a particular order.

POSIX says they must be called in reverse order.




Re: [9fans] Setting up Mail in Acme on the Raspberry Pi.

2014-10-21 Thread k0ga
Hi,

This is my first post in the list, so it is also my presentation.

> 
> Tried again with different setups in  and I didn't get any
> error messages sometimes but auth/fgui didn't start but it works just
> fine manually. Maybe it's a Raspberry Pi thing.

I am running plan9 in a raspberry and I am writing this mail with
acme. I had a problem while I was configuring the mail system, and
maybe you are having the same problem. The default profile has
something like:

prompt=('cpu% ' '   ')
fn cpu%{ $* }
startupasfs
news
if (! test -e /mnt/term/mnt/wsys) {
# cpu call from drawterm
font=/lib/font/bit/pelm/latin1.8.font
plumber
auth/factotum
exec rio -i riostart
}

You can see that startupasfs is executed before auth/factotum, so
the namespace entries created by factotum are not seen by
startupasfs. I had to change it to:

prompt=('cpu% ' '   ')
fn cpu%{ $* }
if (! test -e /mnt/term/mnt/wsys) { 
# cpu call from drawterm
auth/factotum
plumber
startupasfs
mailstart
news
exec rio -i riostart
}
if not {
startupasfs
news
}

You can see that startupasfs is now called after be sure that there is
a factotum running. Maybe, this was not the problem, but in my
case it began to work after this modification.

Regards,