Subversion Repositories freemyipod

Rev

Rev 782 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 782 Rev 784
Line 344... Line 344...
344
    }
344
    }
345
    
345
    
346
    return nread;
346
    return nread;
347
}
347
}
348
 
348
 
-
 
349
int emcorefs_write(const char* path, const char* buf, uint32_t size, off_t offset, struct fuse_file_info* fi) {
-
 
350
    fprintf(stderr, "FUSE_WRITE: path=[%s] size=[%d] offset=[%jd] fi->flags=[%d]\n", path, size, offset, fi->flags);
-
 
351
 
-
 
352
    int res;
-
 
353
    uint32_t emcore_errno_value, addr, nwrite = size;
-
 
354
 
-
 
355
    if (!fi->fh)
-
 
356
    {
-
 
357
        return -EIO;
-
 
358
    }
-
 
359
    
-
 
360
    res = emcore_malloc(&addr, size);
-
 
361
    
-
 
362
    if (EMCORE_SUCCESS != res)
-
 
363
    {
-
 
364
        return -EIO;
-
 
365
    }
-
 
366
    
-
 
367
    do {
-
 
368
        if (offset) {
-
 
369
            res = emcore_file_seek(fi->fh, offset, SEEK_SET);
-
 
370
            
-
 
371
            if (EMCORE_ERROR_IO == res)
-
 
372
            {
-
 
373
                res = emcore_errno(&emcore_errno_value);
-
 
374
 
-
 
375
                if (EMCORE_SUCCESS != res)
-
 
376
                {
-
 
377
                    nwrite = -EIO;
-
 
378
                    break;
-
 
379
                }
-
 
380
 
-
 
381
                if (EMCORE_SUCCESS != emcore_errno_value)
-
 
382
                {
-
 
383
                    nwrite = -emcore_errno_value;
-
 
384
                    break;
-
 
385
                }
-
 
386
            }
-
 
387
        
-
 
388
            if (EMCORE_SUCCESS != res)
-
 
389
            {
-
 
390
                nwrite = -EIO;
-
 
391
                break;
-
 
392
            }
-
 
393
        }
-
 
394
        
-
 
395
        res = emcore_write(buf, addr, nwrite);
-
 
396
        
-
 
397
        if (EMCORE_SUCCESS != res)
-
 
398
        {
-
 
399
            nwrite = -EIO;
-
 
400
            break;
-
 
401
        }
-
 
402
        
-
 
403
        res = emcore_file_write(&nwrite, fi->fh, addr, size);
-
 
404
        
-
 
405
        if (EMCORE_ERROR_IO == res)
-
 
406
        {
-
 
407
            res = emcore_errno(&emcore_errno_value);
-
 
408
 
-
 
409
            if (EMCORE_SUCCESS != res)
-
 
410
            {
-
 
411
                nwrite = -EIO;
-
 
412
                break;
-
 
413
            }
-
 
414
 
-
 
415
            if (EMCORE_SUCCESS != emcore_errno_value)
-
 
416
            {
-
 
417
                nwrite = -emcore_errno_value;
-
 
418
                break;
-
 
419
            }
-
 
420
        }
-
 
421
    
-
 
422
        if (EMCORE_SUCCESS != res)
-
 
423
        {
-
 
424
            nwrite = -EIO;
-
 
425
        }
-
 
426
    }
-
 
427
    while(0);
-
 
428
    
-
 
429
    res = emcore_free(addr);
-
 
430
    
-
 
431
    if (EMCORE_SUCCESS != res)
-
 
432
    {
-
 
433
        return -EIO;
-
 
434
    }
-
 
435
    
-
 
436
    cache_remove(path);
-
 
437
    
-
 
438
    return nwrite;
-
 
439
}
-
 
440
 
349
int emcorefs_release(const char* path, struct fuse_file_info* fi)
441
int emcorefs_release(const char* path, struct fuse_file_info* fi)
350
{
442
{
351
    int res;
443
    int res;
352
    uint32_t emcore_errno_value;
444
    uint32_t emcore_errno_value;
353
    (void)path;
445
    (void)path;
Line 468... Line 560...
468
    return emcorefs_release(path, &fi);
560
    return emcorefs_release(path, &fi);
469
}
561
}
470
 
