From f6347b44fcb2d6b17d12f9f7f833cd0b55333b69 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Wed, 12 Sep 2001 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 2001-09-12 --- bitsy/etherwavelan.c | 6 +++++- pc/etherwavelan.c | 12 +++++++++++- port/chan.c | 15 +++++++++++---- port/sysfile.c | 8 +++++++- 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/bitsy/etherwavelan.c b/bitsy/etherwavelan.c index 38ca8d7016de19fcfdb68079217122ae65300385..25433f31dd10b0466abc1f8ab13e7254310be6a5 100644 --- a/bitsy/etherwavelan.c +++ b/bitsy/etherwavelan.c @@ -105,7 +105,6 @@ enum WTyp_NodeName = 0xfc0e, WTyp_Crypt = 0xfc20, WTyp_XClear = 0xfc22, - WTyp_Tick = 0xfce0, WTyp_CreateIBSS = 0xfc81, WTyp_RtsThres = 0xfc83, WTyp_TxRate = 0xfc84, @@ -115,10 +114,12 @@ enum WTyp_Prom = 0xfc85, WTyp_Keys = 0xfcb0, WTyp_TxKey = 0xfcb1, + WTyp_StationID = 0xfd20, WTyp_CurName = 0xfd41, WTyp_BaseID = 0xfd42, // ID of the currently connected-to base station WTyp_CurTxRate = 0xfd44, // Current TX rate WTyp_HasCrypt = 0xfd4f, + WTyp_Tick = 0xfce0, }; // Controller @@ -435,7 +436,10 @@ ltv_outstr(Ctlr* ctlr, int type, char* val) memset(<v, 0, sizeof(ltv)); ltv.len = (sizeof(ltv.type)+sizeof(ltv.slen)+sizeof(ltv.s))/2; ltv.type = type; + +// This should be ltv.slen = len; according to Axel Belinfante ltv.slen = (len+1) & ~1; + strncpy(ltv.s, val, len); w_outltv(ctlr, <v); } diff --git a/pc/etherwavelan.c b/pc/etherwavelan.c index 472b6cfa95880e1dec5df9301587c95530c73a48..d952917396573759280e88aacc38a71bff3b2c08 100644 --- a/pc/etherwavelan.c +++ b/pc/etherwavelan.c @@ -105,7 +105,7 @@ enum WTyp_NodeName = 0xfc0e, WTyp_Crypt = 0xfc20, WTyp_XClear = 0xfc22, - WTyp_Tick = 0xfce0, + WTyp_CreateIBSS = 0xfc81, WTyp_RtsThres = 0xfc83, WTyp_TxRate = 0xfc84, WTx1Mbps = 0x0, @@ -119,6 +119,7 @@ enum WTyp_BaseID = 0xfd42, // ID of the currently connected-to base station WTyp_CurTxRate = 0xfd44, // Current TX rate WTyp_HasCrypt = 0xfd4f, + WTyp_Tick = 0xfce0, }; // Controller @@ -274,6 +275,7 @@ struct Ctlr int attached; int slot; int iob; + int createibss; int ptype; int apdensity; int rtsthres; @@ -541,6 +543,7 @@ w_enable(Ether* ether) ltv_outs(ctlr, WTyp_Tick, 8); ltv_outs(ctlr, WTyp_MaxLen, ctlr->maxlen); ltv_outs(ctlr, WTyp_Ptype, ctlr->ptype); + ltv_outs(ctlr, WTyp_CreateIBSS, ctlr->createibss); ltv_outs(ctlr, WTyp_RtsThres, ctlr->rtsthres); ltv_outs(ctlr, WTyp_TxRate, ctlr->txrate); ltv_outs(ctlr, WTyp_ApDens, ctlr->apdensity); @@ -1050,6 +1053,12 @@ option(Ctlr* ctlr, char* buf, long n) else r = -1; } + else if(cistrcmp(cb->f[0], "ibss") == 0){ + if(cistrcmp(cb->f[1], "on") == 0) + ctlr->createibss = 1; + else + ctlr->createibss = 0; + } else if(cistrcmp(cb->f[0], "crypt") == 0){ if(cistrcmp(cb->f[1], "off") == 0) ctlr->crypt = 0; @@ -1218,6 +1227,7 @@ reset(Ether* ether) ctlr->chan = 0; ctlr->ptype = WDfltPType; ctlr->txkey = 0; + ctlr->createibss = 0; ctlr->keys.len = sizeof(WKey)*WNKeys/2 + 1; ctlr->keys.type = WTyp_Keys; if(ctlr->hascrypt = ltv_ins(ctlr, WTyp_HasCrypt)) diff --git a/port/chan.c b/port/chan.c index 494dcea91509614d5b4f15d02b65c9f36648b598..10489f6c53b6a2f65f1c5d43f23501235011370a 100644 --- a/port/chan.c +++ b/port/chan.c @@ -546,10 +546,17 @@ cunmount(Chan *mnt, Chan *mounted) Mhead *m, **l; Mount *f, **p; -if(mnt->umh) /* should not happen */ - print("cunmount newp extra umh %p has %p\n", mnt, mnt->umh); -if(mounted && mounted->umh) - print("cunmount old extra umh %p has %p\n", mounted, mounted->umh); + if(mnt->umh) /* should not happen */ + print("cunmount newp extra umh %p has %p\n", mnt, mnt->umh); + + /* + * It _can_ happen that mounted->umh is non-nil, + * because mounted is the result of namec(Aopen) + * (see sysfile.c:/^sysunmount). + * If we open a union directory, it will have a umh. + * Although surprising, this is okay, since the + * cclose will take care of freeing the umh. + */ pg = up->pgrp; wlock(&pg->ns); diff --git a/port/sysfile.c b/port/sysfile.c index 50f24da8440298cbab715741f47ad4fc9940750a..e42c607a1183cc73d43b1e8cccfca6cc2c2ef5d7 100644 --- a/port/sysfile.c +++ b/port/sysfile.c @@ -784,7 +784,13 @@ sysunmount(ulong *arg) nexterror(); } validaddr(arg[0], 1, 0); - cmounted = namec((char*)arg[0], Aaccess, OREAD, 0); + /* + * This has to be namec(..., Aopen, ...) because + * if arg[0] is something like /srv/cs or /fd/0, + * opening it is the only way to get at the real + * Chan underneath. + */ + cmounted = namec((char*)arg[0], Aopen, OREAD, 0); poperror(); }