Ticket #3124: fix_dirent-line-numbers.diff
File fix_dirent-line-numbers.diff, 2.3 KB (added by , 16 years ago) |
---|
-
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) 5464 5465 char buffer[sizeof(struct dirent) + B_FILE_NAME_LENGTH]; 5465 5466 struct dirent* entry; 5466 5467 5467 5468 if (IS_USER_ADDRESS(userEntry)) { 5469 lnd; 5468 5470 entry = (struct dirent*)buffer; 5469 5471 if (user_memcpy(entry, userEntry, sizeof(struct dirent) - 1) != B_OK) 5470 5472 return B_BAD_ADDRESS; … … 5476 5478 return B_BAD_ADDRESS; 5477 5479 } else 5478 5480 entry = userEntry; 5481 lnd; 5479 5482 5480 5483 *_length = entry->d_reclen; 5481 5484 5482 5485 // set d_pdev and d_pino 5483 5486 entry->d_pdev = parent->device; 5484 5487 entry->d_pino = parent->id; 5488 lnd; 5485 5489 5486 5490 // If this is the ".." entry and the directory is the root of a FS, 5487 5491 // we need to replace d_dev and d_ino with the actual values. 5488 5492 if (strcmp(entry->d_name, "..") == 0 5489 5493 && parent->mount->root_vnode == parent 5490 5494 && parent->mount->covers_vnode) { 5495 lnd; 5491 5496 inc_vnode_ref_count(parent); 5492 5497 // vnode_path_to_vnode() puts the node 5493 5498 5494 5499 // Make sure the IO context root is not bypassed. 5495 5500 if (parent == ioContext->root) { 5501 lnd; 5496 5502 entry->d_dev = parent->device; 5497 5503 entry->d_ino = parent->id; 5498 5504 } else { 5505 lnd; 5499 5506 // ".." is guaranteed not to be clobbered by this call 5500 5507 struct vnode *vnode; 5501 5508 status_t status = vnode_path_to_vnode(parent, (char*)"..", false, 0, … … 5507 5514 } 5508 5515 } 5509 5516 } else { 5517 lnd; 5510 5518 // resolve mount points 5511 5519 struct vnode *vnode = NULL; 5512 5520 status_t status = get_vnode(entry->d_dev, entry->d_ino, &vnode, true, … … 5514 5522 if (status != B_OK) 5515 5523 return status; 5516 5524 5525 lnd; 5517 5526 mutex_lock(&sVnodeCoveredByMutex); 5518 5527 if (vnode->covered_by) { 5519 5528 entry->d_dev = vnode->covered_by->device; … … 5522 5531 mutex_unlock(&sVnodeCoveredByMutex); 5523 5532 5524 5533 put_vnode(vnode); 5534 lnd; 5525 5535 } 5536 lnd; 5526 5537 5527 5538 // copy back from userland buffer if needed 5528 5539 if (entry != userEntry) 5529 return user_memcpy(userEntry, entry, sizeof(struct dirent) - 1); 5540 { 5541 status_t st; 5542 lnd; 5543 st= user_memcpy(userEntry, entry, sizeof(struct dirent) - 1); 5544 lnd; 5545 return st; 5546 } 5530 5547 5548 lnd; 5531 5549 return B_OK; 5550 #undef lnd 5532 5551 } 5533 5552 5534 5553