Subversion Repositories Kolibri OS

Rev

Rev 6464 | Rev 6471 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6464 Rev 6468
Line 3... Line 3...
3
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;;
4
;;  Distributed under terms of the GNU General Public License.  ;;
4
;;  Distributed under terms of the GNU General Public License.  ;;
5
;;                                                              ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 7... Line 7...
7
 
7
 
Line 8... Line 8...
8
$Revision: 6464 $
8
$Revision: 6468 $
9
 
9
 
10
ERROR_SUCCESS        = 0
10
ERROR_SUCCESS        = 0
11
ERROR_DISK_BASE      = 1
11
ERROR_DISK_BASE      = 1
12
ERROR_UNSUPPORTED_FS = 2
12
ERROR_UNSUPPORTED_FS = 2
13
ERROR_UNKNOWN_FS     = 3
13
ERROR_UNKNOWN_FS     = 3
14
ERROR_PARTITION      = 4
14
ERROR_PARTITION      = 4
15
ERROR_FILE_NOT_FOUND = 5
15
ERROR_FILE_NOT_FOUND = 5
16
ERROR_END_OF_FILE    = 6
16
ERROR_END_OF_FILE    = 6
17
ERROR_MEMORY_POINTER = 7
-
 
18
ERROR_DISK_FULL      = 8
17
ERROR_MEMORY_POINTER = 7
19
ERROR_FAT_TABLE      = 9 ;deprecated
18
ERROR_DISK_FULL      = 8
20
ERROR_FS_FAIL        = 9
19
ERROR_FS_FAIL        = 9
21
ERROR_ACCESS_DENIED  = 10
20
ERROR_ACCESS_DENIED  = 10
Line -... Line 21...
-
 
21
ERROR_DEVICE         = 11
-
 
22
ERROR_OUT_OF_MEMORY  = 12
22
ERROR_DEVICE         = 11
23
 
23
ERROR_OUT_OF_MEMORY  = 12
24
maxPathLength = 1000h
Line 24... Line 25...
24
 
25
 
Line 48... Line 49...
48
; 5 = get file info
49
; 5 = get file info
49
; 6 = set file info
50
; 6 = set file info
50
; start application
51
; start application
51
; 8 = delete file/folder
52
; 8 = delete file/folder
52
; 9 = create folder
53
; 9 = create folder
53
        lea     esi, [ebx+20]
54
        lea     ebp, [ebx+20]
54
        lodsb
-
 
55
        test    al, al
55
        cmp     byte [ebp], 0
56
        jnz     @f
56
        jnz     @f
57
        mov     esi, [esi]
57
        mov     ebp, [ebx+21]
58
        lodsb
-
 
59
@@:
58
@@:
60
        lea     ebp, [esi-1]
-
 
61
if 0
-
 
62
        cmp     [ebx], dword 0
-
 
63
        jne     .1
-
 
64
        DEBUGF 1,'read file %s\n',ebp
-
 
65
        jmp     @f
-
 
66
.1:
-
 
67
        cmp     [ebx], dword 5
-
 
68
        jne     @f
-
 
69
        DEBUGF 1,'get file attributes %s\n',ebp
-
 
70
@@:
-
 
71
end if
-
 
72
        cmp     dword[ebx], 7   ; start application
59
        cmp     dword[ebx], 7   ; start application
73
        jne     @f
60
        jne     @f
74
        mov     edx, [ebx+4]
61
        mov     edx, [ebx+4]
75
        mov     ebx, [ebx+8]
62
        mov     ebx, [ebx+8]
76
        call    fs_execute      ; ebp, ebx, edx
63
        call    fs_execute      ; ebp, ebx, edx
77
        mov     [image_of_eax], eax
64
        mov     [image_of_eax], eax
78
        ret
65
        ret
Line 79... Line 66...
79
 
66
 
80
@@:
-
 
81
        cmp     al, '/'
-
 
82
        jz      .notcurdir
-
 
83
        dec     esi
-
 
84
        mov     ebp, esi
-
 
85
        test    al, al
-
 
86
        jnz     @f
