Changeset 29
- Timestamp:
- 05/30/07 11:14:12 (3 years ago)
- Location:
- trunk
- Files:
-
- 2 modified
-
ChangeLog (modified) (1 diff)
-
fuse/obexautofs.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r26 r29 1 TODO 2 * Switching to discover API 1 2007-05-30 Christian W. Zuckschwerdt <zany@triq.net> 2 3 * Added USB discovery 4 5 2007-05-29 Christian W. Zuckschwerdt <zany@triq.net> 6 7 * Keep users CFLAGS by Ville SkyttÀon 3 8 4 9 2007-05-27 Christian W. Zuckschwerdt <zany@triq.net> -
trunk/fuse/obexautofs.c
r24 r29 94 94 static int discover_irda(void) { return -1; } 95 95 96 static int discover_usb(void) { return -1; } 96 static int discover_usb(void) { 97 char **devices, **dev; 98 char name[25], *p; 99 connection_t *conn; 100 101 DEBUG("Scanning USB...\n"); 102 devices = obexftp_discover(OBEX_TRANS_USB); 103 104 for(dev = devices; *dev; dev++) { 105 strcpy(name, "usb"); 106 strncpy(&name[3], *dev, sizeof(name)-4); 107 p = strchr(name, ' '); 108 if (p) 109 *p = '\0'; 110 DEBUG("Found %s (%d), %s\n", name, atoi(*dev), *dev); 111 112 for (conn = connections; conn; conn = conn->next) { 113 if (!strcmp(conn->addr, name)) { 114 conn->recent++; 115 break; 116 } 117 } 118 119 if (!conn) { 120 DEBUG("Adding %s\n", name); 121 conn = calloc(1, sizeof(connection_t)); 122 if (!conn) 123 return -1; 124 conn->alias = NULL; 125 conn->transport = OBEX_TRANS_USB; 126 conn->addr = strdup(name); 127 conn->channel = atoi(*dev); 128 //conn->cli = cli_open(OBEX_TRANS_USB, NULL, conn->channel); 129 conn->recent++; 130 conn->next = connections; 131 connections = conn; 132 } 133 } 134 return 0; 135 } 97 136 98 137 static int discover_tty(char *UNUSED(port)) { return -1; } … … 184 223 /* remove from head */ 185 224 while (connections && connections->recent == 0) { 186 fprintf(stderr, "Deleting %s\n", connections->alias);225 DEBUG("Deleting %s\n", connections->addr); 187 226 conn = connections; 188 227 connections = conn->next; 189 228 190 229 cli_close(conn->cli); 191 free(conn->alias); 230 if (conn->alias) 231 free(conn->alias); 192 232 free(conn->addr); 193 233 free(conn); … … 197 237 for (prev = connections; prev; prev = prev->next) 198 238 if(prev->next && prev->next->recent == 0) { 199 fprintf(stderr, "Deleting2 %s\n", prev->next->alias);239 DEBUG("Deleting2 %s\n", prev->next->addr); 200 240 conn = prev->next; 201 241 prev->next = conn->next; 202 242 203 243 cli_close(conn->cli); 204 free(conn->alias); 244 if (conn->alias) 245 free(conn->alias); 205 246 free(conn->addr); 206 247 free(conn); … … 303 344 304 345 for (conn = connections; conn; conn = conn->next) { 305 if (!strncmp(conn->addr, path, namelen) || !strncmp(conn->alias, path, namelen)) {346 if (!strncmp(conn->addr, path, namelen) || (conn->alias && !strncmp(conn->alias, path, namelen))) { 306 347 if (!conn->cli) 307 348 conn->cli = cli_open(conn->transport, conn->addr, conn->channel); … … 357 398 if(!filepath) { 358 399 /* the device entry itself */ 359 if ( strchr(path, ':'))400 if (!strcmp(path + 1, conn->addr)) 360 401 stbuf->st_mode = S_IFDIR | 0755; 361 402 else … … 400 441 401 442 for (conn = connections; conn; conn = conn->next) { 402 if( !strcmp(conn->alias, path + 1)) {443 if(conn->alias && !strcmp(conn->alias, path + 1)) { 403 444 strcpy(link, conn->addr); 404 445 return 0; … … 430 471 for (conn = connections; conn; conn = conn->next) { 431 472 stat.st_mode = DT_DIR; 432 res = filler(h, conn->alias, DT_LNK, 0); 473 if (conn->alias) 474 res = filler(h, conn->alias, DT_LNK, 0); 433 475 res = filler(h, conn->addr, DT_DIR, 0); 434 476 if(res != 0) … … 741 783 for (conn = connections; conn; conn = conn->next) { 742 784 cli_close(conn->cli); 743 free(conn->alias); 785 if (conn->alias) 786 free(conn->alias); 744 787 free(conn->addr); 745 788 free(conn);
