Unified · Split
| @@ -1,3 +1,5 @@ | |||
| 1 | 20090930 | ||
| 2 | emu/*/ipif*.c make "hangup" act as in native Inferno; also delete unused so_setsockopt | ||
| 1 | 20090928 | 3 | 20090928 |
| 2 | update import(4) to remove the restriction to Plan 9 (can use Inferno's own factotum) | 4 | update import(4) to remove the restriction to Plan 9 (can use Inferno's own factotum) |
| 3 | (emu os)^/port/devmnt.c fix from plan 9 (don't access vanished data) | 5 | (emu os)^/port/devmnt.c fix from plan 9 (don't access vanished data) |
| @@ -253,24 +253,6 @@ so_bind(int fd, int su, unsigned long addr, unsigned short port) · 252 unmodified lines | |||
| 253 | oserror(); | 253 | oserror(); |
| 254 | } | 254 | } |
| 255 | 255 | ||
| 256 | void | ||
| 257 | so_setsockopt(int fd, int opt, int value) | ||
| 258 | { | ||
| 259 | int r; | ||
| 260 | struct linger l; | ||
| 261 | |||
| 262 | if(opt == SO_LINGER){ | ||
| 263 | l.l_onoff = 1; | ||
| 264 | l.l_linger = (short) value; | ||
| 265 | osenter(); | ||
| 266 | r = setsockopt(fd, SOL_SOCKET, opt, (char *)&l, sizeof(l)); | ||
| 267 | osleave(); | ||
| 268 | }else | ||
| 269 | error(Ebadctl); | ||
| 270 | if(r < 0) | ||
| 271 | oserror(); | ||
| 272 | } | ||
| 273 | |||
| 274 | int | 256 | int |
| 275 | so_gethostbyname(char *host, char**hostv, int n) | 257 | so_gethostbyname(char *host, char**hostv, int n) |
| 276 | { | 258 | { |
| @@ -334,13 +316,13 @@ so_getservbyname(char *service, char *net, char *port) · 57 unmodified lines | |||
| 334 | } | 316 | } |
| 335 | 317 | ||
| 336 | int | 318 | int |
| 337 | so_hangup(int fd, int linger) | 319 | so_hangup(int fd, int nolinger) |
| 338 | { | 320 | { |
| 339 | int r; | 321 | int r; |
| 340 | static struct linger l = {1, 1000}; | 322 | static struct linger l = {1, 0}; |
| 341 | 323 | ||
| 342 | osenter(); | 324 | osenter(); |
| 343 | if(linger) | 325 | if(nolinger) |
| 344 | setsockopt(fd, SOL_SOCKET, SO_LINGER, (char*)&l, sizeof(l)); | 326 | setsockopt(fd, SOL_SOCKET, SO_LINGER, (char*)&l, sizeof(l)); |
| 345 | r = shutdown(fd, 2); | 327 | r = shutdown(fd, 2); |
| 346 | if(r >= 0) | 328 | if(r >= 0) |
| @@ -253,24 +253,6 @@ so_bind(int fd, int su, unsigned long addr, unsigned short port) · 252 unmodified lines | |||
| 253 | oserror(); | 253 | oserror(); |
| 254 | } | 254 | } |
| 255 | 255 | ||
| 256 | void | ||
| 257 | so_setsockopt(int fd, int opt, int value) | ||
| 258 | { | ||
| 259 | int r; | ||
| 260 | struct linger l; | ||
| 261 | |||
| 262 | if(opt == SO_LINGER){ | ||
| 263 | l.l_onoff = 1; | ||
| 264 | l.l_linger = (short) value; | ||
| 265 | osenter(); | ||
| 266 | r = setsockopt(fd, SOL_SOCKET, opt, (char *)&l, sizeof(l)); | ||
| 267 | osleave(); | ||
| 268 | }else | ||
| 269 | error(Ebadctl); | ||
| 270 | if(r < 0) | ||
| 271 | oserror(); | ||
| 272 | } | ||
| 273 | |||
| 274 | int | 256 | int |
| 275 | so_gethostbyname(char *host, char**hostv, int n) | 257 | so_gethostbyname(char *host, char**hostv, int n) |
| 276 | { | 258 | { |
| @@ -334,13 +316,13 @@ so_getservbyname(char *service, char *net, char *port) · 57 unmodified lines | |||
| 334 | } | 316 | } |
| 335 | 317 | ||
| 336 | int | 318 | int |
| 337 | so_hangup(int fd, int linger) | 319 | so_hangup(int fd, int nolinger) |
| 338 | { | 320 | { |
| 339 | int r; | 321 | int r; |
| 340 | static struct linger l = {1, 1000}; | 322 | static struct linger l = {1, 0}; |
| 341 | 323 | ||
| 342 | osenter(); | 324 | osenter(); |
| 343 | if(linger) | 325 | if(nolinger) |
| 344 | setsockopt(fd, SOL_SOCKET, SO_LINGER, (char*)&l, sizeof(l)); | 326 | setsockopt(fd, SOL_SOCKET, SO_LINGER, (char*)&l, sizeof(l)); |
| 345 | r = shutdown(fd, 2); | 327 | r = shutdown(fd, 2); |
| 346 | if(r >= 0) | 328 | if(r >= 0) |
| @@ -290,24 +290,6 @@ so_bind(int fd, int su, unsigned long addr, unsigned short port) · 289 unmodified lines | |||
| 290 | oserror(); | 290 | oserror(); |
| 291 | } | 291 | } |
| 292 | 292 | ||
| 293 | void | ||
| 294 | so_setsockopt(int fd, int opt, int value) | ||
| 295 | { | ||
| 296 | int r; | ||
| 297 | struct linger l; | ||
| 298 | |||
| 299 | if(opt == SO_LINGER){ | ||
| 300 | l.l_onoff = 1; | ||
| 301 | l.l_linger = (short) value; | ||
| 302 | osenter(); | ||
| 303 | r = setsockopt(fd, SOL_SOCKET, opt, (char *)&l, sizeof(l)); | ||
| 304 | osleave(); | ||
| 305 | }else | ||
| 306 | error(Ebadctl); | ||
| 307 | if(r < 0) | ||
| 308 | oserror(); | ||
| 309 | } | ||
| 310 | |||
| 311 | int | 293 | int |
| 312 | so_gethostbyname(char *host, char**hostv, int n) | 294 | so_gethostbyname(char *host, char**hostv, int n) |
| 313 | { | 295 | { |
| @@ -370,13 +352,13 @@ so_getservbyname(char *service, char *net, char *port) · 56 unmodified lines | |||
| 370 | } | 352 | } |
| 371 | 353 | ||
| 372 | int | 354 | int |
| 373 | so_hangup(int fd, int linger) | 355 | so_hangup(int fd, int nolinger) |
| 374 | { | 356 | { |
| 375 | int r; | 357 | int r; |
| 376 | static struct linger l = {1, 1000}; | 358 | static struct linger l = {1, 0}; |
| 377 | 359 | ||
| 378 | osenter(); | 360 | osenter(); |
| 379 | if(linger) | 361 | if(nolinger) |
| 380 | setsockopt(fd, SOL_SOCKET, SO_LINGER, (char*)&l, sizeof(l)); | 362 | setsockopt(fd, SOL_SOCKET, SO_LINGER, (char*)&l, sizeof(l)); |
| 381 | r = closesocket(fd); | 363 | r = closesocket(fd); |
| 382 | osleave(); | 364 | osleave(); |
| @@ -253,24 +253,6 @@ so_bind(int fd, int su, unsigned long addr, unsigned short port) · 252 unmodified lines | |||
| 253 | oserror(); | 253 | oserror(); |
| 254 | } | 254 | } |
| 255 | 255 | ||
| 256 | void | ||
| 257 | so_setsockopt(int fd, int opt, int value) | ||
| 258 | { | ||
| 259 | int r; | ||
| 260 | struct linger l; | ||
| 261 | |||
| 262 | if(opt == SO_LINGER){ | ||
| 263 | l.l_onoff = 1; | ||
| 264 | l.l_linger = (short) value; | ||
| 265 | osenter(); | ||
| 266 | r = setsockopt(fd, SOL_SOCKET, opt, (char *)&l, sizeof(l)); | ||
| 267 | osleave(); | ||
| 268 | }else | ||
| 269 | error(Ebadctl); | ||
| 270 | if(r < 0) | ||
| 271 | oserror(); | ||
| 272 | } | ||
| 273 | |||
| 274 | int | 256 | int |
| 275 | so_gethostbyname(char *host, char**hostv, int n) | 257 | so_gethostbyname(char *host, char**hostv, int n) |
| 276 | { | 258 | { |
| @@ -334,13 +316,13 @@ so_getservbyname(char *service, char *net, char *port) · 57 unmodified lines | |||
| 334 | } | 316 | } |
| 335 | 317 | ||
| 336 | int | 318 | int |
| 337 | so_hangup(int fd, int linger) | 319 | so_hangup(int fd, int nolinger) |
| 338 | { | 320 | { |
| 339 | int r; | 321 | int r; |
| 340 | static struct linger l = {1, 1000}; | 322 | static struct linger l = {1, 0}; |
| 341 | 323 | ||
| 342 | osenter(); | 324 | osenter(); |
| 343 | if(linger) | 325 | if(nolinger) |
| 344 | setsockopt(fd, SOL_SOCKET, SO_LINGER, (char*)&l, sizeof(l)); | 326 | setsockopt(fd, SOL_SOCKET, SO_LINGER, (char*)&l, sizeof(l)); |
| 345 | r = shutdown(fd, 2); | 327 | r = shutdown(fd, 2); |
| 346 | if(r >= 0) | 328 | if(r >= 0) |
| @@ -148,7 +148,7 @@ ip3gen(Chan *c, int i, Dir *dp) · 147 unmodified lines | |||
| 148 | Conv *cv; | 148 | Conv *cv; |
| 149 | char *p; | 149 | char *p; |
| 150 | 150 | ||
| 151 | cv = ipfs[c->dev]->p[PROTO(c->qid)]->conv[CONV(c->qid)]; | 151 | cv = ipfs[c->devno]->p[PROTO(c->qid)]->conv[CONV(c->qid)]; |
| 152 | if(cv->owner == nil) | 152 | if(cv->owner == nil) |
| 153 | kstrdup(&cv->owner, eve); | 153 | kstrdup(&cv->owner, eve); |
| 154 | mkqid(&q, QID(PROTO(c->qid), CONV(c->qid), i), 0, QTFILE); | 154 | mkqid(&q, QID(PROTO(c->qid), CONV(c->qid), i), 0, QTFILE); |
| @@ -207,7 +207,7 @@ ip1gen(Chan *c, int i, Dir *dp) · 52 unmodified lines | |||
| 207 | Fs *f; | 207 | Fs *f; |
| 208 | extern ulong kerndate; | 208 | extern ulong kerndate; |
| 209 | 209 | ||
| 210 | f = ipfs[c->dev]; | 210 | f = ipfs[c->devno]; |
| 211 | 211 | ||
| 212 | prot = 0664; | 212 | prot = 0664; |
| 213 | mkqid(&q, QID(0, 0, i), 0, QTFILE); | 213 | mkqid(&q, QID(0, 0, i), 0, QTFILE); |
| @@ -219,7 +219,7 @@ ip1gen(Chan *c, int i, Dir *dp) · 5 unmodified lines | |||
| 219 | break; | 219 | break; |
| 220 | case Qndb: | 220 | case Qndb: |
| 221 | p = "ndb"; | 221 | p = "ndb"; |
| 222 | len = strlen(ipfs[c->dev]->ndb); | 222 | len = strlen(ipfs[c->devno]->ndb); |
| 223 | break; | 223 | break; |
| 224 | /* case Qiproute: | 224 | /* case Qiproute: |
| 225 | p = "iproute"; | 225 | p = "iproute"; |
| @@ -252,13 +252,13 @@ ipgen(Chan *c, char *name, Dirtab *tab, int x, int s, Dir *dp) · 26 unmodified lines | |||
| 252 | USED(name); | 252 | USED(name); |
| 253 | USED(tab); | 253 | USED(tab); |
| 254 | USED(x); | 254 | USED(x); |
| 255 | f = ipfs[c->dev]; | 255 | f = ipfs[c->devno]; |
| 256 | 256 | ||
| 257 | switch(TYPE(c->qid)) { | 257 | switch(TYPE(c->qid)) { |
| 258 | case Qtopdir: | 258 | case Qtopdir: |
| 259 | if(s == DEVDOTDOT){ | 259 | if(s == DEVDOTDOT){ |
| 260 | mkqid(&q, QID(0, 0, Qtopdir), 0, QTDIR); | 260 | mkqid(&q, QID(0, 0, Qtopdir), 0, QTDIR); |
| 261 | sprint(up->genbuf, "#I%lud", c->dev); | 261 | sprint(up->genbuf, "#I%ud", c->devno); |
| 262 | devdir(c, q, up->genbuf, 0, network, 0555, dp); | 262 | devdir(c, q, up->genbuf, 0, network, 0555, dp); |
| 263 | return 1; | 263 | return 1; |
| 264 | } | 264 | } |
| @@ -280,7 +280,7 @@ ipgen(Chan *c, char *name, Dirtab *tab, int x, int s, Dir *dp) · 15 unmodified lines | |||
| 280 | case Qprotodir: | 280 | case Qprotodir: |
| 281 | if(s == DEVDOTDOT){ | 281 | if(s == DEVDOTDOT){ |
| 282 | mkqid(&q, QID(0, 0, Qtopdir), 0, QTDIR); | 282 | mkqid(&q, QID(0, 0, Qtopdir), 0, QTDIR); |
| 283 | sprint(up->genbuf, "#I%lud", c->dev); | 283 | sprint(up->genbuf, "#I%ud", c->devno); |
| 284 | devdir(c, q, up->genbuf, 0, network, 0555, dp); | 284 | devdir(c, q, up->genbuf, 0, network, 0555, dp); |
| 285 | return 1; | 285 | return 1; |
| 286 | } | 286 | } |
| @@ -356,7 +356,7 @@ ipattach(char *spec) · 69 unmodified lines | |||
| 356 | 356 | ||
| 357 | c = devattach('I', spec); | 357 | c = devattach('I', spec); |
| 358 | mkqid(&c->qid, QID(0, 0, Qtopdir), 0, QTDIR); | 358 | mkqid(&c->qid, QID(0, 0, Qtopdir), 0, QTDIR); |
| 359 | c->dev = 0; | 359 | c->devno = 0; |
| 360 | 360 | ||
| 361 | return c; | 361 | return c; |
| 362 | } | 362 | } |
| @@ -391,7 +391,7 @@ ipopen(Chan *c, int omode) · 28 unmodified lines | |||
| 391 | 391 | ||
| 392 | perm = m2p[omode&3]; | 392 | perm = m2p[omode&3]; |
| 393 | 393 | ||
| 394 | f = ipfs[c->dev]; | 394 | f = ipfs[c->devno]; |
| 395 | 395 | ||
| 396 | switch(TYPE(c->qid)) { | 396 | switch(TYPE(c->qid)) { |
| 397 | default: | 397 | default: |
| @@ -526,7 +526,7 @@ ipclose(Chan *c) · 128 unmodified lines | |||
| 526 | { | 526 | { |
| 527 | Fs *f; | 527 | Fs *f; |
| 528 | 528 | ||
| 529 | f = ipfs[c->dev]; | 529 | f = ipfs[c->devno]; |
| 530 | switch(TYPE(c->qid)) { | 530 | switch(TYPE(c->qid)) { |
| 531 | case Qdata: | 531 | case Qdata: |
| 532 | case Qctl: | 532 | case Qctl: |
| @@ -546,7 +546,7 @@ ipread(Chan *ch, void *a, long n, vlong off) · 13 unmodified lines | |||
| 546 | Fs *f; | 546 | Fs *f; |
| 547 | ulong offset = off; | 547 | ulong offset = off; |
| 548 | 548 | ||
| 549 | f = ipfs[ch->dev]; | 549 | f = ipfs[ch->devno]; |
| 550 | 550 | ||
| 551 | p = a; | 551 | p = a; |
| 552 | switch(TYPE(ch->qid)) { | 552 | switch(TYPE(ch->qid)) { |
| @@ -816,7 +816,7 @@ ipwrite(Chan *ch, void *a, long n, vlong off) · 263 unmodified lines | |||
| 816 | Cmdbuf *cb; | 816 | Cmdbuf *cb; |
| 817 | Fs *f; | 817 | Fs *f; |
| 818 | 818 | ||
| 819 | f = ipfs[ch->dev]; | 819 | f = ipfs[ch->devno]; |
| 820 | 820 | ||
| 821 | switch(TYPE(ch->qid)) { | 821 | switch(TYPE(ch->qid)) { |
| 822 | default: | 822 | default: |
| @@ -932,7 +932,7 @@ ipwstat(Chan *c, uchar *dp, int n) · 109 unmodified lines | |||
| 932 | Proto *p; | 932 | Proto *p; |
| 933 | Fs *f; | 933 | Fs *f; |
| 934 | 934 | ||
| 935 | f = ipfs[c->dev]; | 935 | f = ipfs[c->devno]; |
| 936 | switch(TYPE(c->qid)) { | 936 | switch(TYPE(c->qid)) { |
| 937 | default: | 937 | default: |
| 938 | error(Eperm); | 938 | error(Eperm); |
| @@ -1071,7 +1071,9 @@ Dev ipdevtab = { · 132 unmodified lines | |||
| 1071 | 'I', | 1071 | 'I', |
| 1072 | "ip", | 1072 | "ip", |
| 1073 | 1073 | ||
| 1074 | devreset, | ||
| 1074 | ipinit, | 1075 | ipinit, |
| 1076 | devshutdown, | ||
| 1075 | ipattach, | 1077 | ipattach, |
| 1076 | ipwalk, | 1078 | ipwalk, |
| 1077 | ipstat, | 1079 | ipstat, |
| @@ -261,24 +261,6 @@ so_bind(int fd, int su, unsigned long addr, unsigned short port) · 260 unmodified lines | |||
| 261 | oserror(); | 261 | oserror(); |
| 262 | } | 262 | } |
| 263 | 263 | ||
| 264 | void | ||
| 265 | so_setsockopt(int fd, int opt, int value) | ||
| 266 | { | ||
| 267 | int r; | ||
| 268 | struct linger l; | ||
| 269 | |||
| 270 | if(opt == SO_LINGER){ | ||
| 271 | l.l_onoff = 1; | ||
| 272 | l.l_linger = (short) value; | ||
| 273 | osenter(); | ||
| 274 | r = setsockopt(fd, SOL_SOCKET, opt, (char *)&l, sizeof(l)); | ||
| 275 | osleave(); | ||
| 276 | }else | ||
| 277 | error(Ebadctl); | ||
| 278 | if(r < 0) | ||
| 279 | oserror(); | ||
| 280 | } | ||
| 281 | |||
| 282 | int | 264 | int |
| 283 | so_gethostbyname(char *host, char**hostv, int n) | 265 | so_gethostbyname(char *host, char**hostv, int n) |
| 284 | { | 266 | { |
| @@ -341,13 +323,13 @@ so_getservbyname(char *service, char *net, char *port) · 56 unmodified lines | |||
| 341 | } | 323 | } |
| 342 | 324 | ||
| 343 | int | 325 | int |
| 344 | so_hangup(int fd, int linger) | 326 | so_hangup(int fd, int nolinger) |
| 345 | { | 327 | { |
| 346 | int r; | 328 | int r; |
| 347 | static struct linger l = {1, 1000}; | 329 | static struct linger l = {1, 0}; |
| 348 | 330 | ||
| 349 | osenter(); | 331 | osenter(); |
| 350 | if(linger) | 332 | if(nolinger) |
| 351 | setsockopt(fd, SOL_SOCKET, SO_LINGER, (char*)&l, sizeof(l)); | 333 | setsockopt(fd, SOL_SOCKET, SO_LINGER, (char*)&l, sizeof(l)); |
| 352 | r = shutdown(fd, 2); | 334 | r = shutdown(fd, 2); |
| 353 | if(r >= 0) | 335 | if(r >= 0) |
| @@ -1 +1 @@ | |||
| 1 | #define VERSION "Fourth Edition (20090928)" | 1 | #define VERSION "Fourth Edition (20090930)" |