9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] lib9p help
@ 2006-02-17 12:15 Gabriel Diaz
  2006-02-17 13:10 ` Russ Cox
  0 siblings, 1 reply; 7+ messages in thread
From: Gabriel Diaz @ 2006-02-17 12:15 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Hello

i am using file/tree structures trying to do a read/write filesystem,
but i cannot make it use my walk functions and cannot create
directories or files with touch.

i read /sys/src/lib9p/srv.c and seems that in swalk():

if(r->fid->file)
    filewalk(r);
else if ( srv->walk1)
    walkandclone(r,oldwalk1,oldclone,srv);
else if ( srv->walk )
    srv->walk(r);
else
    sysfatal(...);

and firewalk(r) is always called.

what is the piece I'm missing? where is filled that r->fid->file ?

i have srv defined as:

srv fs = {
   .destroyfid = fsdestroyfid,
   .create=fscreate,
   .walk1=fswalk1,
   .clone=fsclone,
   .write=fswrite,
   .read=fsread,
   .remove=fsremove,
};



thanks, and sorry if this is obvious.

gabi

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9fans] lib9p help
  2006-02-17 12:15 [9fans] lib9p help Gabriel Diaz
@ 2006-02-17 13:10 ` Russ Cox
  2006-02-17 21:23   ` Gabriel Diaz
  0 siblings, 1 reply; 7+ messages in thread
From: Russ Cox @ 2006-02-17 13:10 UTC (permalink / raw)
  To: 9fans

> i am using file/tree structures trying to do a read/write filesystem,
> but i cannot make it use my walk functions and cannot create
> directories or files with touch.

If you are using file/tree structures, 
then you don't get to provide the walk function.
(Why would you need to?  Lib9p should know
the entire file tree and be able to do it for you.)

Russ



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9fans] lib9p help
  2006-02-17 21:23   ` Gabriel Diaz
@ 2006-02-17 16:30     ` Russ Cox
  2006-02-17 21:50       ` Gabriel Diaz
  0 siblings, 1 reply; 7+ messages in thread
From: Russ Cox @ 2006-02-17 16:30 UTC (permalink / raw)
  To: 9fans

> always fails when using lib9p. i though i need to provide walk1 and
> clone to create
> directories that doesn't exists. Using the chatty option all messages are walks
> when doing mkdirs abd when touching a file.

i don't believe that.  there should be Tcreate messages too.

/sys/src/lib9p/ramfs.c uses file/tree structures
(and allows creation of new files).  9p(2) says

          Create
               The create function must fill in both r->fid->qid and
               r->ofcall.qid on success.  When using file trees,
               create should allocate a new File with createfile; note
               that createfile may return nil (because, say, the file
               already exists).  If the create function is nil, srv
               behaves as though it were a function that always
               responded with the error ``create prohibited''.

russ



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9fans] lib9p help
  2006-02-17 21:50       ` Gabriel Diaz
@ 2006-02-17 17:14         ` Russ Cox
  2006-02-17 22:22           ` Gabriel Diaz
  0 siblings, 1 reply; 7+ messages in thread
From: Russ Cox @ 2006-02-17 17:14 UTC (permalink / raw)
  To: 9fans

> > /sys/src/lib9p/ramfs.c uses file/tree structures
> ramfs has it's own loop, may be it uses something like file/tree structures
> but the ramfs.c i have here doesn't have a  #include <9p.h>.

you are looking at /sys/src/cmd/ramfs.c and not /sys/src/lib9p/ramfs.c

> i have other tests with more fscalls implemented, but i should see
> here the Rwalk message and the Tcreate message?

yes, you should.  make sure you run your test with -c so
that the kernel will actually allow create in the root.

russ



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9fans] lib9p help
  2006-02-17 13:10 ` Russ Cox
@ 2006-02-17 21:23   ` Gabriel Diaz
  2006-02-17 16:30     ` Russ Cox
  0 siblings, 1 reply; 7+ messages in thread
From: Gabriel Diaz @ 2006-02-17 21:23 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Hello

that means that i cannot do an mkdir in a mounted fileserver while
using file/tree structures? that i need to generate the complete tree
inside the fileserver first?

something like
% fs -m /mnt/test
% mkdir /mnt/test/dir1

always fails when using lib9p. i though i need to provide walk1 and
clone to create
directories that doesn't exists. Using the chatty option all messages are walks
when doing mkdirs abd when touching a file.

it is better not to use lib9p for this? ( or file/free structures? )

thanks,

gabi


