Subversion Repositories freemyipod

Rev

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

Rev 784 Rev 898
Line 1... Line 1...
1
//
1
//
2
//
2
//
3
//    Copyright 2011 user890104
3
//    Copyright 2013 user890104
4
//
4
//
5
//
5
//
6
//    This file is part of emCORE.
6
//    This file is part of emCORE.
7
//
7
//
8
//    emCORE is free software: you can redistribute it and/or
8
//    emCORE is free software: you can redistribute it and/or
Line 18... Line 18...
18
//    You should have received a copy of the GNU General Public License along
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/>.
19
//    with emCORE.  If not, see <http://www.gnu.org/licenses/>.
20
//
20
//
21
//
21
//
22
 
22
 
23
 
-
 
24
#include "global.h"
23
#include "global.h"
25
 
24
 
26
#include "usb.h"
25
#include "usb.h"
27
#include "cache.h"
26
#include "cache.h"
28
#include "emcore.h"
27
#include "emcore.h"
29
#include "fuse.h"
28
#include "fuse.h"
30
#include "util.h"
29
#include "util.h"
31
#include "emcorefs.h"
-
 
32
 
-
 
33
 
30
 
34
struct fuse_operations emcorefs_oper =
31
struct fuse_operations emcorefs_oper = {
35
{
-
 
36
    .getattr    = emcorefs_getattr,
32
    .getattr    = emcorefs_getattr,
37
    
33
    
38
    .opendir    = emcorefs_opendir,
34
    .opendir    = emcorefs_opendir,
39
    .readdir    = emcorefs_readdir,
35
    .readdir    = emcorefs_readdir,
40
    .releasedir = emcorefs_releasedir,
36
    .releasedir = emcorefs_releasedir,
Line 54... Line 50...
54
    .truncate   = emcorefs_truncate,
50
    .truncate   = emcorefs_truncate,
55
    
51
    
56
    .ftruncate  = emcorefs_ftruncate,
52
    .ftruncate  = emcorefs_ftruncate,
57
};
53
};
58
 
54
 
59
int main(int argc, char* argv[])
55
int main(int argc, char **argv) {
60
{
-
 
61
    int res, res2;
56
    int32_t res, res2;
62
    uint8_t reattach = 0;
57
    uint8_t reattach = 0;
63
 
58
 
64
    res = usb_init();
59
    res = usb_init();
65
 
60
 
66
    if (LIBUSB_SUCCESS == res)
61
    if (res == LIBUSB_SUCCESS) {
67
    {
-
 
68
        res = usb_find(EMCORE_USB_VID, EMCORE_USB_PID, &reattach);
62
        res = usb_find(EMCORE_USB_VID, EMCORE_USB_PID, &reattach);
69
    }
63
    }
70
 
64
 
71
    if (LIBUSB_SUCCESS == res)
65
    if (res == LIBUSB_SUCCESS) {
72
    {
-
 
73
        res = emcorefs_init();
66
        res = emcorefs_init();
74
    }
67
    }
75
 
68
 
76
    if (EMCORE_SUCCESS == res)
69
    if (res == EMCORE_SUCCESS) {
77
    {
-
 
78
#ifdef TEST_ONLY
70
#ifdef TEST_ONLY
79
        /* gcc complains about unused vars */
71
        /* gcc complains about unused vars */
80
        (void)(argc);
72
        (void)(argc);
81
        (void)(argv);
73
        (void)(argv);
82
 
74
 
Line 88... Line 80...
88
 
80
 
89
        cache_destroy();
81
        cache_destroy();
90
#endif
82
#endif
91
    }
83
    }
92
 
84
 
93
    if (EMCORE_SUCCESS != res)
85
    if (res != EMCORE_SUCCESS) {
94
    {
-
 
95
        print_error(res);
86
        print_error(res);
96
    }
87
    }
97
 
88
 
98
    res2 = usb_destroy(reattach);
89
    res2 = usb_destroy(reattach);
99
 
90
 
100
    if (LIBUSB_SUCCESS != res2)
91
    if (res2 != LIBUSB_SUCCESS) {
101
    {
-
 
102
        print_error(res2);
92
        print_error(res2);
103
    }
93
    }
104
 
94
 
105
    if (res < 0)
95
    if (res < 0) {
106
    {
-
 
107
        res = -res;
96
        res = -res;
108
    }
97
    }
109
 
98
 
110
    return res;
99
    return res;
111
}
100
}