7

I am looking to develop a C implementation of a 9p file server on a Linux machine. There isn't enough documentation in the internet about 9p and I am not very experienced with implementing servers. My general design is as follows:

  1. Use UNIX sockets to listen to incoming 9p messages.
  2. Decode the 9p message and spawn a new thread to perform the required task.
  3. Reply to the client with the appropriate 9p reply message.

The server would just live in the user space and it will translate the 9p messages into a UNIX call.

Do you see any problems or have any recommendations regarding the proposed design? Are there any documentations that you can refer me to that will help me? How do you think I should debug my server and make sure it is working correctly.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Keeto
  • 4,074
  • 9
  • 35
  • 58
  • 4
    Please check my retagging and the URL; you may find alternative and better URLs. When I did a Google search for '9p protocol', I came up with a number of sources of information — what did you find? In general terms, your design is approximately correct. Your biggest problems in the short term may be permissions handling for the files. For debugging, make sure you have a log file and your file server records what it is doing in easily parsed messages (and especially that it records error messages for failed operations on files). Make sure it handles log truncation or removal gracefully. – Jonathan Leffler Jul 15 '15 at 00:07
  • Plan 9 already comes with [u9fs](http://man.cat-v.org/plan_9/4/u9fs), a 9P server for Unix systems like Linux. – osvein Feb 18 '18 at 20:07

1 Answers1

2

Consider libixp (MIT license).

I've played around with wmii and use it in everyday work. libixp was part of wmii (in the earliest releases) and now it is an independent project. Check wmii's early versions to get a good starting point or dive directly into libixp.

To debug your server just mount it with 9PFUSE(4) with parameter −D to print each FUSE and 9P message.

egor7
  • 4,678
  • 7
  • 31
  • 55