-
 
87
        xor     ebp, ebp
-
 
88
@@:
-
 
89
        mov     esi, [current_slot]
-
 
90
        mov     esi, [esi+APPDATA.cur_dir]
-
 
91
        jmp     .parse_normal
-
 
92
 
-
 
93
.notcurdir:
67
@@:
94
        cmp     byte [esi], 0
68
        cmp     word [ebp], '/'
-
 
69
        jz      .rootdir
-
 
70
        stdcall kernel_alloc, maxPathLength
-
 
71
        push    ebx
-
 
72
        mov     ebx, ebp
-
 
73
        mov     ebp, eax
-
 
74
        push    maxPathLength
95
        jz      .rootdir
75
        push    eax
96
        call    process_replace_file_name
76
        call    get_full_file_name
-
 
77
        pop     ebx
97
.parse_normal:
78
        mov     esi, ebp
98
        mov     ax, [esi]
79
        mov     ax, [ebp]
99
        or      ax, 2020h
80
        or      ax, 2020h
100
        cmp     ax, 'cd'
81
        cmp     ax, 'cd'
101
        jz      .CD
82
        jz      .CD
102
        call    dyndisk_handler ; not returns if success
83
        call    dyndisk_handler ; not returns if success
-
 
84
.notfound:
103
.notfound:
85
        stdcall kernel_free, ebp
104
        mov     dword[image_of_eax], ERROR_FILE_NOT_FOUND
86
        mov     dword[image_of_eax], ERROR_FILE_NOT_FOUND
Line 105... Line 87...
105
        ret
87
        ret
106
 
88
 
Line 124... Line 106...
124
        jnz     .notfound
106
        jnz     .notfound
125
        cmp     byte [esi], '/'
107
        cmp     byte [esi], '/'
126
        jnz     @f
108
        jnz     @f
127
        inc     esi
109
        inc     esi
128
@@:
110
@@:
129
        cmp     byte [esi], 0
-
 
130
        jnz     @f
-
 
131
        test    ebp, ebp
-
 
132
        jz      @f
-
 
133
        mov     esi, ebp
-
 
134
        xor     ebp, ebp
-
 
135
@@:
-
 
136
        call    reserve_cd
111
        call    reserve_cd
137
        mov     eax, edi
112
        mov     eax, edi
138
        bt      eax, 0
113
        bt      eax, 0
139
        setc    [DiskNumber]
114
        setc    [DiskNumber]
140
        bt      eax, 1
115
        bt      eax, 1
Line 158... Line 133...
158
        mov     dword[image_of_eax], ERROR_UNSUPPORTED_FS
133
        mov     dword[image_of_eax], ERROR_UNSUPPORTED_FS
159
        cmp     eax, fs_NumCdServices
134
        cmp     eax, fs_NumCdServices
160
        jae     @f
135
        jae     @f
161
        add     ebx, 4
136
        add     ebx, 4
162
        call    dword[fs_CdServices + eax*4]
137
        call    dword[fs_CdServices + eax*4]
163
        call    free_cd_channel
-
 
164
        and     [cd_status], 0
-
 
165
        mov     [image_of_eax], eax
138
        mov     [image_of_eax], eax
166
        mov     [image_of_ebx], ebx
139
        mov     [image_of_ebx], ebx
167
        ret
-
 
168
 
-
 
169
@@:
140
@@:
170
        call    free_cd_channel
141
        call    free_cd_channel
171
        and     [cd_status], 0
142
        and     [cd_status], 0
-
 
143
        stdcall kernel_free, ebp
172
        ret
144
        ret
Line 173... Line 145...
173
 
145
 
174
.nextCD:
146
.nextCD:
175
        test    eax, eax    ; partition number
147
        test    eax, eax    ; partition number
Line 181... Line 153...
181
        ret
153
        ret
Line 182... Line 154...
182
 
154
 
183
.maindir:   ; list partitions
155
.maindir:   ; list partitions
184
        mov     esi, .nextCD
156
        mov     esi, .nextCD
-
 
157
.maindir_noesi:     ; backjump from dyndisk_handler
-
 
