ftpd: Add mkd command #342
@@ -89,7 +89,7 @@ commands: ; all commands must be in uppercase
|
||||
; dd 'HELP', login_first, login_first, login_first, cmd_HELP
|
||||
dd 'LIST', login_first, login_first, login_first, cmdLIST
|
||||
; dd 'MDTM', login_first, login_first, login_first, cmd_MDTM
|
||||
; dd 'MKD', login_first, login_first, login_first, cmd_MKD
|
||||
dd 'MKD', login_first, login_first, login_first, cmd_MKD
|
||||
; dd 'MODE', login_first, login_first, login_first, cmd_MODE
|
||||
; dd 'NLST', login_first, login_first, login_first, cmdNLST
|
||||
dd 'NOOP', login_first, login_first, login_first, cmdNOOP
|
||||
@@ -333,6 +333,55 @@ open_datasock:
|
||||
|
||||
ret
|
||||
|
||||
align 4
|
||||
console_fs_error:
|
||||
|
mxlgv marked this conversation as resolved
Outdated
|
||||
cmp eax, 0x2
|
||||
jne .fs_error_3
|
||||
invoke con_write_asciiz, str_fs_error2
|
||||
|
mxlgv
commented
I suggest using 4 as str_fs_error I suggest using 4 as str_fs_error
|
||||
ret
|
||||
.fs_error_3:
|
||||
cmp eax, 0x3
|
||||
jne .fs_error_5
|
||||
invoke con_write_asciiz, str_fs_error3
|
||||
ret
|
||||
.fs_error_5:
|
||||
cmp eax, 0x5
|
||||
jne .fs_error_6
|
||||
|
mxlgv
commented
I think you can shorten it something like this
I think you can shorten it something like this
```asm
console_fs_error:
mov edx, 4 ; Unknown filesystem error
cmp eax, 2
jb .print_err
cmp eax, 12
ja .print_err
mov edx, eax
.print_err:
sub edx, 2
mov edx, [fs_err_table + edx*4]
invoke con_write_asciiz, edx
ret
```
|
||||
invoke con_write_asciiz, str_fs_error5
|
||||
ret
|
||||
.fs_error_6:
|
||||
cmp eax, 0x6
|
||||
jne .fs_error_7
|
||||
invoke con_write_asciiz, str_fs_error6
|
||||
ret
|
||||
.fs_error_7:
|
||||
cmp eax, 0x7
|
||||
jne .fs_error_8
|
||||
invoke con_write_asciiz, str_fs_error7
|
||||
ret
|
||||
.fs_error_8:
|
||||
cmp eax, 0x8
|
||||
jne .fs_error_9
|
||||
invoke con_write_asciiz, str_fs_error8
|
||||
ret
|
||||
.fs_error_9:
|
||||
cmp eax, 0x9
|
||||
jne .fs_error_10
|
||||
invoke con_write_asciiz, str_fs_error9
|
||||
ret
|
||||
.fs_error_10:
|
||||
cmp eax, 0xA
|
||||
jne .fs_error_11
|
||||
invoke con_write_asciiz, str_fs_error10
|
||||
ret
|
||||
.fs_error_11:
|
||||
cmp eax, 0xB
|
||||
jne .fs_error_12
|
||||
invoke con_write_asciiz, str_fs_error11
|
||||
ret
|
||||
.fs_error_12:
|
||||
invoke con_write_asciiz, str_fs_error12
|
||||
ret
|
||||
|
||||
;------------------------------------------------
|
||||
; "ABOR"
|
||||
@@ -1248,6 +1297,69 @@ cmdTYPE:
|
||||
ret
|
||||
|
||||
;------------------------------------------------
|
||||
; "MKD"
|
||||
;
|
||||
; Create directory
|
||||
;
|
||||
;------------------------------------------------
|
||||
align 4
|
||||
cmd_MKD:
|
||||
|
||||
test [ebp + thread_data.permissions], PERMISSION_WRITE
|
||||
jz permission_denied
|
||||
|
||||
lea esi, [esi + 4]
|
||||
lea edi, [ebp + thread_data.buffer]
|
||||
mov ecx, 1024
|
||||
|
||||
.loop1:
|
||||
lodsb
|
||||
cmp al, 0x20
|
||||
jb .done
|
||||
stosb
|
||||
loop .loop1
|
||||
.done:
|
||||
mov byte [edi], 0x00
|
||||
|
||||
call create_path
|
||||
dec edi
|
||||
|
mxlgv marked this conversation as resolved
mxlgv
commented
Bad ident Bad ident
|
||||
|
||||
|
mxlgv marked this conversation as resolved
mxlgv
commented
May be May be `xor eax, eax` and `push eax`? I also don’t understand why there is `mov` and `push` here. `push` is smaller in size
igorsh
commented
Эта часть скопирована с cmdDELE. Если не добавить 1 байт в стек - получаю Page Fault. Эта часть скопирована с **cmdDELE**. Если не добавить 1 байт в стек - получаю Page Fault.
|
||||
lea esi, [ebp + thread_data.buffer]
|
||||
.loop2:
|
||||
lodsb
|
||||
cmp al, 0x20
|
||||
jb .new_dir_ready
|
||||
stosb
|
||||
loop .loop2
|
||||
.new_dir_ready:
|
||||
|
mxlgv marked this conversation as resolved
Outdated
mxlgv
commented
I guess the problem (https://git.kolibrios.org/KolibriOS/kolibrios/pulls/342/files#issuecomment-4485) is here I guess the problem (https://git.kolibrios.org/KolibriOS/kolibrios/pulls/342/files#issuecomment-4485) is here
igorsh
commented
No, at that line - No, at that line - `mcall SF_FILE`
mxlgv
commented
You are right. I read SF 70 and understood why there is one byte.
You are right. I read SF 70 and understood why there is one byte.
But I would still recommend storing 0 in the register and then doing a `push` and `mov`.
igorsh
commented
Немного не пойму что ты предлагаешь: вместо > But I would still recommend storing 0 in the register and then doing a push and mov.
Немного не пойму что ты предлагаешь:
`push ebx`
`xor eax, eax`
`push eax`
`add esp, 3`
вместо
`push ebx`
`dec esp`
`mov byte[esp], 0`
?
mxlgv
commented
I suggest leaving it as is. I'm already confused myself.
I suggest leaving it as is. I'm already confused myself.
|
||||
mov byte [edi], 0x00
|
||||
|
||||
lea ebx, [ebp + thread_data.fpath]
|
||||
invoke con_write_asciiz, ebx
|
||||
invoke con_write_asciiz, str_newline
|
||||
; called fs function
|
||||
push ebx
|
||||
dec esp
|
||||
mov byte[esp], 0
|
||||
push dword 0
|
||||
push dword 0
|
||||
push dword 0
|
||||
push dword 0
|
||||
push dword SSF_CREATE_FOLDER
|
||||
mov ebx, esp
|
||||
mcall SF_FILE
|
||||
add esp, 6*4 + 1
|
||||
|
||||
test eax, eax
|
||||
jnz .error
|
||||
|
||||
sendFTP "257 Directory created"
|
||||
ret
|
||||
.error:
|
||||
call console_fs_error
|
||||
sendFTP "550 Create directory operation failed."
|
||||
ret
|
||||
;------------------------------------------------
|
||||
; "USER"
|
||||
;
|
||||
; Login to the server, step one of two. ;;; TODO: prevent buffer overflow!
|
||||
|
||||
@@ -63,13 +63,13 @@ use32
|
||||
dd params ; parameters
|
||||
dd path ; path
|
||||
|
||||
include '../../KOSfuncs.inc'
|
||||
include '../../macros.inc'
|
||||
purge mov,add,sub
|
||||
include '../../proc32.inc'
|
||||
include '../../dll.inc'
|
||||
include '../../struct.inc'
|
||||
include '../../develop/libraries/libs-dev/libio/libio.inc'
|
||||
|
||||
include '../../network.inc'
|
||||
|
||||
macro sendFTP str {
|
||||
@@ -363,6 +363,17 @@ str_alopen db 'Data connection already open.',10,0
|
||||
str_notfound db 'ERROR: file not found.',10,0
|
||||
str_sockerr db 'ERROR: socket error.',10,0
|
||||
|
||||
str_fs_error2 db 'Function not supported for this filesystem',10,0
|
||||
str_fs_error3 db 'Unknown filesystem',10,0
|
||||
str_fs_error5 db 'File not found',10,0
|
||||
str_fs_error6 db 'End of file',10,0
|
||||
str_fs_error7 db 'Pointer outside application memory',10,0
|
||||
str_fs_error8 db 'Disk full',10,0
|
||||
str_fs_error9 db 'Filesystem error',10,0
|
||||
str_fs_error10 db 'Access denied',10,0
|
||||
str_fs_error11 db 'Device error',10,0
|
||||
str_fs_error12 db 'Filesystem out of memory',10,0
|
||||
|
||||
str_newline db 10, 0
|
||||
str_mask db '*', 0
|
||||
str_infinity db 0xff, 0xff, 0xff, 0xff, 0
|
||||
|
||||
Don't forget the server in floppy disk image. I think here you can write more optimally, for example, get a line with an error by index.