Subversion Repositories HelenOS

Rev

Rev 2761 | Rev 2771 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2761 Rev 2763
Line 466... Line 466...
466
int rmdir(const char *path)
466
int rmdir(const char *path)
467
{
467
{
468
    return _unlink(path, L_DIRECTORY);
468
    return _unlink(path, L_DIRECTORY);
469
}
469
}
470
 
470
 
-
 
471
int rename(const char *old, const char *new)
-
 
472
{
-
 
473
    int res;
-
 
474
    ipcarg_t rc;
-
 
475
    aid_t req;
-
 
476
   
-
 
477
    char *olda = absolutize(old);
-
 
478
    if (!olda)
-
 
479
        return ENOMEM;
-
 
480
    size_t oldc_len;
-
 
481
    char *oldc = canonify(olda, &oldc_len);
-
 
482
    if (!oldc) {
-
 
483
        free(olda);
-
 
484
        return EINVAL;
-
 
485
    }
-
 
486
    char *newa = absolutize(new);
-
 
487
    if (!newa) {
-
 
488
        free(olda);
-
 
489
        return ENOMEM;
-
 
490
    }
-
 
491
    size_t newc_len;
-
 
492
    char *newc = canonify(newa, &newc_len);
-
 
493
    if (!newc) {
-
 
494
        free(olda);
-
 
495
        free(newa);
-
 
496
        return EINVAL;
-
 
497
    }
-
 
498
 
-
 
499
    futex_down(&vfs_phone_futex);
-
 
500
    async_serialize_start();
-
 
501
    if (vfs_phone < 0) {
-
 
502
        res = vfs_connect();
-
 
503
        if (res < 0) {
-
 
504
            async_serialize_end();
-
 
505
            futex_up(&vfs_phone_futex);
-
 
506
            free(olda);
-
 
507
            free(newa);
-
 
508
            return res;
-
 
509
        }
-
 
510
    }
-
 
511
    req = async_send_0(vfs_phone, VFS_RENAME, NULL);
-
 
512
    rc = ipc_data_write_start(vfs_phone, oldc, oldc_len);
-
 
513
    if (rc != EOK) {
-
 
514
        async_wait_for(req, NULL);
-
 
515
        async_serialize_end();
-
 
516
        futex_up(&vfs_phone_futex);
-
 
517
        free(olda);
-
 
518
        free(newa);
-
 
519
        return (int) rc;
-
 
520
    }
-
 
521
    rc = ipc_data_write_start(vfs_phone, newc, newc_len);
-
 
522
    if (rc != EOK) {
-
 
523
        async_wait_for(req, NULL);
-
 
524
        async_serialize_end();
-
 
525
        futex_up(&vfs_phone_futex);
-
 
526
        free(olda);
-
 
527
        free(newa);
-
 
528
        return (int) rc;
-
 
529
    }
-
 
530
    async_wait_for(req, &rc);
-
 
531
    async_serialize_end();
-
 
532
    futex_up(&vfs_phone_futex);
-
 
533
    free(olda);
-
 
534
    free(newa);
-
 
535
    return rc;
-
 
536
}
-
 
537
 
471
int chdir(const char *path)
538
int chdir(const char *path)
472
{
539
{
473
    char *pa = absolutize(path);
540
    char *pa = absolutize(path);
474
    if (!pa)
541
    if (!pa)
475
        return ENOMEM;
542
        return ENOMEM;