| 1730 | } |
| 1731 | |
| 1732 | U32 writeRecord(KMemory* memory, U32 dirp, U32 len, U32 count, U32 pos, bool is64, const char* name, U32 id, U32 type) { |
| 1733 | U32 recordLen = 0; |
| 1734 | |
| 1735 | if (is64) { |
| 1736 | recordLen = 20+(U32)strlen(name); |
| 1737 | recordLen=(recordLen+3) / 4 * 4; |
| 1738 | if (recordLen+len>count) { |
| 1739 | if (len==0) |
| 1740 | return -K_EINVAL; |
| 1741 | return 0; |
| 1742 | } |
| 1743 | memory->writeq(dirp, id); |
| 1744 | memory->writeq(dirp + 8, pos); |
| 1745 | memory->writew(dirp + 16, recordLen); |
| 1746 | memory->writeb(dirp + 18, type); |
| 1747 | memory->strcpy(dirp + 19, name); |
| 1748 | } else { |
| 1749 | recordLen = 12+(U32)strlen(name); |
| 1750 | recordLen=(recordLen+3) / 4 * 4; |
| 1751 | if (recordLen+len>count) { |
| 1752 | if (len==0) |
| 1753 | return -K_EINVAL; |
| 1754 | return 0; |
| 1755 | } |
| 1756 | memory->writed(dirp, id); |
| 1757 | memory->writed(dirp + 4, pos); |
| 1758 | memory->writew(dirp + 8, recordLen); |
| 1759 | memory->strcpy(dirp + 10, name); |
| 1760 | memory->writeb(dirp + recordLen - 1, type); |
| 1761 | } |
| 1762 | return recordLen; |
| 1763 | } |
| 1764 | |
| 1765 | U32 KProcess::getdents(FD fildes, U32 dirp, U32 count, bool is64) { |
| 1766 | KFileDescriptorPtr fd = this->getFileDescriptor(fildes); |