158
        push    ebp
-
 
159
        mov     ebp, ecx
185
.maindir_noesi:     ; backjump from dyndisk_handler
160
        call    kernel_free
186
        cmp     dword[ebx], 1
161
        cmp     dword[ebx], 1
187
        jnz     .access_denied  ; read folder?
162
        jnz     .access_denied  ; read folder?
-
 
163
        push    ebp
188
        push    ecx
164
        pushd   [ebx+4]         ; first block
189
        mov     ebp, [ebx+12]   ; the number of blocks to read
165
        mov     ebp, [ebx+12]   ; the number of blocks to read
190
        mov     edx, [ebx+16]   ; where to write the result
-
 
191
        push    dword[ebx+4]    ; first block
166
        mov     edx, [ebx+16]   ; buffer
192
        mov     ebx, [ebx+8]    ; flags
167
        mov     ebx, [ebx+8]    ; flags
193
        mov     ecx, 32/4
168
        mov     ecx, 32/4
194
        mov     edi, edx
169
        mov     edi, edx
195
        xor     eax, eax
170
        xor     eax, eax
Line 291... Line 266...
291
        push    eax
266
        push    eax
292
        mov     ecx, 32/4
267
        mov     ecx, 32/4
293
        add     edi, 8
268
        add     edi, 8
294
        xor     eax, eax
269
        xor     eax, eax
295
        rep stosd
270
        rep stosd
296
        push    esi edi
271
        push    edi
297
        lea     esi, [esp+12]
272
        lea     esi, [esp+8]
298
        cmp     ebx, 1
273
        cmp     ebx, 1
299
        jz      .uni2
274
        jz      .uni2
300
@@:
275
@@:
301
        lodsb
276
        lodsb
302
        stosb
277
        stosb
303
        test    eax, eax
278
        test    eax, eax
304
        jnz     @b
279
        jnz     @b
305
        pop     edi esi eax
280
        pop     edi eax
306
        add     edi, 264
281
        add     edi, 264
307
        jmp     .rootdir_loop
282
        jmp     .rootdir_loop
Line 308... Line 283...
308
 
283
 
309
.uni2:
284
.uni2:
310
        lodsb
285
        lodsb
311
        stosw
286
        stosw
312
        test    eax, eax
287
        test    eax, eax
313
        jnz     .uni2
288
        jnz     .uni2
314
        pop     edi esi eax
289
        pop     edi eax
315
        add     edi, 520
290
        add     edi, 520
Line 316... Line 291...
316
        jmp     .rootdir_loop
291
        jmp     .rootdir_loop
317
 
292
 
Line 368... Line 343...
368
@@:
343
@@:
369
        mov     [image_of_eax], eax
344
        mov     [image_of_eax], eax
370
        mov     [image_of_ebx], ebx
345
        mov     [image_of_ebx], ebx
371
        ret
346
        ret
Line 372... Line -...
372
 
-
 
373
fs_NotImplemented:
-
 
374
        mov     eax, 2
-
 
375
        ret
-
 
376
 
-
 
377
;-----------------------------------------------------------------------------
-
 
378
fs_CdServices:
-
 
379
        dd      fs_CdRead
-
 
380
        dd      fs_CdReadFolder
-
 
381
        dd      fs_NotImplemented
-
 
382
        dd      fs_NotImplemented
-
 
383
        dd      fs_NotImplemented
-
 
384
        dd      fs_CdGetFileInfo
-
 
385
        dd      fs_NotImplemented
-
 
386
        dd      0
-
 
387
        dd      fs_NotImplemented
-
 
388
        dd      fs_NotImplemented
-
 
389
fs_NumCdServices = ($ - fs_CdServices)/4
347
 
390
;-----------------------------------------------------------------------------
348
;-----------------------------------------------------------------------------
391
process_replace_file_name:
349
process_replace_file_name:
392
; in: [esi] = virtual path
350
; in: [esi] = virtual path
393
; out: [esi]+[ebp] = physical path
351
; out: [esi]+[ebp] = physical path
Line 474... Line 432...
474
        mov     [lock_flag_for_f30_3], 1    ; lock
