Ticket #3124: d_reclen.diff
File d_reclen.diff, 2.4 KB (added by , 16 years ago) |
---|
-
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 panic("%d = entry->d_reclen > sizeof(buffer) = %d", entry->d_reclen, (unsigned)sizeof(buffer)); 5483 return B_BAD_VALUE; 5484 } 5485 5474 5486 if (user_memcpy(entry->d_name, userEntry->d_name, 5475 5487 entry->d_reclen - sizeof(struct dirent)) != B_OK) 5476 5488 return B_BAD_ADDRESS; 5477 5489 } else 5478 5490 entry = userEntry; 5479 5491 5492 ktrace_printf("fix_dirent(%d): _length=%p, entry=%p, parent=%p, entry->d_name=%s\n", 5493 callCount, _length, entry,parent, entry->d_name); 5480 5494 *_length = entry->d_reclen; 5495 lnd; 5481 5496 5482 5497 // set d_pdev and d_pino 5483 5498 entry->d_pdev = parent->device; 5499 lnd; 5484 5500 entry->d_pino = parent->id; 5501 lnd; 5485 5502 5486 5503 // If this is the ".." entry and the directory is the root of a FS, 5487 5504 // we need to replace d_dev and d_ino with the actual values. … … 5529 5546 return user_memcpy(userEntry, entry, sizeof(struct dirent) - 1); 5530 5547 5531 5548 return B_OK; 5549 #undef lnd 5532 5550 } 5533 5551 5534 5552 … … 5536 5554 dir_read(struct io_context* ioContext, struct vnode *vnode, void *cookie, 5537 5555 struct dirent *buffer, size_t bufferSize, uint32 *_count) 5538 5556 { 5557 static int callCount=0; 5558 callCount ++; 5539 5559 if (!HAS_FS_CALL(vnode, read_dir)) 5540 5560 return EOPNOTSUPP; 5541 5561 … … 5549 5569 if (count > 0) { 5550 5570 for (uint32 i = 0; i < count; i++) { 5551 5571 uint32 length; 5572 ktrace_printf("dir_read(%d): cookie=%p, _count=%p, count=%d, i=%d, bufferSize=%d\n", 5573 callCount, cookie, _count, (unsigned)count, (unsigned)i, (unsigned)bufferSize); 5574 ktrace_printf("fix_dirent args: parent=%p, userEntry=%p, ioContext=%p, _length=%p\n", 5575 vnode, buffer, ioContext, &length); 5552 5576 error = fix_dirent(vnode, buffer, ioContext, &length); 5553 5577 if (error != B_OK) 5554 5578 return error;