summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2013-03-22 04:44:32 (GMT)
committerH. Peter Anvin <hpa@zytor.com>2013-03-22 04:44:32 (GMT)
commitabf91e9ecdcf1245e85e17e85fed23e7598e20c7 (patch)
tree1adf1590e062885ab5ca9f1f337f27cf78ee8295
parent97a6cb7b0e6a6332f860d6b962e3b5538bb18d9e (diff)
downloadvirtio9p-abf91e9ecdcf1245e85e17e85fed23e7598e20c7.zip
virtio9p-abf91e9ecdcf1245e85e17e85fed23e7598e20c7.tar.gz
virtio9p-abf91e9ecdcf1245e85e17e85fed23e7598e20c7.tar.bz2
virtio9p-abf91e9ecdcf1245e85e17e85fed23e7598e20c7.tar.xz
Provide a working chdir function
We can now chdir to valid directories, but not invalid directories.
-rw-r--r--fxn.asm31
-rw-r--r--pathname.asm11
-rw-r--r--protomsg.asm12
-rw-r--r--v9fs.h1
4 files changed, 50 insertions, 5 deletions
diff --git a/fxn.asm b/fxn.asm
index 9f2f94a..adcd5d9 100644
--- a/fxn.asm
+++ b/fxn.asm
@@ -35,7 +35,36 @@
* ------------------------------------------------------------------------- */
GPROC(fxn_chdir)
- stc
+#ifdef DEBUG
+ debugmsg "chdir fn1 = "
+ lfsw dos_sdafn,%si
+ pushw %fs
+ pushw %si
+ call debug_puts_far
+ call debug_crlf
+#endif
+ movl $FID_CHDIR,%eax
+ incw %si /* Skip drive letter */
+ incw %si /* Skip colon */
+ call path_walk
+ jc 1f
+ pushw %ax
+ movl $FID_CHDIR,%eax
+ call clunk
+ popw %ax
+#ifdef DEBUG
+ debugmsg "type "
+ pushw %ax
+ call debug_printhex4
+ call debug_crlf
+#endif
+ andb %al,%al /* Bit 7 = P9_QTDIR */
+ jns 1f
+ xorw %ax,%ax
+ retw
+1:
+ movl $0x08030003,%eax /* Path not found */
+ clc
retw
END(fxn_chdir)
diff --git a/pathname.asm b/pathname.asm
index c13638a..6525ff0 100644
--- a/pathname.asm
+++ b/pathname.asm
@@ -45,7 +45,7 @@ GPROC(genpath_asciiz)
movb %fs:(%bx),%al
incw %bx
andb %al,%al
- jne 1b
+ jnz 1b
decw %bx
popw %ax
call genpath
@@ -77,6 +77,12 @@ GPROC(genpath)
pushw %si
call debug_puts
popw %ds
+ debugmsg " "
+ pushw %si
+ call debug_printhex4
+ debugmsg " "
+ pushw %bx
+ call debug_printhex4
call debug_crlf
#endif
@@ -93,6 +99,9 @@ GPROC(genpath)
movw %di,%bx /* Save pointer to chunk beginning */
2:
+ cmpw -2(%bp),%si
+ jae 3f
+
fs lodsb
cmpb $0x5c,%al /* Backslash */
je 3f
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)
/* ------------------------------------------------------------------------- *
diff --git a/v9fs.h b/v9fs.h
index c3a4851..ade70b0 100644
--- a/v9fs.h
+++ b/v9fs.h
@@ -299,6 +299,7 @@
/* FID numbers we use */
#define FID_ROOT 2
#define FID_DISKSPACE 3
+#define FID_CHDIR 4
/* Invocation frame assuming prev_stack is loaded into gs:bp */
#define F_GS %gs:(%bp)