summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2013-03-18 01:45:19 (GMT)
committerH. Peter Anvin <hpa@zytor.com>2013-03-18 01:45:19 (GMT)
commit1b4d277bd509b53ec506558e0eab82d7504bde6f (patch)
tree9d8233b1aa6cc5b3965c138108bfe8cbee911d9d
parent1658b7dcd16a2a9f75a984de14630082b4ea20e2 (diff)
downloadvirtio9p-1b4d277bd509b53ec506558e0eab82d7504bde6f.zip
virtio9p-1b4d277bd509b53ec506558e0eab82d7504bde6f.tar.gz
virtio9p-1b4d277bd509b53ec506558e0eab82d7504bde6f.tar.bz2
virtio9p-1b4d277bd509b53ec506558e0eab82d7504bde6f.tar.xz
Make the diskspace function work, at least for small filesystems
Now we can return the correct values for small filesystems. The larger filesystems may still be broken. Still unclear if it actually makes any sense to do this much work.
-rw-r--r--fxn.asm53
1 files changed, 46 insertions, 7 deletions
diff --git a/fxn.asm b/fxn.asm
index 0c8a706..acfc7d8 100644
--- a/fxn.asm
+++ b/fxn.asm
@@ -100,20 +100,44 @@ GPROC(fxn_diskspace)
* qword @ 8(%di) = total blocks
* qword @ 24(%di) = free blocks for non-superuser
*/
+#ifdef DEBUG
+ debugmsg "diskspace: "
+ pushl 4(%di)
+ call debug_printhex8
+ debugmsg " "
+ pushl 12(%di)
+ call debug_printhex8
+ pushl 8(%di)
+ call debug_printhex8
+ debugmsg " "
+ pushl 28(%di)
+ call debug_printhex8
+ pushl 24(%di)
+ call debug_printhex8
+ call debug_crlf
+#endif
movl 12(%di),%eax
mull 4(%di)
andl %edx,%edx
jne 10f /* > 2^64 bytes! */
- movl %eax,%ecx
+ movl %eax,%ebx
movl 8(%di),%eax
mull 4(%di)
- addl %ecx,%edx
+ addl %ebx,%edx
jc 10f
/*
* %edx:%eax now contains a byte count; we can represent it in
* a meaningful way iff it is < 2^38...
*/
+#ifdef DEBUG
+ debugmsg "bytes: "
+ pushl %edx
+ call debug_printhex8
+ pushl %eax
+ call debug_printhex8
+ call debug_crlf
+#endif
bsrl %edx,%ecx
jnz 2f
bsrl %eax,%ecx
@@ -122,10 +146,23 @@ GPROC(fxn_diskspace)
addb $32,%cl
3:
cmpb $38,%cl
- jae 10f
- subb $16,%cl
+ ja 10f
+ subb $15,%cl
+ jnb 31f
+ xorb %cl,%cl
+31:
shrdl %cl,%edx,%eax
+#ifdef DEBUG
+ debugmsg "shift: "
+ pushw %cx
+ call debug_printhex2
+ debugmsg "\r\nclusters: "
+ pushw %ax
+ call debug_printhex4
+ call debug_crlf
+#endif
+
4:
movw %ax,F_BX /* Total clusters */
@@ -133,10 +170,10 @@ GPROC(fxn_diskspace)
mull 4(%di)
andl %edx,%edx
jne 11f
- movl %eax,%ecx
+ movl %eax,%ebx
movl 24(%di),%eax
mull 4(%di)
- addl %ecx,%edx
+ addl %ebx,%edx
jc 11f
shrdl %cl,%edx,%eax
@@ -173,11 +210,13 @@ GPROC(fxn_diskspace)
retw
10: /* Total size overflow */
- movb $(37-16),%cl
+ debugmsg "Size overflow\r\n"
+ movb $(38-15),%cl
movw $0xffff,%ax
jmp 4b
11: /* Free space overflow */
+ debugmsg "Free space overflow\r\n"
movw $0xffff,%ax
jmp 5b