Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3402 → Rev 3403

/branches/dynload/uspace/lib/libc/generic/vfs/vfs.c
59,9 → 59,10
char *cwd_path = NULL;
size_t cwd_len = 0;
 
static char *absolutize(const char *path, size_t *retlen)
char *absolutize(const char *path, size_t *retlen)
{
char *ncwd_path;
char *ncwd_path_nc;
 
futex_down(&cwd_futex);
size_t len = strlen(path);
70,28 → 71,40
futex_up(&cwd_futex);
return NULL;
}
ncwd_path = malloc(len + cwd_len + 1);
if (!ncwd_path) {
ncwd_path_nc = malloc(cwd_len + 1 + len + 1);
if (!ncwd_path_nc) {
futex_up(&cwd_futex);
return NULL;
}
strcpy(ncwd_path, cwd_path);
ncwd_path[cwd_len] = '/';
ncwd_path[cwd_len + 1] = '\0';
strcpy(ncwd_path_nc, cwd_path);
ncwd_path_nc[cwd_len] = '/';
ncwd_path_nc[cwd_len + 1] = '\0';
} else {
ncwd_path = malloc(len + 1);
if (!ncwd_path) {
ncwd_path_nc = malloc(len + 1);
if (!ncwd_path_nc) {
futex_up(&cwd_futex);
return NULL;
}
ncwd_path[0] = '\0';
ncwd_path_nc[0] = '\0';
}
strcat(ncwd_path, path);
if (!canonify(ncwd_path, retlen)) {
strcat(ncwd_path_nc, path);
ncwd_path = canonify(ncwd_path_nc, retlen);
if (!ncwd_path) {
futex_up(&cwd_futex);
free(ncwd_path);
free(ncwd_path_nc);
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;
}
105,7 → 118,8
 
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;
171,6 → 185,15
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);
223,7 → 246,8
futex_up(&vfs_phone_futex);
free(pa);
 
if (rc != EOK) return (int) rc;
if (rc != EOK)
return (int) rc;
return (int) IPC_GET_ARG1(answer);
}
 
287,7 → 311,7
if (rc == EOK)
return (ssize_t) IPC_GET_ARG1(answer);
else
return -1;
return rc;
}
 
ssize_t write(int fildes, const void *buf, size_t nbyte)