59,10 → 59,9 |
char *cwd_path = NULL; |
size_t cwd_len = 0; |
|
char *absolutize(const char *path, size_t *retlen) |
static char *absolutize(const char *path, size_t *retlen) |
{ |
char *ncwd_path; |
char *ncwd_path_nc; |
|
futex_down(&cwd_futex); |
size_t len = strlen(path); |
71,40 → 70,28 |
futex_up(&cwd_futex); |
return NULL; |
} |
ncwd_path_nc = malloc(cwd_len + 1 + len + 1); |
if (!ncwd_path_nc) { |
ncwd_path = malloc(len + cwd_len + 1); |
if (!ncwd_path) { |
futex_up(&cwd_futex); |
return NULL; |
} |
strcpy(ncwd_path_nc, cwd_path); |
ncwd_path_nc[cwd_len] = '/'; |
ncwd_path_nc[cwd_len + 1] = '\0'; |
strcpy(ncwd_path, cwd_path); |
ncwd_path[cwd_len] = '/'; |
ncwd_path[cwd_len + 1] = '\0'; |
} else { |
ncwd_path_nc = malloc(len + 1); |
if (!ncwd_path_nc) { |
ncwd_path = malloc(len + 1); |
if (!ncwd_path) { |
futex_up(&cwd_futex); |
return NULL; |
} |
ncwd_path_nc[0] = '\0'; |
ncwd_path[0] = '\0'; |
} |
strcat(ncwd_path_nc, path); |
ncwd_path = canonify(ncwd_path_nc, retlen); |
if (!ncwd_path) { |
strcat(ncwd_path, path); |
if (!canonify(ncwd_path, retlen)) { |
futex_up(&cwd_futex); |
free(ncwd_path_nc); |
free(ncwd_path); |
return NULL; |
} |
/* |
* We need to clone ncwd_path because canonify() works in-place and thus |
* the address in ncwd_path need not be the same as ncwd_path_nc, even |
* though they both point into the same dynamically allocated buffer. |
*/ |
ncwd_path = strdup(ncwd_path); |
free(ncwd_path_nc); |
if (!ncwd_path) { |
futex_up(&cwd_futex); |
return NULL; |
} |
futex_up(&cwd_futex); |
return ncwd_path; |
} |
118,8 → 105,7 |
|
static int device_get_handle(char *name, dev_handle_t *handle) |
{ |
int phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP, DEVMAP_CLIENT, |
0); |
int phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP, DEVMAP_CLIENT, 0); |
if (phone < 0) |
return phone; |
|
185,15 → 171,6 |
free(mpa); |
return (int) rc; |
} |
/* Ask VFS whether it likes fs_name. */ |
rc = async_req_0_0(vfs_phone, IPC_M_PING); |
if (rc != EOK) { |
async_wait_for(req, NULL); |
async_serialize_end(); |
futex_up(&vfs_phone_futex); |
free(mpa); |
return (int) rc; |
} |
rc = ipc_data_write_start(vfs_phone, (void *)mpa, mpa_len); |
if (rc != EOK) { |
async_wait_for(req, NULL); |
245,9 → 222,6 |
async_serialize_end(); |
futex_up(&vfs_phone_futex); |
free(pa); |
|
if (rc != EOK) |
return (int) rc; |
return (int) IPC_GET_ARG1(answer); |
} |
|
311,7 → 285,7 |
if (rc == EOK) |
return (ssize_t) IPC_GET_ARG1(answer); |
else |
return rc; |
return -1; |
} |
|
ssize_t write(int fildes, const void *buf, size_t nbyte) |