fcall.rb (2825B)
1 # Copyright (C) 2007 Kris Maglione 2 # See PERMISSIONS 3 4 module R9P 5 class Fcall <Serial 6 module Constants 7 MaxWelem = 16 8 NoTag = ~0 9 NoFid = ~0 10 end 11 include Constants 12 Types = [] 13 field :size, :dword, :size, 4 14 field :type, :byte 15 field :tag, :word 16 17 def self.type(n) 18 Types[n] = self 19 @type = n 20 end 21 def self.from(data) 22 type = data[4] 23 Types[type].new data 24 end 25 26 def initialize(data = nil) 27 fields[:type] = self.class.module_eval { @type } 28 super(data) 29 end 30 31 def succ(args = {}) 32 Types[type+1].new args.merge(:tag => tag) 33 end 34 35 class Tversion <Fcall 36 type 100 37 field :msize, :dword 38 field :version, :word, :string 39 end 40 class Rversion <Fcall 41 type 101 42 field :msize, :dword 43 field :version, :word, :string 44 end 45 46 class Tauth <Fcall 47 type 102 48 field :afid, :dword 49 field :uname, :word, :string 50 field :aname, :word, :string 51 end 52 class Rauth <Fcall 53 type 103 54 field :aqid, Qid 55 end 56 57 class Tattach <Fcall 58 type 104 59 field :fid, :dword 60 field :afid, :dword 61 field :uname, :word, :string 62 field :aname, :word, :string 63 end 64 class Rattach <Fcall 65 type 105 66 field :qid, Qid 67 end 68 69 class Terror <Fcall 70 type 106 71 def initialize 72 throw "Illegal 9P tag 'Terror' encountered" 73 end 74 end 75 class Rerror <Fcall 76 type 107 77 field :ename, :word, :string 78 end 79 80 class Tflush <Fcall 81 type 108 82 field :oldtag, :word 83 end 84 class Rflush <Fcall 85 type 109 86 end 87 88 class Twalk <Fcall 89 type 110 90 field :fid, :dword 91 field :newfid, :dword 92 field :wname, :word, [ :word, :string ] 93 end 94 class Rwalk <Fcall 95 type 111 96 field :wqid, :word, [ Qid ] 97 end 98 99 class Topen <Fcall 100 type 112 101 field :fid, :dword 102 field :mode, :byte 103 end 104 class Ropen <Fcall 105 type 113 106 field :qid, Qid 107 field :iounit, :dword 108 end 109 110 class Tcreate <Fcall 111 type 114 112 field :fid, :dword 113 field :name, :word, :string 114 field :perm, :dword 115 field :mode, :byte 116 end 117 class Rcreate <Fcall 118 type 115 119 field :qid, Qid 120 field :iounit, :dword 121 end 122 123 class Tread <Fcall 124 type 116 125 field :fid, :dword 126 field :offset, :qword 127 field :count, :dword 128 end 129 class Rread <Fcall 130 type 117 131 field :data, :dword, :string 132 end 133 134 class Twrite <Fcall 135 type 118 136 field :fid, :dword 137 field :offset, :qword 138 field :data, :dword, :string 139 end 140 class Rwrite <Fcall 141 type 119 142 field :count, :dword 143 end 144 145 class Tclunk <Fcall 146 type 120 147 field :fid, :dword 148 end 149 class Rclunk <Fcall 150 type 121 151 end 152 153 class Tremove <Tclunk 154 type 122 155 end 156 class Rremove <Fcall 157 type 123 158 end 159 160 class Tstat <Tclunk 161 type 124 162 end 163 class Rstat <Fcall 164 type 125 165 field :sstat, :word, :size, 2 166 field :stat, Stat 167 end 168 169 class Twstat <Rstat 170 type 126 171 end 172 class Rwstat <Fcall 173 type 127 174 end 175 end 176 end