On 2/17/06, Russ Cox <rsc@swtch.com> wrote:
> > i am using file/tree structures trying to do a read/write filesystem,
> > but i cannot make it use my walk functions and cannot create
> > directories or files with touch.
>
> If you are using file/tree structures,
> then you don't get to provide the walk function.
> (Why would you need to?  Lib9p should know
> the entire file tree and be able to do it for you.)
>
> Russ
>
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9fans] lib9p help
  2006-02-17 16:30     ` Russ Cox
@ 2006-02-17 21:50       ` Gabriel Diaz
  2006-02-17 17:14         ` Russ Cox
  0 siblings, 1 reply; 7+ messages in thread
From: Gabriel Diaz @ 2006-02-17 21:50 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Hello,

i can see the Tcreate messages in ramfs, but not in my buggy test.

ramfs has it's own loop, may be it uses something like file/tree structures
but the ramfs.c i have here doesn't have a  #include <9p.h>.

using chatty i see that ramfs has a Rwalk messagfe with a newquid and
then the Tcreate
message, while in the test with 9p.h i never got it, so it fails.

i have other tests with more fscalls implemented, but i should see
here the Rwalk message and the Tcreate message?

thanks

gabi


my test fs.c is like:

/*
 * test1
 */

#include <u.h>
#include <libc.h>
#include <bio.h>
#include <auth.h>
#include <fcall.h>
#include <thread.h>
#include <9p.h>


Tree * tree;
File *ctlroot;

Srv fs;

static void
usage(void)
{
	fprint(2, "usage: fs [-abcC] [-m mtpt]\n");
	exits("usage");
}

void
main(int argc, char **argv)
{

	ulong flag;
	char *mtpt;

	flag = 0;
	mtpt = "/mnt/test";
	ARGBEGIN{
	case 'D':
		chatty9p++;
		break;
	case 'a':
		flag |= MAFTER;
		break;
	case 'b':
		flag |= MBEFORE;
		break;
	case 'c':
		flag |= MCREATE;
		break;
	case 'C':
		flag |= MCACHE;
		break;
	case 'm':
		mtpt = ARGF();
		break;
	default:
		usage();
		break;
	}ARGEND;

	if(argc != 0)
		usage();
	if ( flag == 0 )
		flag = MAFTER;

	tree = fs.tree = alloctree(getuser(), "sys", DMDIR|0775,nil);
	ctlroot = createfile(fs.tree->root,"ctl",getuser(),0666,nil);

	postmountsrv(&fs, nil, mtpt, flag);
	exits(0);
}


On 2/17/06, Russ Cox <rsc@swtch.com> wrote:
> > always fails when using lib9p. i though i need to provide walk1 and
> > clone to create
> > directories that doesn't exists. Using the chatty option all messages are walks
> > when doing mkdirs abd when touching a file.
>
> i don't believe that.  there should be Tcreate messages too.
>
> /sys/src/lib9p/ramfs.c uses file/tree structures
> (and allows creation of new files).  9p(2) says
>
>           Create
>                The create function must fill in both r->fid->qid and
>                r->ofcall.qid on success.  When using file trees,
>                create should allocate a new File with createfile; note
>                that createfile may return nil (because, say, the file
>                already exists).  If the create function is nil, srv
>                behaves as though it were a function that always
>                responded with the error ``create prohibited''.
>
> russ
>
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9fans] lib9p help
  2006-02-17 17:14         ` Russ Cox
@ 2006-02-17 22:22           ` Gabriel Diaz
  0 siblings, 0 replies; 7+ messages in thread
From: Gabriel Diaz @ 2006-02-17 22:22 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

hello

oh! i will take a look at that ramfs.

thanks

gabi


On 2/17/06, Russ Cox <rsc@swtch.com> wrote:
> > > /sys/src/lib9p/ramfs.c uses file/tree structures
> > ramfs has it's own loop, may be it uses something like file/tree structures
> > but the ramfs.c i have here doesn't have a  #include <9p.h>.
>
> you are looking at /sys/src/cmd/ramfs.c and not /sys/src/lib9p/ramfs.c
>
> > i have other tests with more fscalls implemented, but i should see
> > here the Rwalk message and the Tcreate message?
>
> yes, you should.  make sure you run your test with -c so
> that the kernel will actually allow create in the root.
>
> russ
>
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-02-17 22:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-17 12:15 [9fans] lib9p help Gabriel Diaz
2006-02-17 13:10 ` Russ Cox
2006-02-17 21:23   ` Gabriel Diaz
2006-02-17 16:30     ` Russ Cox
2006-02-17 21:50       ` Gabriel Diaz
2006-02-17 17:14         ` Russ Cox
2006-02-17 22:22           ` Gabriel Diaz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).