fix a TODO in _user_mount : added an argsLength parameter
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16480 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -127,7 +127,7 @@ extern status_t _kern_get_next_image_info(team_id team, int32 *cookie, image_in
|
|||||||
|
|
||||||
// VFS functions
|
// VFS functions
|
||||||
extern dev_t _kern_mount(const char *path, const char *device,
|
extern dev_t _kern_mount(const char *path, const char *device,
|
||||||
const char *fs_name, uint32 flags, const char *args);
|
const char *fs_name, uint32 flags, const char *args, size_t argsLength);
|
||||||
extern status_t _kern_unmount(const char *path, uint32 flags);
|
extern status_t _kern_unmount(const char *path, uint32 flags);
|
||||||
extern status_t _kern_read_fs_info(dev_t device, struct fs_info *info);
|
extern status_t _kern_read_fs_info(dev_t device, struct fs_info *info);
|
||||||
extern status_t _kern_write_fs_info(dev_t device, const struct fs_info *info, int mask);
|
extern status_t _kern_write_fs_info(dev_t device, const struct fs_info *info, int mask);
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ status_t resolve_mount_point_to_volume_root(mount_id mountID, vnode_id nodeID,
|
|||||||
|
|
||||||
/* calls the syscall dispatcher should use for user file I/O */
|
/* calls the syscall dispatcher should use for user file I/O */
|
||||||
dev_t _user_mount(const char *path, const char *device, const char *fs_name,
|
dev_t _user_mount(const char *path, const char *device, const char *fs_name,
|
||||||
uint32 flags, const char *args);
|
uint32 flags, const char *args, size_t argsLength);
|
||||||
status_t _user_unmount(const char *path, uint32 flags);
|
status_t _user_unmount(const char *path, uint32 flags);
|
||||||
status_t _user_read_fs_info(dev_t device, struct fs_info *info);
|
status_t _user_read_fs_info(dev_t device, struct fs_info *info);
|
||||||
status_t _user_write_fs_info(dev_t device, const struct fs_info *info, int mask);
|
status_t _user_write_fs_info(dev_t device, const struct fs_info *info, int mask);
|
||||||
|
|||||||
@@ -5498,7 +5498,7 @@ err:
|
|||||||
|
|
||||||
dev_t
|
dev_t
|
||||||
_kern_mount(const char *path, const char *device, const char *fsName,
|
_kern_mount(const char *path, const char *device, const char *fsName,
|
||||||
uint32 flags, const char *args)
|
uint32 flags, const char *args, size_t argsLength)
|
||||||
{
|
{
|
||||||
KPath pathBuffer(path, false, B_PATH_NAME_LENGTH + 1);
|
KPath pathBuffer(path, false, B_PATH_NAME_LENGTH + 1);
|
||||||
if (pathBuffer.InitCheck() != B_OK)
|
if (pathBuffer.InitCheck() != B_OK)
|
||||||
@@ -6199,7 +6199,7 @@ _kern_setcwd(int fd, const char *path)
|
|||||||
|
|
||||||
dev_t
|
dev_t
|
||||||
_user_mount(const char *userPath, const char *userDevice, const char *userFileSystem,
|
_user_mount(const char *userPath, const char *userDevice, const char *userFileSystem,
|
||||||
uint32 flags, const char *userArgs)
|
uint32 flags, const char *userArgs, size_t argsLength)
|
||||||
{
|
{
|
||||||
char fileSystem[B_OS_NAME_LENGTH];
|
char fileSystem[B_OS_NAME_LENGTH];
|
||||||
KPath path, device;
|
KPath path, device;
|
||||||
@@ -6225,29 +6225,17 @@ _user_mount(const char *userPath, const char *userDevice, const char *userFileSy
|
|||||||
&& user_strlcpy(device.LockBuffer(), userDevice, B_PATH_NAME_LENGTH) < B_OK)
|
&& user_strlcpy(device.LockBuffer(), userDevice, B_PATH_NAME_LENGTH) < B_OK)
|
||||||
return B_BAD_ADDRESS;
|
return B_BAD_ADDRESS;
|
||||||
|
|
||||||
if (userArgs != NULL) {
|
if (userArgs != NULL && argsLength > 0) {
|
||||||
// We have no real length restriction, so we need to create
|
if (argsLength >= 65536)
|
||||||
// a buffer large enough to hold the argument string
|
return B_BAD_VALUE;
|
||||||
// ToDo: we could think about determinung the length of the string
|
args = (char *)malloc(argsLength + 1);
|
||||||
// in userland :)
|
|
||||||
ssize_t length = user_strlcpy(args, userArgs, 0);
|
|
||||||
if (length < B_OK)
|
|
||||||
return B_BAD_ADDRESS;
|
|
||||||
|
|
||||||
// this is a safety restriction
|
|
||||||
if (length > 32 * 1024)
|
|
||||||
return B_NAME_TOO_LONG;
|
|
||||||
|
|
||||||
if (length > 0) {
|
|
||||||
args = (char *)malloc(length + 1);
|
|
||||||
if (args == NULL)
|
if (args == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
if (user_strlcpy(args, userArgs, argsLength + 1) < B_OK) {
|
||||||
if (user_strlcpy(args, userArgs, length + 1) < B_OK) {
|
|
||||||
free(args);
|
free(args);
|
||||||
return B_BAD_ADDRESS;
|
return B_BAD_ADDRESS;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
path.UnlockBuffer();
|
path.UnlockBuffer();
|
||||||
device.UnlockBuffer();
|
device.UnlockBuffer();
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ vfs_bootstrap_file_systems(void)
|
|||||||
status_t status;
|
status_t status;
|
||||||
|
|
||||||
// bootstrap the root filesystem
|
// bootstrap the root filesystem
|
||||||
status = _kern_mount("/", NULL, "rootfs", 0, NULL);
|
status = _kern_mount("/", NULL, "rootfs", 0, NULL, 0);
|
||||||
if (status < B_OK)
|
if (status < B_OK)
|
||||||
panic("error mounting rootfs!\n");
|
panic("error mounting rootfs!\n");
|
||||||
|
|
||||||
@@ -199,13 +199,13 @@ vfs_bootstrap_file_systems(void)
|
|||||||
|
|
||||||
// bootstrap the devfs
|
// bootstrap the devfs
|
||||||
_kern_create_dir(-1, "/dev", 0755);
|
_kern_create_dir(-1, "/dev", 0755);
|
||||||
status = _kern_mount("/dev", NULL, "devfs", 0, NULL);
|
status = _kern_mount("/dev", NULL, "devfs", 0, NULL, 0);
|
||||||
if (status < B_OK)
|
if (status < B_OK)
|
||||||
panic("error mounting devfs\n");
|
panic("error mounting devfs\n");
|
||||||
|
|
||||||
// bootstrap the pipefs
|
// bootstrap the pipefs
|
||||||
_kern_create_dir(-1, "/pipe", 0755);
|
_kern_create_dir(-1, "/pipe", 0755);
|
||||||
status = _kern_mount("/pipe", NULL, "pipefs", 0, NULL);
|
status = _kern_mount("/pipe", NULL, "pipefs", 0, NULL, 0);
|
||||||
if (status < B_OK)
|
if (status < B_OK)
|
||||||
panic("error mounting pipefs\n");
|
panic("error mounting pipefs\n");
|
||||||
|
|
||||||
@@ -240,7 +240,7 @@ vfs_mount_boot_file_system(kernel_args *args)
|
|||||||
if (bootPartition->GetPath(&path) != B_OK)
|
if (bootPartition->GetPath(&path) != B_OK)
|
||||||
panic("could not get boot device!\n");
|
panic("could not get boot device!\n");
|
||||||
|
|
||||||
gBootDevice = _kern_mount("/boot", path.Path(), NULL, 0, NULL);
|
gBootDevice = _kern_mount("/boot", path.Path(), NULL, 0, NULL, 0);
|
||||||
if (gBootDevice >= B_OK)
|
if (gBootDevice >= B_OK)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ dev_t
|
|||||||
fs_mount_volume(const char *where, const char *device,
|
fs_mount_volume(const char *where, const char *device,
|
||||||
const char *fileSystem, uint32 flags, const char *parameters)
|
const char *fileSystem, uint32 flags, const char *parameters)
|
||||||
{
|
{
|
||||||
return _kern_mount(where, device, fileSystem, flags, (void *)parameters);
|
return _kern_mount(where, device, fileSystem, flags, (void *)parameters, parameters ? strlen(parameters) : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user