432
        mov     [lock_flag_for_f30_3], 1    ; lock
475
        popfd
433
        popfd
476
@@:
434
@@:
477
        ret
435
        ret
Line 478... Line -...
478
 
-
 
479
max_cur_dir equ 0x1000  ; length
-
 
480
 
436
 
481
.get:       ; in: ecx -> buffer, edx = length
437
.get:       ; in: ecx -> buffer, edx = length
482
        mov     ebx, edi    ; buffer
438
        mov     ebx, edi    ; buffer
483
        push    ecx
439
        push    ecx
484
        push    edi
440
        push    edi
485
        xor     eax, eax
441
        xor     eax, eax
486
        mov     ecx, max_cur_dir
442
        mov     ecx, maxPathLength
487
        repne scasb
443
        repne scasb
488
        jnz     .error
444
        jnz     .error
489
        sub     edi, ebx
445
        sub     edi, ebx
490
        inc     edi
446
        inc     edi
Line 509... Line 465...
509
        or      dword[esp+32], -1
465
        or      dword[esp+32], -1
510
        ret
466
        ret
Line 511... Line 467...
511
 
467
 
512
.set:
468
.set:
513
        pop     eax
469
        pop     eax
514
        push    max_cur_dir
470
        push    maxPathLength
515
        push    edi
471
        push    edi
516
        push    eax
472
        push    eax
517
        mov     ebx, ecx
473
        mov     ebx, ecx
518
get_full_file_name:
474
get_full_file_name:
519
; in: ebx -> file name, [esp+4] -> destination, [esp+8] = max length
475
; in: ebx -> file name, [esp+4] -> destination, [esp+8] = max length
520
; destroys all registers
476
; destroys all registers
521
        push    ebp
-
 
522
        mov     esi, [current_slot]
-
 
523
        mov     esi, [esi+APPDATA.cur_dir]
-
 
524
        mov     edx, esi
-
 
525
@@:
-
 
526
        inc     esi
-
 
527
        cmp     byte [esi-1], 0
-
 
528
        jnz     @b
-
 
529
        dec     esi
477
        push    ebp
-
 
478
        cmp     byte [ebx], '/'
-
 
479
        jnz     .set_relative
-
 
480
        lea     esi, [ebx+1]
-
 
481
        call    process_replace_file_name
-
 
482
        mov     edi, [esp+8]
-
 
483
        mov     edx, [esp+12]
-
 
484
        add     edx, edi
-
 
485
.set_copy:
-
 
486
        lodsb
-
 
487
        stosb
530
        cmp     byte [ebx], '/'
488
        test    al, al
-
 
489
        jz      .set_part2
-
 
490
.set_copy_cont:
-
 
491
        cmp     edi, edx
-
 
492
        jb      .set_copy
-
 
493
.overflow:
-
 
494
        dec     edi
-
 
495
.fail:
-
 
496
        mov     byte [edi], 0
-
 
497
        xor     eax, eax
-
 
498
        pop     ebp
-
 
499
        ret     8
-
 
500
 
-
 
501
.set_part2:
-
 
502
        mov     esi, ebp
-
 
503
        xor     ebp, ebp
-
 
504
        test    esi, esi
-
 
505
        jz      .ret.ok
-
 
506
        mov     byte [edi-1], '/'
-
 
507
        jmp     .set_copy_cont
-
 
508
 
-
 
509
.set_relative:
-
 
510
        mov     edi, [current_slot]
-
 
511
        mov     edi, [edi+APPDATA.cur_dir]
-
 
512
        mov     edx, edi
-
 
513
        mov     ecx, [esp+12]
-
 
514
        xor     eax, eax
-
 
515
        repnz scasb
-
 
516
        mov     esi, edi
531
        jz      .set_absolute
517
        dec     esi
-
 
518
        mov     edi, [esp+8]
532
        mov     edi, [esp+8]
519
        jecxz   .fail
533
.relative:
520
.relative:
534
        cmp     byte [ebx], 0
