Lines Matching defs:fs
62 register Fs_t* fs;
72 for (fs = state.fs; fs < state.fs + elementsof(state.fs); fs++)
73 if (!(fs->flags & (FS_ERROR|FS_INIT)) && (fs->flags & (FS_BOUND|FS_OPEN)) && (!x || x == fs->key))
77 if (fs->flags & FS_BOUND) n = sfsprintf(buf, 0, "%-*s", fs->servicesize ? fs->servicesize : strlen(fs->service), fs->service);
79 n += sfsprintf(buf + n, 0, " /#%s/%s", gs->special, fs->special);
82 if (fs->ack)
85 n += msggetmask(buf + n, SHRT_MAX, fs->ack);
87 if (fs->call != ~0)
90 n += msggetmask(buf + n, SHRT_MAX, fs->call);
92 if (fs->flags & FS_CLOSE)
94 if (fs->flags & FS_FLUSH)
96 if (fs->flags & FS_GLOBAL)
99 if (!(fs->flags & FS_ACTIVE))
101 if (mp->fs == fs && mp->channel && mp->channel != -1)
107 if (fs->flags & FS_INTERACTIVE)
109 if (fs->match)
110 n += sfsprintf(buf + n, 0, "/match=%-*s", fs->matchsize ? fs->matchsize : strlen(fs->match), fs->match);
111 if (fs->flags & FS_MONITOR)
113 if (fs->flags & FS_NAME)
115 if (!(fs->flags & FS_ON))
117 if (fs->flags & FS_RECEIVE)
119 if (fs->flags & FS_REGULAR)
121 if (fs->retry)
122 n += sfsprintf(buf + n, 0, "/retry=%d", fs->retry);
123 if (fs->terse)
126 n += msggetmask(buf + n, SHRT_MAX, fs->terse);
128 if (fs->flags & FS_UNIQUE)
130 if (fs->flags & FS_WRITE)
132 n += getattr(fs->attr, buf + n);
134 if ((flags & (MAP_EXEC|MAP_INIT)) && (fs->flags & FS_OPEN))
136 if (!(fs->flags & FS_CLOSE))
138 if (fs->fd >= RESERVED_FD)
139 n += sfsprintf(buf + n, 0, "/fd=%d", fs->fd);
141 else if ((flags & MAP_EXEC) && !(fs->flags & FS_BOUND))
144 if (n > m || (fs->flags & FS_BOUND))
151 else n = ((fs->flags & FS_BOUND) ? (fs->servicesize ? fs->servicesize : strlen(fs->service)) : 0) +
153 fs->specialsize +
155 (fs->ack ? (msggetmask(NiL, 0, fs->ack) + 6) : 0) +
156 (fs->call != ~0 ? (msggetmask(NiL, 0, fs->call) + 6) : 0) +
157 ((fs->flags & FS_CLOSE) ? 6 : 0) +
158 ((fs->flags & FS_FLUSH) ? 6 : 0) +
159 ((fs->flags & FS_GLOBAL) ? ((fs->flags & (FS_ACTIVE|FS_CLOSE)) ? 7 : 22) : 0) +
160 ((fs->flags & FS_INTERACTIVE) ? 11 : 0) +
161 (fs->match ? ((fs->matchsize ? fs->matchsize : strlen(fs->match)) + 7) : 0) +
162 ((fs->flags & FS_MONITOR) ? 0 : 8) +
163 ((fs->flags & FS_NAME) ? 5 : 0) +
164 ((fs->flags & FS_ON) ? 0 : 3) +
165 ((fs->flags & FS_RECEIVE) ? 0 : 8) +
166 ((fs->flags & FS_REGULAR) ? 0 : 8) +
167 (fs->retry ? 12 : 0) +
168 (fs->terse ? (msggetmask(NiL, 0, fs->terse) + 8) : 0) +
169 ((fs->flags & FS_UNIQUE) ? 0 : 7) +
170 ((fs->flags & FS_WRITE) ? 0 : 6) +
171 getattr(fs->attr, NiL) +
173 ((flags & (MAP_EXEC|MAP_INIT)) && (fs->flags & (FS_CLOSE|FS_OPEN)) == FS_OPEN ? 10 : 0) +
178 state.visit.fs = fs;
185 state.visit.fs = 0;
215 set_fs(register Fs_t* fs, const char* arg, int argsize, const char* op, int opsize)
235 for (ff = 0, fs = state.fs; fs < state.fs + elementsof(state.fs); fs++)
236 if ((fs->flags & (FS_BOUND|FS_INTERNAL)) && fs->key == x) break;
237 else if (!ff && !fs->flags) ff = fs;
238 if (fs >= state.fs + elementsof(state.fs))
241 if (!(fs = ff)) return(-1);
242 fs->specialsize = state.key.next ? (state.key.next - (char*)op - 1) : opsize ? opsize : strlen(op);
243 if (fs->specialsize >= elementsof(fs->special))
244 fs->specialsize = elementsof(fs->special) - 1;
245 strncpy(fs->special, op, fs->specialsize);
246 fs->special[fs->specialsize] = 0;
247 fs->key = x;
248 fs->call = ~0;
253 fsdrop(fs, 1);
260 if (!fs->service || (fs->servicesize ? fs->servicesize : strlen(fs->service)) != n || strncmp(arg, fs->service, n))
262 fsdrop(fs, 1);
263 if (fs->servicesize = argsize) fs->service = (char*)arg;
264 else fs->service = strcpy(newof(0, char, n, 1), arg);
265 fs->flags |= FS_BOUND|FS_ON;
266 if (!(fs->flags & FS_INTERNAL)) fs->flags |= FS_FS;
267 if (fs == &state.fs[FS_safe] && !(fs->flags & FS_INIT))
268 state.safe = fs;
275 fsdrop(fs, 0);
276 if ((fs->fd = strtol(state.key.value, NiL, 0)) > 0)
277 fsinit(fs, fs->fd);
280 if (state.key.invert) fs->flags |= FS_ON;
281 else fs->flags &= ~FS_ON;
284 if (state.key.invert) fs->flags &= ~FS_ON;
285 else fs->flags |= FS_ON;
289 fs->ack = getmsgmask(oe);
292 if (!(fs->flags & FS_INTERNAL))
294 if (state.key.invert) fs->flags &= ~FS_ACTIVE;
295 else fs->flags |= FS_ACTIVE;
299 fs->call = getmsgmask(oe);
302 if (!(fs->flags & FS_INTERNAL))
304 if (state.key.invert) fs->flags &= ~FS_CLOSE;
305 else fs->flags |= FS_CLOSE;
309 if (state.key.invert) fs->flags &= ~FS_FLUSH;
310 else fs->flags |= FS_FLUSH;
313 if (!(fs->flags & FS_INTERNAL))
315 if (state.key.invert) fs->flags &= ~FS_FORK;
316 else fs->flags |= FS_FORK;
320 if (state.key.invert) fs->flags &= ~FS_GLOBAL;
321 else fs->flags |= FS_GLOBAL;
322 for (mp = state.global, pm = 0; mp && mp->fs != fs; pm = mp, mp = mp->global);
327 for (mp = state.mount; mp < state.mount + elementsof(state.mount) && mp->fs; mp++);
330 mp->fs = fs;
347 mp->fs = 0;
354 if (state.key.invert) fs->flags &= ~FS_INTERACTIVE;
355 else fs->flags |= FS_INTERACTIVE;
358 if (!(fs->flags & (FS_INTERNAL|FS_LOAD)) && fs->service)
364 if ((dll = dlopen(fs->service, RTLD_LAZY)) && (set = (Fs_set_t)dlsym(dll, "set")))
366 fs->flags |= FS_LOAD|FS_INIT|FS_ON;
367 fs->set = set;
368 (*fs->set)(fs, state.null, 0, "init", 4);
370 fs->get = get;
375 if (fs->match)
377 if (fs->matchsize) fs->matchsize = 0;
378 else free(fs->match);
379 fs->match = 0;
385 fs->match = state.key.value;
386 fs->matchsize = state.key.valsize;
388 else fs->match = strcpy(newof(0, char, state.key.valsize, 1), state.key.value);
392 if (!(fs->flags & FS_INTERNAL))
394 if (state.key.invert) fs->flags &= ~FS_MONITOR;
395 else fs->flags |= FS_MONITOR;
399 if (!(fs->flags & FS_INTERNAL))
401 if (state.key.invert) fs->flags &= ~FS_NAME;
402 else fs->flags |= FS_NAME;
406 if (!(fs->flags & FS_INTERNAL))
408 if (state.key.invert) fs->flags &= ~FS_RECEIVE;
409 else fs->flags |= FS_RECEIVE;
413 if (state.key.invert) fs->flags &= ~FS_REGULAR;
414 else fs->flags |= FS_REGULAR;
417 fs->retry = strtol(state.key.value, NiL, 0);
420 fs->terse = getmsgmask(oe);
423 if (state.key.invert) fs->flags &= ~FS_UNIQUE;
424 else fs->flags |= FS_UNIQUE;
427 if (state.key.invert) fs->flags &= ~FS_WRITE;
428 else fs->flags |= FS_WRITE;
431 setattr(fs->attr, op, oe);
438 if ((fs->flags & (FS_ACTIVE|FS_MONITOR)) == FS_ACTIVE)
439 fs->call |= MSG_MASK(MSG_fork);
440 if (fs->flags & FS_NAME) state.call.name++;
448 get_map(Fs_t* fs, register char* buf, const char* op, int flags)
453 state.visit.prefix = fs->special;
454 state.visit.prelen = fs->specialsize + 4;
462 set_map(Fs_t* fs, const char* arg, int argsize, const char* op, int opsize)
464 NoP(fs);
469 get_safe(Fs_t* fs, register char* buf, const char* op, int flags)
474 state.visit.prefix = fs->special;
475 state.visit.prelen = fs->specialsize + 4;
483 set_safe(Fs_t* fs, const char* arg, int argsize, const char* op, int opsize)
485 NoP(fs);
490 get_intercept(Fs_t* fs, register char* buf, const char* op, int flags)
496 state.visit.prefix = fs->special;
497 state.visit.prelen = fs->specialsize + 4;
507 set_intercept(Fs_t* fs, const char* arg, int argsize, const char* op, int opsize)
515 NoP(fs);
566 get_option(register Fs_t* fs, register char* buf, const char* op, int flags)
586 n = sfsprintf(buf, 0, "- /#%s/version=%d ", fs->special, TABLE_VERSION);
589 else n = fs->specialsize + 18;
597 if (!x && (fs->flags & FS_BOUND))
601 n = sfsprintf(buf, 0, "%-*s /#%s/%s ", fs->servicesize ? fs->servicesize : strlen(fs->service), fs->service, state.fs[FS_fs].special, fs->special);
604 else n = (fs->servicesize ? fs->servicesize : strlen(fs->service)) + state.fs[FS_fs].specialsize + fs->specialsize + 4;
616 n = sfsprintf(buf, 0, "- /#%s/test=0%lo ", fs->special, state.test);
619 else n = fs->specialsize + 23;
631 n = sfsprintf(buf, 0, "- /#%s/%sboundary ", fs->special, state.boundary ? state.null : "no");
634 else n = fs->specialsize + 16;
647 n = sfsprintf(buf, 0, "- /#%s/debug=%d ", fs->special, -error_info.trace);
650 else n = fs->specialsize + 18;
663 n = sfsprintf(buf, 0, "- /#%s/license=%s ", fs->special, state.license);
666 else n = fs->specialsize + strlen(state.license) + 14;
678 n = (state.limit == TABSIZE) ? sfsprintf(buf, 0, "- /#%s/%cd ", fs->special, state.in_2d ? '2' : '3') : sfsprintf(buf, 0, "- /#%s/2d=%d ", fs->special, state.limit);
681 else n = fs->specialsize + (state.limit == TABSIZE) ? 8 : 11;
720 n = sfsprintf(buf, 0, "- /#%s/file=%s ", fs->special, b);
723 else n += fs->specialsize + 11;
758 n = sfsprintf(buf, 0, "- /#%s/table=%d ", fs->special, n);
762 else n = fs->specialsize + 18;
774 n = sfsprintf(buf, 0, "- /#%s/%scount ", fs->special, state.trace.count ? state.null : "no");
777 else n = fs->specialsize + 13;
789 n = sfsprintf(buf, 0, "- /#%s/trace=%u ", fs->special, state.trace.pid + ((flags & (MAP_EXEC|MAP_INIT)) && state.trace.pid <= 2));
792 else n = fs->specialsize + 18;
804 n = sfsprintf(buf, 0, "- /#%s/call=", fs->special);
809 else n = fs->specialsize + msggetmask(NiL, 0, state.trace.call) + 12;
823 n = sfsprintf(buf, 0, "- /#%s/timeout=%d ", fs->special, msg_info.timeout);
826 else n = fs->specialsize + 20;
879 register Fs_t* fs;
886 if ((on = fsfd(&state.fs[FS_option])) <= 0) return;
961 for (fs = state.fs; fs < state.fs + elementsof(state.fs); fs++)
962 if (fs->flags)
964 if ((n = fs - state.fs) < 10) n += '0';
966 bprintf(&b, e, " [%c] %-*s", n, sizeof(fs->special), fs->special);
967 if (fs->flags & FS_BOUND) bprintf(&b, e, " service=%-*s", fs->servicesize ? fs->servicesize : strlen(fs->service), fs->service);
968 if (fs->flags & FS_ACTIVE) bprintf(&b, e, " active");
969 if (fs->flags & FS_CLOSE) bprintf(&b, e, " close");
970 if (fs->flags & FS_ERROR) bprintf(&b, e, " error");
971 if (fs->flags & FS_FLUSH) bprintf(&b, e, " flush");
972 if (fs->flags & FS_FORK) bprintf(&b, e, " fork");
973 if (fs->flags & FS_FS) bprintf(&b, e, " fs");
974 if (fs->flags & FS_GLOBAL) bprintf(&b, e, " global");
975 if (fs->flags & FS_INIT) bprintf(&b, e, " init");
976 if (fs->flags & FS_INTERACTIVE) bprintf(&b, e, " interactive");
977 if (fs->flags & FS_INTERNAL) bprintf(&b, e, " internal");
979 if (fs->flags & FS_LICENSED) bprintf(&b, e, " licensed");
981 if (fs->flags & FS_LOAD) bprintf(&b, e, " load");
982 if (fs->flags & FS_LOCK) bprintf(&b, e, " lock");
983 if (fs->flags & FS_MAGIC) bprintf(&b, e, " magic");
984 if (fs->flags & FS_MONITOR) bprintf(&b, e, " monitor");
985 if (fs->flags & FS_NAME) bprintf(&b, e, " name");
986 if (!(fs->flags & FS_ON)) bprintf(&b, e, " off");
987 if (fs->flags & FS_OPEN) bprintf(&b, e, " open=%d", fs->fd);
988 if (fs->flags & FS_RAW) bprintf(&b, e, " raw");
989 if (fs->flags & FS_RECEIVE) bprintf(&b, e, " receive");
990 if (fs->flags & FS_REFERENCED) bprintf(&b, e, " referenced");
991 if (fs->flags & FS_REGULAR) bprintf(&b, e, " regular");
992 if (fs->flags & FS_UNIQUE) bprintf(&b, e, " unique");
993 if (fs->flags & FS_VALIDATED) bprintf(&b, e, " validated");
994 if (fs->flags & FS_WRITE) bprintf(&b, e, " write");
995 if (fs->call != ~0)
998 b += msggetmask(b, e - b, fs->call);
1000 if (fs->ack)
1003 b += msggetmask(b, e - b, fs->ack);
1005 if (fs->terse)
1008 b += msggetmask(b, e - b, fs->terse);
1010 bprintf(&b, e, "%s", fs->attr);
1018 if (mp->fs)
1022 bprintf(&b, e, " [%c] %-*s", n, sizeof(mp->fs->special), mp->fs->special);
1024 else if (mp->fs->flags & FS_GLOBAL) bprintf(&b, e, " global");
1042 bprintf(&b, e, " mount=%s[%c]", mp->fs->special, n);
1068 set_option(Fs_t* fs, const char* arg, int argsize, const char* op, int opsize)
1206 if (!(fs->flags & FS_OPEN) && !FSTAT(2, &fs->st))
1208 fs->flags |= FS_OPEN;
1209 fs->fd = 2;
1226 error(0, "getmount: %s: %s + %s", state.path.name, mp->fs->special, *arg ? arg : state.dot);
1263 if (state.fs[FS_option].fd == 2 && (i = FCNTL(2, F_DUPFD, RESERVED_FD)) >= 0)
1265 state.fs[FS_option].fd = i;
1266 reserve(&state.fs[FS_option].fd);
1279 get_pwd(register Fs_t* fs, register char* buf, const char* op, int flags)
1287 if (buf) n = sfsprintf(buf, 0, "%s /#%s ", state.pwd, fs->special);
1288 else n = state.pwdsize + fs->specialsize + 4;
1337 set_pwd(Fs_t* fs, const char* arg, int argsize, const char* op, int opsize)
1342 NoP(fs);
1360 get_view(Fs_t* fs, register char* buf, const char* op, int flags)
1362 NoP(fs);
1368 set_view(Fs_t* fs, const char* arg, int argsize, const char* op, int opsize)
1370 NoP(fs);
1417 FSINIT("fs", get_fs, set_fs, 0,
1539 Fs_t* fs;
1571 state.fs[FS_safe].flags |= FS_INIT;
1572 for (fs = state.fs; fs < state.fs + elementsof(state.fs) && fs->specialsize; fs++)
1574 fs->flags |= FS_ON;
1575 if (fs->set) (*fs->set)(fs, state.null, 0, "init", 4);
1696 if (state.fs[FS_safe].flags & FS_BOUND)
1698 state.safe = &state.fs[FS_safe];
1711 state.fs[FS_safe].flags &= ~FS_INIT;