19 |
|
*/ |
20 |
|
|
21 |
|
/* |
22 |
< |
TODO: |
23 |
< |
LockRng |
24 |
< |
UnlockRng |
25 |
< |
(CatSearch) |
26 |
< |
(MakeFSSpec) |
27 |
< |
(GetVolMountInfoSize) |
28 |
< |
(GetVolMountInfo) |
29 |
< |
(GetForeignPrivs) |
30 |
< |
(SetForeignPrivs) |
31 |
< |
*/ |
22 |
> |
* SEE ALSO |
23 |
> |
* Guide to the File System Manager (from FSM 1.2 SDK) |
24 |
> |
* |
25 |
> |
* TODO |
26 |
> |
* LockRng |
27 |
> |
* UnlockRng |
28 |
> |
* (CatSearch) |
29 |
> |
* (MakeFSSpec) |
30 |
> |
* (GetVolMountInfoSize) |
31 |
> |
* (GetVolMountInfo) |
32 |
> |
* (GetForeignPrivs) |
33 |
> |
* (SetForeignPrivs) |
34 |
> |
*/ |
35 |
> |
|
36 |
> |
#include "sysdeps.h" |
37 |
|
|
38 |
|
#include <sys/types.h> |
39 |
|
#include <sys/stat.h> |
40 |
+ |
#include <string.h> |
41 |
|
#include <stdio.h> |
42 |
|
#include <stdlib.h> |
43 |
|
#include <unistd.h> |
44 |
+ |
#include <fcntl.h> |
45 |
|
#include <dirent.h> |
46 |
|
#include <errno.h> |
47 |
|
|
41 |
– |
#include "sysdeps.h" |
48 |
|
#include "cpu_emulation.h" |
49 |
|
#include "macos_util.h" |
50 |
|
#include "emul_op.h" |
204 |
|
const int MAX_PATH_LENGTH = 1024; |
205 |
|
static char full_path[MAX_PATH_LENGTH]; |
206 |
|
|
207 |
< |
static void add_path_component(const char *s) |
207 |
> |
static void add_path_comp(const char *s) |
208 |
|
{ |
209 |
< |
int l = strlen(full_path); |
204 |
< |
if (l < MAX_PATH_LENGTH-1 && full_path[l-1] != '/') { |
205 |
< |
full_path[l] = '/'; |
206 |
< |
full_path[l+1] = 0; |
207 |
< |
} |
208 |
< |
strncat(full_path, s, MAX_PATH_LENGTH-1); |
209 |
> |
add_path_component(full_path, s, MAX_PATH_LENGTH); |
210 |
|
} |
211 |
|
|
212 |
|
static void get_path_for_fsitem(FSItem *p) |
216 |
|
full_path[MAX_PATH_LENGTH-1] = 0; |
217 |
|
} else { |
218 |
|
get_path_for_fsitem(p->parent); |
219 |
< |
add_path_component(p->name); |
219 |
> |
add_path_comp(p->name); |
220 |
|
} |
221 |
|
} |
222 |
|
|
320 |
|
cstr2pstr(FS_NAME, GetString(STR_EXTFS_NAME)); |
321 |
|
cstr2pstr(VOLUME_NAME, GetString(STR_EXTFS_VOLUME_NAME)); |
322 |
|
|
323 |
< |
// Create root FSItem |
323 |
> |
// Create root's parent FSItem |
324 |
|
FSItem *p = new FSItem; |
325 |
|
first_fs_item = last_fs_item = p; |
326 |
|
p->next = NULL; |
327 |
+ |
p->id = ROOT_PARENT_ID; |
328 |
+ |
p->parent_id = 0; |
329 |
+ |
p->parent = NULL; |
330 |
+ |
p->name[0] = 0; |
331 |
+ |
|
332 |
+ |
// Create root FSItem |
333 |
+ |
p = new FSItem; |
334 |
+ |
last_fs_item->next = p; |
335 |
+ |
p->next = NULL; |
336 |
+ |
last_fs_item = p; |
337 |
|
p->id = ROOT_ID; |
338 |
|
p->parent_id = ROOT_PARENT_ID; |
339 |
< |
p->parent = NULL; |
339 |
> |
p->parent = first_fs_item; |
340 |
|
strncpy(p->name, GetString(STR_EXTFS_VOLUME_NAME), 32); |
341 |
|
|
342 |
|
// Find path for root |
387 |
|
r.d[0] = gestaltFSAttr; |
388 |
|
Execute68kTrap(0xa1ad, &r); // Gestalt() |
389 |
|
D(bug("FSAttr %ld, %08lx\n", r.d[0], r.a[0])); |
390 |
< |
if ((r.d[0] & 0xffff) || !(r.a[0] & (1 << gestaltHasFileSystemManager))) |
390 |
> |
if ((r.d[0] & 0xffff) || !(r.a[0] & (1 << gestaltHasFileSystemManager))) { |
391 |
> |
printf("WARNING: No FSM present, disabling ExtFS\n"); |
392 |
|
return; |
393 |
+ |
} |
394 |
|
|
395 |
|
// Yes, version >=1.2? |
396 |
|
r.d[0] = gestaltFSMVersion; |
397 |
|
Execute68kTrap(0xa1ad, &r); // Gestalt() |
398 |
|
D(bug("FSMVersion %ld, %08lx\n", r.d[0], r.a[0])); |
399 |
< |
if ((r.d[0] & 0xffff) || (r.a[0] < 0x0120)) |
399 |
> |
if ((r.d[0] & 0xffff) || (r.a[0] < 0x0120)) { |
400 |
> |
printf("WARNING: FSM <1.2 found, disabling ExtFS\n"); |
401 |
|
return; |
402 |
+ |
} |
403 |
|
|
404 |
|
D(bug("FSM present\n")); |
405 |
|
|
435 |
|
WriteMacInt16(p, 0x7006); p+= 2; // UTAllocateVCB |
436 |
|
WriteMacInt16(p, 0xa824); p+= 2; // FSMgr |
437 |
|
WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 |
438 |
< |
WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; |
438 |
> |
WriteMacInt16(p, M68K_RTS); p+= 2; |
439 |
|
if (p - fs_data != fsAddNewVCB) |
440 |
|
goto fsdat_error; |
441 |
|
WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) |
445 |
|
WriteMacInt16(p, 0x7007); p+= 2; // UTAddNewVCB |
446 |
|
WriteMacInt16(p, 0xa824); p+= 2; // FSMgr |
447 |
|
WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 |
448 |
< |
WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; |
448 |
> |
WriteMacInt16(p, M68K_RTS); p+= 2; |
449 |
|
if (p - fs_data != fsDetermineVol) |
450 |
|
goto fsdat_error; |
451 |
|
WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) |
457 |
|
WriteMacInt16(p, 0x701d); p+= 2; // UTDetermineVol |
458 |
|
WriteMacInt16(p, 0xa824); p+= 2; // FSMgr |
459 |
|
WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 |
460 |
< |
WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; |
460 |
> |
WriteMacInt16(p, M68K_RTS); p+= 2; |
461 |
|
if (p - fs_data != fsResolveWDCB) |
462 |
|
goto fsdat_error; |
463 |
|
WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) |
468 |
|
WriteMacInt16(p, 0x700e); p+= 2; // UTResolveWDCB |
469 |
|
WriteMacInt16(p, 0xa824); p+= 2; // FSMgr |
470 |
|
WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 |
471 |
< |
WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; |
471 |
> |
WriteMacInt16(p, M68K_RTS); p+= 2; |
472 |
|
if (p - fs_data != fsGetDefaultVol) |
473 |
|
goto fsdat_error; |
474 |
|
WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) |
476 |
|
WriteMacInt16(p, 0x7012); p+= 2; // UTGetDefaultVol |
477 |
|
WriteMacInt16(p, 0xa824); p+= 2; // FSMgr |
478 |
|
WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 |
479 |
< |
WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; |
479 |
> |
WriteMacInt16(p, M68K_RTS); p+= 2; |
480 |
|
if (p - fs_data != fsGetPathComponentName) |
481 |
|
goto fsdat_error; |
482 |
|
WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) |
484 |
|
WriteMacInt16(p, 0x701c); p+= 2; // UTGetPathComponentName |
485 |
|
WriteMacInt16(p, 0xa824); p+= 2; // FSMgr |
486 |
|
WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 |
487 |
< |
WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; |
487 |
> |
WriteMacInt16(p, M68K_RTS); p+= 2; |
488 |
|
if (p - fs_data != fsParsePathname) |
489 |
|
goto fsdat_error; |
490 |
|
WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) |
493 |
|
WriteMacInt16(p, 0x701b); p+= 2; // UTParsePathname |
494 |
|
WriteMacInt16(p, 0xa824); p+= 2; // FSMgr |
495 |
|
WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 |
496 |
< |
WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; |
496 |
> |
WriteMacInt16(p, M68K_RTS); p+= 2; |
497 |
|
if (p - fs_data != fsDisposeVCB) |
498 |
|
goto fsdat_error; |
499 |
|
WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) |
501 |
|
WriteMacInt16(p, 0x7008); p+= 2; // UTDisposeVCB |
502 |
|
WriteMacInt16(p, 0xa824); p+= 2; // FSMgr |
503 |
|
WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 |
504 |
< |
WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; |
504 |
> |
WriteMacInt16(p, M68K_RTS); p+= 2; |
505 |
|
if (p - fs_data != fsCheckWDRefNum) |
506 |
|
goto fsdat_error; |
507 |
|
WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) |
509 |
|
WriteMacInt16(p, 0x7013); p+= 2; // UTCheckWDRefNum |
510 |
|
WriteMacInt16(p, 0xa824); p+= 2; // FSMgr |
511 |
|
WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 |
512 |
< |
WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; |
512 |
> |
WriteMacInt16(p, M68K_RTS); p+= 2; |
513 |
|
if (p - fs_data != fsSetDefaultVol) |
514 |
|
goto fsdat_error; |
515 |
|
WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) |
519 |
|
WriteMacInt16(p, 0x7011); p+= 2; // UTSetDefaultVol |
520 |
|
WriteMacInt16(p, 0xa824); p+= 2; // FSMgr |
521 |
|
WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 |
522 |
< |
WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; |
522 |
> |
WriteMacInt16(p, M68K_RTS); p+= 2; |
523 |
|
if (p - fs_data != fsAllocateFCB) |
524 |
|
goto fsdat_error; |
525 |
|
WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) |
528 |
|
WriteMacInt16(p, 0x7000); p+= 2; // UTAllocateFCB |
529 |
|
WriteMacInt16(p, 0xa824); p+= 2; // FSMgr |
530 |
|
WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 |
531 |
< |
WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; |
531 |
> |
WriteMacInt16(p, M68K_RTS); p+= 2; |
532 |
|
if (p - fs_data != fsReleaseFCB) |
533 |
|
goto fsdat_error; |
534 |
|
WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) |
536 |
|
WriteMacInt16(p, 0x7001); p+= 2; // UTReleaseFCB |
537 |
|
WriteMacInt16(p, 0xa824); p+= 2; // FSMgr |
538 |
|
WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 |
539 |
< |
WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; |
539 |
> |
WriteMacInt16(p, M68K_RTS); p+= 2; |
540 |
|
if (p - fs_data != fsIndexFCB) |
541 |
|
goto fsdat_error; |
542 |
|
WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) |
546 |
|
WriteMacInt16(p, 0x7004); p+= 2; // UTIndexFCB |
547 |
|
WriteMacInt16(p, 0xa824); p+= 2; // FSMgr |
548 |
|
WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 |
549 |
< |
WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; |
549 |
> |
WriteMacInt16(p, M68K_RTS); p+= 2; |
550 |
|
if (p - fs_data != fsResolveFCB) |
551 |
|
goto fsdat_error; |
552 |
|
WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) |
555 |
|
WriteMacInt16(p, 0x7005); p+= 2; // UTResolveFCB |
556 |
|
WriteMacInt16(p, 0xa824); p+= 2; // FSMgr |
557 |
|
WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 |
558 |
< |
WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; |
558 |
> |
WriteMacInt16(p, M68K_RTS); p+= 2; |
559 |
|
if (p - fs_data != fsAdjustEOF) |
560 |
|
goto fsdat_error; |
561 |
|
WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) |
563 |
|
WriteMacInt16(p, 0x7010); p+= 2; // UTAdjustEOF |
564 |
|
WriteMacInt16(p, 0xa824); p+= 2; // FSMgr |
565 |
|
WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 |
566 |
< |
WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; |
566 |
> |
WriteMacInt16(p, M68K_RTS); p+= 2; |
567 |
|
if (p - fs_data != fsAllocateWDCB) |
568 |
|
goto fsdat_error; |
569 |
|
WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) |
571 |
|
WriteMacInt16(p, 0x700c); p+= 2; // UTAllocateWDCB |
572 |
|
WriteMacInt16(p, 0xa824); p+= 2; // FSMgr |
573 |
|
WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 |
574 |
< |
WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; |
574 |
> |
WriteMacInt16(p, M68K_RTS); p+= 2; |
575 |
|
if (p - fs_data != fsReleaseWDCB) |
576 |
|
goto fsdat_error; |
577 |
|
WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) |
579 |
|
WriteMacInt16(p, 0x700d); p+= 2; // UTReleaseWDCB |
580 |
|
WriteMacInt16(p, 0xa824); p+= 2; // FSMgr |
581 |
|
WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 |
582 |
< |
WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; |
582 |
> |
WriteMacInt16(p, M68K_RTS); p+= 2; |
583 |
|
if (p - fs_data != SIZEOF_fsdat) |
584 |
|
goto fsdat_error; |
585 |
|
|
694 |
|
int16 result; |
695 |
|
|
696 |
|
// Determine volume |
697 |
< |
// D(bug(" determining volume\n")); |
697 |
> |
D(bug(" determining volume, dirID %d\n", dirID)); |
698 |
|
r.a[0] = pb; |
699 |
|
r.a[1] = fs_data + fsReturn; |
700 |
|
r.a[2] = fs_data + fsReturn + 2; |
712 |
|
int16 more_matches = ReadMacInt16(fs_data + fsReturn + 2); |
713 |
|
int16 vRefNum = ReadMacInt16(fs_data + fsReturn + 4); |
714 |
|
uint32 vcb = ReadMacInt32(fs_data + fsReturn + 6); |
715 |
< |
// D(bug(" UTDetermineVol() returned %d, status %d\n", r.d[0], status)); |
715 |
> |
D(bug(" UTDetermineVol() returned %d, status %d\n", r.d[0], status)); |
716 |
|
result = r.d[0] & 0xffff; |
717 |
|
|
718 |
|
if (result == noErr) { |
795 |
|
uint32 current_dir; |
796 |
|
if ((result = get_current_dir(pb, dirID, current_dir, no_vol_name)) != noErr) |
797 |
|
return result; |
798 |
+ |
D(bug(" current dir %08x\n", current_dir)); |
799 |
|
FSItem *p = find_fsitem_by_id(current_dir); |
800 |
|
if (p == NULL) |
801 |
|
return dirNFErr; |
809 |
|
WriteMacInt8(parseRec + ppFoundDelimiter, false); |
810 |
|
|
811 |
|
// Get length of volume name |
812 |
< |
// D(bug(" parsing pathname\n")); |
812 |
> |
D(bug(" parsing pathname\n")); |
813 |
|
r.a[0] = parseRec + ppStartOffset; |
814 |
|
r.a[1] = ReadMacInt32(parseRec + ppNamePtr); |
815 |
|
Execute68k(fs_data + fsParsePathname, &r); |
816 |
< |
// D(bug(" UTParsePathname() returned %d, startOffset %d\n", r.d[0], ReadMacInt16(parseRec + ppStartOffset))); |
816 |
> |
D(bug(" UTParsePathname() returned %d, startOffset %d\n", r.d[0], ReadMacInt16(parseRec + ppStartOffset))); |
817 |
|
result = r.d[0] & 0xffff; |
818 |
|
if (result == noErr) { |
819 |
|
|
1092 |
|
// Set default volume (WDParam) |
1093 |
|
static int16 fs_set_vol(uint32 pb, bool hfs, uint32 vcb) |
1094 |
|
{ |
1095 |
< |
D(bug(" fs_set_vol(%08lx), vRefNum %d, name %#s, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), ReadMacInt32(pb + ioWDDirID))); |
1095 |
> |
D(bug(" fs_set_vol(%08lx), vRefNum %d, name %.31s, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr) + 1), ReadMacInt32(pb + ioWDDirID))); |
1096 |
|
M68kRegisters r; |
1097 |
|
|
1098 |
|
// Determine parameters |
1148 |
|
// Query file attributes (HFileParam) |
1149 |
|
static int16 fs_get_file_info(uint32 pb, bool hfs, uint32 dirID) |
1150 |
|
{ |
1151 |
< |
D(bug(" fs_get_file_info(%08lx), vRefNum %d, name %#s, idx %d, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), ReadMacInt16(pb + ioFDirIndex), dirID)); |
1151 |
> |
D(bug(" fs_get_file_info(%08lx), vRefNum %d, name %.31s, idx %d, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr) + 1), ReadMacInt16(pb + ioFDirIndex), dirID)); |
1152 |
|
|
1153 |
|
FSItem *fs_item; |
1154 |
< |
int16 dir_index = ReadMacInt16(pb + ioFDirIndex); |
1155 |
< |
if (dir_index == 0) { // Query item specified by ioDirID and ioNamePtr |
1154 |
> |
int16 dir_index = (int16)ReadMacInt16(pb + ioFDirIndex); |
1155 |
> |
if (dir_index <= 0) { // Query item specified by ioDirID and ioNamePtr |
1156 |
|
|
1157 |
|
// Find FSItem for given file |
1158 |
|
int16 result = get_item_and_path(pb, dirID, fs_item); |
1187 |
|
goto read_next_de; // Suppress name beginning with '.' (MacOS could interpret these as driver names) |
1188 |
|
//!! suppress directories |
1189 |
|
} |
1190 |
< |
add_path_component(de->d_name); |
1190 |
> |
add_path_comp(de->d_name); |
1191 |
|
|
1192 |
|
// Get FSItem for queried item |
1193 |
|
fs_item = find_fsitem(de->d_name, p); |
1244 |
|
// Set file attributes (HFileParam) |
1245 |
|
static int16 fs_set_file_info(uint32 pb, bool hfs, uint32 dirID) |
1246 |
|
{ |
1247 |
< |
D(bug(" fs_set_file_info(%08lx), vRefNum %d, name %#s, idx %d, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), ReadMacInt16(pb + ioFDirIndex), dirID)); |
1247 |
> |
D(bug(" fs_set_file_info(%08lx), vRefNum %d, name %.31s, idx %d, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr) + 1), ReadMacInt16(pb + ioFDirIndex), dirID)); |
1248 |
|
|
1249 |
|
// Find FSItem for given file/dir |
1250 |
|
FSItem *fs_item; |
1269 |
|
// Query file/directory attributes |
1270 |
|
static int16 fs_get_cat_info(uint32 pb) |
1271 |
|
{ |
1272 |
< |
D(bug(" fs_get_cat_info(%08lx), vRefNum %d, name %#s, idx %d, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), ReadMacInt16(pb + ioFDirIndex), ReadMacInt32(pb + ioDirID))); |
1272 |
> |
D(bug(" fs_get_cat_info(%08lx), vRefNum %d, name %.31s, idx %d, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr) + 1), ReadMacInt16(pb + ioFDirIndex), ReadMacInt32(pb + ioDirID))); |
1273 |
|
|
1274 |
|
FSItem *fs_item; |
1275 |
< |
int16 dir_index = ReadMacInt16(pb + ioFDirIndex); |
1276 |
< |
if (dir_index == -1) { // Query directory specified by ioDirID |
1275 |
> |
int16 dir_index = (int16)ReadMacInt16(pb + ioFDirIndex); |
1276 |
> |
if (dir_index < 0) { // Query directory specified by ioDirID |
1277 |
|
|
1278 |
|
// Find FSItem for directory |
1279 |
|
fs_item = find_fsitem_by_id(ReadMacInt32(pb + ioDrDirID)); |
1315 |
|
if (de->d_name[0] == '.') |
1316 |
|
goto read_next_de; // Suppress name beginning with '.' (MacOS could interpret these as driver names) |
1317 |
|
} |
1318 |
< |
add_path_component(de->d_name); |
1318 |
> |
add_path_comp(de->d_name); |
1319 |
|
|
1320 |
|
// Get FSItem for queried item |
1321 |
|
fs_item = find_fsitem(de->d_name, p); |
1403 |
|
// Set file/directory attributes |
1404 |
|
static int16 fs_set_cat_info(uint32 pb) |
1405 |
|
{ |
1406 |
< |
D(bug(" fs_set_cat_info(%08lx), vRefNum %d, name %#s, idx %d, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), ReadMacInt16(pb + ioFDirIndex), ReadMacInt32(pb + ioDirID))); |
1406 |
> |
D(bug(" fs_set_cat_info(%08lx), vRefNum %d, name %.31s, idx %d, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr) + 1), ReadMacInt16(pb + ioFDirIndex), ReadMacInt32(pb + ioDirID))); |
1407 |
|
|
1408 |
|
// Find FSItem for given file/dir |
1409 |
|
FSItem *fs_item; |
1430 |
|
// Open file |
1431 |
|
static int16 fs_open(uint32 pb, uint32 dirID, uint32 vcb, bool resource_fork) |
1432 |
|
{ |
1433 |
< |
D(bug(" fs_open(%08lx), %s, vRefNum %d, name %#s, dirID %d, perm %d\n", pb, resource_fork ? "rsrc" : "data", ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), dirID, ReadMacInt8(pb + ioPermssn))); |
1433 |
> |
D(bug(" fs_open(%08lx), %s, vRefNum %d, name %.31s, dirID %d, perm %d\n", pb, resource_fork ? "rsrc" : "data", ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr) + 1), dirID, ReadMacInt8(pb + ioPermssn))); |
1434 |
|
M68kRegisters r; |
1435 |
|
|
1436 |
|
// Find FSItem for given file |
1717 |
|
if (lseek(fd, ReadMacInt32(pb + ioPosOffset), SEEK_SET) < 0) |
1718 |
|
return posErr; |
1719 |
|
break; |
1720 |
+ |
case fsFromLEOF: |
1721 |
+ |
if (lseek(fd, (int32)ReadMacInt32(pb + ioPosOffset), SEEK_END) < 0) |
1722 |
+ |
return posErr; |
1723 |
+ |
break; |
1724 |
|
case fsFromMark: |
1725 |
< |
if (lseek(fd, ReadMacInt32(pb + ioPosOffset), SEEK_CUR) < 0) |
1725 |
> |
if (lseek(fd, (int32)ReadMacInt32(pb + ioPosOffset), SEEK_CUR) < 0) |
1726 |
|
return posErr; |
1727 |
+ |
break; |
1728 |
|
default: |
1729 |
|
break; |
1730 |
|
} |
1836 |
|
// Create file |
1837 |
|
static int16 fs_create(uint32 pb, uint32 dirID) |
1838 |
|
{ |
1839 |
< |
D(bug(" fs_create(%08lx), vRefNum %d, name %#s, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), dirID)); |
1839 |
> |
D(bug(" fs_create(%08lx), vRefNum %d, name %.31s, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr) + 1), dirID)); |
1840 |
|
|
1841 |
|
// Find FSItem for given file |
1842 |
|
FSItem *fs_item; |
1861 |
|
// Create directory |
1862 |
|
static int16 fs_dir_create(uint32 pb) |
1863 |
|
{ |
1864 |
< |
D(bug(" fs_dir_create(%08lx), vRefNum %d, name %#s, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), ReadMacInt32(pb + ioDirID))); |
1864 |
> |
D(bug(" fs_dir_create(%08lx), vRefNum %d, name %.31s, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr) + 1), ReadMacInt32(pb + ioDirID))); |
1865 |
|
|
1866 |
|
// Find FSItem for given directory |
1867 |
|
FSItem *fs_item; |
1885 |
|
// Delete file/directory |
1886 |
|
static int16 fs_delete(uint32 pb, uint32 dirID) |
1887 |
|
{ |
1888 |
< |
D(bug(" fs_delete(%08lx), vRefNum %d, name %#s, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), dirID)); |
1888 |
> |
D(bug(" fs_delete(%08lx), vRefNum %d, name %.31s, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr) + 1), dirID)); |
1889 |
|
|
1890 |
|
// Find FSItem for given file/dir |
1891 |
|
FSItem *fs_item; |
1910 |
|
// Rename file/directory |
1911 |
|
static int16 fs_rename(uint32 pb, uint32 dirID) |
1912 |
|
{ |
1913 |
< |
D(bug(" fs_rename(%08lx), vRefNum %d, name %#s, dirID %d, new name %#s\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), dirID, Mac2HostAddr(ReadMacInt32(pb + ioMisc)))); |
1913 |
> |
D(bug(" fs_rename(%08lx), vRefNum %d, name %.31s, dirID %d, new name %.31s\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr) + 1), dirID, Mac2HostAddr(ReadMacInt32(pb + ioMisc) + 1))); |
1914 |
|
|
1915 |
|
// Find path of given file/dir |
1916 |
|
FSItem *fs_item; |
1951 |
|
// Move file/directory (CMovePBRec) |
1952 |
|
static int16 fs_cat_move(uint32 pb) |
1953 |
|
{ |
1954 |
< |
D(bug(" fs_cat_move(%08lx), vRefNum %d, name %#s, dirID %d, new name %#s, new dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), ReadMacInt32(pb + ioDirID), Mac2HostAddr(ReadMacInt32(pb + ioNewName)), ReadMacInt32(pb + ioNewDirID))); |
1954 |
> |
D(bug(" fs_cat_move(%08lx), vRefNum %d, name %.31s, dirID %d, new name %.31s, new dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr) + 1), ReadMacInt32(pb + ioDirID), Mac2HostAddr(ReadMacInt32(pb + ioNewName) + 1), ReadMacInt32(pb + ioNewDirID))); |
1955 |
|
|
1956 |
|
// Find path of given file/dir |
1957 |
|
FSItem *fs_item; |
1973 |
|
return result; |
1974 |
|
|
1975 |
|
// Append old file/dir name |
1976 |
< |
add_path_component(fs_item->name); |
1976 |
> |
add_path_comp(fs_item->name); |
1977 |
|
|
1978 |
|
// Does the new name already exist? |
1979 |
|
if (access(full_path, F_OK) == 0) |
1998 |
|
// Open working directory (WDParam) |
1999 |
|
static int16 fs_open_wd(uint32 pb) |
2000 |
|
{ |
2001 |
< |
D(bug(" fs_open_wd(%08lx), vRefNum %d, name %#s, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), ReadMacInt32(pb + ioWDDirID))); |
2001 |
> |
D(bug(" fs_open_wd(%08lx), vRefNum %d, name %.31s, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr) + 1), ReadMacInt32(pb + ioWDDirID))); |
2002 |
|
M68kRegisters r; |
2003 |
|
|
2004 |
|
// Allocate WDCB |