Changeset 4 for trunk

Show
Ignore:
Timestamp:
01/15/04 01:00:00 (5 years ago)
Author:
zany
Message:

Release 0.2

Location:
trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/configure.in

    r2 r4  
    11AC_INIT(fuse/obexfs.c) 
    2 AM_INIT_AUTOMAKE(obexfs, 0.1) 
     2AM_INIT_AUTOMAKE(obexfs, 0.2) 
    33AM_CONFIG_HEADER(config.h) 
    44 
  • trunk/fuse/Makefile.am

    r2 r4  
    22 
    33LDADD =                         -lfuse -lpthread \ 
    4                                 -lopenobex -lobexftp \ 
    5                                 -lcobexbfb -lbfb -lcobexpe 
     4                                -lopenobex -lbluetooth \ 
     5                                -L/var/tmp/y/usr/local/lib -lobexftp -lcobexbfb -lbfb 
    66 
    77obexfs_SOURCES =                obexfs.c 
  • trunk/fuse/obexfs.c

    r2 r4  
    22 *  obexfs.c: FUSE Filesystem to access OBEX 
    33 * 
    4  *  Copyright (c) 2003 Christian W. Zuckschwerdt <zany@triq.net> 
     4 *  Copyright (c) 2003-2004 Christian W. Zuckschwerdt <zany@triq.net> 
    55 * 
    66 *  This program is free software; you can redistribute it and/or modify it 
     
    3737#include <errno.h> 
    3838#include <sys/statfs.h> 
     39#include <getopt.h> 
    3940 
    4041#include <obexftp/obexftp.h> 
    4142#include <obexftp/client.h> 
    4243#include <cobexbfb/cobex_bfb.h> 
    43 #include <cobexpe/cobex_pe.h> 
    44  
    45 /* we do not want to include <linux/msdos_fs.h> */ 
    46 #define MSDOS_SUPER_MAGIC     0x4d44 
    47  
    48 #if __GNUC__ 
    49 #define UNUSED __attribute__((unused)) 
    50 #else 
    51 #define UNUSED 
    52 #endif 
     44 
     45#define UNUSED(x) x __attribute__((unused)) 
    5346 
    5447typedef struct { 
     
    6962 
    7063static obexftp_client_t *cli = NULL; 
    71 static char *tty = "/dev/ttyS0"; 
    72 static char *transport = "siemens"; 
     64static char *tty = NULL; // "/dev/ttyS0"; 
     65static int transport = 0; 
     66static char *btaddr = NULL; // "00:11:22:33:44:55"; 
     67static int btchannel = 5; // 10; 
    7368 
    7469static int info; 
     
    137132 
    138133        if (tty != NULL) { 
    139                 if ((transport != NULL) && !strcasecmp(transport, "ericsson")) { 
    140                         /* Custom transport set to 'Ericsson' */ 
    141                         ctrans = cobex_pe_ctrans (tty); 
    142                 } else { 
    143                         /* Custom transport set to 'Siemens' */ 
    144                         ctrans = cobex_ctrans (tty); 
    145                 } 
     134                /* Custom transport Siemens/Ericsson */ 
     135                ctrans = cobex_ctrans (tty); 
    146136        } 
    147137        else { 
     
    151141 
    152142        /* Open */ 
    153         cli = obexftp_cli_open (ofs_info_cb, ctrans, NULL); 
     143        cli = obexftp_cli_open (transport, ctrans, ofs_info_cb, NULL); 
    154144        if(cli == NULL) { 
    155145                /* Error opening obexftp-client */ 
     
    160150 
    161151                /* Connect */ 
    162                 if (obexftp_cli_connect (cli) >= 0) 
     152                if (obexftp_cli_connect (cli, btaddr, btchannel) >= 0) 
    163153                        return 0; 
    164154                /* Still trying to connect */ 
     155                sleep(1); 
    165156        } 
    166157 
     
    303294                        for (dir = cache[i].dir; dir && dir->name; dir++) { 
    304295                                if (strcmp(p, dir->name) == 0) { 
     296                                        printf("found entry %s\n", dir->name); 
    305297                                        stbuf->st_mode = dir->mode; 
    306298                                        stbuf->st_nlink = 1; 
     
    346338        cache_ptr++; 
    347339 
     340        printf("<<<<%s>>>>\n", path); 
    348341        ofs_disconnect(); 
    349342        return 0; 
     
    373366                } 
    374367 
    375                 (void) obexftp_setpath(cli, p, 0); 
     368                (void) obexftp_setpath(cli, p); 
    376369        } 
    377370 
     
    413406static int ofs_truncate(const char *path, off_t size) 
    414407{ 
    415         printf("Truncating %s to %ld\n", path, size); 
     408        printf("Truncating %s to %lld\n", path, size); 
    416409 
    417410        return 0; 
     
    442435                ofs_disconnect(); 
    443436        } 
    444         printf("reading %s at %ld for %d\n", path, offset, size); 
     437        printf("reading %s at %lld for %d\n", path, offset, size); 
    445438        memcpy(buf, xfer_data + offset, size); 
    446439 
     
    452445static int ofs_write(const char *path, const char *UNUSED(buf), size_t size, off_t offset) 
    453446{ 
    454         printf("Writing %s at %ld for %d\n", path, offset, size); 
    455  
    456         return 0; 
    457 } 
    458  
    459 static int ofs_statfs(struct statfs *fst) 
     447        printf("Writing %s at %lld for %d\n", path, offset, size); 
     448 
     449        return 0; 
     450} 
     451 
     452static int ofs_statfs(struct fuse_statfs *fst) 
    460453{ 
    461454        int res; 
    462455        int size, free; 
    463456 
    464         memset(fst, 0, sizeof(struct statfs)); 
     457        memset(fst, 0, sizeof(struct fuse_statfs)); 
    465458 
    466459        res = ofs_connect(); 
     
    476469        ofs_disconnect(); 
    477470 
    478         /* fst->f_type;     / * type of filesystem (see below) */ 
    479         fst->f_bsize = 1;    /* optimal transfer block size */ 
    480         fst->f_blocks = size;   /* total data blocks in file system */ 
    481         fst->f_bfree = free;    /* free blocks in fs */ 
    482         fst->f_bavail = free;   /* free blocks avail to non-superuser */ 
    483  
    484         /* long    f_files;    / * total file nodes in file system */ 
    485         /* long    f_ffree;    / * free file nodes in fs */ 
    486         /* fsid_t  f_fsid;     / * file system id */ 
    487         /* fst->f_namelen;  / * maximum length of filenames */ 
     471        fst->block_size = 1;    /* optimal transfer block size */ 
     472        fst->blocks = size;   /* total data blocks in file system */ 
     473        fst->blocks_free = free;    /* free blocks in fs */ 
     474 
     475        /* fst->files;    / * total file nodes in file system */ 
     476        /* fst->files_free;    / * free file nodes in fs */ 
     477        /* fst->namelen;  / * maximum length of filenames */ 
    488478 
    489479        return 0; 
     
    509499        write:          ofs_write, 
    510500        statfs:         ofs_statfs, 
     501        release:        NULL, 
     502        fsync:          NULL 
     503                 
    511504}; 
    512505 
    513506int main(int argc, char *argv[]) 
    514507{ 
    515         fuse_main(argc, argv, &ofs_oper); 
    516         return 0; 
    517 } 
     508        while (1) { 
     509                int option_index = 0; 
     510                int c; 
     511                static struct option long_options[] = { 
     512                        {"irda",        no_argument, NULL, 'i'}, 
     513                        {"bluetooth",   required_argument, NULL, 'b'}, 
     514                        {"channel",     required_argument, NULL, 'B'}, 
     515                        {"tty",         required_argument, NULL, 't'}, 
     516                        {"help",        no_argument, NULL, 'h'}, 
     517                        {"usage",       no_argument, NULL, 'u'}, 
     518                        {0, 0, 0, 0} 
     519                }; 
     520                 
     521                c = getopt_long (argc, argv, "+ib:B:t:h", 
     522                                 long_options, &option_index); 
     523                if (c == -1) 
     524                        break; 
     525 
     526                switch (c) { 
     527                 
     528                case 'i': 
     529                        transport = OBEX_TRANS_IRDA; 
     530                        break; 
     531                 
     532                case 'b': 
     533                        transport = OBEX_TRANS_BLUETOOTH; 
     534                        if (btaddr != NULL) 
     535                                free (btaddr); 
     536                        btaddr = optarg; 
     537                        break; 
     538                         
     539                case 'B': 
     540                        btchannel = atoi(optarg); 
     541                        break; 
     542                 
     543                case 't': 
     544                        transport = OBEX_TRANS_CUSTOM; 
     545                        if (tty != NULL) 
     546                                free (tty); 
     547 
     548                        if (!strcasecmp(optarg, "irda")) 
     549                                tty = NULL; 
     550                        else 
     551                                tty = optarg; 
     552                        break; 
     553 
     554                case 'h': 
     555                case 'u': 
     556                        printf("Usage: %s [-i | -b <dev> [-B <chan>] | -t <dev>] [-- <fuse options>]\n" 
     557                                "Transfer files from/to Mobile Equipment.\n" 
     558                                "Copyright (c) 2002-2004 Christian W. Zuckschwerdt\n" 
     559                                "\n" 
     560                                " -i, --irda                  connect using IrDA transport\n" 
     561                                " -b, --bluetooth <device>    connect to this bluetooth device\n" 
     562                                " -B, --channel <number>      use this bluetooth channel when connecting\n" 
     563                                " -t, --tty <device>          connect to this tty using a custom transport\n\n" 
     564                                " -h, --help, --usage         this help text\n\n" 
     565                                "Options to fusermount need to be preceeded by two dashes (--).\n" 
     566                                "\n", 
     567                                argv[0]); 
     568                        exit(0); 
     569                        break; 
     570 
     571                default: 
     572                        printf("Try `%s --help' for more information.\n", 
     573                                 argv[0]); 
     574                        exit(0); 
     575                } 
     576        } 
     577 
     578        if (transport == 0) { 
     579                fprintf(stderr, "No device selected. Use --help for help.\n"); 
     580                exit(0); 
     581        } 
     582 
     583        argv[optind-1] = argv[0]; 
     584        fuse_main(argc-optind+1, &argv[optind-1], &ofs_oper); 
     585        return 0; 
     586}