39,7 → 39,6 |
#include <dirent.h> |
#include <fcntl.h> |
#include <sys/stat.h> |
#include <stdio.h> |
#include <sys/types.h> |
#include <ipc/ipc.h> |
#include <ipc/services.h> |
58,7 → 57,7 |
char *cwd_path = NULL; |
size_t cwd_len = 0; |
|
static char *absolutize(const char *path, size_t *retlen) |
static char *absolutize(const char *path) |
{ |
char *ncwd_path; |
|
86,11 → 85,6 |
ncwd_path[0] = '\0'; |
} |
strcat(ncwd_path, path); |
if (!canonify(ncwd_path, retlen)) { |
futex_up(&cwd_futex); |
free(ncwd_path); |
return NULL; |
} |
futex_up(&cwd_futex); |
return ncwd_path; |
} |
108,12 → 102,17 |
ipcarg_t rc; |
aid_t req; |
|
dev_handle_t dev_handle = 0; /* TODO */ |
int dev_handle = 0; /* TODO */ |
|
size_t mpa_len; |
char *mpa = absolutize(mp, &mpa_len); |
char *mpa = absolutize(mp); |
if (!mpa) |
return ENOMEM; |
size_t mpc_len; |
char *mpc = canonify(mpa, &mpc_len); |
if (!mpc) { |
free(mpa); |
return EINVAL; |
} |
|
futex_down(&vfs_phone_futex); |
async_serialize_start(); |
135,7 → 134,7 |
free(mpa); |
return (int) rc; |
} |
rc = ipc_data_write_start(vfs_phone, (void *)mpa, mpa_len); |
rc = ipc_data_write_start(vfs_phone, (void *)mpc, mpc_len); |
if (rc != EOK) { |
async_wait_for(req, NULL); |
async_serialize_end(); |
157,10 → 156,15 |
ipc_call_t answer; |
aid_t req; |
|
size_t pa_len; |
char *pa = absolutize(path, &pa_len); |
char *pa = absolutize(path); |
if (!pa) |
return ENOMEM; |
size_t pc_len; |
char *pc = canonify(pa, &pc_len); |
if (!pc) { |
free(pa); |
return EINVAL; |
} |
|
futex_down(&vfs_phone_futex); |
async_serialize_start(); |
174,7 → 178,7 |
} |
} |
req = async_send_3(vfs_phone, VFS_OPEN, lflag, oflag, 0, &answer); |
rc = ipc_data_write_start(vfs_phone, pa, pa_len); |
rc = ipc_data_write_start(vfs_phone, pc, pc_len); |
if (rc != EOK) { |
async_wait_for(req, NULL); |
async_serialize_end(); |
375,10 → 379,15 |
ipcarg_t rc; |
aid_t req; |
|
size_t pa_len; |
char *pa = absolutize(path, &pa_len); |
char *pa = absolutize(path); |
if (!pa) |
return ENOMEM; |
size_t pc_len; |
char *pc = canonify(pa, &pc_len); |
if (!pc) { |
free(pa); |
return EINVAL; |
} |
|
futex_down(&vfs_phone_futex); |
async_serialize_start(); |
392,7 → 401,7 |
} |
} |
req = async_send_1(vfs_phone, VFS_MKDIR, mode, NULL); |
rc = ipc_data_write_start(vfs_phone, pa, pa_len); |
rc = ipc_data_write_start(vfs_phone, pc, pc_len); |
if (rc != EOK) { |
async_wait_for(req, NULL); |
async_serialize_end(); |
413,11 → 422,15 |
ipcarg_t rc; |
aid_t req; |
|
size_t pa_len; |
char *pa = absolutize(path, &pa_len); |
char *pa = absolutize(path); |
if (!pa) |
return ENOMEM; |
|
size_t pc_len; |
char *pc = canonify(pa, &pc_len); |
if (!pc) { |
free(pa); |
return EINVAL; |
} |
futex_down(&vfs_phone_futex); |
async_serialize_start(); |
if (vfs_phone < 0) { |
430,7 → 443,7 |
} |
} |
req = async_send_0(vfs_phone, VFS_UNLINK, NULL); |
rc = ipc_data_write_start(vfs_phone, pa, pa_len); |
rc = ipc_data_write_start(vfs_phone, pc, pc_len); |
if (rc != EOK) { |
async_wait_for(req, NULL); |
async_serialize_end(); |
461,17 → 474,27 |
ipcarg_t rc; |
aid_t req; |
|
size_t olda_len; |
char *olda = absolutize(old, &olda_len); |
char *olda = absolutize(old); |
if (!olda) |
return ENOMEM; |
|
size_t newa_len; |
char *newa = absolutize(new, &newa_len); |
size_t oldc_len; |
char *oldc = canonify(olda, &oldc_len); |
if (!oldc) { |
free(olda); |
return EINVAL; |
} |
char *newa = absolutize(new); |
if (!newa) { |
free(olda); |
return ENOMEM; |
} |
size_t newc_len; |
char *newc = canonify(newa, &newc_len); |
if (!newc) { |
free(olda); |
free(newa); |
return EINVAL; |
} |
|
futex_down(&vfs_phone_futex); |
async_serialize_start(); |
486,7 → 509,7 |
} |
} |
req = async_send_0(vfs_phone, VFS_RENAME, NULL); |
rc = ipc_data_write_start(vfs_phone, olda, olda_len); |
rc = ipc_data_write_start(vfs_phone, oldc, oldc_len); |
if (rc != EOK) { |
async_wait_for(req, NULL); |
async_serialize_end(); |
495,7 → 518,7 |
free(newa); |
return (int) rc; |
} |
rc = ipc_data_write_start(vfs_phone, newa, newa_len); |
rc = ipc_data_write_start(vfs_phone, newc, newc_len); |
if (rc != EOK) { |
async_wait_for(req, NULL); |
async_serialize_end(); |
514,12 → 537,17 |
|
int chdir(const char *path) |
{ |
size_t pa_len; |
char *pa = absolutize(path, &pa_len); |
char *pa = absolutize(path); |
if (!pa) |
return ENOMEM; |
size_t pc_len; |
char *pc = canonify(pa, &pc_len); |
if (!pc) { |
free(pa); |
return ENOENT; |
} |
|
DIR *d = opendir(pa); |
DIR *d = opendir(pc); |
if (!d) { |
free(pa); |
return ENOENT; |
534,8 → 562,8 |
cwd_len = 0; |
} |
cwd_dir = d; |
cwd_path = pa; |
cwd_len = pa_len; |
cwd_path = pc; |
cwd_len = pc_len; |
futex_up(&cwd_futex); |
} |
|