summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2013-03-22 05:09:02 (GMT)
committerH. Peter Anvin <hpa@zytor.com>2013-03-22 05:09:02 (GMT)
commit81d9cd91c09e12ad29f66d579d0b9bd765ad260c (patch)
tree6ae9c5823ebcf37d26edf0bd5d1b5697aa17a1ab
parentad0a8d14550dad96e4f5ee2f30c2d766fae26837 (diff)
downloadvirtio9p-81d9cd91c09e12ad29f66d579d0b9bd765ad260c.zip
virtio9p-81d9cd91c09e12ad29f66d579d0b9bd765ad260c.tar.gz
virtio9p-81d9cd91c09e12ad29f66d579d0b9bd765ad260c.tar.bz2
virtio9p-81d9cd91c09e12ad29f66d579d0b9bd765ad260c.tar.xz
Generalize pathname parsing functions
For create and mkdir we will need to be able to split a path into directory name and file name.
-rw-r--r--diskspc.asm2
-rw-r--r--fxn.asm2
-rw-r--r--pathname.asm81
-rw-r--r--protomsg.asm8
4 files changed, 74 insertions, 19 deletions
diff --git a/diskspc.asm b/diskspc.asm
index 218f427..ef89908 100644
--- a/diskspc.asm
+++ b/diskspc.asm
@@ -43,7 +43,7 @@ GPROC(fxn_diskspace)
addw %fs:CDS_ROOTOFFSET(%si),%si
movl $FID_DISKSPACE,%eax
pushl %eax
- call path_walk
+ call path_walk_asciiz
movw msgbuf7,%di
popl %eax
diff --git a/fxn.asm b/fxn.asm
index adcd5d9..06d03cb 100644
--- a/fxn.asm
+++ b/fxn.asm
@@ -46,7 +46,7 @@ GPROC(fxn_chdir)
movl $FID_CHDIR,%eax
incw %si /* Skip drive letter */
incw %si /* Skip colon */
- call path_walk
+ call path_walk_asciiz
jc 1f
pushw %ax
movl $FID_CHDIR,%eax
diff --git a/pathname.asm b/pathname.asm
index 6525ff0..0e801b9 100644
--- a/pathname.asm
+++ b/pathname.asm
@@ -31,35 +31,52 @@
.section ".rtext","ax"
/* ------------------------------------------------------------------------- *
- * genpath_asciiz
+ * get_end_path
*
- * Convert a DOS-format path in FS:SI into a walk path in (ES|DS):DI
- *
- * The DOS path is expected to be an absolute path starting with \
+ * Set up BX to point to the end of a path in FS:SI
* ------------------------------------------------------------------------- */
-GPROC(genpath_asciiz)
- pushw %bx
+GPROC(get_end_path)
pushw %ax
- movw %si,%bx
+ xchg %si,%bx
1:
- movb %fs:(%bx),%al
- incw %bx
+ fs lodsb
andb %al,%al
jnz 1b
- decw %bx
+ decw %si
+ xchg %si,%bx
popw %ax
- call genpath
- popw %bx
retw
-END(genpath_asciiz)
+END(get_end_path)
/* ------------------------------------------------------------------------- *
+ * get_dir_path
+ *
+ * Set up BX to point to the last backslash in FS:SI
+ * ------------------------------------------------------------------------- */
+GPROC(get_dir_path)
+ pushw %ax
+ pushw %si
+ xorw %bx,%bx
+1:
+ fs lodsb
+ cmpb $0x5c,%al
+ jne 2f
+ leaw -1(%si),%bx
+2:
+ andb %al,%al
+ jnz 1b
+ popw %si
+ popw %ax
+ retw
+END(get_dir_path)
+
+/* ------------------------------------------------------------------------- *
* genpath
*
* Convert a DOS-format path in FS:SI into a walk path in (ES|DS):DI
* BX marks the end of the path to convert.
*
- * The DOS path is expected to be an absolute path starting with \
+ * The DOS path is expected to be an absolute path *without* leading \
* ------------------------------------------------------------------------- */
GPROC(genpath)
@@ -86,8 +103,6 @@ GPROC(genpath)
call debug_crlf
#endif
- incw %si /* Skip leading backslash */
-
xorw %ax,%ax
stosw
@@ -125,3 +140,37 @@ GPROC(genpath)
popw %bp
retw
END(genpath)
+
+/* ------------------------------------------------------------------------- *
+ * genfilename
+ *
+ * Convert a DOS-format file name (null-terminated) in FS:SI into
+ * path element in (ES|DS):DI
+ * ------------------------------------------------------------------------- */
+
+GPROC(genfilename)
+ pushw %si
+ pushw %bx
+ pushw %ax
+
+ stosw /* Space for chunk length */
+ movw %di,%bx /* Save pointer to chunk beginning */
+
+2:
+ fs lodsb
+ andb %al,%al
+ jz 3f
+
+ call cptoutf
+ jmp 2b
+3:
+ /* Update chunk length */
+ movw %di,%ax
+ subw %bx,%ax
+ movw %ax,-2(%bx)
+
+ popw %ax
+ popw %bx
+ popw %si
+ retw
+END(genfilename)
diff --git a/protomsg.asm b/protomsg.asm
index a0bc4e8..286a336 100644
--- a/protomsg.asm
+++ b/protomsg.asm
@@ -39,13 +39,19 @@
* On error, CF=1 and %ax contains the Linux error number.
* ------------------------------------------------------------------------- */
+GPROC(path_walk_asciiz)
+ call get_end_path /* Point BX to the end of string */
+ /* jmp path_walk */
+END(path_walk_asciiz)
+
GPROC(path_walk)
movw msgbuf7,%di
movl $FID_ROOT,(%di)
movl %eax,4(%di)
addw $8,%di
pushw %di
- call genpath_asciiz
+ incw %si /* Skip leading backslash */
+ call genpath
popw %si
pushw (%si) /* Number of pathname chunks */
movb $P9_TWALK,%al