79,13 → 79,12 |
* carry mount options in the future. |
*/ |
|
ipc_callid_t callid; |
size_t size; |
|
/* |
* Now, we expect the client to send us data with the name of the file |
* system. |
* system and the path of the mountpoint. |
*/ |
ipc_callid_t callid; |
size_t size; |
if (!ipc_data_receive(&callid, NULL, &size)) { |
ipc_answer_0(callid, EINVAL); |
ipc_answer_0(rid, EINVAL); |
93,10 → 92,12 |
} |
|
/* |
* Don't receive more than is necessary for storing a full file system |
* name. |
* There is no sense in receiving data that can't hold a single |
* character of path. We won't accept data that exceed certain limits |
* either. |
*/ |
if (size < 1 || size > FS_NAME_MAXLEN) { |
if ((size < FS_NAME_MAXLEN + 1) || |
(size > FS_NAME_MAXLEN + MAX_PATH_LEN)) { |
ipc_answer_0(callid, EINVAL); |
ipc_answer_0(rid, EINVAL); |
return; |
103,42 → 104,8 |
} |
|
/* |
* Deliver the file system name. |
* Allocate buffer for the data being received. |
*/ |
char fs_name[FS_NAME_MAXLEN + 1]; |
(void) ipc_data_deliver(callid, fs_name, size); |
fs_name[size] = '\0'; |
|
/* |
* Check if we know a file system with the same name as is in fs_name. |
* This will also give us its file system handle. |
*/ |
int fs_handle = fs_name_to_handle(fs_name, true); |
if (!fs_handle) { |
ipc_answer_0(rid, ENOENT); |
return; |
} |
|
/* |
* Now, we want the client to send us the mount point. |
*/ |
if (!ipc_data_receive(&callid, NULL, &size)) { |
ipc_answer_0(callid, EINVAL); |
ipc_answer_0(rid, EINVAL); |
return; |
} |
|
/* |
* Check whether size is reasonable wrt. the mount point. |
*/ |
if (size < 1 || size > MAX_PATH_LEN) { |
ipc_answer_0(callid, EINVAL); |
ipc_answer_0(rid, EINVAL); |
return; |
} |
/* |
* Allocate buffer for the mount point data being received. |
*/ |
uint8_t *buf; |
buf = malloc(size); |
if (!buf) { |
148,11 → 115,26 |
} |
|
/* |
* Deliver the mount point. |
* Deliver the data. |
*/ |
(void) ipc_data_deliver(callid, buf, size); |
|
char fs_name[FS_NAME_MAXLEN + 1]; |
memcpy(fs_name, buf, FS_NAME_MAXLEN); |
fs_name[FS_NAME_MAXLEN] = '\0'; |
|
/* |
* Check if we know a file system with the same name as is in fs_name. |
* This will also give us its file system handle. |
*/ |
int fs_handle = fs_name_to_handle(fs_name, true); |
if (!fs_handle) { |
free(buf); |
ipc_answer_0(rid, ENOENT); |
return; |
} |
|
/* |
* Lookup the root node of the filesystem being mounted. |
* In this case, we don't need to take the unlink_futex as the root node |
* cannot be removed. However, we do take a reference to it so that |
183,7 → 165,8 |
* We already have the root FS. |
*/ |
futex_down(&unlink_futex); |
rc = vfs_lookup_internal(buf, size, &mp, NULL); |
rc = vfs_lookup_internal((char *) (buf + FS_NAME_MAXLEN), |
size - FS_NAME_MAXLEN, &mp, NULL); |
if (rc != EOK) { |
/* |
* The lookup failed for some reason. |
214,7 → 197,8 |
/* |
* We still don't have the root file system mounted. |
*/ |
if ((size == 1) && (buf[0] == '/')) { |
if ((size - FS_NAME_MAXLEN == strlen("/")) && |
(buf[FS_NAME_MAXLEN] == '/')) { |
/* |
* For this simple, but important case, we are done. |
*/ |