Pure Erlang implementation of 9p2000 protocol
filesystem fs 9p2000 erlang 9p

Properly encode file type into stat.mode

hauleth.dev d72fd0b3 e421ca06

verified
+9 -8
+8 -7
src/e9p_msg.erl
··· 173 173 parse_stat(<<_Size:2/?int, 174 174 Type:2/?int, 175 175 Dev:4/?int, 176 - QID:13/binary, 176 + RawQID:13/binary, 177 177 Mode:4/?int, 178 178 Atime:4/?int, 179 179 Mtime:4/?int, ··· 183 183 GLen:?len, Gid:GLen/binary, 184 184 MULen:?len, MUid:MULen/binary>>) 185 185 -> 186 + QID = binary_to_qid(RawQID), 187 + Flags = qid_to_mode_flags(QID), 186 188 {ok, #{ 187 189 type => Type, 188 190 dev => Dev, 189 - qid => binary_to_qid(QID), 190 - mode => Mode, 191 + qid => QID, 192 + mode => Mode band (bnot Flags), 191 193 atime => Atime, 192 194 mtime => Mtime, 193 195 length => Len, ··· 308 310 gid => ~"", 309 311 muid => ~"" 310 312 }, Stat), 311 - FullMode = case e9p:is_type(QID, directory) of 312 - true -> 16#80000000 bor Mode; 313 - false -> Mode 314 - end, 313 + FullMode = qid_to_mode_flags(QID) bor Mode, 315 314 Encoded = [<< 316 315 Type:2/?int, 317 316 Dev:4/?int ··· 329 328 ELen = iolist_size(Encoded), 330 329 [<<ELen:?len>> | Encoded]. 331 330 331 + qid_to_mode_flags(#qid{type = Type}) -> 332 + (Type band 2#11100100) bsl 24. 332 333 333 334 %% ========== Utilities ========== 334 335
+1 -1
test/prop_e9p_msg.erl
··· 120 120 enc_dec(#tstat{fid = FID})). 121 121 prop_rstat() -> 122 122 ?FORALL({QID, Type, Dev, Mode, Atime, Mtime, Len, Name, Uid, Gid, Muid}, 123 - {qid(regular), int(2), int(2), int(4), int(4), int(4), int(8), bin_str(), bin_str(), 123 + {qid(), int(2), int(2), int(4), int(4), int(4), int(8), bin_str(), bin_str(), 124 124 bin_str(), bin_str()}, 125 125 begin 126 126 enc_dec(#rstat{