ftpd: Add mkd command
This commit is contained in:
@@ -89,7 +89,7 @@ commands: ; all commands must be in uppercase
|
|||||||
; dd 'HELP', login_first, login_first, login_first, cmd_HELP
|
; dd 'HELP', login_first, login_first, login_first, cmd_HELP
|
||||||
dd 'LIST', login_first, login_first, login_first, cmdLIST
|
dd 'LIST', login_first, login_first, login_first, cmdLIST
|
||||||
; dd 'MDTM', login_first, login_first, login_first, cmd_MDTM
|
; 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 'MODE', login_first, login_first, login_first, cmd_MODE
|
||||||
; dd 'NLST', login_first, login_first, login_first, cmdNLST
|
; dd 'NLST', login_first, login_first, login_first, cmdNLST
|
||||||
dd 'NOOP', login_first, login_first, login_first, cmdNOOP
|
dd 'NOOP', login_first, login_first, login_first, cmdNOOP
|
||||||
@@ -333,6 +333,55 @@ open_datasock:
|
|||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
align 4
|
||||||
|
console_fs_error:
|
||||||
|
cmp eax, 0x2
|
||||||
|
jne .fs_error_3
|
||||||
|
invoke con_write_asciiz, str_fs_error2
|
||||||
|
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
|
||||||
|
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"
|
; "ABOR"
|
||||||
@@ -1248,6 +1297,69 @@ cmdTYPE:
|
|||||||
ret
|
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
|
||||||
|
|
||||||
|
lea esi, [ebp + thread_data.buffer]
|
||||||
|
.loop2:
|
||||||
|
lodsb
|
||||||
|
cmp al, 0x20
|
||||||
|
jb .new_dir_ready
|
||||||
|
stosb
|
||||||
|
loop .loop2
|
||||||
|
.new_dir_ready:
|
||||||
|
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"
|
; "USER"
|
||||||
;
|
;
|
||||||
; Login to the server, step one of two. ;;; TODO: prevent buffer overflow!
|
; Login to the server, step one of two. ;;; TODO: prevent buffer overflow!
|
||||||
|
|||||||
@@ -63,13 +63,13 @@ use32
|
|||||||
dd params ; parameters
|
dd params ; parameters
|
||||||
dd path ; path
|
dd path ; path
|
||||||
|
|
||||||
|
include '../../KOSfuncs.inc'
|
||||||
include '../../macros.inc'
|
include '../../macros.inc'
|
||||||
purge mov,add,sub
|
purge mov,add,sub
|
||||||
include '../../proc32.inc'
|
include '../../proc32.inc'
|
||||||
include '../../dll.inc'
|
include '../../dll.inc'
|
||||||
include '../../struct.inc'
|
include '../../struct.inc'
|
||||||
include '../../develop/libraries/libs-dev/libio/libio.inc'
|
include '../../develop/libraries/libs-dev/libio/libio.inc'
|
||||||
|
|
||||||
include '../../network.inc'
|
include '../../network.inc'
|
||||||
|
|
||||||
macro sendFTP str {
|
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_notfound db 'ERROR: file not found.',10,0
|
||||||
str_sockerr db 'ERROR: socket error.',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_newline db 10, 0
|
||||||
str_mask db '*', 0
|
str_mask db '*', 0
|
||||||
str_infinity db 0xff, 0xff, 0xff, 0xff, 0
|
str_infinity db 0xff, 0xff, 0xff, 0xff, 0
|
||||||
|
|||||||
Reference in New Issue
Block a user