521
        cmp     byte [ebx], 0
535
        jz      .set_ok
522
        jz      .set_ok
536
        cmp     word [ebx], '.'
523
        cmp     word [ebx], '.'
Line 554... Line 541...
554
        add     ebx, 3
541
        add     ebx, 3
555
        jmp     .relative
542
        jmp     .relative
Line 556... Line 543...
556
 
543
 
557
.set_ok:
544
.set_ok:
558
        cmp     edx, edi        ; is destination equal to APPDATA.cur_dir?
-
 
559
        jz      .set_ok.cur_dir
-
 
560
        sub     esi, edx
-
 
561
        cmp     esi, [esp+12]
-
 
562
        jb      .set_ok.copy
-
 
563
.fail:
-
 
564
        mov     byte [edi], 0
-
 
565
        xor     eax, eax
-
 
566
        pop     ebp
545
        cmp     edx, edi        ; is destination equal to APPDATA.cur_dir?
567
        ret     8
-
 
568
 
-
 
569
.set_ok.copy:
546
        jz      @f
-
 
547
        mov     ecx, esi
570
        mov     ecx, esi
548
        sub     ecx, edx
571
        mov     esi, edx
549
        mov     esi, edx
572
        rep movsb
550
        rep movsb
573
        mov     byte [edi], 0
551
        mov     byte [edi], 0
574
.ret.ok:
552
.ret.ok:
575
        mov     al, 1
553
        mov     al, 1
576
        pop     ebp
554
        pop     ebp
Line 577... Line 555...
577
        ret     8
555
        ret     8
578
 
556
 
579
.set_ok.cur_dir:
557
@@:
Line 580... Line 558...
580
        mov     byte [esi], 0
558
        mov     byte [esi], 0
581
        jmp     .ret.ok
559
        jmp     .ret.ok
582
 
560
 
583
.doset_relative:
-
 
584
        cmp     edx, edi
-
 
585
        jz      .doset_relative.cur_dir
-
 
586
        sub     esi, edx
561
.doset_relative:
-
 
562
        cmp     edx, edi
587
        cmp     esi, [esp+12]
563
        jz      .doset_relative.cur_dir
588
        jae     .fail
564
        mov     ecx, esi
589
        mov     ecx, esi
565
        sub     ecx, edx
590
        mov     esi, edx
566
        mov     esi, edx
Line 606... Line 582...
606
        stosb
582
        stosb
607
        test    al, al
583
        test    al, al
608
        jz      .ret.ok
584
        jz      .ret.ok
609
        cmp     edi, edx
585
        cmp     edi, edx
610
        jb      @b
586
        jb      @b
611
.overflow:
-
 
612
        dec     edi
-
 
613
        jmp     .fail
-
 
614
 
-
 
615
.set_absolute:
-
 
616
        lea     esi, [ebx+1]
-
 
617
        call    process_replace_file_name
-
 
618
        mov     edi, [esp+8]
-
 
619
        mov     edx, [esp+12]
-
 
620
        add     edx, edi
-
 
621
.set_copy:
-
 
622
        lodsb
-
 
623
        stosb
-
 
624
        test    al, al
-
 
625
        jz      .set_part2
-
 
626
.set_copy_cont:
-
 
627
        cmp     edi, edx
-
 
628
        jb      .set_copy
-
 
629
        jmp     .overflow
587
        jmp     .overflow
Line 630... Line -...
630
 
-
 
631
.set_part2:
-
 
632
        mov     esi, ebp
-
 
633
        xor     ebp, ebp
-
 
634
        test    esi, esi
-
 
635
        jz      .ret.ok
-
 
636
        mov     byte [edi-1], '/'
-
 
637
        jmp     .set_copy_cont
-
 
638
 
588
 
639
include "parse_fn.inc"
589
include "parse_fn.inc"
640
include "fs_common.inc"
590
include "fs_common.inc"
641
include "iso9660.inc"   ; read for CD filesystem
591
include "iso9660.inc"   ; read for CD filesystem
642
include "fat.inc"
592
include "fat.inc"