- Timestamp:
- 01/15/04 01:00:00 (5 years ago)
- Location:
- trunk
- Files:
-
- 3 modified
-
configure.in (modified) (1 diff)
-
fuse/Makefile.am (modified) (1 diff)
-
fuse/obexfs.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/configure.in
r2 r4 1 1 AC_INIT(fuse/obexfs.c) 2 AM_INIT_AUTOMAKE(obexfs, 0. 1)2 AM_INIT_AUTOMAKE(obexfs, 0.2) 3 3 AM_CONFIG_HEADER(config.h) 4 4 -
trunk/fuse/Makefile.am
r2 r4 2 2 3 3 LDADD = -lfuse -lpthread \ 4 -lopenobex -l obexftp\5 - lcobexbfb -lbfb -lcobexpe4 -lopenobex -lbluetooth \ 5 -L/var/tmp/y/usr/local/lib -lobexftp -lcobexbfb -lbfb 6 6 7 7 obexfs_SOURCES = obexfs.c -
trunk/fuse/obexfs.c
r2 r4 2 2 * obexfs.c: FUSE Filesystem to access OBEX 3 3 * 4 * Copyright (c) 2003 Christian W. Zuckschwerdt <zany@triq.net>4 * Copyright (c) 2003-2004 Christian W. Zuckschwerdt <zany@triq.net> 5 5 * 6 6 * This program is free software; you can redistribute it and/or modify it … … 37 37 #include <errno.h> 38 38 #include <sys/statfs.h> 39 #include <getopt.h> 39 40 40 41 #include <obexftp/obexftp.h> 41 42 #include <obexftp/client.h> 42 43 #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)) 53 46 54 47 typedef struct { … … 69 62 70 63 static obexftp_client_t *cli = NULL; 71 static char *tty = "/dev/ttyS0"; 72 static char *transport = "siemens"; 64 static char *tty = NULL; // "/dev/ttyS0"; 65 static int transport = 0; 66 static char *btaddr = NULL; // "00:11:22:33:44:55"; 67 static int btchannel = 5; // 10; 73 68 74 69 static int info; … … 137 132 138 133 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); 146 136 } 147 137 else { … … 151 141 152 142 /* Open */ 153 cli = obexftp_cli_open ( ofs_info_cb, ctrans, NULL);143 cli = obexftp_cli_open (transport, ctrans, ofs_info_cb, NULL); 154 144 if(cli == NULL) { 155 145 /* Error opening obexftp-client */ … … 160 150 161 151 /* Connect */ 162 if (obexftp_cli_connect (cli ) >= 0)152 if (obexftp_cli_connect (cli, btaddr, btchannel) >= 0) 163 153 return 0; 164 154 /* Still trying to connect */ 155 sleep(1); 165 156 } 166 157 … … 303 294 for (dir = cache[i].dir; dir && dir->name; dir++) { 304 295 if (strcmp(p, dir->name) == 0) { 296 printf("found entry %s\n", dir->name); 305 297 stbuf->st_mode = dir->mode; 306 298 stbuf->st_nlink = 1; … … 346 338 cache_ptr++; 347 339 340 printf("<<<<%s>>>>\n", path); 348 341 ofs_disconnect(); 349 342 return 0; … … 373 366 } 374 367 375 (void) obexftp_setpath(cli, p , 0);368 (void) obexftp_setpath(cli, p); 376 369 } 377 370 … … 413 406 static int ofs_truncate(const char *path, off_t size) 414 407 { 415 printf("Truncating %s to %l d\n", path, size);408 printf("Truncating %s to %lld\n", path, size); 416 409 417 410 return 0; … … 442 435 ofs_disconnect(); 443 436 } 444 printf("reading %s at %l d for %d\n", path, offset, size);437 printf("reading %s at %lld for %d\n", path, offset, size); 445 438 memcpy(buf, xfer_data + offset, size); 446 439 … … 452 445 static int ofs_write(const char *path, const char *UNUSED(buf), size_t size, off_t offset) 453 446 { 454 printf("Writing %s at %l d 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 452 static int ofs_statfs(struct fuse_statfs *fst) 460 453 { 461 454 int res; 462 455 int size, free; 463 456 464 memset(fst, 0, sizeof(struct statfs));457 memset(fst, 0, sizeof(struct fuse_statfs)); 465 458 466 459 res = ofs_connect(); … … 476 469 ofs_disconnect(); 477 470 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 */ 488 478 489 479 return 0; … … 509 499 write: ofs_write, 510 500 statfs: ofs_statfs, 501 release: NULL, 502 fsync: NULL 503 511 504 }; 512 505 513 506 int main(int argc, char *argv[]) 514 507 { 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 }
