Ticket #3124: devfs_create_vnode.diff

File devfs_create_vnode.diff, 3.2 KB (added by Adek336, 16 years ago)

trace vnodes created in devfs. print name of offending direntry

  • src/system/kernel/device_manager/devfs.cpp

     
    215215{
    216216    struct devfs_vnode* vnode;
    217217
     218    ktrace_printf("devfs_create_vnode: fs=%p, parent=%p, name=%s\n", fs,parent,name);
     219
    218220    vnode = (struct devfs_vnode*)malloc(sizeof(struct devfs_vnode));
    219221    if (vnode == NULL)
    220222        return NULL;
  • src/system/kernel/fs/vfs.cpp

     
    54615461fix_dirent(struct vnode *parent, struct dirent *userEntry,
    54625462    struct io_context* ioContext, uint32* _length)
    54635463{
     5464#define lnd do { ktrace_printf("fix_dirent: %d\n", __LINE__); } while(0)
     5465    static int callCount = 0;
     5466    callCount++;
    54645467    char buffer[sizeof(struct dirent) + B_FILE_NAME_LENGTH];
    54655468    struct dirent* entry;
    54665469
     5470    bzero(&buffer, sizeof(buffer));
     5471
    54675472    if (IS_USER_ADDRESS(userEntry)) {
     5473        lnd;
    54685474        entry = (struct dirent*)buffer;
    54695475        if (user_memcpy(entry, userEntry, sizeof(struct dirent) - 1) != B_OK)
    54705476            return B_BAD_ADDRESS;
    54715477
    54725478        ASSERT(entry->d_reclen >= sizeof(struct dirent));
    54735479
     5480        if ( entry->d_reclen > sizeof(buffer))
     5481        {
     5482            char tmpBuf[2048];
     5483            char *pos = tmpBuf;
     5484            unsigned i;
     5485
     5486            for (i = 0; i < entry->d_reclen - sizeof(struct dirent) + 1; i++)
     5487                pos += sprintf(pos, "%02x ", (unsigned char)(userEntry->d_name[i]));
     5488
     5489            ktrace_printf("fix_dirent: name is %s\n", tmpBuf);
     5490
     5491            panic("%d = entry->d_reclen > sizeof(buffer) = %d", entry->d_reclen, (unsigned)sizeof(buffer));
     5492
     5493            entry->d_reclen = sizeof(buffer) - 1;
     5494        }
     5495
    54745496        if (user_memcpy(entry->d_name, userEntry->d_name,
    5475                 entry->d_reclen - sizeof(struct dirent)) != B_OK)
     5497                entry->d_reclen - sizeof(struct dirent) + 1) != B_OK)
    54765498            return B_BAD_ADDRESS;
    54775499    } else
    54785500        entry = userEntry;
    54795501
     5502    ktrace_printf("fix_dirent(%d): _length=%p, entry=%p, parent=%p, entry->d_name=%s\n",
     5503            callCount, _length, entry,parent, entry->d_name);
    54805504    *_length = entry->d_reclen;
     5505    lnd;
    54815506
    54825507    // set d_pdev and d_pino
    54835508    entry->d_pdev = parent->device;
     5509    lnd;
    54845510    entry->d_pino = parent->id;
     5511    lnd;
    54855512
    54865513    // If this is the ".." entry and the directory is the root of a FS,
    54875514    // we need to replace d_dev and d_ino with the actual values.
     
    55295556        return user_memcpy(userEntry, entry, sizeof(struct dirent) - 1);
    55305557
    55315558    return B_OK;
     5559#undef lnd
    55325560}
    55335561
    55345562
     
    55365564dir_read(struct io_context* ioContext, struct vnode *vnode, void *cookie,
    55375565    struct dirent *buffer, size_t bufferSize, uint32 *_count)
    55385566{
     5567    static int callCount=0;
     5568    callCount ++;
     5569
    55395570    if (!HAS_FS_CALL(vnode, read_dir))
    55405571        return EOPNOTSUPP;
    55415572
     
    55495580    if (count > 0) {
    55505581        for (uint32 i = 0; i < count; i++) {
    55515582            uint32 length;
     5583            ktrace_printf("dir_read(%d): cookie=%p, _count=%p, count=%d, i=%d, bufferSize=%d\n",
     5584                    callCount, cookie, _count, (unsigned)count, (unsigned)i, (unsigned)bufferSize);
     5585            ktrace_printf("fix_dirent args: parent=%p, userEntry=%p, ioContext=%p, _length=%p\n",
     5586                    vnode, buffer, ioContext, &length);
    55525587            error = fix_dirent(vnode, buffer, ioContext, &length);
    55535588            if (error != B_OK)
    55545589                return error;