From mboxrd@z Thu Jan 1 00:00:00 1970 Mime-Version: 1.0 (Apple Message framework v753) In-Reply-To: References: <326364c20801140111v1bf9b574p80ea0305edf09c14@mail.gmail.com> <268E33BD-890D-4E18-962E-D868224ACC90@mac.com> Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <3DD6ABDB-0089-4E61-9BA8-01F206BF39EA@mac.com> Content-Transfer-Encoding: 7bit From: Gary Wright Subject: Re: [9fans] Easiest way to make a filesystem Date: Mon, 14 Jan 2008 16:23:42 -0500 To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> Topicbox-Message-UUID: 2e515f4a-ead3-11e9-9d60-3106f5b1d025 On Jan 14, 2008, at 4:10 PM, roger peppe wrote: > On Jan 14, 2008 9:00 PM, Gary Wright wrote: >> I've been playing around with my own implementation of 9P in Ruby in >> an effort to explore this problem space and to better understand 9P. > [...] >> I'd appreciate comments/feedback. > > how do you deal with filesystems where the name space is dynamically > constructed? for instance, how would you go about specifying the #I > (/net) namespace > with your system? The filesystem is just a data structure. It can be manipulated from the 9P side via create/remove (subject to all the regular access rules) or it can be manipulated on the internal side: # assume that 'd' is a reference to an instance of Directory d['newfile'] = Resource.new The default behavior of a resource is to just map file I/O to an in memory string but you can define new resources that intercept and interpret 9P ops at will: class TimeOfDay < Resource def read(fid, offset, count) Time.now.to_s[0,count] end undef_method write end d['time'] = TimeOfDay.new now every read attempt on 'time' will return the time of day and write requests will generate an error. Gary Wright