5 #include <sys/socket.h>
9 #include <9p-mixp/mixp.h>
10 #include <9p-mixpsrv/types.h>
11 #include <9p-mixpsrv/p9srv.h>
12 #include <9p-mixpsrv/prototypes.h>
13 #include <9p-mixpsrv/errors.h>
15 extern MIXPSRV_FILE_HANDLE
* open_root();
17 MIXPSRV_FILESERVER fileserver
= {
18 .magic
= MIXPSRV_FILESERVER_MAGIC
,
22 /* --------------------- root directory ops ----------------------- */
24 MIXPSRV_FILE_HANDLE
* rootops_lookup(MIXPSRV_FILE_HANDLE
*parent
, char* name
)
26 printf("rootops_lookup() requested: \"%s\"\n",name
);
28 if ((!name
) || (!strlen(name
)) || (!strcmp(name
,"/")))
30 printf("rootops_lookup() requested the root directory\n");
34 if (!strcmp(name
,"etc"))
36 printf(" --> /etc\n");
37 return p9srv_get_file();
40 if (!strcmp(name
,"foo"))
42 printf(" --> /foo\n");
43 MIXPSRV_FILE_HANDLE
* n
= p9srv_get_file();
44 mixpsrv_hostfile_ops_init(n
,"/etc/hosts");
51 MIXPSRV_FILE_OPS rootops
= {
54 .lookup
= rootops_lookup
,
58 MIXPSRV_FILE_HANDLE
* open_root(MIXPSRV_FILESERVER
* server
)
60 MIXPSRV_FILE_HANDLE
*f
= p9srv_get_file();
62 f
->name
= strdup("/");
65 f
->perm
= 0500|P9_DMDIR
;
71 printf("starting 9p \n");
72 char* errstr
= "OKAY";
75 fd
= ixp_serversock_tcp("*",9999,&errstr
);
78 printf("fd=%d err=%s\n",fd
,errstr
);
82 p9srv_run_server(fd
, &fileserver
);