Changeset 9eb3623 in mainline for uspace/lib/libc/generic/vfs/vfs.c


Ignore:
Timestamp:
2009-04-08T18:47:17Z (15 years ago)
Author:
Jiri Svoboda <jirik.svoboda@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8be693b
Parents:
6071a8f
Message:

Replace some uses of old string functions in C library.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libc/generic/vfs/vfs.c

    r6071a8f r9eb3623  
    5858DIR *cwd_dir = NULL;
    5959char *cwd_path = NULL;
    60 size_t cwd_len = 0;
     60size_t cwd_size = 0;
    6161
    6262char *absolutize(const char *path, size_t *retlen)
     
    6666
    6767        futex_down(&cwd_futex);
    68         size_t len = strlen(path);
     68        size_t size = str_size(path);
    6969        if (*path != '/') {
    7070                if (!cwd_path) {
     
    7272                        return NULL;
    7373                }
    74                 ncwd_path_nc = malloc(cwd_len + 1 + len + 1);
     74                ncwd_path_nc = malloc(cwd_size + 1 + size + 1);
    7575                if (!ncwd_path_nc) {
    7676                        futex_up(&cwd_futex);
    7777                        return NULL;
    7878                }
    79                 strcpy(ncwd_path_nc, cwd_path);
    80                 ncwd_path_nc[cwd_len] = '/';
    81                 ncwd_path_nc[cwd_len + 1] = '\0';
     79                str_ncpy(ncwd_path_nc, cwd_path, cwd_size + 1 + size + 1);
     80                ncwd_path_nc[cwd_size] = '/';
     81                ncwd_path_nc[cwd_size + 1] = '\0';
    8282        } else {
    83                 ncwd_path_nc = malloc(len + 1);
     83                ncwd_path_nc = malloc(size + 1);
    8484                if (!ncwd_path_nc) {
    8585                        futex_up(&cwd_futex);
     
    133133            &answer);
    134134       
    135         ipcarg_t retval = ipc_data_write_start(phone, name, strlen(name) + 1);
     135        ipcarg_t retval = ipc_data_write_start(phone, name, str_size(name) + 1);
    136136       
    137137        if (retval != EOK) {
     
    167167                return res;
    168168       
    169         size_t mpa_len;
    170         char *mpa = absolutize(mp, &mpa_len);
     169        size_t mpa_size;
     170        char *mpa = absolutize(mp, &mpa_size);
    171171        if (!mpa)
    172172                return ENOMEM;
     
    177177       
    178178        req = async_send_2(vfs_phone, VFS_MOUNT, dev_handle, flags, NULL);
    179         rc = ipc_data_write_start(vfs_phone, (void *) mpa, mpa_len);
     179        rc = ipc_data_write_start(vfs_phone, (void *) mpa, mpa_size);
    180180        if (rc != EOK) {
    181181                async_wait_for(req, NULL);
     
    186186        }
    187187       
    188         rc = ipc_data_write_start(vfs_phone, (void *) fs_name, strlen(fs_name));
     188        rc = ipc_data_write_start(vfs_phone, (void *) fs_name, str_size(fs_name));
    189189        if (rc != EOK) {
    190190                async_wait_for(req, NULL);
     
    209209        aid_t req;
    210210       
    211         size_t pa_len;
    212         char *pa = absolutize(path, &pa_len);
     211        size_t pa_size;
     212        char *pa = absolutize(path, &pa_size);
    213213        if (!pa)
    214214                return ENOMEM;
     
    219219       
    220220        req = async_send_3(vfs_phone, VFS_OPEN, lflag, oflag, 0, &answer);
    221         rc = ipc_data_write_start(vfs_phone, pa, pa_len);
     221        rc = ipc_data_write_start(vfs_phone, pa, pa_size);
    222222        if (rc != EOK) {
    223223                async_wait_for(req, NULL);
     
    385385        aid_t req;
    386386       
    387         size_t pa_len;
    388         char *pa = absolutize(path, &pa_len);
     387        size_t pa_size;
     388        char *pa = absolutize(path, &pa_size);
    389389        if (!pa)
    390390                return ENOMEM;
     
    395395       
    396396        req = async_send_1(vfs_phone, VFS_MKDIR, mode, NULL);
    397         rc = ipc_data_write_start(vfs_phone, pa, pa_len);
     397        rc = ipc_data_write_start(vfs_phone, pa, pa_size);
    398398        if (rc != EOK) {
    399399                async_wait_for(req, NULL);
     
    415415        aid_t req;
    416416       
    417         size_t pa_len;
    418         char *pa = absolutize(path, &pa_len);
     417        size_t pa_size;
     418        char *pa = absolutize(path, &pa_size);
    419419        if (!pa)
    420420                return ENOMEM;
     
    425425       
    426426        req = async_send_0(vfs_phone, VFS_UNLINK, NULL);
    427         rc = ipc_data_write_start(vfs_phone, pa, pa_len);
     427        rc = ipc_data_write_start(vfs_phone, pa, pa_size);
    428428        if (rc != EOK) {
    429429                async_wait_for(req, NULL);
     
    455455        aid_t req;
    456456       
    457         size_t olda_len;
    458         char *olda = absolutize(old, &olda_len);
     457        size_t olda_size;
     458        char *olda = absolutize(old, &olda_size);
    459459        if (!olda)
    460460                return ENOMEM;
    461461
    462         size_t newa_len;
    463         char *newa = absolutize(new, &newa_len);
     462        size_t newa_size;
     463        char *newa = absolutize(new, &newa_size);
    464464        if (!newa) {
    465465                free(olda);
     
    472472       
    473473        req = async_send_0(vfs_phone, VFS_RENAME, NULL);
    474         rc = ipc_data_write_start(vfs_phone, olda, olda_len);
     474        rc = ipc_data_write_start(vfs_phone, olda, olda_size);
    475475        if (rc != EOK) {
    476476                async_wait_for(req, NULL);
     
    481481                return (int) rc;
    482482        }
    483         rc = ipc_data_write_start(vfs_phone, newa, newa_len);
     483        rc = ipc_data_write_start(vfs_phone, newa, newa_size);
    484484        if (rc != EOK) {
    485485                async_wait_for(req, NULL);
     
    500500int chdir(const char *path)
    501501{
    502         size_t pa_len;
    503         char *pa = absolutize(path, &pa_len);
     502        size_t pa_size;
     503        char *pa = absolutize(path, &pa_size);
    504504        if (!pa)
    505505                return ENOMEM;
     
    517517                free(cwd_path);
    518518                cwd_path = NULL;
    519                 cwd_len = 0;
     519                cwd_size = 0;
    520520        }
    521521        cwd_dir = d;
    522522        cwd_path = pa;
    523         cwd_len = pa_len;
     523        cwd_size = pa_size;
    524524        futex_up(&cwd_futex);
    525525        return EOK;
     
    531531                return NULL;
    532532        futex_down(&cwd_futex);
    533         if (size < cwd_len + 1) {
     533        if (size < cwd_size + 1) {
    534534                futex_up(&cwd_futex);
    535535                return NULL;
Note: See TracChangeset for help on using the changeset viewer.