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