summaryrefslogtreecommitdiffstats
path: root/protomsg.asm
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2013-03-21 21:44:32 -0700
committerH. Peter Anvin <hpa@zytor.com>2013-03-21 21:44:32 -0700
commitabf91e9ecdcf1245e85e17e85fed23e7598e20c7 (patch)
tree1adf1590e062885ab5ca9f1f337f27cf78ee8295 /protomsg.asm
parent97a6cb7b0e6a6332f860d6b962e3b5538bb18d9e (diff)
downloadvirtio9p-abf91e9ecdcf1245e85e17e85fed23e7598e20c7.tar.gz
virtio9p-abf91e9ecdcf1245e85e17e85fed23e7598e20c7.tar.xz
virtio9p-abf91e9ecdcf1245e85e17e85fed23e7598e20c7.zip
Provide a working chdir function
We can now chdir to valid directories, but not invalid directories.
Diffstat (limited to 'protomsg.asm')
-rw-r--r--protomsg.asm12
1 files changed, 9 insertions, 3 deletions
diff --git a/protomsg.asm b/protomsg.asm
index 0d4f89b..a0bc4e8 100644
--- a/protomsg.asm
+++ b/protomsg.asm
@@ -52,8 +52,9 @@ GPROC(path_walk)
call simple_message
jc 1f /* Message error */
popw %dx
- movw (%di),%cx /* %ax = nwqid */
+ movw (%di),%cx /* %cx = nwqid */
imul $13,%cx,%bx /* Each qid is 13 bytes */
+ jz 4f /* Special case for the root directory */
movb -11(%bx,%di),%al /* Type of the final QID */
cmpw %dx,%cx
jne 2f
@@ -65,13 +66,18 @@ GPROC(path_walk)
* We receieved a subset of the desired qids. If the final
* component is a directory, this is ENOENT, otherwise ENOTDIR.
*/
- testb $P9_QTDIR,%al
+ andb %al,%al
movw $L_ENOENT,%ax
- je 3f
+ jns 3f /* Bit 7 = P9_QTDIR */
movw $L_ENOTDIR,%ax
3:
stc
retw
+4:
+ /* It is the root directory, so we get zero qids back */
+ movb $P9_QTDIR,%al
+ /* CF = 0 already */
+ retw
END(path_walk)
/* ------------------------------------------------------------------------- *