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:
@@ -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,
|
status_t vfs_get_vnode_name(struct vnode *vnode, char *name,
|
||||||
size_t nameSize);
|
size_t nameSize);
|
||||||
status_t vfs_entry_ref_to_path(dev_t device, ino_t inode, const char *leaf,
|
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);
|
status_t vfs_get_cwd(dev_t *_mountID, ino_t *_vnodeID);
|
||||||
void vfs_unlock_vnode_if_locked(struct file_descriptor *descriptor);
|
void vfs_unlock_vnode_if_locked(struct file_descriptor *descriptor);
|
||||||
status_t vfs_unmount(dev_t mountID, uint32 flags);
|
status_t vfs_unmount(dev_t mountID, uint32 flags);
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ struct Volume::PackagesDirectory {
|
|||||||
RETURN_ERROR(normalizedPath.InitCheck());
|
RETURN_ERROR(normalizedPath.InitCheck());
|
||||||
|
|
||||||
char* normalizedPathBuffer = normalizedPath.LockBuffer();
|
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());
|
normalizedPathBuffer, normalizedPath.BufferSize());
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
|
|||||||
@@ -1086,7 +1086,7 @@ DirectoryWatcher::EventOccurred(NotificationService& service,
|
|||||||
|
|
||||||
KPath path(B_PATH_NAME_LENGTH + 1);
|
KPath path(B_PATH_NAME_LENGTH + 1);
|
||||||
if (path.InitCheck() != B_OK || vfs_entry_ref_to_path(device, directory,
|
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;
|
return;
|
||||||
|
|
||||||
path.UnlockBuffer();
|
path.UnlockBuffer();
|
||||||
|
|||||||
@@ -201,8 +201,8 @@ public:
|
|||||||
KPath path(B_PATH_NAME_LENGTH + 1);
|
KPath path(B_PATH_NAME_LENGTH + 1);
|
||||||
if (path.InitCheck() != B_OK
|
if (path.InitCheck() != B_OK
|
||||||
|| vfs_entry_ref_to_path(event->device, event->directory,
|
|| vfs_entry_ref_to_path(event->device, event->directory,
|
||||||
event->name, path.LockBuffer(),
|
event->name, true, path.LockBuffer(),
|
||||||
path.BufferSize()) != B_OK) {
|
path.BufferSize()) != B_OK) {
|
||||||
delete event;
|
delete event;
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4664,7 +4664,7 @@ vfs_get_vnode_name(struct vnode* vnode, char* name, size_t nameSize)
|
|||||||
|
|
||||||
status_t
|
status_t
|
||||||
vfs_entry_ref_to_path(dev_t device, ino_t inode, const char* leaf,
|
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;
|
struct vnode* vnode;
|
||||||
status_t status;
|
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)) {
|
if (leaf && (strcmp(leaf, ".") == 0 || strcmp(leaf, "..") == 0)) {
|
||||||
// special cases "." and "..": we can directly get the vnode of the
|
// special cases "." and "..": we can directly get the vnode of the
|
||||||
// referenced directory
|
// 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;
|
leaf = NULL;
|
||||||
} else
|
} else
|
||||||
status = get_vnode(device, inode, &vnode, true, false);
|
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;
|
return status;
|
||||||
|
|
||||||
// get the directory path
|
// 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);
|
put_vnode(vnode);
|
||||||
// we don't need the vnode anymore
|
// we don't need the vnode anymore
|
||||||
if (status != B_OK)
|
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,
|
status_t status = vfs_entry_ref_to_path(device, inode, leaf,
|
||||||
path.LockBuffer(), path.BufferSize());
|
false, path.LockBuffer(), path.BufferSize());
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
|
|||||||
@@ -1412,7 +1412,7 @@ ModuleNotificationService::_AddModuleNode(dev_t device, ino_t node, int fd,
|
|||||||
KPath path;
|
KPath path;
|
||||||
status = path.InitCheck();
|
status = path.InitCheck();
|
||||||
if (status == B_OK) {
|
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());
|
path.LockBuffer(), path.BufferSize());
|
||||||
}
|
}
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
@@ -1583,7 +1583,7 @@ ModuleNotificationService::_Notify(int32 opcode, dev_t device, ino_t directory,
|
|||||||
if (name != NULL) {
|
if (name != NULL) {
|
||||||
// we have an entry ref
|
// we have an entry ref
|
||||||
if (pathBuffer.InitCheck() != B_OK
|
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)
|
pathBuffer.LockBuffer(), pathBuffer.BufferSize()) != B_OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -2690,7 +2690,7 @@ vfs_get_vnode_name(void *_vnode, char *name, fssh_size_t nameSize)
|
|||||||
|
|
||||||
fssh_status_t
|
fssh_status_t
|
||||||
vfs_entry_ref_to_path(fssh_dev_t device, fssh_ino_t inode, const char *leaf,
|
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;
|
struct vnode *vnode;
|
||||||
fssh_status_t status;
|
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,
|
_kern_entry_ref_to_path(fssh_dev_t device, fssh_ino_t inode, const char *leaf,
|
||||||
char* path, fssh_size_t pathLength)
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user