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
//
898 user890104 3
//    Copyright 2013 user890104
770 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
#include "global.h"
24
 
25
#include "usb.h"
26
#include "cache.h"
27
#include "emcore.h"
28
#include "fuse.h"
29
#include "util.h"
30
 
898 user890104 31
struct fuse_operations emcorefs_oper = {
770 user890104 32
    .getattr    = emcorefs_getattr,
784 user890104 33
 
770 user890104 34
    .opendir    = emcorefs_opendir,
35
    .readdir    = emcorefs_readdir,
36
    .releasedir = emcorefs_releasedir,
784 user890104 37
 
770 user890104 38
    .open       = emcorefs_open,
39
    .read       = emcorefs_read,
784 user890104 40
    .write      = emcorefs_write,
770 user890104 41
    .release    = emcorefs_release,
784 user890104 42
 
782 user890104 43
    .mkdir      = emcorefs_mkdir,
44
    .rmdir      = emcorefs_rmdir,
784 user890104 45
 
782 user890104 46
    .create     = emcorefs_create,
47
    .mknod      = emcorefs_mknod,
48
    .unlink     = emcorefs_unlink,
784 user890104 49
    .rename     = emcorefs_rename,
50
    .truncate   = emcorefs_truncate,
51
 
52
    .ftruncate  = emcorefs_ftruncate,
770 user890104 53
};
54
 
898 user890104 55
int main(int argc, char **argv) {
56
    int32_t res, res2;
770 user890104 57
    uint8_t reattach = 0;
58
 
59
    res = usb_init();
60
 
898 user890104 61
    if (res == LIBUSB_SUCCESS) {
770 user890104 62
        res = usb_find(EMCORE_USB_VID, EMCORE_USB_PID, &reattach);
63
    }
64
 
898 user890104 65
    if (res == LIBUSB_SUCCESS) {
770 user890104 66
        res = emcorefs_init();
67
    }
68
 
898 user890104 69
    if (res == EMCORE_SUCCESS) {
770 user890104 70
#ifdef TEST_ONLY
71
        /* gcc complains about unused vars */
72
        (void)(argc);
73
        (void)(argv);
74
 
75
        res = emcore_test();
76
#else
77
        cache_init();
78
 
79
        res = fuse_main(argc, argv, &emcorefs_oper, NULL);
80
 
81
        cache_destroy();
82
#endif
83
    }
84
 
898 user890104 85
    if (res != EMCORE_SUCCESS) {
770 user890104 86
        print_error(res);
87
    }
88
 
89
    res2 = usb_destroy(reattach);
90
 
898 user890104 91
    if (res2 != LIBUSB_SUCCESS) {
770 user890104 92
        print_error(res2);
93
    }
94
 
898 user890104 95
    if (res < 0) {
770 user890104 96
        res = -res;
97
    }
98
 
99
    return res;
100
}