Ticket #3124: devfs_create_vnode.diff
File devfs_create_vnode.diff, 3.2 KB (added by , 16 years ago) |
---|
-
src/system/kernel/device_manager/devfs.cpp
215 215 { 216 216 struct devfs_vnode* vnode; 217 217 218 ktrace_printf("devfs_create_vnode: fs=%p, parent=%p, name=%s\n", fs,parent,name); 219 218 220 vnode = (struct devfs_vnode*)malloc(sizeof(struct devfs_vnode)); 219 221 if (vnode == NULL) 220 222 return NULL; -
src/system/kernel/fs/vfs.cpp
5461 5461 fix_dirent(struct vnode *parent, struct dirent *userEntry, 5462 5462 struct io_context* ioContext, uint32* _length) 5463 5463 { 5464 #define lnd do { ktrace_printf("fix_dirent: %d\n", __LINE__); } while(0) 5465 static int callCount = 0; 5466 callCount++; 5464 5467 char buffer[sizeof(struct dirent) + B_FILE_NAME_LENGTH]; 5465 5468 struct dirent* entry; 5466 5469 5470 bzero(&buffer, sizeof(buffer)); 5471 5467 5472 if (IS_USER_ADDRESS(userEntry)) { 5473 lnd; 5468 5474 entry = (struct dirent*)buffer; 5469 5475 if (user_memcpy(entry, userEntry, sizeof(struct dirent) - 1) != B_OK) 5470 5476 return B_BAD_ADDRESS; 5471 5477 5472 5478 ASSERT(entry->d_reclen >= sizeof(struct dirent)); 5473 5479 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 5474 5496 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) 5476 5498 return B_BAD_ADDRESS; 5477 5499 } else 5478 5500 entry = userEntry; 5479 5501 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); 5480 5504 *_length = entry->d_reclen; 5505 lnd; 5481 5506 5482 5507 // set d_pdev and d_pino 5483 5508 entry->d_pdev = parent->device; 5509 lnd; 5484 5510 entry->d_pino = parent->id; 5511 lnd; 5485 5512 5486 5513 // If this is the ".." entry and the directory is the root of a FS, 5487 5514 // we need to replace d_dev and d_ino with the actual values. … … 5529 5556 return user_memcpy(userEntry, entry, sizeof(struct dirent) - 1); 5530 5557 5531 5558 return B_OK; 5559 #undef lnd 5532 5560 } 5533 5561 5534 5562 … … 5536 5564 dir_read(struct io_context* ioContext, struct vnode *vnode, void *cookie, 5537 5565 struct dirent *buffer, size_t bufferSize, uint32 *_count) 5538 5566 { 5567 static int callCount=0; 5568 callCount ++; 5569 5539 5570 if (!HAS_FS_CALL(vnode, read_dir)) 5540 5571 return EOPNOTSUPP; 5541 5572 … … 5549 5580 if (count > 0) { 5550 5581 for (uint32 i = 0; i < count; i++) { 5551 5582 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); 5552 5587 error = fix_dirent(vnode, buffer, ioContext, &length); 5553 5588 if (error != B_OK) 5554 5589 return error;