1063 |
|
// D(bug(" fs_get_vol_parms(%08lx)\n", pb)); |
1064 |
|
|
1065 |
|
// Return parameter block |
1066 |
– |
uint8 vol[SIZEOF_GetVolParmsInfoBuffer]; |
1067 |
– |
WriteMacInt16((uint32)vol + vMVersion, 2); |
1068 |
– |
WriteMacInt32((uint32)vol + vMAttrib, kNoMiniFndr | kNoVNEdit | kNoLclSync | kTrshOffLine | kNoSwitchTo | kNoBootBlks | kNoSysDir | kHasExtFSVol); |
1069 |
– |
WriteMacInt32((uint32)vol + vMLocalHand, 0); |
1070 |
– |
WriteMacInt32((uint32)vol + vMServerAdr, 0); |
1071 |
– |
WriteMacInt32((uint32)vol + vMVolumeGrade, 0); |
1072 |
– |
WriteMacInt16((uint32)vol + vMForeignPrivID, 0); |
1066 |
|
uint32 actual = ReadMacInt32(pb + ioReqCount); |
1067 |
< |
if (actual > sizeof(vol)) |
1068 |
< |
actual = sizeof(vol); |
1076 |
< |
Host2Mac_memcpy(ReadMacInt32(pb + ioBuffer), vol, actual); |
1067 |
> |
if (actual > SIZEOF_GetVolParmsInfoBuffer) |
1068 |
> |
actual = SIZEOF_GetVolParmsInfoBuffer; |
1069 |
|
WriteMacInt32(pb + ioActCount, actual); |
1070 |
+ |
uint32 p = ReadMacInt32(pb + ioBuffer); |
1071 |
+ |
if (actual > vMVersion) WriteMacInt16(p + vMVersion, 2); |
1072 |
+ |
if (actual > vMAttrib) WriteMacInt32(p + vMAttrib, kNoMiniFndr | kNoVNEdit | kNoLclSync | kTrshOffLine | kNoSwitchTo | kNoBootBlks | kNoSysDir | kHasExtFSVol); |
1073 |
+ |
if (actual > vMLocalHand) WriteMacInt32(p + vMLocalHand, 0); |
1074 |
+ |
if (actual > vMServerAdr) WriteMacInt32(p + vMServerAdr, 0); |
1075 |
+ |
if (actual > vMVolumeGrade) WriteMacInt32(p + vMVolumeGrade, 0); |
1076 |
+ |
if (actual > vMForeignPrivID) WriteMacInt16(p + vMForeignPrivID, 0); |
1077 |
|
return noErr; |
1078 |
|
} |
1079 |
|
|
1186 |
|
return fnfErr; |
1187 |
|
} |
1188 |
|
if (de->d_name[0] == '.') |
1189 |
< |
goto read_next_de; // Suppress name beginning with '.' (MacOS could interpret these as driver names) |
1189 |
> |
goto read_next_de; // Suppress names beginning with '.' (MacOS could interpret these as driver names) |
1190 |
|
//!! suppress directories |
1191 |
|
} |
1192 |
|
add_path_comp(de->d_name); |
1315 |
|
return fnfErr; |
1316 |
|
} |
1317 |
|
if (de->d_name[0] == '.') |
1318 |
< |
goto read_next_de; // Suppress name beginning with '.' (MacOS could interpret these as driver names) |
1318 |
> |
goto read_next_de; // Suppress names beginning with '.' (MacOS could interpret these as driver names) |
1319 |
|
} |
1320 |
|
add_path_comp(de->d_name); |
1321 |
|
|
1351 |
|
fs_item->mtime = mtime; |
1352 |
|
cached = false; |
1353 |
|
} |
1354 |
< |
WriteMacInt32(pb + ioFlMdDat, mtime); |
1354 |
> |
WriteMacInt32(pb + ioFlMdDat, mtime + TIME_OFFSET); |
1355 |
|
WriteMacInt32(pb + ioFlBkDat, 0); |
1356 |
|
if (S_ISDIR(st.st_mode)) { |
1357 |
|
Mac_memset(pb + ioDrUsrWds, 0, SIZEOF_DInfo); |
1373 |
|
de = readdir(d); |
1374 |
|
if (de == NULL) |
1375 |
|
break; |
1376 |
+ |
if (de->d_name[0] == '.') |
1377 |
+ |
continue; // Suppress names beginning with '.' |
1378 |
|
count++; |
1379 |
|
} |
1380 |
|
closedir(d); |
1474 |
|
return fnfErr; |
1475 |
|
fd = open_rfork(full_path, flag); |
1476 |
|
if (fd > 0) { |
1477 |
< |
if (fstat(fd, &st) < 0) |
1477 |
> |
if (fstat(fd, &st) < 0) { |
1478 |
> |
close(fd); |
1479 |
|
return errno2oserr(); |
1480 |
+ |
} |
1481 |
|
} else { // Resource fork not supported, silently ignore it ("pseudo" resource fork) |
1482 |
|
st.st_size = 0; |
1483 |
|
st.st_mode = 0; |
1486 |
|
fd = open(full_path, flag); |
1487 |
|
if (fd < 0) |
1488 |
|
return errno2oserr(); |
1489 |
< |
if (fstat(fd, &st) < 0) |
1489 |
> |
if (fstat(fd, &st) < 0) { |
1490 |
> |
close(fd); |
1491 |
|
return errno2oserr(); |
1492 |
+ |
} |
1493 |
|
} |
1494 |
|
|
1495 |
|
// File open, allocate FCB |
1512 |
|
WriteMacInt32(fcb + fcbCrPs, 0); |
1513 |
|
WriteMacInt32(fcb + fcbVPtr, vcb); |
1514 |
|
WriteMacInt32(fcb + fcbClmpSize, 1024); |
1515 |
< |
uint32 type, creator; // fcb may point to kernel space, but stack is switched |
1515 |
> |
uint32 type, creator; // BeOS: fcb may point to kernel space, but stack is switched |
1516 |
|
get_finder_type(full_path, type, creator); |
1517 |
|
WriteMacInt32(fcb + fcbFType, type); |
1518 |
|
WriteMacInt32(fcb + fcbCatPos, fd); |
1779 |
|
|
1780 |
|
// Read |
1781 |
|
size_t actual = extfs_read(fd, Mac2HostAddr(ReadMacInt32(pb + ioBuffer)), ReadMacInt32(pb + ioReqCount)); |
1782 |
+ |
int16 read_err = errno2oserr(); |
1783 |
|
D(bug(" actual %d\n", actual)); |
1784 |
|
WriteMacInt32(pb + ioActCount, actual); |
1785 |
|
uint32 pos = lseek(fd, 0, SEEK_CUR); |
1786 |
|
WriteMacInt32(fcb + fcbCrPs, pos); |
1787 |
|
WriteMacInt32(pb + ioPosOffset, pos); |
1788 |
|
if (actual != ReadMacInt32(pb + ioReqCount)) |
1789 |
< |
if (errno) |
1784 |
< |
return errno2oserr(); |
1785 |
< |
else |
1786 |
< |
return eofErr; |
1789 |
> |
return read_err ? read_err : eofErr; |
1790 |
|
else |
1791 |
|
return noErr; |
1792 |
|
} |
1828 |
|
|
1829 |
|
// Write |
1830 |
|
size_t actual = extfs_write(fd, Mac2HostAddr(ReadMacInt32(pb + ioBuffer)), ReadMacInt32(pb + ioReqCount)); |
1831 |
+ |
int16 write_err = errno2oserr(); |
1832 |
|
D(bug(" actual %d\n", actual)); |
1833 |
|
WriteMacInt32(pb + ioActCount, actual); |
1834 |
|
uint32 pos = lseek(fd, 0, SEEK_CUR); |
1835 |
|
WriteMacInt32(fcb + fcbCrPs, pos); |
1836 |
|
WriteMacInt32(pb + ioPosOffset, pos); |
1837 |
|
if (actual != ReadMacInt32(pb + ioReqCount)) |
1838 |
< |
return errno2oserr(); |
1838 |
> |
return write_err; |
1839 |
|
else |
1840 |
|
return noErr; |
1841 |
|
} |
1901 |
|
return result; |
1902 |
|
|
1903 |
|
// Delete file |
1904 |
< |
if (remove(full_path) < 0) { |
1905 |
< |
int16 err = errno2oserr(); |
1906 |
< |
if (errno == EISDIR) { // Workaround for BeOS bug |
1903 |
< |
if (rmdir(full_path) < 0) |
1904 |
< |
return errno2oserr(); |
1905 |
< |
else |
1906 |
< |
return noErr; |
1907 |
< |
} else |
1908 |
< |
return err; |
1909 |
< |
} else |
1904 |
> |
if (!extfs_remove(full_path)) |
1905 |
> |
return errno2oserr(); |
1906 |
> |
else |
1907 |
|
return noErr; |
1908 |
|
} |
1909 |
|
|
1936 |
|
|
1937 |
|
// Rename item |
1938 |
|
D(bug(" renaming %s -> %s\n", old_path, full_path)); |
1939 |
< |
if (rename(old_path, full_path) < 0) |
1939 |
> |
if (!extfs_rename(old_path, full_path)) |
1940 |
|
return errno2oserr(); |
1941 |
|
else { |
1942 |
|
// The ID of the old file/dir has to stay the same, so we swap the IDs of the FSItems |
1963 |
|
strcpy(old_path, full_path); |
1964 |
|
|
1965 |
|
// Find path for new directory |
1966 |
< |
Mac2Host_memcpy(fs_data + fsPB, pb, SIZEOF_IOParam); |
1966 |
> |
Mac2Mac_memcpy(fs_data + fsPB, pb, SIZEOF_IOParam); |
1967 |
|
WriteMacInt32(fs_data + fsPB + ioNamePtr, ReadMacInt32(pb + ioNewName)); |
1968 |
|
FSItem *new_dir_item; |
1969 |
|
result = get_item_and_path(fs_data + fsPB, ReadMacInt32(pb + ioNewDirID), new_dir_item); |
1979 |
|
|
1980 |
|
// Move item |
1981 |
|
D(bug(" moving %s -> %s\n", old_path, full_path)); |
1982 |
< |
if (rename(old_path, full_path) < 0) |
1982 |
> |
if (!extfs_rename(old_path, full_path)) |
1983 |
|
return errno2oserr(); |
1984 |
|
else { |
1985 |
|
// The ID of the old file/dir has to stay the same, so we swap the IDs of the FSItems |
2050 |
|
return r.d[0]; |
2051 |
|
|
2052 |
|
// Return information |
2053 |
< |
WriteMacInt16(pb + ioWDProcID, ReadMacInt32(wdcb + wdProcID)); |
2053 |
> |
WriteMacInt32(pb + ioWDProcID, ReadMacInt32(wdcb + wdProcID)); |
2054 |
|
WriteMacInt16(pb + ioWDVRefNum, ReadMacInt16(ReadMacInt32(wdcb + wdVCBPtr) + vcbVRefNum)); |
2055 |
|
if (ReadMacInt32(pb + ioNamePtr)) |
2056 |
|
Mac2Mac_memcpy(ReadMacInt32(pb + ioNamePtr), ReadMacInt32(wdcb + wdVCBPtr) + vcbVN, 28); |