lib9p

Go 9P library.
Log | Files | Refs | LICENSE

commit 6b0f642ec2992f334e5d33bf334dfb88972181e2
parent f1ef31934f6a1eff05525b52c119ce811481cd72
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Wed, 17 Jan 2024 08:36:21 +0900

add comment

Diffstat:
Mcmd/semfs/fs.go | 12------------
Mcmd/semfs/main.go | 39+++++++++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+), 12 deletions(-)

diff --git a/cmd/semfs/fs.go b/cmd/semfs/fs.go @@ -38,18 +38,6 @@ func (fsys *semFS) OpenFile(name string, _ int) (lib9p.File, error) { } } -// This function assumes that group and uid both exist and -// the leader of group has the same name as group itself. -func (fsys *semFS) IsGroupLeader(group, uid string) bool { - return group == uid -} - -// This function assumes that group and uid both exists and -// only the member of group has the same name as group itself. -func (fsys *semFS) IsGroupMember(group, uid string) bool { - return group == uid -} - func (fsys *semFS) Create(name string, uid string, mode lib9p.OpenMode, perm lib9p.FileMode) (lib9p.File, error) { for _, f := range fsys.semfiles { if f.name == name { diff --git a/cmd/semfs/main.go b/cmd/semfs/main.go @@ -1,3 +1,42 @@ +/* +Semfs is a semaphore file system. +The original idea is from this book ([Ballesteros 2006]). + +You can mount this file system via 9P using 9pfuse for example. +The file system is initially empty, and you can make files on it. +Each file represents a semaphore length of which is the number of tickets. +To add tickets to an file, write the number of tickets to be added to the file. +To consume a ticket, read the file. + + $ 9pfuse localhost:5640 /mnt + $ echo 1 > /mnt/sem + $ ls -l /mnt/sem + -rw-rw-rw- 1 kenji kenji 1 Jan 17 08:16 /mnt/sem + $ cat /mnt/sem + $ ls -l /mnt/sem + -rw-rw-rw- 1 kenji kenji 0 Jan 17 08:17 /mnt/sem + +Reading a file with length 0 blocks until someone adds tickets to +the file. + + $ ls -l /mnt/sem + -rw-rw-rw- 1 kenji kenji 0 Jan 17 08:17 /mnt/sem + $ (cat /mnt/sem; echo done) & sleep 1; echo write; echo 1 > /mnt/sem + [2] 42872 + write + $ done + +Usage: + + semfs [-D] + +The Flags are: + + -D + print very chatty 9P conversation dialogue to the standard output. + +[Ballesteros 2006]: http://doc.cat-v.org/plan_9/9.intro.pdf +*/ package main import (