Skip to content

9Pにおける識別子

Qidlibc.h で定義されていて、ファイルサーバーが扱うファイルについて一意な値となるIDを意味する。Plan 9に関する由来でも書いたがこれはUnique IDの省略形。

struct Qid {
uvlong path;
ulong vers;
uchar type;
}
/* bits in Qid.type */
#define QTDIR 0x80
#define QTAPPEND 0x40
#define QTEXCL 0x20
#define QTMOUNT 0x10
#define QTAUTH 0x08
#define QTTMP 0x04
#define QTFILE 0x00

path はUnixにおけるinode相当な数値で、具体的なファイルを識別する。vers はファイルのバージョンで、更新されるときにインクリメントされるのでリモートのクライアントが変化を知ることができる。type はその属性。

Fid9p.h で定義される型で、ファイルディスクリプタに近い概念を表現する。

struct Fid {
ulong fid;
char omode;
File* file;
char* uid;
Qid qid;
}
struct File {
Ref;
Dir;
File* parent;
}

Req9p.h で定義される型で、クライアントからのリクエストを表現する。

struct Req {
ulong tag;
Fcall ifcall;
Fcall ofcall;
Dir d;
Req* oldreq
Fid* fid;
Fid* afid;
Fid* newfid
Srv* srv;
}

Fcallfcall.h で定義されていて、9pパケットのフォーマットを表す。

struct Fcall {
uchar type;
u32int fid;
ushort tag;
union {
/* Tversion, Rauthなど命令固有のデータ */
}
}