562
 
471
int emcorefs_unlink(const char* path)
563
int emcorefs_unlink(const char* path)
472
{
564
{
473
    
-
 
474
    int res;
565
    int res;
475
    uint32_t emcore_errno_value;
566
    uint32_t emcore_errno_value;
476
 
567
 
477
    res = emcore_file_unlink(path);
568
    res = emcore_file_unlink(path);
478
    
569
    
Line 497... Line 588...
497
    }
588
    }
498
    
589
    
499
    cache_remove(path);
590
    cache_remove(path);
500
    
591
    
501
    return 0;
592
    return 0;
502
}
-
 
503
593
}
-
 
594
 
-
 
595
int emcorefs_rename(const char* path, const char* new_path)
-
 
596
{
-
 
597
    int res;
-
 
598
    uint32_t emcore_errno_value;
-
 
599
 
-
 
600
    res = emcore_file_rename(path, new_path);
-
 
601
    
-
 
602
    if (EMCORE_ERROR_IO == res)
-
 
603
    {
-
 
604
        res = emcore_errno(&emcore_errno_value);
-
 
605
 
-
 
606
        if (EMCORE_SUCCESS != res)
-
 
607
        {
-
 
608
            return -EIO;
-
 
609
        }
-
 
610
 
-
 
611
        if (EMCORE_SUCCESS != emcore_errno_value)
-
 
612
        {
-
 
613
            return -emcore_errno_value;
-
 
614
        }
-
 
615
    }
-
 
616
    
-
 
617
    if (EMCORE_SUCCESS != res)
-
 
618
    {
-
 
619
        return -EIO;
-
 
620
    }
-
 
621
    
-
 
622
    cache_remove(path);
-
 
623
    
-
 
624
    return 0;
-
 
625
}
-
 
626
 
-
 
627
int emcorefs_truncate(const char* path, off_t size)
-
 
628
{
-
 
629
    int res;
-
 
630
    struct fuse_file_info fi;
-
 
631
    
-
 
632
    res = emcorefs_open(path, &fi);
-
 
633
    
-
 
634
    if (0 != res) {
-
 
635
        return res;
-
 
636
    }
-
 
637
    
-
 
638
    res = emcorefs_ftruncate(path, size, &fi);
-
 
639
    
-
 
640
    if (0 != res) {
-
 
641
        return res;
-
 
642
    }
-
 
643
    
-
 
644
    return emcorefs_release(path, &fi);
-
 
645
}
-
 
646
 
-
 
647
int emcorefs_ftruncate(const char* path, off_t size, struct fuse_file_info* fi)
-
 
648
{
-
 
649
    int res;
-
 
650
    uint32_t emcore_errno_value;
-
 
651
    (void)path;
-
 
652
 
-
 
653
    if (!fi->fh)
-
 
654
    {
-
 
655
        return -EIO;
-
 
656
    }
-
 
657
    
-
 
658
    res = emcore_file_truncate(fi->fh, size);
-
 
659
    
-
 
660
    if (EMCORE_ERROR_IO == res)
-
 
661
    {
-
 
662
        res = emcore_errno(&emcore_errno_value);
-
 
663
 
-
 
664
        if (EMCORE_SUCCESS != res)
-
 
665
        {
-
 
666
            return -EIO;
-
 
667
        }
-
 
668
 
-
 
669
        if (EMCORE_SUCCESS != emcore_errno_value)
-
 
670
        {
-
 
671
            return -emcore_errno_value;
-
 
672
        }
-
 
673
    }
-
 
674
    
-
 
675
    if (EMCORE_SUCCESS != res)
-
 
676
    {
-
 
677
        return -EIO;
-
 
678
    }
-
 
679
    
-
 
680
    cache_remove(path);
-
 
681
    
-
 
682
    return 0;
-
 
683
}
-
 
684
 
-
 
685