Lines Matching refs:fs

25  * 3d mounted fs support
41 * initialize mount channel and return fs fd for mp
47 register Fs_t* fs;
52 fs = mp->fs;
53 if (mp->channel && fs->fd)
54 return fs->fd;
55 if ((fd = fsfd(fs)) <= 0)
58 return fs->fd;
79 if (!(np = getmount(MNTNAM, NiL)) || (nd = fsfd(np->fs)) < 0)
81 else if (!(np->fs->flags & FS_LOCK) && WRITE(nd, MNTFD, sizeof(MNTFD) - 1) == sizeof(MNTFD) - 1)
83 np->fs->flags |= FS_LOCK;
86 np->fs->flags &= ~FS_LOCK;
92 message((-3, "fs: phony: %s", buf));
108 register Fs_t* fs = mp->fs;
118 n = sfsprintf(s, sizeof(dev) - 1, "%s %-*s %s%s%-*s pwd=%s%s%s", msgname(call), lz, mp->logical, up, pz ? " physical=" : "", pz, mp->physical ? mp->physical : "", state.pwd, mp->fs->attr, mp->attr);
120 message((-2, "fs: %s: real: service=%-*s request=\"%s\"", fs->special, fs->servicesize, fs->service, s));
122 if ((fd = fsfd(fs)) <= 0)
127 fsdrop(fs, 0);
135 message((-2, "fs: %s: real: %s", fs->special, s + 2));
138 message((-2, "fs: %s: real: path=%s", fs->special, s));
143 * do fs call
152 register Fs_t* fs;
196 fs = mp->fs;
197 if ((!(fs->flags & FS_REGULAR) || (fp->flags & FILE_REGULAR)) && (!(fs->flags & FS_WRITE) || (fp->flags & FILE_WRITE)) && ((mp->flags & MOUNT_PRIMARY) || fd > 2) && !(fp->open & (1<<(mp-state.mount))))
213 if (!mp || ((fs = mp->fs)->flags & n) != FS_ON)
215 if (fs->flags & FS_MONITOR)
217 if (!state.kernel && (fs->call & MSG_MASK(call)))
219 if (sp && fs->match)
221 if (fs->matchsize)
223 cd = fs->match[fs->matchsize];
224 fs->match[fs->matchsize] = 0;
226 if (strmatch(sp, fs->match))
228 if (fs->matchsize)
229 fs->match[fs->matchsize] = cd;
236 else if (((fs = mp->fs)->flags & (FS_ERROR|FS_INIT|FS_LOCK|FS_ON)) != FS_ON)
238 if (!(fs->call & MSG_MASK(call)))
240 if (fs->flags & FS_MONITOR)
256 if ((fs->flags & FS_REGULAR) && !(fp->flags & FILE_REGULAR) || (fs->flags & FS_WRITE) && !(fp->flags & FILE_WRITE))
265 if (fs->flags & FS_WRITE)
290 fs->flags |= FS_LOCK;
297 message((-3, "fs: %s: open: path=%s", fs->special, sp));
298 if (fs == &state.fs[FS_fd])
328 else if ((sp = (const char*)fsreal(mp, MSG_open, up)) && (fd = fsfd(mp->fs)) > 0)
380 if (fs->flags & FS_NAME)
382 if (up && fs != &state.fs[FS_fd])
391 message((-3, "fs: %s: %s: call", fs->special, msgname(call)));
392 fs->flags |= FS_LOCK;
393 if (fs->terse & MSG_MASK(call))
404 if (!(fs->flags & FS_MONITOR)) break;
416 if (fs->flags & FS_ACTIVE)
418 if (!(fs->flags & FS_MONITOR))
420 else if (fs->ack & MSG_MASK(call))
421 call |= (fs->flags & FS_INTERACTIVE) ? MSG_RETURN : MSG_ACK;
422 retry = fs->retry;
425 if ((fs->flags & FS_FLUSH) && (call |= MSG_FLUSH) || retry)
432 message((-2, "fs: %s: %s: connect error on try %d", fs->special, msgname(call), tries));
441 if (!(fs->flags & FS_MONITOR))
449 if (!(fs->flags & FS_MONITOR))
486 if (!(fs->flags & FS_MONITOR))
490 message((-2, "fs: %s: %s: error on try %d", fs->special, msgname(call), tries));
493 fsdrop(fs, 0);
495 if ((fs->flags & FS_FLUSH) || retry)
497 if (fs->flags & FS_ACTIVE)
499 if ((state.ret = n) > 0 && (fs->flags & (FS_ACTIVE|FS_INTERACTIVE|FS_MONITOR)) == (FS_ACTIVE|FS_INTERACTIVE|FS_MONITOR) && (fs->ack & MSG_MASK(call)))
508 else message((-3, "fs: %s: %s: interactive ack failed", fs->special, msgname(call)));
511 else if (!(fs->flags & FS_MONITOR))
514 message((-3, "fs: %s: %s: return: passive fs", fs->special, msgname(call)));
516 else if (fs->ack & MSG_MASK(call))
519 message((-3, "fs: %s: %s: ack: passive fs", fs->special, msgname(call)));
523 fs->flags &= ~FS_LOCK;
534 * initialize mounted fs and return device service fd
538 fsinit(register Fs_t* fs, int fd)
543 if (fd < 0 && (fs->flags & (FS_BOUND|FS_ERROR|FS_INIT|FS_ON)) != (FS_BOUND|FS_ON) || state.kernel && (fs->flags & FS_GLOBAL))
546 fs->flags |= FS_INIT;
547 if ((fs->flags & (FS_ON|FS_OPEN)) != (FS_ON|FS_OPEN))
550 if ((fs->fd = fd) < 0)
555 if (n = fs->servicesize)
558 svc = (char*)memcpy(buf, fs->service, n);
561 else svc = fs->service;
562 message((-3, "fs: %s: init#1: service=%s", fs->special, svc));
564 fs->fd = cslocal(&cs, svc);
565 message((-3, "fs: %s: init#2: service=%s cslocal=%d", fs->special, svc, fs->fd));
566 if (fs->fd >= 0)
568 if (fs->flags & FS_RECEIVE)
570 n = csrecv(&cs, fs->fd, NiL, &fd, 1);
571 CLOSE(fs->fd);
572 fs->fd = n == 1 ? fd : -1;
577 fs->fd = fs3d_open(svc, O_CREAT|O_RDWR|O_APPEND, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
579 if (fs->fd < 0 || FSTAT(fs->fd, &fs->st))
581 fs->fd = -1;
582 fs->flags |= FS_ERROR;
586 if (fs->flags & FS_CLOSE)
587 FCNTL(fs->fd, F_SETFD, FD_CLOEXEC);
588 if (S_ISREG(fs->st.st_mode))
589 fs->flags &= ~FS_ACTIVE;
590 fs->flags |= FS_ON|FS_OPEN;
591 reserve(&fs->fd);
593 message((-3, "fs: %s: init#3: service=%-*s fd=%d cache=%d", fs->special, fs->servicesize ? fs->servicesize : strlen(fs->service), fs->service, fs->fd, state.cache));
597 fs->flags &= ~FS_INIT;
599 return fs->fd;
608 fsdrop(register Fs_t* fs, int clear)
614 message((-3, "fs: %s: drop:%s", fs->special, clear ? " clear" : state.null));
615 if (fs->flags & FS_OPEN)
617 fs->flags &= ~FS_OPEN;
618 cancel(&fs->fd);
620 fs->flags &= ~FS_ERROR;
624 if (fs->flags & FS_FS)
631 if ((mp = state.file[n].mount) && mp->fs == fs)
635 if (((Mount_t*)state.vmount.table[n].val)->fs != fs)
646 if (state.mount[n].fs == fs)
648 state.mount[n].fs = 0;
657 if (fs->flags & FS_INTERNAL) fs->flags &= ~(FS_BOUND|FS_ON);
660 fs->flags = 0;
661 if (fs->service && !fs->servicesize)
663 free(fs->service);
664 fs->service = 0;