Subversion Repositories freemyipod

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
770 user890104 1
//
2
//
3
//    Copyright 2011 user890104
4
//
5
//
6
//    This file is part of emCORE.
7
//
8
//    emCORE is free software: you can redistribute it and/or
9
//    modify it under the terms of the GNU General Public License as
10
//    published by the Free Software Foundation, either version 2 of the
11
//    License, or (at your option) any later version.
12
//
13
//    emCORE is distributed in the hope that it will be useful,
14
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
//    See the GNU General Public License for more details.
17
//
18
//    You should have received a copy of the GNU General Public License along
19
//    with emCORE.  If not, see <http://www.gnu.org/licenses/>.
20
//
21
//
22
 
23
 
24
#include "global.h"
25
 
26
#include "usb.h"
27
#include "cache.h"
28
#include "emcore.h"
29
#include "fuse.h"
30
#include "util.h"
31
#include "emcorefs.h"
32
 
33
 
34
struct fuse_operations emcorefs_oper =
35
{
36
    .getattr    = emcorefs_getattr,
784 user890104 37
 
770 user890104 38
    .opendir    = emcorefs_opendir,
39
    .readdir    = emcorefs_readdir,
40
    .releasedir = emcorefs_releasedir,
784 user890104 41
 
770 user890104 42
    .open       = emcorefs_open,
43
    .read       = emcorefs_read,
784 user890104 44
    .write      = emcorefs_write,
770 user890104 45
    .release    = emcorefs_release,
784 user890104 46
 
782 user890104 47
    .mkdir      = emcorefs_mkdir,
48
    .rmdir      = emcorefs_rmdir,
784 user890104 49
 
782 user890104 50
    .create     = emcorefs_create,
51
    .mknod      = emcorefs_mknod,
52
    .unlink     = emcorefs_unlink,
784 user890104 53
    .rename     = emcorefs_rename,
54
    .truncate   = emcorefs_truncate,
55
 
56
    .ftruncate  = emcorefs_ftruncate,
770 user890104 57
};
58
 
59
int main(int argc, char* argv[])
60
{
61
    int res, res2;
62
    uint8_t reattach = 0;
63
 
64
    res = usb_init();
65
 
66
    if (LIBUSB_SUCCESS == res)
67
    {
68
        res = usb_find(EMCORE_USB_VID, EMCORE_USB_PID, &reattach);
69
    }
70
 
71
    if (LIBUSB_SUCCESS == res)
72
    {
73
        res = emcorefs_init();
74
    }
75
 
76
    if (EMCORE_SUCCESS == res)
77
    {
78
#ifdef TEST_ONLY
79
        /* gcc complains about unused vars */
80
        (void)(argc);
81
        (void)(argv);
82
 
83
        res = emcore_test();
84
#else
85
        cache_init();
86
 
87
        res = fuse_main(argc, argv, &emcorefs_oper, NULL);
88
 
89
        cache_destroy();
90
#endif
91
    }
92
 
93
    if (EMCORE_SUCCESS != res)
94
    {
95
        print_error(res);
96
    }
97
 
98
    res2 = usb_destroy(reattach);
99
 
100
    if (LIBUSB_SUCCESS != res2)
101
    {
102
        print_error(res2);
103
    }
104
 
105
    if (res < 0)
106
    {
107
        res = -res;
108
    }
109
 
110
    return res;
111
}