tangled
alpha
login
or
join now
hauleth.dev
/
e9p
9
fork
atom
Pure Erlang implementation of 9p2000 protocol
filesystem
fs
9p2000
erlang
9p
9
fork
atom
overview
issues
4
pulls
pipelines
Properly encode file type into stat.mode
hauleth.dev
1 month ago
d72fd0b3
e421ca06
verified
This commit was signed with the committer's
known signature
.
hauleth.dev
SSH Key Fingerprint:
SHA256:1hEP8QO8nM2KQfQ8jK4Q19y/CmqVZQI/cNSht3c1QlI=
+9
-8
2 changed files
expand all
collapse all
unified
split
src
e9p_msg.erl
test
prop_e9p_msg.erl
+8
-7
src/e9p_msg.erl
···
173
173
parse_stat(<<_Size:2/?int,
174
174
Type:2/?int,
175
175
Dev:4/?int,
176
176
-
QID:13/binary,
176
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
186
+
QID = binary_to_qid(RawQID),
187
187
+
Flags = qid_to_mode_flags(QID),
186
188
{ok, #{
187
189
type => Type,
188
190
dev => Dev,
189
189
-
qid => binary_to_qid(QID),
190
190
-
mode => Mode,
191
191
+
qid => QID,
192
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
311
-
FullMode = case e9p:is_type(QID, directory) of
312
312
-
true -> 16#80000000 bor Mode;
313
313
-
false -> Mode
314
314
-
end,
313
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
331
+
qid_to_mode_flags(#qid{type = Type}) ->
332
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
123
-
{qid(regular), int(2), int(2), int(4), int(4), int(4), int(8), bin_str(), bin_str(),
123
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{