223 |
|
|
224 |
|
|
225 |
|
/* |
226 |
+ |
* Exchange parent CNIDs in all FSItems |
227 |
+ |
*/ |
228 |
+ |
|
229 |
+ |
static void swap_parent_ids(uint32 parent1, uint32 parent2) |
230 |
+ |
{ |
231 |
+ |
FSItem *p = first_fs_item; |
232 |
+ |
while (p) { |
233 |
+ |
if (p->parent_id == parent1) |
234 |
+ |
p->parent_id = parent2; |
235 |
+ |
else if (p->parent_id == parent2) |
236 |
+ |
p->parent_id = parent1; |
237 |
+ |
p = p->next; |
238 |
+ |
} |
239 |
+ |
} |
240 |
+ |
|
241 |
+ |
|
242 |
+ |
/* |
243 |
|
* String handling functions |
244 |
|
*/ |
245 |
|
|
1795 |
|
} |
1796 |
|
|
1797 |
|
// Read |
1798 |
< |
size_t actual = extfs_read(fd, Mac2HostAddr(ReadMacInt32(pb + ioBuffer)), ReadMacInt32(pb + ioReqCount)); |
1798 |
> |
ssize_t actual = extfs_read(fd, Mac2HostAddr(ReadMacInt32(pb + ioBuffer)), ReadMacInt32(pb + ioReqCount)); |
1799 |
|
int16 read_err = errno2oserr(); |
1800 |
|
D(bug(" actual %d\n", actual)); |
1801 |
< |
WriteMacInt32(pb + ioActCount, actual); |
1801 |
> |
WriteMacInt32(pb + ioActCount, actual >= 0 ? actual : 0); |
1802 |
|
uint32 pos = lseek(fd, 0, SEEK_CUR); |
1803 |
|
WriteMacInt32(fcb + fcbCrPs, pos); |
1804 |
|
WriteMacInt32(pb + ioPosOffset, pos); |
1805 |
|
if (actual != ReadMacInt32(pb + ioReqCount)) |
1806 |
< |
return read_err ? read_err : eofErr; |
1806 |
> |
return actual < 0 ? read_err : eofErr; |
1807 |
|
else |
1808 |
|
return noErr; |
1809 |
|
} |
1844 |
|
} |
1845 |
|
|
1846 |
|
// Write |
1847 |
< |
size_t actual = extfs_write(fd, Mac2HostAddr(ReadMacInt32(pb + ioBuffer)), ReadMacInt32(pb + ioReqCount)); |
1847 |
> |
ssize_t actual = extfs_write(fd, Mac2HostAddr(ReadMacInt32(pb + ioBuffer)), ReadMacInt32(pb + ioReqCount)); |
1848 |
|
int16 write_err = errno2oserr(); |
1849 |
|
D(bug(" actual %d\n", actual)); |
1850 |
< |
WriteMacInt32(pb + ioActCount, actual); |
1850 |
> |
WriteMacInt32(pb + ioActCount, actual >= 0 ? actual : 0); |
1851 |
|
uint32 pos = lseek(fd, 0, SEEK_CUR); |
1852 |
|
WriteMacInt32(fcb + fcbCrPs, pos); |
1853 |
|
WriteMacInt32(pb + ioPosOffset, pos); |
1957 |
|
return errno2oserr(); |
1958 |
|
else { |
1959 |
|
// The ID of the old file/dir has to stay the same, so we swap the IDs of the FSItems |
1960 |
+ |
swap_parent_ids(fs_item->id, new_item->id); |
1961 |
|
uint32 t = fs_item->id; |
1962 |
|
fs_item->id = new_item->id; |
1963 |
|
new_item->id = t; |
2003 |
|
// The ID of the old file/dir has to stay the same, so we swap the IDs of the FSItems |
2004 |
|
FSItem *new_item = find_fsitem(fs_item->name, new_dir_item); |
2005 |
|
if (new_item) { |
2006 |
+ |
swap_parent_ids(fs_item->id, new_item->id); |
2007 |
|
uint32 t = fs_item->id; |
2008 |
|
fs_item->id = new_item->id; |
2009 |
|
new_item->id = t; |