Fix _user_entry_ref_to_path() in chroot
* Add "bool kernel" parameter to vfs_entry_ref_to_path(), so it can be specified for which I/O context the entry ref shall be translated. * _user_entry_ref_to_path(): Use the calling team's I/O context instead of the kernel's. Fixes the bug that in a chroot the syscall would return a path for outside the chroot.
This commit is contained in:
parent
5be84d5f00
commit
237127fbe4
@ -119,7 +119,7 @@ status_t vfs_stat_node_ref(dev_t device, ino_t inode, struct stat *stat);
|
||||
status_t vfs_get_vnode_name(struct vnode *vnode, char *name,
|
||||
size_t nameSize);
|
||||
status_t vfs_entry_ref_to_path(dev_t device, ino_t inode, const char *leaf,
|
||||
char *path, size_t pathLength);
|
||||
bool kernel, char *path, size_t pathLength);
|
||||
status_t vfs_get_cwd(dev_t *_mountID, ino_t *_vnodeID);
|
||||
void vfs_unlock_vnode_if_locked(struct file_descriptor *descriptor);
|
||||
status_t vfs_unmount(dev_t mountID, uint32 flags);
|
||||
|
@ -162,7 +162,7 @@ struct Volume::PackagesDirectory {
|
||||
RETURN_ERROR(normalizedPath.InitCheck());
|
||||
|
||||
char* normalizedPathBuffer = normalizedPath.LockBuffer();
|
||||
error = vfs_entry_ref_to_path(fDeviceID, fNodeID, NULL,
|
||||
error = vfs_entry_ref_to_path(fDeviceID, fNodeID, NULL, true,
|
||||
normalizedPathBuffer, normalizedPath.BufferSize());
|
||||
if (error != B_OK)
|
||||
RETURN_ERROR(error);
|
||||
|
@ -1086,7 +1086,7 @@ DirectoryWatcher::EventOccurred(NotificationService& service,
|
||||
|
||||
KPath path(B_PATH_NAME_LENGTH + 1);
|
||||
if (path.InitCheck() != B_OK || vfs_entry_ref_to_path(device, directory,
|
||||
name, path.LockBuffer(), path.BufferSize()) != B_OK)
|
||||
name, true, path.LockBuffer(), path.BufferSize()) != B_OK)
|
||||
return;
|
||||
|
||||
path.UnlockBuffer();
|
||||
|
@ -201,8 +201,8 @@ public:
|
||||
KPath path(B_PATH_NAME_LENGTH + 1);
|
||||
if (path.InitCheck() != B_OK
|
||||
|| vfs_entry_ref_to_path(event->device, event->directory,
|
||||
event->name, path.LockBuffer(),
|
||||
path.BufferSize()) != B_OK) {
|
||||
event->name, true, path.LockBuffer(),
|
||||
path.BufferSize()) != B_OK) {
|
||||
delete event;
|
||||
return B_ERROR;
|
||||
}
|
||||
|
@ -4664,7 +4664,7 @@ vfs_get_vnode_name(struct vnode* vnode, char* name, size_t nameSize)
|
||||
|
||||
status_t
|
||||
vfs_entry_ref_to_path(dev_t device, ino_t inode, const char* leaf,
|
||||
char* path, size_t pathLength)
|
||||
bool kernel, char* path, size_t pathLength)
|
||||
{
|
||||
struct vnode* vnode;
|
||||
status_t status;
|
||||
@ -4677,7 +4677,7 @@ vfs_entry_ref_to_path(dev_t device, ino_t inode, const char* leaf,
|
||||
if (leaf && (strcmp(leaf, ".") == 0 || strcmp(leaf, "..") == 0)) {
|
||||
// special cases "." and "..": we can directly get the vnode of the
|
||||
// referenced directory
|
||||
status = entry_ref_to_vnode(device, inode, leaf, false, true, &vnode);
|
||||
status = entry_ref_to_vnode(device, inode, leaf, false, kernel, &vnode);
|
||||
leaf = NULL;
|
||||
} else
|
||||
status = get_vnode(device, inode, &vnode, true, false);
|
||||
@ -4685,7 +4685,7 @@ vfs_entry_ref_to_path(dev_t device, ino_t inode, const char* leaf,
|
||||
return status;
|
||||
|
||||
// get the directory path
|
||||
status = dir_vnode_to_path(vnode, path, pathLength, true);
|
||||
status = dir_vnode_to_path(vnode, path, pathLength, kernel);
|
||||
put_vnode(vnode);
|
||||
// we don't need the vnode anymore
|
||||
if (status != B_OK)
|
||||
@ -8708,7 +8708,7 @@ _user_entry_ref_to_path(dev_t device, ino_t inode, const char* leaf,
|
||||
}
|
||||
|
||||
status_t status = vfs_entry_ref_to_path(device, inode, leaf,
|
||||
path.LockBuffer(), path.BufferSize());
|
||||
false, path.LockBuffer(), path.BufferSize());
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
|
||||
|
@ -1412,7 +1412,7 @@ ModuleNotificationService::_AddModuleNode(dev_t device, ino_t node, int fd,
|
||||
KPath path;
|
||||
status = path.InitCheck();
|
||||
if (status == B_OK) {
|
||||
status = vfs_entry_ref_to_path(device, directory, name,
|
||||
status = vfs_entry_ref_to_path(device, directory, name, true,
|
||||
path.LockBuffer(), path.BufferSize());
|
||||
}
|
||||
if (status != B_OK)
|
||||
@ -1583,7 +1583,7 @@ ModuleNotificationService::_Notify(int32 opcode, dev_t device, ino_t directory,
|
||||
if (name != NULL) {
|
||||
// we have an entry ref
|
||||
if (pathBuffer.InitCheck() != B_OK
|
||||
|| vfs_entry_ref_to_path(device, directory, name,
|
||||
|| vfs_entry_ref_to_path(device, directory, name, true,
|
||||
pathBuffer.LockBuffer(), pathBuffer.BufferSize()) != B_OK)
|
||||
return;
|
||||
|
||||
|
@ -2690,7 +2690,7 @@ vfs_get_vnode_name(void *_vnode, char *name, fssh_size_t nameSize)
|
||||
|
||||
fssh_status_t
|
||||
vfs_entry_ref_to_path(fssh_dev_t device, fssh_ino_t inode, const char *leaf,
|
||||
char *path, fssh_size_t pathLength)
|
||||
bool kernel, char *path, fssh_size_t pathLength)
|
||||
{
|
||||
struct vnode *vnode;
|
||||
fssh_status_t status;
|
||||
@ -5691,7 +5691,7 @@ fssh_status_t
|
||||
_kern_entry_ref_to_path(fssh_dev_t device, fssh_ino_t inode, const char *leaf,
|
||||
char* path, fssh_size_t pathLength)
|
||||
{
|
||||
return vfs_entry_ref_to_path(device, inode, leaf, path, pathLength);
|
||||
return vfs_entry_ref_to_path(device, inode, leaf, true, path, pathLength);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user