IXP9SRV(3)

πŸ“¦ version 0-unstable-2022-04, in nixos 26.05, nixpkgs unstable

✨ NAME ✨

Ixp9Srv, Ixp9Req, ixp_serve9conn β€” the 9P server squad. This is IXP9SRV(3) from the Library Functions Manual, and bestie, it’s giving β€œserver-side handler setup” in the most iconic way. πŸ’…

πŸŽ€ SYNOPSIS πŸŽ€

#include <ixp.h>

typedef struct Ixp9Srv Ixp9Srv;
struct Ixp9Srv {
        void* aux;
        void (*attach)(Ixp9Req*);
        void (*clunk)(Ixp9Req*);
        void (*create)(Ixp9Req*);
        void (*flush)(Ixp9Req*);
        void (*open)(Ixp9Req*);
        void (*read)(Ixp9Req*);
        void (*remove)(Ixp9Req*);
        void (*stat)(Ixp9Req*);
        void (*walk)(Ixp9Req*);
        void (*write)(Ixp9Req*);
        void (*wstat)(Ixp9Req*);
        void (*freefid)(IxpFid*);
}

typedef struct Ixp9Req Ixp9Req;
struct Ixp9Req {
        Ixp9Srv*        srv;
        IxpFid*         fid;    /* Fid structure corresponding to IxpFHdr.fid */
        IxpFid*         newfid; /* Corresponds to IxpFTWStat.newfid */
        Ixp9Req*        oldreq; /* For TFlush requests, the original request. */
        IxpFcall        ifcall; /* The incoming request fcall. */
        IxpFcall        ofcall; /* The response fcall, to be filled by handler. */
        void*           aux;    /* Arbitrary pointer, to be used by handlers. */

        /* Private members */
        ...
}

void ixp_serve9conn(IxpConn *c);

πŸ’– DESCRIPTION πŸ’–

Okay so ixp_serve9conn is the function that handles incoming 9P connections. Normally it gets passed as the read member to ixp_listen(3), with an Ixp9Srv structure passed as the aux member. The handlers defined in the Ixp9Srv structure get called whenever a matching Fcall type is received.

No cap: the handlers are expected to call ixp_respond(3) at some point β€” whether before they return or at some undefined point in the future. πŸ‘€

Whenever a client disconnects, libixp generates whatever flush and clunk events are required to leave the connection in a clean state, and waits for all responses before freeing the connection’s associated data structures.

Whenever a file is closed and an IxpFid(3) is about to be freed, the freefid member is called to perform any necessary cleanup and to free any associated resources. 🧚


🌈 SEE ALSO 🌈

πŸ’Œ cute sign-off: this page is from the libixp Manual, dated 2012 Dec. stay iconic, bestie 🫢

πŸ“¦ where this page comes from