Subversion Repositories freemyipod

Rev

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

Rev 770 Rev 782
Line 27... Line 27...
27
#include "util.h"
27
#include "util.h"
28
#include "cache.h"
28
#include "cache.h"
29
#include "emcore.h"
29
#include "emcore.h"
30
 
30
 
31
 
31
 
-
 
32
int emcorefs_init(void)
-
 
33
{
-
 
34
    int res;
-
 
35
    uint32_t count;
-
 
36
 
-
 
37
    res = emcore_file_close_all(&count);
-
 
38
 
-
 
39
    if (EMCORE_SUCCESS != res)
-
 
40
    {
-
 
41
        return res;
-
 
42
    }
-
 
43
 
-
 
44
    res = emcore_dir_close_all(&count);
-
 
45
 
-
 
46
    return res;
-
 
47
}
-
 
48
 
32
int emcorefs_getattr(const char* path, struct stat* stbuf)
49
int emcorefs_getattr(const char* path, struct stat* stbuf)
33
{
50
{
34
    int res = 0;
51
    int res = 0;
35
    struct emcore_dir_entry *entry = NULL, curr_entry;
52
    struct emcore_dir_entry *entry = NULL, curr_entry;
36
    uint32_t dir_handle;
53
    uint32_t dir_handle;
37
    char *parent, *filename;
54
    char *parent, *filename;
38
 
55
 
39
    memset(stbuf, 0, sizeof(*stbuf));
56
    memset(stbuf, 0, sizeof(*stbuf));
40
 
57
 
-
 
58
#ifdef DEBUG2
-
 
59
    if (0 == strcmp(path, "/__cache_dump"))
-
 
60
    {
-
 
61
        cache_dump();
-
 
62
    }
-
 
63
#endif
41
    entry = cache_get(path);
64
    entry = cache_get(path);
42
 
65
 
43
    if (NULL == entry)
66
    if (NULL == entry)
44
    {
67
    {
45
        parent = strdup(path);
68
        parent = strdup(path);
Line 198... Line 221...
198
 
221
 
199
int emcorefs_open(const char* path, struct fuse_file_info* fi)
222
int emcorefs_open(const char* path, struct fuse_file_info* fi)
200
{
223
{
201
    int res;
224
    int res;
202
    uint32_t handle, emcore_errno_value;
225
    uint32_t handle, emcore_errno_value;
-
 
226
    
-
 
227
#ifdef DEBUG
-
 
228
    fprintf(stderr, "FILE OPEN: [%s], 0x%08x\n", path, fi->flags);
-
 
229
#endif
203
 
230
    
204
    res = emcore_file_open(&handle, path, fi->flags);
231
    res = emcore_file_open(&handle, path, fi->flags);
205
    
232
    
206
    if (EMCORE_ERROR_IO == res)
233
    if (EMCORE_ERROR_IO == res)
207
    {
234
    {
208
        res = emcore_errno(&emcore_errno_value);
235
        res = emcore_errno(&emcore_errno_value);
Line 352... Line 379...
352
        return -EIO;
379
        return -EIO;
353
    }
380
    }
354
    
381
    
355
    return 0;
382
    return 0;
356
}
383
}
-
 
384
 
-
 
385
int emcorefs_mkdir(const char* path, mode_t mode)
-
 
386
{
-
 
387
    (void)mode;
-
 
388
    int res;
-
 
389
    uint32_t emcore_errno_value;
-
 
390
 
-
 
391
    res = emcore_dir_create(path);
-
 
392
    
-
 
393
    if (EMCORE_ERROR_IO == res)
-
 
394
    {
-
 
395
        res = emcore_errno(&emcore_errno_value);
-
 
396
 
-
 
397
        if (EMCORE_SUCCESS != res)
-
 
398
        {
-
 
399
            return -EIO;
-
 
400
        }
-
 
401
 
-
 
402
        if (EMCORE_SUCCESS != emcore_errno_value)
-
 
403
        {
-
 
404
            return -emcore_errno_value;
-
 
405
        }
-
 
406
    }
-
 
407
    
-
 
408
    if (EMCORE_SUCCESS != res)
-
 
409
    {
-
 
410
        return -EIO;
-
 
411
    }
-
 
412
    
-
 
413
    return 0;
-
 
414
}
-
 
415
 
-
 
416
int emcorefs_rmdir(const char* path)
-
 
417
{
-
 
418
    int res;
-
 
419
    uint32_t emcore_errno_value;
-
 
420
 
-
 
421
    res = emcore_dir_remove(path);
-
 
422
    
-
 
423
    if (EMCORE_ERROR_IO == res)
-
 
424
    {
-
 
425
        res = emcore_errno(&emcore_errno_value);
-
 
426
 
-
 
427
        if (EMCORE_SUCCESS != res)
-
 
428
        {
-
 
429
            return -EIO;
-
 
430
        }
-
 
431
 
-
 
432
        if (EMCORE_SUCCESS != emcore_errno_value)
-
 
433
        {
-
 
434
            return -emcore_errno_value;
-
 
435
        }
-
 
436
    }
-
 
437
    
-
 
438
    if (EMCORE_SUCCESS != res)
-
 
439
    {
-
 
440
        return -EIO;
-
 
441
    }
-
 
442
    
-
 
443
    cache_remove(path);
-
 
444
    
-
 
445
    return 0;
-
 
446
}
-
 
447
 
-
 
448
int emcorefs_create(const char* path, mode_t mode, struct fuse_file_info* fi)
-
 
449
{
-
 
450
    (void)mode;
-
 
451
    return emcorefs_open(path, fi);
-
 
452
}
-
 
453
 
-
 
454
int emcorefs_mknod(const char* path, mode_t mode, dev_t dev)
-
 
455
{
-
 
456
    (void)dev;
-
 
457
    int res;
-
 
458
    struct fuse_file_info fi;
-
 
459
    
-
 
460
    fi.flags = O_WRONLY | O_CREAT | O_TRUNC;
-
 
461
    
-
 
462
    res = emcorefs_create(path, mode, &fi);
-
 
463
    
-
 
464
    if (0 != res) {
-
 
465
        return res;
-
 
466
    }
-
 
467
    
-
 
468
    return emcorefs_release(path, &fi);
-
 
469
}
-
 
470
 
-
 
471
int emcorefs_unlink(const char* path)
-
 
472
{
-
 
473
    
-
 
474
    int res;
-
 
475
    uint32_t emcore_errno_value;
-
 
476
 
-
 
477
    res = emcore_file_unlink(path);
-
 
478
    
-
 
479
    if (EMCORE_ERROR_IO == res)
-
 
480
    {
-
 
481
        res = emcore_errno(&emcore_errno_value);
-
 
482
 
-
 
483
        if (EMCORE_SUCCESS != res)
-
 
484
        {
-
 
485
            return -EIO;
-
 
486
        }
-
 
487
 
-
 
488
        if (EMCORE_SUCCESS != emcore_errno_value)
-
 
489
        {
-
 
490
            return -emcore_errno_value;
-
 
491
        }
-
 
492
    }
-
 
493
    
-
 
494
    if (EMCORE_SUCCESS != res)
-
 
495
    {
-
 
496
        return -EIO;
-
 
497
    }
-
 
498
    
-
 
499
    cache_remove(path);
-
 
500
    
-
 
501
    return 0;
-
 
502
}
357
503