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,
37
    .opendir    = emcorefs_opendir,
38
    .readdir    = emcorefs_readdir,
39
    .releasedir = emcorefs_releasedir,
40
    .open       = emcorefs_open,
41
    .read       = emcorefs_read,
42
    .release    = emcorefs_release,
782 user890104 43
    .mkdir      = emcorefs_mkdir,
44
    .rmdir      = emcorefs_rmdir,
45
    .create     = emcorefs_create,
46
    .mknod      = emcorefs_mknod,
47
    .unlink     = emcorefs_unlink,
770 user890104 48
};
49
 
50
int main(int argc, char* argv[])
51
{
52
    int res, res2;
53
    uint8_t reattach = 0;
54
 
55
    res = usb_init();
56
 
57
    if (LIBUSB_SUCCESS == res)
58
    {
59
        res = usb_find(EMCORE_USB_VID, EMCORE_USB_PID, &reattach);
60
    }
61
 
62
    if (LIBUSB_SUCCESS == res)
63
    {
64
        res = emcorefs_init();
65
    }
66
 
67
    if (EMCORE_SUCCESS == res)
68
    {
69
#ifdef TEST_ONLY
70
        /* gcc complains about unused vars */
71
        (void)(argc);
72
        (void)(argv);
73
 
74
        res = emcore_test();
75
#else
76
        cache_init();
77
 
78
        res = fuse_main(argc, argv, &emcorefs_oper, NULL);
79
 
80
        cache_destroy();
81
#endif
82
    }
83
 
84
    if (EMCORE_SUCCESS != res)
85
    {
86
        print_error(res);
87
    }
88
 
89
    res2 = usb_destroy(reattach);
90
 
91
    if (LIBUSB_SUCCESS != res2)
92
    {
93
        print_error(res2);
94
    }
95
 
96
    if (res < 0)
97
    {
98
        res = -res;
99
    }
100
 
101
    return res;
102
}