├── .gitignore ├── AUTHORS ├── COPYING ├── ChangeLog ├── INSTALL ├── Makefile.am ├── Makefile.in ├── NEWS ├── README ├── _config.yml ├── autogen.sh ├── configure ├── configure.ac ├── id3read.c ├── id3read.h ├── mtpfs.c └── mtpfs.h /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | .deps 3 | Makefile 4 | aclocal.m4 5 | autom4te.cache 6 | config.log 7 | config.status 8 | mtpfs 9 | compile 10 | depcomp 11 | install-sh 12 | missing 13 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Chris Debenham 2 | 3 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | 2007-11-26 2 | 3 | * mtpfs.c: fixed several memory leaks with valgrind 4 | 5 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | Installation Instructions 2 | ************************* 3 | 4 | Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, 5 | 2006, 2007, 2008, 2009 Free Software Foundation, Inc. 6 | 7 | Copying and distribution of this file, with or without modification, 8 | are permitted in any medium without royalty provided the copyright 9 | notice and this notice are preserved. This file is offered as-is, 10 | without warranty of any kind. 11 | 12 | Basic Installation 13 | ================== 14 | 15 | Briefly, the shell commands `./configure; make; make install' should 16 | configure, build, and install this package. The following 17 | more-detailed instructions are generic; see the `README' file for 18 | instructions specific to this package. Some packages provide this 19 | `INSTALL' file but do not implement all of the features documented 20 | below. The lack of an optional feature in a given package is not 21 | necessarily a bug. More recommendations for GNU packages can be found 22 | in *note Makefile Conventions: (standards)Makefile Conventions. 23 | 24 | The `configure' shell script attempts to guess correct values for 25 | various system-dependent variables used during compilation. It uses 26 | those values to create a `Makefile' in each directory of the package. 27 | It may also create one or more `.h' files containing system-dependent 28 | definitions. Finally, it creates a shell script `config.status' that 29 | you can run in the future to recreate the current configuration, and a 30 | file `config.log' containing compiler output (useful mainly for 31 | debugging `configure'). 32 | 33 | It can also use an optional file (typically called `config.cache' 34 | and enabled with `--cache-file=config.cache' or simply `-C') that saves 35 | the results of its tests to speed up reconfiguring. Caching is 36 | disabled by default to prevent problems with accidental use of stale 37 | cache files. 38 | 39 | If you need to do unusual things to compile the package, please try 40 | to figure out how `configure' could check whether to do them, and mail 41 | diffs or instructions to the address given in the `README' so they can 42 | be considered for the next release. If you are using the cache, and at 43 | some point `config.cache' contains results you don't want to keep, you 44 | may remove or edit it. 45 | 46 | The file `configure.ac' (or `configure.in') is used to create 47 | `configure' by a program called `autoconf'. You need `configure.ac' if 48 | you want to change it or regenerate `configure' using a newer version 49 | of `autoconf'. 50 | 51 | The simplest way to compile this package is: 52 | 53 | 1. `cd' to the directory containing the package's source code and type 54 | `./configure' to configure the package for your system. 55 | 56 | Running `configure' might take a while. While running, it prints 57 | some messages telling which features it is checking for. 58 | 59 | 2. Type `make' to compile the package. 60 | 61 | 3. Optionally, type `make check' to run any self-tests that come with 62 | the package, generally using the just-built uninstalled binaries. 63 | 64 | 4. Type `make install' to install the programs and any data files and 65 | documentation. When installing into a prefix owned by root, it is 66 | recommended that the package be configured and built as a regular 67 | user, and only the `make install' phase executed with root 68 | privileges. 69 | 70 | 5. Optionally, type `make installcheck' to repeat any self-tests, but 71 | this time using the binaries in their final installed location. 72 | This target does not install anything. Running this target as a 73 | regular user, particularly if the prior `make install' required 74 | root privileges, verifies that the installation completed 75 | correctly. 76 | 77 | 6. You can remove the program binaries and object files from the 78 | source code directory by typing `make clean'. To also remove the 79 | files that `configure' created (so you can compile the package for 80 | a different kind of computer), type `make distclean'. There is 81 | also a `make maintainer-clean' target, but that is intended mainly 82 | for the package's developers. If you use it, you may have to get 83 | all sorts of other programs in order to regenerate files that came 84 | with the distribution. 85 | 86 | 7. Often, you can also type `make uninstall' to remove the installed 87 | files again. In practice, not all packages have tested that 88 | uninstallation works correctly, even though it is required by the 89 | GNU Coding Standards. 90 | 91 | 8. Some packages, particularly those that use Automake, provide `make 92 | distcheck', which can by used by developers to test that all other 93 | targets like `make install' and `make uninstall' work correctly. 94 | This target is generally not run by end users. 95 | 96 | Compilers and Options 97 | ===================== 98 | 99 | Some systems require unusual options for compilation or linking that 100 | the `configure' script does not know about. Run `./configure --help' 101 | for details on some of the pertinent environment variables. 102 | 103 | You can give `configure' initial values for configuration parameters 104 | by setting variables in the command line or in the environment. Here 105 | is an example: 106 | 107 | ./configure CC=c99 CFLAGS=-g LIBS=-lposix 108 | 109 | *Note Defining Variables::, for more details. 110 | 111 | Compiling For Multiple Architectures 112 | ==================================== 113 | 114 | You can compile the package for more than one kind of computer at the 115 | same time, by placing the object files for each architecture in their 116 | own directory. To do this, you can use GNU `make'. `cd' to the 117 | directory where you want the object files and executables to go and run 118 | the `configure' script. `configure' automatically checks for the 119 | source code in the directory that `configure' is in and in `..'. This 120 | is known as a "VPATH" build. 121 | 122 | With a non-GNU `make', it is safer to compile the package for one 123 | architecture at a time in the source code directory. After you have 124 | installed the package for one architecture, use `make distclean' before 125 | reconfiguring for another architecture. 126 | 127 | On MacOS X 10.5 and later systems, you can create libraries and 128 | executables that work on multiple system types--known as "fat" or 129 | "universal" binaries--by specifying multiple `-arch' options to the 130 | compiler but only a single `-arch' option to the preprocessor. Like 131 | this: 132 | 133 | ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ 134 | CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ 135 | CPP="gcc -E" CXXCPP="g++ -E" 136 | 137 | This is not guaranteed to produce working output in all cases, you 138 | may have to build one architecture at a time and combine the results 139 | using the `lipo' tool if you have problems. 140 | 141 | Installation Names 142 | ================== 143 | 144 | By default, `make install' installs the package's commands under 145 | `/usr/local/bin', include files under `/usr/local/include', etc. You 146 | can specify an installation prefix other than `/usr/local' by giving 147 | `configure' the option `--prefix=PREFIX', where PREFIX must be an 148 | absolute file name. 149 | 150 | You can specify separate installation prefixes for 151 | architecture-specific files and architecture-independent files. If you 152 | pass the option `--exec-prefix=PREFIX' to `configure', the package uses 153 | PREFIX as the prefix for installing programs and libraries. 154 | Documentation and other data files still use the regular prefix. 155 | 156 | In addition, if you use an unusual directory layout you can give 157 | options like `--bindir=DIR' to specify different values for particular 158 | kinds of files. Run `configure --help' for a list of the directories 159 | you can set and what kinds of files go in them. In general, the 160 | default for these options is expressed in terms of `${prefix}', so that 161 | specifying just `--prefix' will affect all of the other directory 162 | specifications that were not explicitly provided. 163 | 164 | The most portable way to affect installation locations is to pass the 165 | correct locations to `configure'; however, many packages provide one or 166 | both of the following shortcuts of passing variable assignments to the 167 | `make install' command line to change installation locations without 168 | having to reconfigure or recompile. 169 | 170 | The first method involves providing an override variable for each 171 | affected directory. For example, `make install 172 | prefix=/alternate/directory' will choose an alternate location for all 173 | directory configuration variables that were expressed in terms of 174 | `${prefix}'. Any directories that were specified during `configure', 175 | but not in terms of `${prefix}', must each be overridden at install 176 | time for the entire installation to be relocated. The approach of 177 | makefile variable overrides for each directory variable is required by 178 | the GNU Coding Standards, and ideally causes no recompilation. 179 | However, some platforms have known limitations with the semantics of 180 | shared libraries that end up requiring recompilation when using this 181 | method, particularly noticeable in packages that use GNU Libtool. 182 | 183 | The second method involves providing the `DESTDIR' variable. For 184 | example, `make install DESTDIR=/alternate/directory' will prepend 185 | `/alternate/directory' before all installation names. The approach of 186 | `DESTDIR' overrides is not required by the GNU Coding Standards, and 187 | does not work on platforms that have drive letters. On the other hand, 188 | it does better at avoiding recompilation issues, and works well even 189 | when some directory options were not specified in terms of `${prefix}' 190 | at `configure' time. 191 | 192 | Optional Features 193 | ================= 194 | 195 | If the package supports it, you can cause programs to be installed 196 | with an extra prefix or suffix on their names by giving `configure' the 197 | option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. 198 | 199 | Some packages pay attention to `--enable-FEATURE' options to 200 | `configure', where FEATURE indicates an optional part of the package. 201 | They may also pay attention to `--with-PACKAGE' options, where PACKAGE 202 | is something like `gnu-as' or `x' (for the X Window System). The 203 | `README' should mention any `--enable-' and `--with-' options that the 204 | package recognizes. 205 | 206 | For packages that use the X Window System, `configure' can usually 207 | find the X include and library files automatically, but if it doesn't, 208 | you can use the `configure' options `--x-includes=DIR' and 209 | `--x-libraries=DIR' to specify their locations. 210 | 211 | Some packages offer the ability to configure how verbose the 212 | execution of `make' will be. For these packages, running `./configure 213 | --enable-silent-rules' sets the default to minimal output, which can be 214 | overridden with `make V=1'; while running `./configure 215 | --disable-silent-rules' sets the default to verbose, which can be 216 | overridden with `make V=0'. 217 | 218 | Particular systems 219 | ================== 220 | 221 | On HP-UX, the default C compiler is not ANSI C compatible. If GNU 222 | CC is not installed, it is recommended to use the following options in 223 | order to use an ANSI C compiler: 224 | 225 | ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" 226 | 227 | and if that doesn't work, install pre-built binaries of GCC for HP-UX. 228 | 229 | On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot 230 | parse its `' header file. The option `-nodtk' can be used as 231 | a workaround. If GNU CC is not installed, it is therefore recommended 232 | to try 233 | 234 | ./configure CC="cc" 235 | 236 | and if that doesn't work, try 237 | 238 | ./configure CC="cc -nodtk" 239 | 240 | On Solaris, don't put `/usr/ucb' early in your `PATH'. This 241 | directory contains several dysfunctional programs; working variants of 242 | these programs are available in `/usr/bin'. So, if you need `/usr/ucb' 243 | in your `PATH', put it _after_ `/usr/bin'. 244 | 245 | On Haiku, software installed for all users goes in `/boot/common', 246 | not `/usr/local'. It is recommended to use the following options: 247 | 248 | ./configure --prefix=/boot/common 249 | 250 | Specifying the System Type 251 | ========================== 252 | 253 | There may be some features `configure' cannot figure out 254 | automatically, but needs to determine by the type of machine the package 255 | will run on. Usually, assuming the package is built to be run on the 256 | _same_ architectures, `configure' can figure that out, but if it prints 257 | a message saying it cannot guess the machine type, give it the 258 | `--build=TYPE' option. TYPE can either be a short name for the system 259 | type, such as `sun4', or a canonical name which has the form: 260 | 261 | CPU-COMPANY-SYSTEM 262 | 263 | where SYSTEM can have one of these forms: 264 | 265 | OS 266 | KERNEL-OS 267 | 268 | See the file `config.sub' for the possible values of each field. If 269 | `config.sub' isn't included in this package, then this package doesn't 270 | need to know the machine type. 271 | 272 | If you are _building_ compiler tools for cross-compiling, you should 273 | use the option `--target=TYPE' to select the type of system they will 274 | produce code for. 275 | 276 | If you want to _use_ a cross compiler, that generates code for a 277 | platform different from the build platform, you should specify the 278 | "host" platform (i.e., that on which the generated programs will 279 | eventually be run) with `--host=TYPE'. 280 | 281 | Sharing Defaults 282 | ================ 283 | 284 | If you want to set default values for `configure' scripts to share, 285 | you can create a site shell script called `config.site' that gives 286 | default values for variables like `CC', `cache_file', and `prefix'. 287 | `configure' looks for `PREFIX/share/config.site' if it exists, then 288 | `PREFIX/etc/config.site' if it exists. Or, you can set the 289 | `CONFIG_SITE' environment variable to the location of the site script. 290 | A warning: not all `configure' scripts look for a site script. 291 | 292 | Defining Variables 293 | ================== 294 | 295 | Variables not defined in a site shell script can be set in the 296 | environment passed to `configure'. However, some packages may run 297 | configure again during the build, and the customized values of these 298 | variables may be lost. In order to avoid this problem, you should set 299 | them in the `configure' command line, using `VAR=value'. For example: 300 | 301 | ./configure CC=/usr/local2/bin/gcc 302 | 303 | causes the specified `gcc' to be used as the C compiler (unless it is 304 | overridden in the site shell script). 305 | 306 | Unfortunately, this technique does not work for `CONFIG_SHELL' due to 307 | an Autoconf bug. Until the bug is fixed you can use this workaround: 308 | 309 | CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash 310 | 311 | `configure' Invocation 312 | ====================== 313 | 314 | `configure' recognizes the following options to control how it 315 | operates. 316 | 317 | `--help' 318 | `-h' 319 | Print a summary of all of the options to `configure', and exit. 320 | 321 | `--help=short' 322 | `--help=recursive' 323 | Print a summary of the options unique to this package's 324 | `configure', and exit. The `short' variant lists options used 325 | only in the top level, while the `recursive' variant lists options 326 | also present in any nested packages. 327 | 328 | `--version' 329 | `-V' 330 | Print the version of Autoconf used to generate the `configure' 331 | script, and exit. 332 | 333 | `--cache-file=FILE' 334 | Enable the cache: use and save the results of the tests in FILE, 335 | traditionally `config.cache'. FILE defaults to `/dev/null' to 336 | disable caching. 337 | 338 | `--config-cache' 339 | `-C' 340 | Alias for `--cache-file=config.cache'. 341 | 342 | `--quiet' 343 | `--silent' 344 | `-q' 345 | Do not print messages saying which checks are being made. To 346 | suppress all normal output, redirect it to `/dev/null' (any error 347 | messages will still be shown). 348 | 349 | `--srcdir=DIR' 350 | Look for the package's source code in directory DIR. Usually 351 | `configure' can determine that directory automatically. 352 | 353 | `--prefix=DIR' 354 | Use DIR as the installation prefix. *note Installation Names:: 355 | for more details, including other options available for fine-tuning 356 | the installation locations. 357 | 358 | `--no-create' 359 | `-n' 360 | Run the configure checks, but stop before creating any output 361 | files. 362 | 363 | `configure' also accepts some other, not widely useful, options. Run 364 | `configure --help' for more details. 365 | 366 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = mtpfs 2 | mtpfs_SOURCES = mtpfs.c mtpfs.h 3 | mtpfs_CPPFLAGS = -DFUSE_USE_VERSION=22 $(FUSE_CFLAGS) $(GLIB_CFLAGS) $(MTP_CFLAGS) 4 | mtpfs_LDADD = $(FUSE_LIBS) $(GLIB_LIBS) $(MTP_LIBS) 5 | 6 | if USEMAD 7 | mtpfs_SOURCES += id3read.c id3read.h 8 | mtpfs_CPPFLAGS += $(MAD_CFLAGS) -DUSEMAD 9 | mtpfs_LDADD += $(MAD_LIBS) 10 | endif 11 | -------------------------------------------------------------------------------- /Makefile.in: -------------------------------------------------------------------------------- 1 | # Makefile.in generated by automake 1.15 from Makefile.am. 2 | # @configure_input@ 3 | 4 | # Copyright (C) 1994-2014 Free Software Foundation, Inc. 5 | 6 | # This Makefile.in is free software; the Free Software Foundation 7 | # gives unlimited permission to copy and/or distribute it, 8 | # with or without modifications, as long as this notice is preserved. 9 | 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without 12 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | # PARTICULAR PURPOSE. 14 | 15 | @SET_MAKE@ 16 | 17 | VPATH = @srcdir@ 18 | am__is_gnu_make = { \ 19 | if test -z '$(MAKELEVEL)'; then \ 20 | false; \ 21 | elif test -n '$(MAKE_HOST)'; then \ 22 | true; \ 23 | elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ 24 | true; \ 25 | else \ 26 | false; \ 27 | fi; \ 28 | } 29 | am__make_running_with_option = \ 30 | case $${target_option-} in \ 31 | ?) ;; \ 32 | *) echo "am__make_running_with_option: internal error: invalid" \ 33 | "target option '$${target_option-}' specified" >&2; \ 34 | exit 1;; \ 35 | esac; \ 36 | has_opt=no; \ 37 | sane_makeflags=$$MAKEFLAGS; \ 38 | if $(am__is_gnu_make); then \ 39 | sane_makeflags=$$MFLAGS; \ 40 | else \ 41 | case $$MAKEFLAGS in \ 42 | *\\[\ \ ]*) \ 43 | bs=\\; \ 44 | sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ 45 | | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ 46 | esac; \ 47 | fi; \ 48 | skip_next=no; \ 49 | strip_trailopt () \ 50 | { \ 51 | flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ 52 | }; \ 53 | for flg in $$sane_makeflags; do \ 54 | test $$skip_next = yes && { skip_next=no; continue; }; \ 55 | case $$flg in \ 56 | *=*|--*) continue;; \ 57 | -*I) strip_trailopt 'I'; skip_next=yes;; \ 58 | -*I?*) strip_trailopt 'I';; \ 59 | -*O) strip_trailopt 'O'; skip_next=yes;; \ 60 | -*O?*) strip_trailopt 'O';; \ 61 | -*l) strip_trailopt 'l'; skip_next=yes;; \ 62 | -*l?*) strip_trailopt 'l';; \ 63 | -[dEDm]) skip_next=yes;; \ 64 | -[JT]) skip_next=yes;; \ 65 | esac; \ 66 | case $$flg in \ 67 | *$$target_option*) has_opt=yes; break;; \ 68 | esac; \ 69 | done; \ 70 | test $$has_opt = yes 71 | am__make_dryrun = (target_option=n; $(am__make_running_with_option)) 72 | am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 73 | pkgdatadir = $(datadir)/@PACKAGE@ 74 | pkgincludedir = $(includedir)/@PACKAGE@ 75 | pkglibdir = $(libdir)/@PACKAGE@ 76 | pkglibexecdir = $(libexecdir)/@PACKAGE@ 77 | am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd 78 | install_sh_DATA = $(install_sh) -c -m 644 79 | install_sh_PROGRAM = $(install_sh) -c 80 | install_sh_SCRIPT = $(install_sh) -c 81 | INSTALL_HEADER = $(INSTALL_DATA) 82 | transform = $(program_transform_name) 83 | NORMAL_INSTALL = : 84 | PRE_INSTALL = : 85 | POST_INSTALL = : 86 | NORMAL_UNINSTALL = : 87 | PRE_UNINSTALL = : 88 | POST_UNINSTALL = : 89 | bin_PROGRAMS = mtpfs$(EXEEXT) 90 | @USEMAD_TRUE@am__append_1 = id3read.c id3read.h 91 | @USEMAD_TRUE@am__append_2 = $(MAD_CFLAGS) -DUSEMAD 92 | @USEMAD_TRUE@am__append_3 = $(MAD_LIBS) 93 | subdir = . 94 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 95 | am__aclocal_m4_deps = $(top_srcdir)/configure.ac 96 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ 97 | $(ACLOCAL_M4) 98 | DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \ 99 | $(am__configure_deps) $(am__DIST_COMMON) 100 | am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ 101 | configure.lineno config.status.lineno 102 | mkinstalldirs = $(install_sh) -d 103 | CONFIG_CLEAN_FILES = 104 | CONFIG_CLEAN_VPATH_FILES = 105 | am__installdirs = "$(DESTDIR)$(bindir)" 106 | PROGRAMS = $(bin_PROGRAMS) 107 | am__mtpfs_SOURCES_DIST = mtpfs.c mtpfs.h id3read.c id3read.h 108 | @USEMAD_TRUE@am__objects_1 = mtpfs-id3read.$(OBJEXT) 109 | am_mtpfs_OBJECTS = mtpfs-mtpfs.$(OBJEXT) $(am__objects_1) 110 | mtpfs_OBJECTS = $(am_mtpfs_OBJECTS) 111 | am__DEPENDENCIES_1 = 112 | @USEMAD_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) 113 | mtpfs_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ 114 | $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) 115 | AM_V_P = $(am__v_P_@AM_V@) 116 | am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) 117 | am__v_P_0 = false 118 | am__v_P_1 = : 119 | AM_V_GEN = $(am__v_GEN_@AM_V@) 120 | am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) 121 | am__v_GEN_0 = @echo " GEN " $@; 122 | am__v_GEN_1 = 123 | AM_V_at = $(am__v_at_@AM_V@) 124 | am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) 125 | am__v_at_0 = @ 126 | am__v_at_1 = 127 | DEFAULT_INCLUDES = -I.@am__isrc@ 128 | depcomp = $(SHELL) $(top_srcdir)/depcomp 129 | am__depfiles_maybe = depfiles 130 | am__mv = mv -f 131 | AM_V_lt = $(am__v_lt_@AM_V@) 132 | am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) 133 | am__v_lt_0 = --silent 134 | am__v_lt_1 = 135 | COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ 136 | $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) 137 | AM_V_CC = $(am__v_CC_@AM_V@) 138 | am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) 139 | am__v_CC_0 = @echo " CC " $@; 140 | am__v_CC_1 = 141 | CCLD = $(CC) 142 | LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ 143 | AM_V_CCLD = $(am__v_CCLD_@AM_V@) 144 | am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) 145 | am__v_CCLD_0 = @echo " CCLD " $@; 146 | am__v_CCLD_1 = 147 | SOURCES = $(mtpfs_SOURCES) 148 | DIST_SOURCES = $(am__mtpfs_SOURCES_DIST) 149 | am__can_run_installinfo = \ 150 | case $$AM_UPDATE_INFO_DIR in \ 151 | n|no|NO) false;; \ 152 | *) (install-info --version) >/dev/null 2>&1;; \ 153 | esac 154 | am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) 155 | # Read a list of newline-separated strings from the standard input, 156 | # and print each of them once, without duplicates. Input order is 157 | # *not* preserved. 158 | am__uniquify_input = $(AWK) '\ 159 | BEGIN { nonempty = 0; } \ 160 | { items[$$0] = 1; nonempty = 1; } \ 161 | END { if (nonempty) { for (i in items) print i; }; } \ 162 | ' 163 | # Make sure the list of sources is unique. This is necessary because, 164 | # e.g., the same source file might be shared among _SOURCES variables 165 | # for different programs/libraries. 166 | am__define_uniq_tagged_files = \ 167 | list='$(am__tagged_files)'; \ 168 | unique=`for i in $$list; do \ 169 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 170 | done | $(am__uniquify_input)` 171 | ETAGS = etags 172 | CTAGS = ctags 173 | CSCOPE = cscope 174 | AM_RECURSIVE_TARGETS = cscope 175 | am__DIST_COMMON = $(srcdir)/Makefile.in AUTHORS COPYING ChangeLog \ 176 | INSTALL NEWS README compile depcomp install-sh missing 177 | DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 178 | distdir = $(PACKAGE)-$(VERSION) 179 | top_distdir = $(distdir) 180 | am__remove_distdir = \ 181 | if test -d "$(distdir)"; then \ 182 | find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ 183 | && rm -rf "$(distdir)" \ 184 | || { sleep 5 && rm -rf "$(distdir)"; }; \ 185 | else :; fi 186 | am__post_remove_distdir = $(am__remove_distdir) 187 | DIST_ARCHIVES = $(distdir).tar.gz 188 | GZIP_ENV = --best 189 | DIST_TARGETS = dist-gzip 190 | distuninstallcheck_listfiles = find . -type f -print 191 | am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ 192 | | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' 193 | distcleancheck_listfiles = find . -type f -print 194 | ACLOCAL = @ACLOCAL@ 195 | AMTAR = @AMTAR@ 196 | AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ 197 | AUTOCONF = @AUTOCONF@ 198 | AUTOHEADER = @AUTOHEADER@ 199 | AUTOMAKE = @AUTOMAKE@ 200 | AWK = @AWK@ 201 | CC = @CC@ 202 | CCDEPMODE = @CCDEPMODE@ 203 | CFLAGS = @CFLAGS@ 204 | CPPFLAGS = @CPPFLAGS@ 205 | CYGPATH_W = @CYGPATH_W@ 206 | DEFS = @DEFS@ 207 | DEPDIR = @DEPDIR@ 208 | ECHO_C = @ECHO_C@ 209 | ECHO_N = @ECHO_N@ 210 | ECHO_T = @ECHO_T@ 211 | EXEEXT = @EXEEXT@ 212 | FUSE_CFLAGS = @FUSE_CFLAGS@ 213 | FUSE_LIBS = @FUSE_LIBS@ 214 | GLIB_CFLAGS = @GLIB_CFLAGS@ 215 | GLIB_LIBS = @GLIB_LIBS@ 216 | INSTALL = @INSTALL@ 217 | INSTALL_DATA = @INSTALL_DATA@ 218 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 219 | INSTALL_SCRIPT = @INSTALL_SCRIPT@ 220 | INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ 221 | LDFLAGS = @LDFLAGS@ 222 | LIBOBJS = @LIBOBJS@ 223 | LIBS = @LIBS@ 224 | LTLIBOBJS = @LTLIBOBJS@ 225 | MAD_CFLAGS = @MAD_CFLAGS@ 226 | MAD_LIBS = @MAD_LIBS@ 227 | MAKEINFO = @MAKEINFO@ 228 | MKDIR_P = @MKDIR_P@ 229 | MTP_CFLAGS = @MTP_CFLAGS@ 230 | MTP_LIBS = @MTP_LIBS@ 231 | OBJEXT = @OBJEXT@ 232 | PACKAGE = @PACKAGE@ 233 | PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ 234 | PACKAGE_NAME = @PACKAGE_NAME@ 235 | PACKAGE_STRING = @PACKAGE_STRING@ 236 | PACKAGE_TARNAME = @PACKAGE_TARNAME@ 237 | PACKAGE_URL = @PACKAGE_URL@ 238 | PACKAGE_VERSION = @PACKAGE_VERSION@ 239 | PATH_SEPARATOR = @PATH_SEPARATOR@ 240 | PKG_CONFIG = @PKG_CONFIG@ 241 | PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ 242 | PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ 243 | SET_MAKE = @SET_MAKE@ 244 | SHELL = @SHELL@ 245 | STRIP = @STRIP@ 246 | VERSION = @VERSION@ 247 | abs_builddir = @abs_builddir@ 248 | abs_srcdir = @abs_srcdir@ 249 | abs_top_builddir = @abs_top_builddir@ 250 | abs_top_srcdir = @abs_top_srcdir@ 251 | ac_ct_CC = @ac_ct_CC@ 252 | am__include = @am__include@ 253 | am__leading_dot = @am__leading_dot@ 254 | am__quote = @am__quote@ 255 | am__tar = @am__tar@ 256 | am__untar = @am__untar@ 257 | bindir = @bindir@ 258 | build_alias = @build_alias@ 259 | builddir = @builddir@ 260 | datadir = @datadir@ 261 | datarootdir = @datarootdir@ 262 | docdir = @docdir@ 263 | dvidir = @dvidir@ 264 | exec_prefix = @exec_prefix@ 265 | host_alias = @host_alias@ 266 | htmldir = @htmldir@ 267 | includedir = @includedir@ 268 | infodir = @infodir@ 269 | install_sh = @install_sh@ 270 | libdir = @libdir@ 271 | libexecdir = @libexecdir@ 272 | localedir = @localedir@ 273 | localstatedir = @localstatedir@ 274 | mandir = @mandir@ 275 | mkdir_p = @mkdir_p@ 276 | oldincludedir = @oldincludedir@ 277 | pdfdir = @pdfdir@ 278 | prefix = @prefix@ 279 | program_transform_name = @program_transform_name@ 280 | psdir = @psdir@ 281 | sbindir = @sbindir@ 282 | sharedstatedir = @sharedstatedir@ 283 | srcdir = @srcdir@ 284 | sysconfdir = @sysconfdir@ 285 | target_alias = @target_alias@ 286 | top_build_prefix = @top_build_prefix@ 287 | top_builddir = @top_builddir@ 288 | top_srcdir = @top_srcdir@ 289 | mtpfs_SOURCES = mtpfs.c mtpfs.h $(am__append_1) 290 | mtpfs_CPPFLAGS = -DFUSE_USE_VERSION=22 $(FUSE_CFLAGS) $(GLIB_CFLAGS) \ 291 | $(MTP_CFLAGS) $(am__append_2) 292 | mtpfs_LDADD = $(FUSE_LIBS) $(GLIB_LIBS) $(MTP_LIBS) $(am__append_3) 293 | all: all-am 294 | 295 | .SUFFIXES: 296 | .SUFFIXES: .c .o .obj 297 | am--refresh: Makefile 298 | @: 299 | $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) 300 | @for dep in $?; do \ 301 | case '$(am__configure_deps)' in \ 302 | *$$dep*) \ 303 | echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \ 304 | $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \ 305 | && exit 0; \ 306 | exit 1;; \ 307 | esac; \ 308 | done; \ 309 | echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ 310 | $(am__cd) $(top_srcdir) && \ 311 | $(AUTOMAKE) --gnu Makefile 312 | Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status 313 | @case '$?' in \ 314 | *config.status*) \ 315 | echo ' $(SHELL) ./config.status'; \ 316 | $(SHELL) ./config.status;; \ 317 | *) \ 318 | echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ 319 | cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ 320 | esac; 321 | 322 | $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) 323 | $(SHELL) ./config.status --recheck 324 | 325 | $(top_srcdir)/configure: $(am__configure_deps) 326 | $(am__cd) $(srcdir) && $(AUTOCONF) 327 | $(ACLOCAL_M4): $(am__aclocal_m4_deps) 328 | $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) 329 | $(am__aclocal_m4_deps): 330 | install-binPROGRAMS: $(bin_PROGRAMS) 331 | @$(NORMAL_INSTALL) 332 | @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ 333 | if test -n "$$list"; then \ 334 | echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ 335 | $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ 336 | fi; \ 337 | for p in $$list; do echo "$$p $$p"; done | \ 338 | sed 's/$(EXEEXT)$$//' | \ 339 | while read p p1; do if test -f $$p \ 340 | ; then echo "$$p"; echo "$$p"; else :; fi; \ 341 | done | \ 342 | sed -e 'p;s,.*/,,;n;h' \ 343 | -e 's|.*|.|' \ 344 | -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ 345 | sed 'N;N;N;s,\n, ,g' | \ 346 | $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ 347 | { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ 348 | if ($$2 == $$4) files[d] = files[d] " " $$1; \ 349 | else { print "f", $$3 "/" $$4, $$1; } } \ 350 | END { for (d in files) print "f", d, files[d] }' | \ 351 | while read type dir files; do \ 352 | if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ 353 | test -z "$$files" || { \ 354 | echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ 355 | $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ 356 | } \ 357 | ; done 358 | 359 | uninstall-binPROGRAMS: 360 | @$(NORMAL_UNINSTALL) 361 | @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ 362 | files=`for p in $$list; do echo "$$p"; done | \ 363 | sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ 364 | -e 's/$$/$(EXEEXT)/' \ 365 | `; \ 366 | test -n "$$list" || exit 0; \ 367 | echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ 368 | cd "$(DESTDIR)$(bindir)" && rm -f $$files 369 | 370 | clean-binPROGRAMS: 371 | -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) 372 | 373 | mtpfs$(EXEEXT): $(mtpfs_OBJECTS) $(mtpfs_DEPENDENCIES) $(EXTRA_mtpfs_DEPENDENCIES) 374 | @rm -f mtpfs$(EXEEXT) 375 | $(AM_V_CCLD)$(LINK) $(mtpfs_OBJECTS) $(mtpfs_LDADD) $(LIBS) 376 | 377 | mostlyclean-compile: 378 | -rm -f *.$(OBJEXT) 379 | 380 | distclean-compile: 381 | -rm -f *.tab.c 382 | 383 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mtpfs-id3read.Po@am__quote@ 384 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mtpfs-mtpfs.Po@am__quote@ 385 | 386 | .c.o: 387 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< 388 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po 389 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ 390 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 391 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< 392 | 393 | .c.obj: 394 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` 395 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po 396 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ 397 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 398 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` 399 | 400 | mtpfs-mtpfs.o: mtpfs.c 401 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mtpfs_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mtpfs-mtpfs.o -MD -MP -MF $(DEPDIR)/mtpfs-mtpfs.Tpo -c -o mtpfs-mtpfs.o `test -f 'mtpfs.c' || echo '$(srcdir)/'`mtpfs.c 402 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/mtpfs-mtpfs.Tpo $(DEPDIR)/mtpfs-mtpfs.Po 403 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mtpfs.c' object='mtpfs-mtpfs.o' libtool=no @AMDEPBACKSLASH@ 404 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 405 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mtpfs_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mtpfs-mtpfs.o `test -f 'mtpfs.c' || echo '$(srcdir)/'`mtpfs.c 406 | 407 | mtpfs-mtpfs.obj: mtpfs.c 408 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mtpfs_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mtpfs-mtpfs.obj -MD -MP -MF $(DEPDIR)/mtpfs-mtpfs.Tpo -c -o mtpfs-mtpfs.obj `if test -f 'mtpfs.c'; then $(CYGPATH_W) 'mtpfs.c'; else $(CYGPATH_W) '$(srcdir)/mtpfs.c'; fi` 409 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/mtpfs-mtpfs.Tpo $(DEPDIR)/mtpfs-mtpfs.Po 410 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mtpfs.c' object='mtpfs-mtpfs.obj' libtool=no @AMDEPBACKSLASH@ 411 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 412 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mtpfs_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mtpfs-mtpfs.obj `if test -f 'mtpfs.c'; then $(CYGPATH_W) 'mtpfs.c'; else $(CYGPATH_W) '$(srcdir)/mtpfs.c'; fi` 413 | 414 | mtpfs-id3read.o: id3read.c 415 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mtpfs_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mtpfs-id3read.o -MD -MP -MF $(DEPDIR)/mtpfs-id3read.Tpo -c -o mtpfs-id3read.o `test -f 'id3read.c' || echo '$(srcdir)/'`id3read.c 416 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/mtpfs-id3read.Tpo $(DEPDIR)/mtpfs-id3read.Po 417 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='id3read.c' object='mtpfs-id3read.o' libtool=no @AMDEPBACKSLASH@ 418 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 419 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mtpfs_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mtpfs-id3read.o `test -f 'id3read.c' || echo '$(srcdir)/'`id3read.c 420 | 421 | mtpfs-id3read.obj: id3read.c 422 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mtpfs_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mtpfs-id3read.obj -MD -MP -MF $(DEPDIR)/mtpfs-id3read.Tpo -c -o mtpfs-id3read.obj `if test -f 'id3read.c'; then $(CYGPATH_W) 'id3read.c'; else $(CYGPATH_W) '$(srcdir)/id3read.c'; fi` 423 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/mtpfs-id3read.Tpo $(DEPDIR)/mtpfs-id3read.Po 424 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='id3read.c' object='mtpfs-id3read.obj' libtool=no @AMDEPBACKSLASH@ 425 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 426 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mtpfs_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mtpfs-id3read.obj `if test -f 'id3read.c'; then $(CYGPATH_W) 'id3read.c'; else $(CYGPATH_W) '$(srcdir)/id3read.c'; fi` 427 | 428 | ID: $(am__tagged_files) 429 | $(am__define_uniq_tagged_files); mkid -fID $$unique 430 | tags: tags-am 431 | TAGS: tags 432 | 433 | tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) 434 | set x; \ 435 | here=`pwd`; \ 436 | $(am__define_uniq_tagged_files); \ 437 | shift; \ 438 | if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ 439 | test -n "$$unique" || unique=$$empty_fix; \ 440 | if test $$# -gt 0; then \ 441 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 442 | "$$@" $$unique; \ 443 | else \ 444 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 445 | $$unique; \ 446 | fi; \ 447 | fi 448 | ctags: ctags-am 449 | 450 | CTAGS: ctags 451 | ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) 452 | $(am__define_uniq_tagged_files); \ 453 | test -z "$(CTAGS_ARGS)$$unique" \ 454 | || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ 455 | $$unique 456 | 457 | GTAGS: 458 | here=`$(am__cd) $(top_builddir) && pwd` \ 459 | && $(am__cd) $(top_srcdir) \ 460 | && gtags -i $(GTAGS_ARGS) "$$here" 461 | cscope: cscope.files 462 | test ! -s cscope.files \ 463 | || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) 464 | clean-cscope: 465 | -rm -f cscope.files 466 | cscope.files: clean-cscope cscopelist 467 | cscopelist: cscopelist-am 468 | 469 | cscopelist-am: $(am__tagged_files) 470 | list='$(am__tagged_files)'; \ 471 | case "$(srcdir)" in \ 472 | [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ 473 | *) sdir=$(subdir)/$(srcdir) ;; \ 474 | esac; \ 475 | for i in $$list; do \ 476 | if test -f "$$i"; then \ 477 | echo "$(subdir)/$$i"; \ 478 | else \ 479 | echo "$$sdir/$$i"; \ 480 | fi; \ 481 | done >> $(top_builddir)/cscope.files 482 | 483 | distclean-tags: 484 | -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags 485 | -rm -f cscope.out cscope.in.out cscope.po.out cscope.files 486 | 487 | distdir: $(DISTFILES) 488 | $(am__remove_distdir) 489 | test -d "$(distdir)" || mkdir "$(distdir)" 490 | @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 491 | topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 492 | list='$(DISTFILES)'; \ 493 | dist_files=`for file in $$list; do echo $$file; done | \ 494 | sed -e "s|^$$srcdirstrip/||;t" \ 495 | -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ 496 | case $$dist_files in \ 497 | */*) $(MKDIR_P) `echo "$$dist_files" | \ 498 | sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ 499 | sort -u` ;; \ 500 | esac; \ 501 | for file in $$dist_files; do \ 502 | if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ 503 | if test -d $$d/$$file; then \ 504 | dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ 505 | if test -d "$(distdir)/$$file"; then \ 506 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 507 | fi; \ 508 | if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ 509 | cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ 510 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 511 | fi; \ 512 | cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ 513 | else \ 514 | test -f "$(distdir)/$$file" \ 515 | || cp -p $$d/$$file "$(distdir)/$$file" \ 516 | || exit 1; \ 517 | fi; \ 518 | done 519 | -test -n "$(am__skip_mode_fix)" \ 520 | || find "$(distdir)" -type d ! -perm -755 \ 521 | -exec chmod u+rwx,go+rx {} \; -o \ 522 | ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ 523 | ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ 524 | ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ 525 | || chmod -R a+r "$(distdir)" 526 | dist-gzip: distdir 527 | tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz 528 | $(am__post_remove_distdir) 529 | 530 | dist-bzip2: distdir 531 | tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 532 | $(am__post_remove_distdir) 533 | 534 | dist-lzip: distdir 535 | tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz 536 | $(am__post_remove_distdir) 537 | 538 | dist-xz: distdir 539 | tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz 540 | $(am__post_remove_distdir) 541 | 542 | dist-tarZ: distdir 543 | @echo WARNING: "Support for distribution archives compressed with" \ 544 | "legacy program 'compress' is deprecated." >&2 545 | @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 546 | tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z 547 | $(am__post_remove_distdir) 548 | 549 | dist-shar: distdir 550 | @echo WARNING: "Support for shar distribution archives is" \ 551 | "deprecated." >&2 552 | @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 553 | shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz 554 | $(am__post_remove_distdir) 555 | 556 | dist-zip: distdir 557 | -rm -f $(distdir).zip 558 | zip -rq $(distdir).zip $(distdir) 559 | $(am__post_remove_distdir) 560 | 561 | dist dist-all: 562 | $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:' 563 | $(am__post_remove_distdir) 564 | 565 | # This target untars the dist file and tries a VPATH configuration. Then 566 | # it guarantees that the distribution is self-contained by making another 567 | # tarfile. 568 | distcheck: dist 569 | case '$(DIST_ARCHIVES)' in \ 570 | *.tar.gz*) \ 571 | GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ 572 | *.tar.bz2*) \ 573 | bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ 574 | *.tar.lz*) \ 575 | lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ 576 | *.tar.xz*) \ 577 | xz -dc $(distdir).tar.xz | $(am__untar) ;;\ 578 | *.tar.Z*) \ 579 | uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ 580 | *.shar.gz*) \ 581 | GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ 582 | *.zip*) \ 583 | unzip $(distdir).zip ;;\ 584 | esac 585 | chmod -R a-w $(distdir) 586 | chmod u+w $(distdir) 587 | mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst 588 | chmod a-w $(distdir) 589 | test -d $(distdir)/_build || exit 0; \ 590 | dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ 591 | && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ 592 | && am__cwd=`pwd` \ 593 | && $(am__cd) $(distdir)/_build/sub \ 594 | && ../../configure \ 595 | $(AM_DISTCHECK_CONFIGURE_FLAGS) \ 596 | $(DISTCHECK_CONFIGURE_FLAGS) \ 597 | --srcdir=../.. --prefix="$$dc_install_base" \ 598 | && $(MAKE) $(AM_MAKEFLAGS) \ 599 | && $(MAKE) $(AM_MAKEFLAGS) dvi \ 600 | && $(MAKE) $(AM_MAKEFLAGS) check \ 601 | && $(MAKE) $(AM_MAKEFLAGS) install \ 602 | && $(MAKE) $(AM_MAKEFLAGS) installcheck \ 603 | && $(MAKE) $(AM_MAKEFLAGS) uninstall \ 604 | && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ 605 | distuninstallcheck \ 606 | && chmod -R a-w "$$dc_install_base" \ 607 | && ({ \ 608 | (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ 609 | && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ 610 | && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ 611 | && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ 612 | distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ 613 | } || { rm -rf "$$dc_destdir"; exit 1; }) \ 614 | && rm -rf "$$dc_destdir" \ 615 | && $(MAKE) $(AM_MAKEFLAGS) dist \ 616 | && rm -rf $(DIST_ARCHIVES) \ 617 | && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ 618 | && cd "$$am__cwd" \ 619 | || exit 1 620 | $(am__post_remove_distdir) 621 | @(echo "$(distdir) archives ready for distribution: "; \ 622 | list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ 623 | sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' 624 | distuninstallcheck: 625 | @test -n '$(distuninstallcheck_dir)' || { \ 626 | echo 'ERROR: trying to run $@ with an empty' \ 627 | '$$(distuninstallcheck_dir)' >&2; \ 628 | exit 1; \ 629 | }; \ 630 | $(am__cd) '$(distuninstallcheck_dir)' || { \ 631 | echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ 632 | exit 1; \ 633 | }; \ 634 | test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ 635 | || { echo "ERROR: files left after uninstall:" ; \ 636 | if test -n "$(DESTDIR)"; then \ 637 | echo " (check DESTDIR support)"; \ 638 | fi ; \ 639 | $(distuninstallcheck_listfiles) ; \ 640 | exit 1; } >&2 641 | distcleancheck: distclean 642 | @if test '$(srcdir)' = . ; then \ 643 | echo "ERROR: distcleancheck can only run from a VPATH build" ; \ 644 | exit 1 ; \ 645 | fi 646 | @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ 647 | || { echo "ERROR: files left in build directory after distclean:" ; \ 648 | $(distcleancheck_listfiles) ; \ 649 | exit 1; } >&2 650 | check-am: all-am 651 | check: check-am 652 | all-am: Makefile $(PROGRAMS) 653 | installdirs: 654 | for dir in "$(DESTDIR)$(bindir)"; do \ 655 | test -z "$$dir" || $(MKDIR_P) "$$dir"; \ 656 | done 657 | install: install-am 658 | install-exec: install-exec-am 659 | install-data: install-data-am 660 | uninstall: uninstall-am 661 | 662 | install-am: all-am 663 | @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am 664 | 665 | installcheck: installcheck-am 666 | install-strip: 667 | if test -z '$(STRIP)'; then \ 668 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 669 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 670 | install; \ 671 | else \ 672 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 673 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 674 | "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ 675 | fi 676 | mostlyclean-generic: 677 | 678 | clean-generic: 679 | 680 | distclean-generic: 681 | -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) 682 | -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) 683 | 684 | maintainer-clean-generic: 685 | @echo "This command is intended for maintainers to use" 686 | @echo "it deletes files that may require special tools to rebuild." 687 | clean: clean-am 688 | 689 | clean-am: clean-binPROGRAMS clean-generic mostlyclean-am 690 | 691 | distclean: distclean-am 692 | -rm -f $(am__CONFIG_DISTCLEAN_FILES) 693 | -rm -rf ./$(DEPDIR) 694 | -rm -f Makefile 695 | distclean-am: clean-am distclean-compile distclean-generic \ 696 | distclean-tags 697 | 698 | dvi: dvi-am 699 | 700 | dvi-am: 701 | 702 | html: html-am 703 | 704 | html-am: 705 | 706 | info: info-am 707 | 708 | info-am: 709 | 710 | install-data-am: 711 | 712 | install-dvi: install-dvi-am 713 | 714 | install-dvi-am: 715 | 716 | install-exec-am: install-binPROGRAMS 717 | 718 | install-html: install-html-am 719 | 720 | install-html-am: 721 | 722 | install-info: install-info-am 723 | 724 | install-info-am: 725 | 726 | install-man: 727 | 728 | install-pdf: install-pdf-am 729 | 730 | install-pdf-am: 731 | 732 | install-ps: install-ps-am 733 | 734 | install-ps-am: 735 | 736 | installcheck-am: 737 | 738 | maintainer-clean: maintainer-clean-am 739 | -rm -f $(am__CONFIG_DISTCLEAN_FILES) 740 | -rm -rf $(top_srcdir)/autom4te.cache 741 | -rm -rf ./$(DEPDIR) 742 | -rm -f Makefile 743 | maintainer-clean-am: distclean-am maintainer-clean-generic 744 | 745 | mostlyclean: mostlyclean-am 746 | 747 | mostlyclean-am: mostlyclean-compile mostlyclean-generic 748 | 749 | pdf: pdf-am 750 | 751 | pdf-am: 752 | 753 | ps: ps-am 754 | 755 | ps-am: 756 | 757 | uninstall-am: uninstall-binPROGRAMS 758 | 759 | .MAKE: install-am install-strip 760 | 761 | .PHONY: CTAGS GTAGS TAGS all all-am am--refresh check check-am clean \ 762 | clean-binPROGRAMS clean-cscope clean-generic cscope \ 763 | cscopelist-am ctags ctags-am dist dist-all dist-bzip2 \ 764 | dist-gzip dist-lzip dist-shar dist-tarZ dist-xz dist-zip \ 765 | distcheck distclean distclean-compile distclean-generic \ 766 | distclean-tags distcleancheck distdir distuninstallcheck dvi \ 767 | dvi-am html html-am info info-am install install-am \ 768 | install-binPROGRAMS install-data install-data-am install-dvi \ 769 | install-dvi-am install-exec install-exec-am install-html \ 770 | install-html-am install-info install-info-am install-man \ 771 | install-pdf install-pdf-am install-ps install-ps-am \ 772 | install-strip installcheck installcheck-am installdirs \ 773 | maintainer-clean maintainer-clean-generic mostlyclean \ 774 | mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ 775 | tags tags-am uninstall uninstall-am uninstall-binPROGRAMS 776 | 777 | .PRECIOUS: Makefile 778 | 779 | 780 | # Tell versions [3.59,3.63) of GNU make to not export all variables. 781 | # Otherwise a system limit (for SysV at least) may be exceeded. 782 | .NOEXPORT: 783 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | What's new in 1.1 2 | ----------------- 3 | * Support Multiple storage aread 4 | * Many, many bugfixes 5 | 6 | What's new in 0.9 7 | ----------------- 8 | * Support libmtp 0.3.0 9 | 10 | What's new in 0.8 11 | ----------------- 12 | * Many memory leaks fixed 13 | 14 | What's new in 0.7 15 | ----------------- 16 | * Minor bugfixes 17 | 18 | What's new in 0.6 19 | ----------------- 20 | * Return device size/free 21 | 22 | What's new in 0.5 23 | ----------------- 24 | * Fix configure scripts 25 | 26 | What's new in 0.4 27 | ----------------- 28 | * Fix file permissions so they show uid/gid correctly 29 | * Update for newer versions of libmtp 30 | 31 | What's new in 0.3 32 | ----------------- 33 | * Mp3 song lengths set correctly when uploading 34 | * Locking on device access so copying multiple files work 35 | * Playlist reading and writing 36 | 37 | 38 | What's new in 0.2 39 | ----------------- 40 | 41 | * Working configure 42 | * Writing mp3 files to device 43 | 44 | What's new in 0.1 45 | ----------------- 46 | 47 | * Initial release 48 | * Can browse the MTP device and read files from it 49 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | MTPFS 2 | -------- 3 | 4 | MTPFS is a FUSE filesystem based on libmtp that allows a mtp device 5 | to be browsed as if it were a normal external harddisk 6 | 7 | Requirements 8 | ------------ 9 | 10 | FUSE >= 2.2 11 | GLib >= 2.30 12 | libmtp >= 1.1.2 13 | 14 | How to mount a filesystem 15 | ------------------------- 16 | 17 | To mount a device run: 18 | 19 | mtpfs 20 | 21 | To unmount do: 22 | 23 | fusermount -u 24 | 25 | Note that you may need to be root to do all this if permissions on the 26 | MTP device are not correct 27 | 28 | Debugging 29 | --------- 30 | To enable debugging info use the --enable-debug option when running ./configure 31 | 32 | Acknowledgements 33 | ---------------- 34 | This wouldn't be possible without libmtp, libusb and fuse. 35 | Sections of code (in id3read.c and mp3file.c) blatently ripped from gnomad 36 | 37 | Contact info 38 | ------------ 39 | Chris Debenham 40 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-architect -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | aclocal 2 | autoconf 3 | automake -a 4 | #./configure --enable-debug 5 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | AC_INIT([MTPfs], [1.1], [Chris Debenham ],[mtpfs]) 2 | AM_INIT_AUTOMAKE 3 | AC_PROG_CC 4 | AM_PROG_CC_C_O 5 | AC_PROG_INSTALL 6 | 7 | PKG_CHECK_MODULES(FUSE, fuse >= 2.2) 8 | AC_SUBST(FUSE_CFLAGS) 9 | AC_SUBST(FUSE_LIBS) 10 | 11 | PKG_CHECK_MODULES(MTP, libmtp >= 1.1.0) 12 | AC_SUBST(MTP_CFLAGS) 13 | AC_SUBST(MTP_LIBS) 14 | 15 | PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.6 \ 16 | gthread-2.0 >= 1.2 \ 17 | gio-2.0 >= 2.6) 18 | AC_SUBST(GLIB_CFLAGS) 19 | AC_SUBST(GLIB_LIBS) 20 | 21 | AC_ARG_ENABLE([mad], 22 | [AS_HELP_STRING([--disable-mad], [disable libmad handling of mp3 files])]) 23 | 24 | AS_IF([test "x$enable_mad" != "xno"] , [ 25 | PKG_CHECK_MODULES(MAD, mad >= 0.15 \ 26 | id3tag >= 0.15) 27 | AC_SUBST(MAD_CFLAGS) 28 | AC_SUBST(MAD_LIBS) 29 | ]) 30 | AM_CONDITIONAL([USEMAD], [test "x$enable_mad" != "xno"]) 31 | 32 | AC_ARG_ENABLE(debug, 33 | AC_HELP_STRING([--enable-debug], 34 | [enable debugging features]), 35 | , enable_debug=no) 36 | if test "x$enable_debug" != xyes -a "x$enable_debug" != xno; then 37 | AC_MSG_ERROR(You may not pass an argument to --enable-debug) 38 | fi 39 | 40 | if test "x$enable_debug" = xyes; then 41 | AC_DEFINE(DEBUG,1,[Define if debug logging is enabled]) 42 | else 43 | AC_DEFINE(DEBUG,0,[Define if debug logging is enabled]) 44 | fi 45 | 46 | 47 | AC_CONFIG_FILES([Makefile]) 48 | AC_OUTPUT 49 | -------------------------------------------------------------------------------- /id3read.c: -------------------------------------------------------------------------------- 1 | /* id3read.c 2 | interface for the id3tag library 3 | Copyright (C) 2001 Linus Walleij 4 | 5 | This file is part of the GNOMAD package. 6 | 7 | GNOMAD is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2, or (at your option) 10 | any later version. 11 | 12 | You should have received a copy of the GNU General Public License 13 | along with GNOMAD; see the file COPYING. If not, write to 14 | the Free Software Foundation, 59 Temple Place - Suite 330, 15 | Boston, MA 02111-1307, USA. 16 | 17 | */ 18 | 19 | #define ID3V2_MAX_STRING_LEN 4096 20 | #include 21 | #include 22 | #include /* atol() */ 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | /* Converts a figure representing a number of seconds to 32 | * * a string in mm:ss notation */ 33 | gchar * 34 | seconds_to_mmss (uint32_t seconds) 35 | { 36 | gchar tmp2[10]; 37 | gchar tmp[10]; 38 | uint32_t secfrac = seconds % 60; 39 | uint32_t minfrac = seconds / 60; 40 | 41 | if (seconds == 0) 42 | return g_strdup ("0:00"); 43 | 44 | snprintf (tmp2, 10, "0%u", secfrac); 45 | while (strlen (tmp2) > 2) 46 | { 47 | tmp2[0] = tmp2[1]; 48 | tmp2[1] = tmp2[2]; 49 | tmp2[2] = '\0'; 50 | } 51 | snprintf (tmp, 10, "%u:%s", minfrac, tmp2); 52 | return g_strdup (tmp); 53 | } 54 | 55 | /* Converts a string in mm:ss notation to a figure 56 | * * representing seconds */ 57 | guint 58 | mmss_to_seconds (gchar * mmss) 59 | { 60 | gchar **tmp; 61 | guint seconds = 0; 62 | 63 | if (!mmss) 64 | return seconds; 65 | 66 | tmp = g_strsplit (mmss, ":", 0); 67 | if (tmp[1] != NULL) 68 | { 69 | seconds = 60 * strtoul (tmp[0], NULL, 10); 70 | seconds += strtoul (tmp[1], NULL, 10); 71 | } 72 | if (tmp != NULL) 73 | g_strfreev (tmp); 74 | return seconds; 75 | } 76 | 77 | /* Eventually make charset selectable */ 78 | 79 | static id3_utf8_t * 80 | charset_to_utf8 (const id3_latin1_t * str) 81 | { 82 | id3_utf8_t *tmp; 83 | 84 | tmp = 85 | (id3_utf8_t *) g_convert ((gchar *) str, -1, "UTF-8", "ISO-8859-1", 86 | NULL, NULL, NULL); 87 | return (id3_utf8_t *) tmp; 88 | } 89 | 90 | /***************************************************************************** 91 | * ID3TAG interface 92 | * Many parts of this code copied in from gtkpod or plagiated, I confess. 93 | * Acknowledgements to Jorg Schuler for that... 94 | *****************************************************************************/ 95 | 96 | /* 97 | * Returns a text frame, or NULL 98 | */ 99 | 100 | static gchar * 101 | getFrameText (struct id3_tag *tag, char *frame_name) 102 | { 103 | const id3_ucs4_t *string; 104 | struct id3_frame *frame; 105 | union id3_field *field; 106 | gchar *utf8 = NULL; 107 | enum id3_field_textencoding encoding = ID3_FIELD_TEXTENCODING_ISO_8859_1; 108 | 109 | frame = id3_tag_findframe (tag, frame_name, 0); 110 | if (!frame) 111 | return NULL; 112 | 113 | /* Find the encoding used for the field */ 114 | field = id3_frame_field (frame, 0); 115 | //printf ("field: %p\n", field); 116 | if (field && (id3_field_type (field) == ID3_FIELD_TYPE_TEXTENCODING)) 117 | { 118 | encoding = field->number.value; 119 | //printf ("encoding: %d\n", encoding); 120 | } 121 | 122 | if (strcmp (frame_name, ID3_FRAME_COMMENT) == 0) 123 | field = id3_frame_field (frame, 3); 124 | else 125 | field = id3_frame_field (frame, 1); 126 | 127 | //printf ("field: %p\n", field); 128 | 129 | if (!field) 130 | return NULL; 131 | 132 | if (strcmp (frame_name, ID3_FRAME_COMMENT) == 0) 133 | string = id3_field_getfullstring (field); 134 | else 135 | string = id3_field_getstrings (field, 0); 136 | 137 | // g_debug("string: %s\n", string); 138 | 139 | if (!string) 140 | return NULL; 141 | 142 | if (strcmp (frame_name, ID3_FRAME_GENRE) == 0) 143 | string = id3_genre_name (string); 144 | 145 | if (encoding == ID3_FIELD_TEXTENCODING_ISO_8859_1) 146 | { 147 | /* ISO_8859_1 is just a "marker" -- most people just drop 148 | whatever coding system they are using into it, so we use 149 | charset_to_utf8() to convert to utf8 */ 150 | id3_latin1_t *raw = id3_ucs4_latin1duplicate (string); 151 | utf8 = (gchar *) charset_to_utf8 (raw); 152 | g_free (raw); 153 | } 154 | else 155 | { 156 | /* Standard unicode is being used -- we won't have to worry 157 | about charsets then. */ 158 | // g_debug("This frame is a Unicode frame!\n"); 159 | utf8 = (gchar *) id3_ucs4_utf8duplicate (string); 160 | } 161 | // g_debug("Found tag: %s, value: %s\n", frame_name, utf8); 162 | return utf8; 163 | } 164 | 165 | /***************************************************************************** 166 | * FUNCTIONS FOR GETTING ID3v2 FIELDS 167 | *****************************************************************************/ 168 | 169 | gchar * 170 | getArtist (struct id3_tag * tag) 171 | { 172 | gchar *artname = NULL; 173 | 174 | artname = getFrameText (tag, "TPE1"); 175 | if (artname == NULL) 176 | artname = getFrameText (tag, "TPE2"); 177 | if (artname == NULL) 178 | artname = getFrameText (tag, "TPE3"); 179 | if (artname == NULL) 180 | artname = getFrameText (tag, "TPE4"); 181 | if (artname == NULL) 182 | artname = getFrameText (tag, "TCOM"); 183 | return artname; 184 | } 185 | 186 | gchar * 187 | getTitle (struct id3_tag * tag) 188 | { 189 | return getFrameText (tag, "TIT2"); 190 | } 191 | 192 | gchar * 193 | getAlbum (struct id3_tag * tag) 194 | { 195 | return getFrameText (tag, "TALB"); 196 | } 197 | 198 | gchar * 199 | getYear (struct id3_tag * tag) 200 | { 201 | gchar *year = NULL; 202 | 203 | year = getFrameText (tag, "TYER"); 204 | if (year == NULL) 205 | { 206 | year = getFrameText (tag, "TDRC"); 207 | } 208 | if (year == NULL) 209 | { 210 | year = g_strdup ("None"); 211 | } 212 | return year; 213 | } 214 | 215 | gchar * 216 | getGenre (struct id3_tag * tag) 217 | { 218 | return getFrameText (tag, "TCON"); 219 | } 220 | 221 | int 222 | getSonglen (struct id3_tag *tag) 223 | { 224 | gchar *timetext; 225 | long milliseconds; 226 | int seconds; 227 | 228 | timetext = getFrameText (tag, "TLEN"); 229 | if (timetext == NULL) 230 | return -1; 231 | 232 | // g_debug("Found time tag TLEN: %s ms ... ", timetext); 233 | milliseconds = atol (timetext); 234 | g_free (timetext); 235 | 236 | if (milliseconds > 0) 237 | { 238 | seconds = (int) milliseconds / 1000; 239 | // g_debug("%d milliseconds is %d seconds.\n", milliseconds, seconds); 240 | return seconds; 241 | } 242 | 243 | g_debug ("ID3v2 TLEN tag time was 0\n"); 244 | 245 | return -1; 246 | } 247 | 248 | gchar * 249 | getTracknum (struct id3_tag * tag) 250 | { 251 | gchar trackno[40]; 252 | gchar *trackstr = getFrameText (tag, "TRCK"); 253 | gchar *posstr = getFrameText (tag, "TPOS"); 254 | gint i; 255 | 256 | if (trackstr == NULL) 257 | { 258 | return NULL; 259 | } 260 | trackno[0] = '\0'; 261 | // Take care of any a/b formats 262 | for (i = 0; i < strlen (trackstr); i++) 263 | { 264 | if (trackstr[i] == '/') 265 | { 266 | // Terminate it at switch character 267 | trackstr[i] = '\0'; 268 | break; 269 | } 270 | } 271 | // "Part of set" variable 272 | if (posstr != NULL) 273 | { 274 | // Same a/b format problem again 275 | for (i = 0; i < strlen (posstr); i++) 276 | { 277 | if (posstr[i] == '/') 278 | { 279 | // Terminate it at switch character 280 | posstr[i] = '\0'; 281 | break; 282 | } 283 | } 284 | strncpy (trackno, posstr, sizeof (trackno)); 285 | if (strlen (trackstr) == 1) 286 | { 287 | strcat (trackno, "0"); 288 | } 289 | strncat (trackno, trackstr, sizeof (trackno) - strlen (trackno) - 1); 290 | g_free (trackstr); 291 | g_free (posstr); 292 | } 293 | else 294 | { 295 | strncpy (trackno, trackstr, sizeof (trackno)); 296 | g_free (trackstr); 297 | } 298 | // Terminate and return 299 | trackno[sizeof (trackno) - 1] = '\0'; 300 | return g_strdup (trackno); 301 | } 302 | 303 | gchar * 304 | getOrigFilename (struct id3_tag * tag) 305 | { 306 | return getFrameText (tag, "TOFN"); 307 | } 308 | -------------------------------------------------------------------------------- /id3read.h: -------------------------------------------------------------------------------- 1 | #ifndef ID3HEADER_INCLUDED 2 | #define ID3HEADER_INCLUDED 3 | 4 | gchar *getArtist (struct id3_tag * tag); 5 | gchar *getAlbum (struct id3_tag *tag); 6 | gchar *getYear (struct id3_tag *tag); 7 | gchar *getTitle (struct id3_tag *tag); 8 | gchar *getGenre (struct id3_tag *tag); 9 | int getSonglen (struct id3_tag *tag); 10 | gchar *getTracknum (struct id3_tag *tag); 11 | gchar *getOrigFilename (struct id3_tag *tag); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /mtpfs.c: -------------------------------------------------------------------------------- 1 | /* 2 | FUSE: Filesystem in Userspace 3 | Copyright (C) 2001-2005 Miklos Szeredi 4 | 5 | This program can be distributed under the terms of the GNU GPL. 6 | See the file COPYING. 7 | */ 8 | 9 | #include 10 | #include 11 | #include /* strtoul() */ 12 | 13 | #if DEBUG 14 | #define STRINGIFY(x) #x 15 | #define TOSTRING(x) STRINGIFY(x) 16 | #define DBG(a...) {g_printf( "[" __FILE__ ":" TOSTRING(__LINE__) "] " a );g_printf("\n");} 17 | #else 18 | #define DBG(a...) 19 | #endif 20 | 21 | #if DEBUG 22 | static void 23 | dump_mtp_error () 24 | { 25 | LIBMTP_Dump_Errorstack (device); 26 | LIBMTP_Clear_Errorstack (device); 27 | } 28 | #else 29 | #define dump_mtp_error() 30 | #endif 31 | 32 | #define enter_lock(a...) do { DBG("lock"); DBG(a); g_mutex_lock(&device_lock); } while(0) 33 | #define return_unlock(a) do { DBG("return unlock"); g_mutex_unlock(&device_lock); return a; } while(0) 34 | 35 | void 36 | free_files (LIBMTP_file_t * filelist) 37 | { 38 | LIBMTP_file_t *file = filelist, *tmp; 39 | while (file) 40 | { 41 | tmp = file; 42 | file = file->next; 43 | LIBMTP_destroy_file_t (tmp); 44 | } 45 | } 46 | 47 | void 48 | free_playlists (LIBMTP_playlist_t * pl) 49 | { 50 | LIBMTP_playlist_t *playlist = pl, *tmp; 51 | while (playlist) 52 | { 53 | tmp = playlist; 54 | playlist = playlist->next; 55 | LIBMTP_destroy_playlist_t (tmp); 56 | } 57 | } 58 | 59 | void 60 | check_files () 61 | { 62 | if (files_changed) 63 | { 64 | DBG ("Refreshing Filelist"); 65 | LIBMTP_file_t *newfiles = NULL; 66 | if (files) 67 | free_files (files); 68 | newfiles = LIBMTP_Get_Filelisting_With_Callback (device, NULL, NULL); 69 | files = newfiles; 70 | newfiles = NULL; 71 | files_changed = FALSE; 72 | //check_lost_files (); 73 | DBG ("Refreshing Filelist exiting"); 74 | } 75 | } 76 | 77 | static void 78 | check_lost_files () 79 | { 80 | int last_parent_id = -1; 81 | gboolean last_parent_found = FALSE; 82 | LIBMTP_file_t *item; 83 | 84 | if (lostfiles != NULL) 85 | g_slist_free (lostfiles); 86 | 87 | lostfiles = NULL; 88 | for (item = files; item != NULL; item = item->next) 89 | { 90 | gboolean parent_found; 91 | 92 | if (last_parent_id == -1 || last_parent_id != item->parent_id) 93 | { 94 | if (item->parent_id == 0) 95 | { 96 | parent_found = TRUE; 97 | } 98 | else 99 | { 100 | int i; 101 | for (i = 0; i < 4; i++) 102 | { 103 | if (storageArea[i].folders != NULL) 104 | { 105 | if (LIBMTP_Find_Folder 106 | (storageArea[i].folders, item->parent_id) != NULL) 107 | { 108 | parent_found = FALSE; 109 | } 110 | } 111 | } 112 | } 113 | last_parent_id = item->parent_id; 114 | last_parent_found = parent_found; 115 | } 116 | else 117 | { 118 | parent_found = last_parent_found; 119 | } 120 | DBG ("MTPFS checking for lost files %s, parent %d - %s", 121 | item->filename, last_parent_id, (parent_found ? "FALSE" : "TRUE")); 122 | if (parent_found == FALSE) 123 | { 124 | lostfiles = g_slist_append (lostfiles, item); 125 | } 126 | } 127 | DBG ("MTPFS checking for lost files exit found %d lost tracks", 128 | g_slist_length (lostfiles)); 129 | } 130 | 131 | void 132 | check_folders () 133 | { 134 | int i; 135 | for (i = 0; i < 4; i++) 136 | { 137 | if (storageArea[i].folders_changed) 138 | { 139 | DBG ("Refreshing Folderlist %d-%s", i, 140 | storageArea[i].storage->StorageDescription); 141 | LIBMTP_folder_t *newfolders = NULL; 142 | if (storageArea[i].folders) 143 | { 144 | LIBMTP_destroy_folder_t (storageArea[i].folders); 145 | } 146 | newfolders = 147 | LIBMTP_Get_Folder_List_For_Storage (device, 148 | storageArea[i].storage->id); 149 | storageArea[i].folders = newfolders; 150 | newfolders = NULL; 151 | storageArea[i].folders_changed = FALSE; 152 | } 153 | } 154 | } 155 | 156 | void 157 | check_playlists () 158 | { 159 | if (playlists_changed) 160 | { 161 | DBG ("Refreshing Playlists"); 162 | LIBMTP_playlist_t *newplaylists; 163 | if (playlists) 164 | free_playlists (playlists); 165 | newplaylists = LIBMTP_Get_Playlist_List (device); 166 | playlists = newplaylists; 167 | playlists_changed = FALSE; 168 | } 169 | } 170 | 171 | int 172 | save_playlist (const char *path, struct fuse_file_info *fi) 173 | { 174 | DBG ("save_playlist"); 175 | int ret = 0; 176 | 177 | LIBMTP_playlist_t *playlist; 178 | FILE *file = NULL; 179 | char item_path[1024]; 180 | uint32_t item_id = 0; 181 | uint32_t *tracks; 182 | gchar **fields; 183 | GSList *tmplist = NULL; 184 | 185 | fields = g_strsplit (path, "/", -1); 186 | gchar *playlist_name; 187 | playlist_name = g_strndup (fields[2], strlen (fields[2]) - 4); 188 | DBG ("Adding:%s", playlist_name); 189 | g_strfreev (fields); 190 | 191 | playlist = LIBMTP_new_playlist_t (); 192 | playlist->name = g_strdup (playlist_name); 193 | 194 | file = fdopen (fi->fh, "r"); 195 | while (fgets (item_path, sizeof (item_path) - 1, file) != NULL) 196 | { 197 | g_strchomp (item_path); 198 | item_id = parse_path (item_path); 199 | if (item_id != -1) 200 | { 201 | tmplist = g_slist_append (tmplist, GUINT_TO_POINTER (item_id)); 202 | DBG ("Adding to tmplist:%d", item_id); 203 | } 204 | } 205 | playlist->no_tracks = g_slist_length (tmplist); 206 | tracks = g_malloc (playlist->no_tracks * sizeof (uint32_t)); 207 | int i; 208 | for (i = 0; i < playlist->no_tracks; i++) 209 | { 210 | tracks[i] = (uint32_t) GPOINTER_TO_UINT (g_slist_nth_data (tmplist, i)); 211 | DBG ("Adding:%d-%d", i, tracks[i]); 212 | } 213 | playlist->tracks = tracks; 214 | DBG ("Total:%d", playlist->no_tracks); 215 | 216 | int playlist_id = 0; 217 | LIBMTP_playlist_t *tmp_playlist; 218 | check_playlists (); 219 | tmp_playlist = playlists; 220 | while (tmp_playlist != NULL) 221 | { 222 | if (g_ascii_strcasecmp (tmp_playlist->name, playlist_name) == 0) 223 | { 224 | playlist_id = playlist->playlist_id; 225 | } 226 | tmp_playlist = tmp_playlist->next; 227 | } 228 | 229 | if (playlist_id > 0) 230 | { 231 | DBG ("Update playlist %d", playlist_id); 232 | playlist->playlist_id = playlist_id; 233 | ret = LIBMTP_Update_Playlist (device, playlist); 234 | } 235 | else 236 | { 237 | DBG ("New playlist"); 238 | ret = LIBMTP_Create_New_Playlist (device, playlist); 239 | } 240 | playlists_changed = TRUE; 241 | return ret; 242 | } 243 | 244 | /* Find the file type based on extension */ 245 | static LIBMTP_filetype_t 246 | find_filetype (const gchar * filename) 247 | { 248 | DBG ("find_filetype"); 249 | gchar **fields; 250 | fields = g_strsplit (filename, ".", -1); 251 | gchar *ptype; 252 | ptype = g_strdup (fields[g_strv_length (fields) - 1]); 253 | g_strfreev (fields); 254 | LIBMTP_filetype_t filetype; 255 | 256 | // This need to be kept constantly updated as new file types arrive. 257 | if (!g_ascii_strncasecmp (ptype, "wav", 3)) 258 | { 259 | filetype = LIBMTP_FILETYPE_WAV; 260 | } 261 | else if (!g_ascii_strncasecmp (ptype, "mp3", 3)) 262 | { 263 | filetype = LIBMTP_FILETYPE_MP3; 264 | } 265 | else if (!g_ascii_strncasecmp (ptype, "wma", 3)) 266 | { 267 | filetype = LIBMTP_FILETYPE_WMA; 268 | } 269 | else if (!g_ascii_strncasecmp (ptype, "ogg", 3)) 270 | { 271 | filetype = LIBMTP_FILETYPE_OGG; 272 | } 273 | else if (!g_ascii_strncasecmp (ptype, "aa", 2)) 274 | { 275 | filetype = LIBMTP_FILETYPE_AUDIBLE; 276 | } 277 | else if (!g_ascii_strncasecmp (ptype, "mp4", 3)) 278 | { 279 | filetype = LIBMTP_FILETYPE_MP4; 280 | } 281 | else if (!g_ascii_strncasecmp (ptype, "wmv", 3)) 282 | { 283 | filetype = LIBMTP_FILETYPE_WMV; 284 | } 285 | else if (!g_ascii_strncasecmp (ptype, "avi", 3)) 286 | { 287 | filetype = LIBMTP_FILETYPE_AVI; 288 | } 289 | else if (!g_ascii_strncasecmp (ptype, "mpeg", 4) 290 | || !g_ascii_strncasecmp (ptype, "mpg", 3)) 291 | { 292 | filetype = LIBMTP_FILETYPE_MPEG; 293 | } 294 | else if (!g_ascii_strncasecmp (ptype, "asf", 3)) 295 | { 296 | filetype = LIBMTP_FILETYPE_ASF; 297 | } 298 | else if (!g_ascii_strncasecmp (ptype, "qt", 2) 299 | || !g_ascii_strncasecmp (ptype, "mov", 3)) 300 | { 301 | filetype = LIBMTP_FILETYPE_QT; 302 | } 303 | else if (!g_ascii_strncasecmp (ptype, "wma", 3)) 304 | { 305 | filetype = LIBMTP_FILETYPE_WMA; 306 | } 307 | else if (!g_ascii_strncasecmp (ptype, "jpg", 3) 308 | || !g_ascii_strncasecmp (ptype, "jpeg", 4)) 309 | { 310 | filetype = LIBMTP_FILETYPE_JPEG; 311 | } 312 | else if (!g_ascii_strncasecmp (ptype, "jfif", 4)) 313 | { 314 | filetype = LIBMTP_FILETYPE_JFIF; 315 | } 316 | else if (!g_ascii_strncasecmp (ptype, "tif", 3) 317 | || !g_ascii_strncasecmp (ptype, "tiff", 4)) 318 | { 319 | filetype = LIBMTP_FILETYPE_TIFF; 320 | } 321 | else if (!g_ascii_strncasecmp (ptype, "bmp", 3)) 322 | { 323 | filetype = LIBMTP_FILETYPE_BMP; 324 | } 325 | else if (!g_ascii_strncasecmp (ptype, "gif", 3)) 326 | { 327 | filetype = LIBMTP_FILETYPE_GIF; 328 | } 329 | else if (!g_ascii_strncasecmp (ptype, "pic", 3) 330 | || !g_ascii_strncasecmp (ptype, "pict", 4)) 331 | { 332 | filetype = LIBMTP_FILETYPE_PICT; 333 | } 334 | else if (!g_ascii_strncasecmp (ptype, "png", 3)) 335 | { 336 | filetype = LIBMTP_FILETYPE_PNG; 337 | } 338 | else if (!g_ascii_strncasecmp (ptype, "wmf", 3)) 339 | { 340 | filetype = LIBMTP_FILETYPE_WINDOWSIMAGEFORMAT; 341 | } 342 | else if (!g_ascii_strncasecmp (ptype, "ics", 3)) 343 | { 344 | filetype = LIBMTP_FILETYPE_VCALENDAR2; 345 | } 346 | else if (!g_ascii_strncasecmp (ptype, "exe", 3) 347 | || !g_ascii_strncasecmp (ptype, "com", 3) 348 | || !g_ascii_strncasecmp (ptype, "bat", 3) 349 | || !g_ascii_strncasecmp (ptype, "dll", 3) 350 | || !g_ascii_strncasecmp (ptype, "sys", 3)) 351 | { 352 | filetype = LIBMTP_FILETYPE_WINEXEC; 353 | } 354 | else if (!g_ascii_strncasecmp (ptype, "txt", 3)) 355 | { 356 | filetype = LIBMTP_FILETYPE_TEXT; 357 | } 358 | else if (!g_ascii_strncasecmp (ptype, "htm", 3) 359 | || !g_ascii_strncasecmp (ptype, "html", 4)) 360 | { 361 | filetype = LIBMTP_FILETYPE_HTML; 362 | } 363 | else if (!g_ascii_strncasecmp (ptype, "bin", 3)) 364 | { 365 | filetype = LIBMTP_FILETYPE_FIRMWARE; 366 | } 367 | else if (!g_ascii_strncasecmp (ptype, "aac", 3)) 368 | { 369 | filetype = LIBMTP_FILETYPE_AAC; 370 | } 371 | else if (!g_ascii_strncasecmp (ptype, "flac", 4) 372 | || !g_ascii_strncasecmp (ptype, "fla", 3)) 373 | { 374 | filetype = LIBMTP_FILETYPE_FLAC; 375 | } 376 | else if (!g_ascii_strncasecmp (ptype, "mp2", 3)) 377 | { 378 | filetype = LIBMTP_FILETYPE_MP2; 379 | } 380 | else if (!g_ascii_strncasecmp (ptype, "m4a", 3)) 381 | { 382 | filetype = LIBMTP_FILETYPE_M4A; 383 | } 384 | else if (!g_ascii_strncasecmp (ptype, "doc", 3)) 385 | { 386 | filetype = LIBMTP_FILETYPE_DOC; 387 | } 388 | else if (!g_ascii_strncasecmp (ptype, "xml", 3)) 389 | { 390 | filetype = LIBMTP_FILETYPE_XML; 391 | } 392 | else if (!g_ascii_strncasecmp (ptype, "xls", 3)) 393 | { 394 | filetype = LIBMTP_FILETYPE_XLS; 395 | } 396 | else if (!g_ascii_strncasecmp (ptype, "ppt", 3)) 397 | { 398 | filetype = LIBMTP_FILETYPE_PPT; 399 | } 400 | else if (!g_ascii_strncasecmp (ptype, "mht", 3)) 401 | { 402 | filetype = LIBMTP_FILETYPE_MHT; 403 | } 404 | else if (!g_ascii_strncasecmp (ptype, "jp2", 3)) 405 | { 406 | filetype = LIBMTP_FILETYPE_JP2; 407 | } 408 | else if (!g_ascii_strncasecmp (ptype, "jpx", 3)) 409 | { 410 | filetype = LIBMTP_FILETYPE_JPX; 411 | } 412 | else 413 | { 414 | DBG ("Sorry, file type \"%s\" is not yet supported", ptype); 415 | DBG ("Tagging as unknown file type."); 416 | filetype = LIBMTP_FILETYPE_UNKNOWN; 417 | } 418 | g_free (ptype); 419 | return filetype; 420 | } 421 | 422 | static int 423 | find_storage (const gchar * path) 424 | { 425 | int i; 426 | DBG ("find_storage:%s", path); 427 | for (i = 0; i < 4; i++) 428 | { 429 | if (storageArea[i].storage != NULL) 430 | { 431 | int maxlen = strlen (storageArea[i].storage->StorageDescription); 432 | if (strlen (path + 1) < maxlen) 433 | maxlen = strlen (path + 1); 434 | if (strncmp 435 | (storageArea[i].storage->StorageDescription, 436 | path + 1, maxlen) == 0) 437 | { 438 | DBG ("%s found as %d", 439 | storageArea[i].storage->StorageDescription, i); 440 | return i; 441 | } 442 | } 443 | } 444 | DBG ("could not find storage for %s", path); 445 | return -1; 446 | } 447 | 448 | static int 449 | lookup_folder_id (LIBMTP_folder_t * folderlist, gchar * path, gchar * parent) 450 | { 451 | DBG ("lookup_folder_id %s,%s", path, parent); 452 | int ret = -1; 453 | if (folderlist == NULL) 454 | { 455 | return -1; 456 | } 457 | gchar *mypath; 458 | mypath = path; 459 | check_folders (); 460 | if (parent == NULL) 461 | { 462 | if (g_strrstr (path + 1, "/") == NULL) 463 | { 464 | DBG ("Storage dir"); 465 | return -2; 466 | } 467 | else 468 | { 469 | DBG ("Strip storage area name"); 470 | mypath = strstr (path + 1, "/"); 471 | parent = ""; 472 | } 473 | } 474 | 475 | gchar *current; 476 | current = g_strconcat (parent, "/", folderlist->name, NULL); 477 | LIBMTP_devicestorage_t *storage; 478 | 479 | DBG ("compare %s,%s", mypath, current); 480 | if (g_ascii_strcasecmp (mypath, current) == 0) 481 | { 482 | ret = folderlist->folder_id; 483 | } 484 | else if (g_ascii_strncasecmp (mypath, current, strlen (current)) == 0) 485 | { 486 | ret = lookup_folder_id (folderlist->child, mypath, current); 487 | } 488 | 489 | if (ret == -1) 490 | { 491 | ret = lookup_folder_id (folderlist->sibling, mypath, parent); 492 | } 493 | g_free (current); 494 | return ret; 495 | } 496 | 497 | static int 498 | parse_path (const gchar * path) 499 | { 500 | DBG ("parse_path:%s", path); 501 | int res; 502 | int item_id = -1; 503 | int i; 504 | // Check cached files first 505 | GSList *item; 506 | item = g_slist_find_custom (myfiles, path, (GCompareFunc) strcmp); 507 | if (item != NULL) 508 | return 0; 509 | 510 | // Check Playlists 511 | if (strncmp ("/Playlists", path, 10) == 0) 512 | { 513 | LIBMTP_playlist_t *playlist; 514 | 515 | res = -ENOENT; 516 | check_playlists (); 517 | playlist = playlists; 518 | while (playlist != NULL) 519 | { 520 | gchar *tmppath; 521 | tmppath = g_strconcat ("/Playlists/", playlist->name, ".m3u", NULL); 522 | if (g_ascii_strcasecmp (path, tmppath) == 0) 523 | { 524 | res = playlist->playlist_id; 525 | g_free (tmppath); 526 | break; 527 | } 528 | g_free (tmppath); 529 | playlist = playlist->next; 530 | } 531 | return res; 532 | } 533 | // Check lost+found 534 | if (strncmp ("/lost+found", path, 11) == 0) 535 | { 536 | GSList *item; 537 | gchar *filename = g_path_get_basename (path); 538 | 539 | res = -ENOENT; 540 | for (item = lostfiles; item != NULL; item = g_slist_next (item)) 541 | { 542 | LIBMTP_file_t *file = (LIBMTP_file_t *) item->data; 543 | 544 | if (strcmp (file->filename, filename) == 0) 545 | { 546 | res = file->item_id; 547 | break; 548 | } 549 | } 550 | g_free (filename); 551 | return res; 552 | } 553 | // Check device 554 | LIBMTP_folder_t *folder; 555 | gchar **fields; 556 | gchar *directory; 557 | directory = (gchar *) g_malloc (strlen (path) + 1); 558 | directory = strcpy (directory, ""); 559 | fields = g_strsplit (path, "/", -1); 560 | res = -ENOENT; 561 | int storageid; 562 | storageid = find_storage (path); 563 | if (storageid < 0) 564 | { 565 | return res; 566 | } 567 | for (i = 0; fields[i] != NULL; i++) 568 | { 569 | if (strlen (fields[i]) > 0) 570 | { 571 | if (fields[i + 1] != NULL) 572 | { 573 | directory = strcat (directory, "/"); 574 | directory = strcat (directory, fields[i]); 575 | } 576 | else 577 | { 578 | check_folders (); 579 | folder = storageArea[storageid].folders; 580 | int folder_id = 0; 581 | if (strcmp (directory, "") != 0) 582 | { 583 | folder_id = lookup_folder_id (folder, directory, NULL); 584 | } 585 | DBG ("parent id:%d:%s", folder_id, directory); 586 | LIBMTP_file_t *file; 587 | check_files (); 588 | file = files; 589 | while (file != NULL) 590 | { 591 | if ((file->parent_id == folder_id) || 592 | (folder_id == -2 593 | && (file->parent_id == 0) 594 | && (file->storage_id == 595 | storageArea[storageid].storage->id))) 596 | { 597 | if (file->filename == NULL) 598 | DBG ("MTPFS filename NULL"); 599 | if (file->filename != NULL 600 | && 601 | g_ascii_strcasecmp (file->filename, fields[i]) == 0) 602 | { 603 | DBG ("found:%d:%s", file->item_id, file->filename); 604 | 605 | item_id = file->item_id; 606 | break; // found! 607 | } 608 | } 609 | file = file->next; 610 | } 611 | if (item_id < 0) 612 | { 613 | directory = strcat (directory, "/"); 614 | directory = strcat (directory, fields[i]); 615 | item_id = lookup_folder_id (folder, directory, NULL); 616 | res = item_id; 617 | break; 618 | } 619 | else 620 | { 621 | res = item_id; 622 | break; 623 | } 624 | } 625 | } 626 | } 627 | g_free (directory); 628 | g_strfreev (fields); 629 | DBG ("parse_path exiting:%s - %d", path, res); 630 | return res; 631 | } 632 | 633 | static int 634 | mtpfs_release (const char *path, struct fuse_file_info *fi) 635 | { 636 | enter_lock ("release: %s", path); 637 | // Check cached files first 638 | GSList *item; 639 | item = g_slist_find_custom (myfiles, path, (GCompareFunc) strcmp); 640 | 641 | if (item != NULL) 642 | { 643 | if (strncmp ("/Playlists/", path, 11) == 0) 644 | { 645 | save_playlist (path, fi); 646 | close (fi->fh); 647 | return_unlock (0); 648 | } 649 | else 650 | { 651 | //find parent id 652 | gchar *filename = g_strdup (""); 653 | gchar **fields; 654 | gchar *directory; 655 | directory = (gchar *) g_malloc (strlen (path) + 1); 656 | directory = strcpy (directory, "/"); 657 | fields = g_strsplit (path, "/", -1); 658 | int i; 659 | int parent_id = 0; 660 | int storageid; 661 | storageid = find_storage (path); 662 | if (storageid < 0) 663 | { 664 | return_unlock (-ENOENT); 665 | } 666 | for (i = 0; fields[i] != NULL; i++) 667 | { 668 | if (strlen (fields[i]) > 0) 669 | { 670 | if (fields[i + 1] == NULL) 671 | { 672 | gchar *tmp = g_strndup (directory, 673 | strlen (directory) - 1); 674 | parent_id = 675 | lookup_folder_id (storageArea 676 | [storageid].folders, tmp, NULL); 677 | g_free (tmp); 678 | if (parent_id < 0) 679 | parent_id = 0; 680 | g_free (filename); 681 | filename = g_strdup (fields[i]); 682 | } 683 | else 684 | { 685 | directory = strcat (directory, fields[i]); 686 | directory = strcat (directory, "/"); 687 | } 688 | } 689 | } 690 | DBG ("%s:%s:%d", filename, directory, parent_id); 691 | 692 | struct stat st; 693 | uint64_t filesize; 694 | fstat (fi->fh, &st); 695 | filesize = (uint64_t) st.st_size; 696 | 697 | // Setup file 698 | int ret; 699 | LIBMTP_filetype_t filetype; 700 | filetype = find_filetype (filename); 701 | #ifdef USEMAD 702 | if (filetype == LIBMTP_FILETYPE_MP3) 703 | { 704 | LIBMTP_track_t *genfile; 705 | genfile = LIBMTP_new_track_t (); 706 | gint songlen; 707 | struct id3_file *id3_fh; 708 | struct id3_tag *tag; 709 | gchar *tracknum; 710 | 711 | id3_fh = id3_file_fdopen (fi->fh, ID3_FILE_MODE_READONLY); 712 | tag = id3_file_tag (id3_fh); 713 | 714 | genfile->artist = getArtist (tag); 715 | genfile->title = getTitle (tag); 716 | genfile->album = getAlbum (tag); 717 | genfile->genre = getGenre (tag); 718 | genfile->date = getYear (tag); 719 | genfile->usecount = 0; 720 | genfile->parent_id = (uint32_t) parent_id; 721 | genfile->storage_id = storageArea[storageid].storage->id; 722 | 723 | /* If there is a songlength tag it will take 724 | * precedence over any length calculated from 725 | * the bitrate and filesize */ 726 | songlen = getSonglen (tag); 727 | if (songlen > 0) 728 | { 729 | genfile->duration = songlen * 1000; 730 | } 731 | else 732 | { 733 | genfile->duration = (uint16_t) calc_length (fi->fh) * 1000; 734 | //genfile->duration = 293000; 735 | } 736 | 737 | tracknum = getTracknum (tag); 738 | if (tracknum != NULL) 739 | { 740 | genfile->tracknumber = strtoul (tracknum, NULL, 10); 741 | } 742 | else 743 | { 744 | genfile->tracknumber = 0; 745 | } 746 | g_free (tracknum); 747 | 748 | // Compensate for missing tag information 749 | if (!genfile->artist) 750 | genfile->artist = g_strdup (""); 751 | if (!genfile->title) 752 | genfile->title = g_strdup (""); 753 | if (!genfile->album) 754 | genfile->album = g_strdup (""); 755 | if (!genfile->genre) 756 | genfile->genre = g_strdup (""); 757 | 758 | genfile->filesize = filesize; 759 | genfile->filetype = filetype; 760 | genfile->filename = g_strdup (filename); 761 | //title,artist,genre,album,date,tracknumber,duration,samplerate,nochannels,wavecodec,bitrate,bitratetype,rating,usecount 762 | //DBG("%d:%d:%d",fi->fh,genfile->duration,genfile->filesize); 763 | ret = 764 | LIBMTP_Send_Track_From_File_Descriptor 765 | (device, fi->fh, genfile, NULL, NULL); 766 | id3_file_close (id3_fh); 767 | LIBMTP_destroy_track_t (genfile); 768 | DBG ("Sent TRACK %s", path); 769 | } 770 | else 771 | { 772 | #endif 773 | LIBMTP_file_t *genfile; 774 | genfile = LIBMTP_new_file_t (); 775 | genfile->filesize = filesize; 776 | genfile->filetype = filetype; 777 | genfile->filename = g_strdup (filename); 778 | genfile->parent_id = (uint32_t) parent_id; 779 | genfile->storage_id = storageArea[storageid].storage->id; 780 | 781 | ret = 782 | LIBMTP_Send_File_From_File_Descriptor 783 | (device, fi->fh, genfile, NULL, NULL); 784 | LIBMTP_destroy_file_t (genfile); 785 | DBG ("Sent FILE %s", path); 786 | #ifdef USEMAD 787 | } 788 | #endif 789 | if (ret == 0) 790 | { 791 | DBG ("Sent %s", path); 792 | } 793 | else 794 | { 795 | DBG ("Problem sending %s - %d", path, ret); 796 | } 797 | // Cleanup 798 | if (item && item->data) 799 | g_free (item->data); 800 | myfiles = g_slist_remove (myfiles, item->data); 801 | g_strfreev (fields); 802 | g_free (filename); 803 | g_free (directory); 804 | close (fi->fh); 805 | // Refresh filelist 806 | files_changed = TRUE; 807 | return_unlock (ret); 808 | } 809 | } 810 | close (fi->fh); 811 | return_unlock (0); 812 | } 813 | 814 | void 815 | mtpfs_destroy (void *buf) 816 | { 817 | enter_lock ("destroy"); 818 | if (files) 819 | free_files (files); 820 | int i; 821 | for (i = 0; i < 4; i++) 822 | { 823 | if (storageArea[i].folders) 824 | LIBMTP_destroy_folder_t (storageArea[i].folders); 825 | } 826 | if (playlists) 827 | free_playlists (playlists); 828 | if (device) 829 | LIBMTP_Release_Device (device); 830 | return_unlock (); 831 | } 832 | 833 | static int 834 | mtpfs_readdir (const gchar * path, void *buf, fuse_fill_dir_t filler, 835 | off_t offset, struct fuse_file_info *fi) 836 | { 837 | enter_lock ("readdir %s", path); 838 | LIBMTP_folder_t *folder; 839 | 840 | // Add common entries 841 | filler (buf, ".", NULL, 0); 842 | filler (buf, "..", NULL, 0); 843 | 844 | // If in root directory 845 | if (strcmp (path, "/") == 0) 846 | { 847 | filler (buf, "Playlists", NULL, 0); 848 | if (lostfiles != NULL) 849 | { 850 | filler (buf, "lost+found", NULL, 0); 851 | } 852 | LIBMTP_devicestorage_t *storage; 853 | for (storage = device->storage; storage != 0; storage = storage->next) 854 | { 855 | struct stat st; 856 | memset (&st, 0, sizeof (st)); 857 | st.st_nlink = 2; 858 | st.st_ino = storage->id; 859 | st.st_mode = S_IFREG | 0555; 860 | gchar *name; 861 | filler (buf, storage->StorageDescription, &st, 0); 862 | } 863 | return_unlock (0); 864 | } 865 | // Are we looking at the playlists? 866 | if (strncmp (path, "/Playlists", 10) == 0) 867 | { 868 | DBG ("Checking Playlists"); 869 | LIBMTP_playlist_t *playlist; 870 | check_playlists (); 871 | playlist = playlists; 872 | while (playlist != NULL) 873 | { 874 | struct stat st; 875 | memset (&st, 0, sizeof (st)); 876 | st.st_ino = playlist->playlist_id; 877 | st.st_mode = S_IFREG | 0666; 878 | gchar *name; 879 | name = g_strconcat (playlist->name, ".m3u", NULL); 880 | DBG ("Playlist:%s", name); 881 | if (filler (buf, name, &st, 0)) 882 | { 883 | g_free (name); 884 | break; 885 | } 886 | g_free (name); 887 | playlist = playlist->next; 888 | } 889 | return_unlock (0); 890 | } 891 | // Are we looking at lost+found dir? 892 | if (strncmp (path, "/lost+found", 11) == 0) 893 | { 894 | check_files (); 895 | GSList *item; 896 | 897 | for (item = lostfiles; item != NULL; item = g_slist_next (item)) 898 | { 899 | LIBMTP_file_t *file = (LIBMTP_file_t *) item->data; 900 | 901 | struct stat st; 902 | memset (&st, 0, sizeof (st)); 903 | st.st_ino = file->item_id; 904 | st.st_mode = S_IFREG | 0444; 905 | if (filler 906 | (buf, 907 | (file->filename == 908 | NULL ? "" : file->filename), &st, 0)) 909 | break; 910 | } 911 | return_unlock (0); 912 | } 913 | // Get storage area 914 | int i; 915 | int storageid = -1; 916 | storageid = find_storage (path); 917 | if (storageid < 0) 918 | { 919 | return_unlock (-ENOENT); 920 | } 921 | // Get folder listing. 922 | int folder_id = 0; 923 | if (strcmp (path, "/") != 0) 924 | { 925 | check_folders (); 926 | folder_id = 927 | lookup_folder_id (storageArea[storageid].folders, 928 | (gchar *) path, NULL); 929 | } 930 | 931 | DBG ("Checking folders for %d", storageid); 932 | check_folders (); 933 | if (folder_id == -2) 934 | { 935 | DBG ("Root of storage area"); 936 | folder = storageArea[storageid].folders; 937 | } 938 | else 939 | { 940 | folder = LIBMTP_Find_Folder (storageArea[storageid].folders, folder_id); 941 | if (folder == NULL) 942 | return_unlock (0); 943 | folder = folder->child; 944 | } 945 | 946 | while (folder != NULL) 947 | { 948 | if ((folder->parent_id == folder_id) || 949 | (folder_id == -2 950 | && (folder->storage_id == storageArea[storageid].storage->id))) 951 | { 952 | DBG ("found folder: %s, id %d", folder->name, folder->folder_id); 953 | struct stat st; 954 | memset (&st, 0, sizeof (st)); 955 | st.st_ino = folder->folder_id; 956 | st.st_mode = S_IFDIR | 0777; 957 | if (filler (buf, folder->name, &st, 0)) 958 | break; 959 | } 960 | folder = folder->sibling; 961 | } 962 | DBG ("Checking folders end"); 963 | LIBMTP_destroy_folder_t (folder); 964 | DBG ("Checking files"); 965 | // Find files 966 | LIBMTP_file_t *file, *tmp; 967 | check_files (); 968 | file = files; 969 | while (file != NULL) 970 | { 971 | if ((file->parent_id == folder_id) || 972 | (folder_id == -2 && (file->parent_id == 0) 973 | && (file->storage_id == storageArea[storageid].storage->id))) 974 | { 975 | struct stat st; 976 | memset (&st, 0, sizeof (st)); 977 | st.st_ino = file->item_id; 978 | st.st_mode = S_IFREG | 0444; 979 | if (filler 980 | (buf, 981 | (file->filename == 982 | NULL ? "" : file->filename), &st, 0)) 983 | break; 984 | } 985 | tmp = file; 986 | file = file->next; 987 | } 988 | DBG ("readdir exit"); 989 | return_unlock (0); 990 | } 991 | 992 | static int 993 | mtpfs_getattr_real (const gchar * path, struct stat *stbuf) 994 | { 995 | int ret = 0; 996 | if (path == NULL) 997 | return -ENOENT; 998 | memset (stbuf, 0, sizeof (struct stat)); 999 | 1000 | // Set uid/gid of file 1001 | struct fuse_context *fc; 1002 | fc = fuse_get_context (); 1003 | stbuf->st_uid = fc->uid; 1004 | stbuf->st_gid = fc->gid; 1005 | if (strcmp (path, "/") == 0) 1006 | { 1007 | stbuf->st_mode = S_IFDIR | 0777; 1008 | stbuf->st_nlink = 2; 1009 | return 0; 1010 | } 1011 | // Check cached files first (stuff that hasn't been written to dev yet) 1012 | GSList *item; 1013 | if (myfiles != NULL) 1014 | { 1015 | item = g_slist_find_custom (myfiles, path, (GCompareFunc) strcmp); 1016 | if (item != NULL) 1017 | { 1018 | stbuf->st_mode = S_IFREG | 0777; 1019 | stbuf->st_size = 0; 1020 | stbuf->st_blocks = 2; 1021 | stbuf->st_mtime = time (NULL); 1022 | return 0; 1023 | } 1024 | } 1025 | // Special case directory 'Playlists', 'lost+found' 1026 | // Special case root directory items 1027 | if (g_strrstr (path + 1, "/") == NULL) 1028 | { 1029 | stbuf->st_mode = S_IFDIR | 0777; 1030 | stbuf->st_nlink = 2; 1031 | return 0; 1032 | } 1033 | 1034 | int storageid; 1035 | storageid = find_storage (path); 1036 | if (storageid < 0) 1037 | { 1038 | return -ENOENT; 1039 | } 1040 | 1041 | if (g_ascii_strncasecmp (path, "/Playlists", 10) == 0) 1042 | { 1043 | LIBMTP_playlist_t *playlist; 1044 | check_playlists (); 1045 | playlist = playlists; 1046 | while (playlist != NULL) 1047 | { 1048 | gchar *tmppath; 1049 | tmppath = g_strconcat ("/Playlists/", playlist->name, ".m3u", NULL); 1050 | if (g_ascii_strcasecmp (path, tmppath) == 0) 1051 | { 1052 | int filesize = 0; 1053 | int i; 1054 | for (i = 0; i < playlist->no_tracks; i++) 1055 | { 1056 | LIBMTP_file_t *file; 1057 | LIBMTP_folder_t *folder; 1058 | file = 1059 | LIBMTP_Get_Filemetadata (device, playlist->tracks[i]); 1060 | if (file != NULL) 1061 | { 1062 | int parent_id = file->parent_id; 1063 | filesize = filesize + strlen (file->filename) + 2; 1064 | while (parent_id != 0) 1065 | { 1066 | check_folders (); 1067 | folder = 1068 | LIBMTP_Find_Folder 1069 | (storageArea[storageid].folders, parent_id); 1070 | if (folder == NULL) 1071 | { 1072 | DBG ("could not find %d in storage-area %d", 1073 | parent_id, storageid); 1074 | return -ENOENT; 1075 | } 1076 | parent_id = folder->parent_id; 1077 | filesize = filesize + strlen (folder->name) + 1; 1078 | } 1079 | } 1080 | } 1081 | stbuf->st_mode = S_IFREG | 0777; 1082 | stbuf->st_size = filesize; 1083 | stbuf->st_blocks = 2; 1084 | stbuf->st_mtime = time (NULL); 1085 | return 0; 1086 | } 1087 | playlist = playlist->next; 1088 | } 1089 | return -ENOENT; 1090 | } 1091 | 1092 | if (strncasecmp (path, "/lost+found", 11) == 0) 1093 | { 1094 | GSList *item; 1095 | int item_id = parse_path (path); 1096 | for (item = lostfiles; item != NULL; item = g_slist_next (item)) 1097 | { 1098 | LIBMTP_file_t *file = (LIBMTP_file_t *) item->data; 1099 | 1100 | if (item_id == file->item_id) 1101 | { 1102 | stbuf->st_ino = item_id; 1103 | stbuf->st_size = file->filesize; 1104 | stbuf->st_blocks = (file->filesize / 512) + 1105 | (file->filesize % 512 > 0 ? 1 : 0); 1106 | stbuf->st_nlink = 1; 1107 | stbuf->st_mode = S_IFREG | 0777; 1108 | stbuf->st_mtime = file->modificationdate; 1109 | return 0; 1110 | } 1111 | } 1112 | 1113 | return -ENOENT; 1114 | } 1115 | 1116 | int item_id = -1; 1117 | check_folders (); 1118 | item_id = 1119 | lookup_folder_id (storageArea[storageid].folders, (gchar *) path, NULL); 1120 | if (item_id >= 0) 1121 | { 1122 | // Must be a folder 1123 | stbuf->st_ino = item_id; 1124 | stbuf->st_mode = S_IFDIR | 0777; 1125 | stbuf->st_nlink = 2; 1126 | } 1127 | else 1128 | { 1129 | // Must be a file 1130 | item_id = parse_path (path); 1131 | LIBMTP_file_t *file; 1132 | DBG ("id:path=%d:%s", item_id, path); 1133 | check_files (); 1134 | file = files; 1135 | gboolean found = FALSE; 1136 | while (file != NULL) 1137 | { 1138 | if (file->item_id == item_id) 1139 | { 1140 | stbuf->st_ino = item_id; 1141 | stbuf->st_size = file->filesize; 1142 | stbuf->st_blocks = (file->filesize / 512) + 1143 | (file->filesize % 512 > 0 ? 1 : 0); 1144 | stbuf->st_nlink = 1; 1145 | stbuf->st_mode = S_IFREG | 0777; 1146 | DBG ("time:%s", ctime (&(file->modificationdate))); 1147 | stbuf->st_mtime = file->modificationdate; 1148 | stbuf->st_ctime = file->modificationdate; 1149 | stbuf->st_atime = file->modificationdate; 1150 | found = TRUE; 1151 | } 1152 | file = file->next; 1153 | } 1154 | if (!found) 1155 | { 1156 | ret = -ENOENT; 1157 | } 1158 | } 1159 | 1160 | return ret; 1161 | } 1162 | 1163 | static int 1164 | mtpfs_getattr (const gchar * path, struct stat *stbuf) 1165 | { 1166 | enter_lock ("getattr %s", path); 1167 | 1168 | int ret = mtpfs_getattr_real (path, stbuf); 1169 | 1170 | DBG ("getattr exit"); 1171 | return_unlock (ret); 1172 | } 1173 | 1174 | static int 1175 | mtpfs_mknod (const gchar * path, mode_t mode, dev_t dev) 1176 | { 1177 | enter_lock ("mknod %s", path); 1178 | int item_id = parse_path (path); 1179 | if (item_id > 0) 1180 | return_unlock (-EEXIST); 1181 | myfiles = g_slist_append (myfiles, (gpointer) (g_strdup (path))); 1182 | DBG ("NEW FILE"); 1183 | return_unlock (0); 1184 | } 1185 | 1186 | static int 1187 | mtpfs_open (const gchar * path, struct fuse_file_info *fi) 1188 | { 1189 | enter_lock ("open"); 1190 | int item_id = -1; 1191 | item_id = parse_path (path); 1192 | if (item_id < 0) 1193 | return_unlock (-ENOENT); 1194 | 1195 | switch (fi->flags & O_ACCMODE) 1196 | { 1197 | case O_RDONLY: 1198 | DBG ("read"); 1199 | break; 1200 | case O_WRONLY: 1201 | DBG ("write"); 1202 | break; 1203 | case O_RDWR: 1204 | DBG ("rdwrite"); 1205 | break; 1206 | default: 1207 | DBG ("unexpected access mode: %d", fi->flags & O_ACCMODE); 1208 | } 1209 | 1210 | int storageid; 1211 | storageid = find_storage (path); 1212 | if (storageid < 0) 1213 | { 1214 | return_unlock (-ENOENT); 1215 | } 1216 | FILE *filetmp = tmpfile (); 1217 | int tmpfile = fileno (filetmp); 1218 | if (tmpfile != -1) 1219 | { 1220 | if (item_id == 0) 1221 | { 1222 | fi->fh = tmpfile; 1223 | } 1224 | else if (strncmp ("/Playlists/", path, 11) == 0) 1225 | { 1226 | // Is a playlist 1227 | gchar **fields; 1228 | fields = g_strsplit (path, "/", -1); 1229 | gchar *name; 1230 | name = g_strndup (fields[2], strlen (fields[2]) - 4); 1231 | g_strfreev (fields); 1232 | fi->fh = tmpfile; 1233 | LIBMTP_playlist_t *playlist; 1234 | check_playlists (); 1235 | playlist = playlists; 1236 | while (playlist != NULL) 1237 | { 1238 | if (g_ascii_strcasecmp (playlist->name, name) == 0) 1239 | { 1240 | //int playlist_id=playlist->playlist_id; 1241 | int i; 1242 | for (i = 0; i < playlist->no_tracks; i++) 1243 | { 1244 | LIBMTP_file_t *file; 1245 | LIBMTP_folder_t *folder; 1246 | file = 1247 | LIBMTP_Get_Filemetadata (device, playlist->tracks[i]); 1248 | if (file != NULL) 1249 | { 1250 | gchar *path; 1251 | path = (gchar *) g_malloc (1024); 1252 | path = strcpy (path, "/"); 1253 | int parent_id = file->parent_id; 1254 | while (parent_id != 0) 1255 | { 1256 | check_folders (); 1257 | folder = 1258 | LIBMTP_Find_Folder 1259 | (storageArea[storageid].folders, parent_id); 1260 | path = strcat (path, folder->name); 1261 | path = strcat (path, "/"); 1262 | parent_id = folder->parent_id; 1263 | } 1264 | path = strcat (path, file->filename); 1265 | fprintf (filetmp, "%s\n", path); 1266 | DBG ("%s\n", path); 1267 | } 1268 | } 1269 | //LIBMTP_destroy_file_t(file); 1270 | fflush (filetmp); 1271 | break; 1272 | } 1273 | playlist = playlist->next; 1274 | } 1275 | } 1276 | else 1277 | { 1278 | int ret = LIBMTP_Get_File_To_File_Descriptor (device, item_id, 1279 | tmpfile, 1280 | NULL, NULL); 1281 | if (ret == 0) 1282 | { 1283 | fi->fh = tmpfile; 1284 | } 1285 | else 1286 | { 1287 | return_unlock (-ENOENT); 1288 | } 1289 | } 1290 | } 1291 | else 1292 | { 1293 | return_unlock (-ENOENT); 1294 | } 1295 | 1296 | return_unlock (0); 1297 | } 1298 | 1299 | static int 1300 | mtpfs_read (const gchar * path, gchar * buf, size_t size, off_t offset, 1301 | struct fuse_file_info *fi) 1302 | { 1303 | enter_lock ("read"); 1304 | int ret; 1305 | 1306 | int item_id = -1; 1307 | item_id = parse_path (path); 1308 | if (item_id < 0) 1309 | return_unlock (-ENOENT); 1310 | 1311 | ret = pread (fi->fh, buf, size, offset); 1312 | if (ret == -1) 1313 | ret = -errno; 1314 | 1315 | return_unlock (ret); 1316 | } 1317 | 1318 | static int 1319 | mtpfs_write (const gchar * path, const gchar * buf, size_t size, off_t offset, 1320 | struct fuse_file_info *fi) 1321 | { 1322 | enter_lock ("write"); 1323 | int ret; 1324 | if (fi->fh != -1) 1325 | { 1326 | ret = pwrite (fi->fh, buf, size, offset); 1327 | } 1328 | else 1329 | { 1330 | ret = -ENOENT; 1331 | } 1332 | 1333 | return_unlock (ret); 1334 | } 1335 | 1336 | static int 1337 | mtpfs_unlink (const gchar * path) 1338 | { 1339 | enter_lock ("unlink"); 1340 | int ret = 0; 1341 | int item_id = -1; 1342 | item_id = parse_path (path); 1343 | if (item_id < 0) 1344 | return_unlock (-ENOENT); 1345 | ret = LIBMTP_Delete_Object (device, item_id); 1346 | if (ret != 0) 1347 | LIBMTP_Dump_Errorstack (device); 1348 | if (strncmp (path, "/Playlists", 10) == 0) 1349 | { 1350 | playlists_changed = TRUE; 1351 | } 1352 | else 1353 | { 1354 | files_changed = TRUE; 1355 | } 1356 | 1357 | return_unlock (ret); 1358 | } 1359 | 1360 | static int 1361 | mtpfs_mkdir_real (const char *path, mode_t mode) 1362 | { 1363 | if (g_str_has_prefix (path, "/.Trash") == TRUE) 1364 | return_unlock (-EPERM); 1365 | 1366 | int ret = 0; 1367 | GSList *item; 1368 | item = g_slist_find_custom (myfiles, path, (GCompareFunc) strcmp); 1369 | int item_id = parse_path (path); 1370 | int storageid = find_storage (path); 1371 | if (storageid < 0) 1372 | { 1373 | return_unlock (-ENOENT); 1374 | } 1375 | if ((item == NULL) && (item_id < 0)) 1376 | { 1377 | // Split path and find parent_id 1378 | gchar *filename = g_strdup (""); 1379 | gchar **fields; 1380 | gchar *directory; 1381 | 1382 | directory = (gchar *) g_malloc (strlen (path) + 1); 1383 | directory = strcpy (directory, "/"); 1384 | fields = g_strsplit (path, "/", -1); 1385 | int i; 1386 | uint32_t parent_id = 0; 1387 | for (i = 0; fields[i] != NULL; i++) 1388 | { 1389 | if (strlen (fields[i]) > 0) 1390 | { 1391 | if (fields[i + 1] == NULL) 1392 | { 1393 | gchar *tmp = g_strndup (directory, 1394 | strlen (directory) - 1); 1395 | check_folders (); 1396 | parent_id = 1397 | lookup_folder_id (storageArea 1398 | [storageid].folders, tmp, NULL); 1399 | g_free (tmp); 1400 | if (parent_id < 0) 1401 | parent_id = 0; 1402 | g_free (filename); 1403 | filename = g_strdup (fields[i]); 1404 | } 1405 | else 1406 | { 1407 | directory = strcat (directory, fields[i]); 1408 | directory = strcat (directory, "/"); 1409 | } 1410 | } 1411 | } 1412 | DBG ("%s:%s:%d", filename, directory, parent_id); 1413 | ret = LIBMTP_Create_Folder (device, filename, parent_id, 0); 1414 | g_strfreev (fields); 1415 | g_free (directory); 1416 | g_free (filename); 1417 | if (ret == 0) 1418 | { 1419 | ret = -EEXIST; 1420 | } 1421 | else 1422 | { 1423 | storageArea[storageid].folders_changed = TRUE; 1424 | ret = 0; 1425 | } 1426 | } 1427 | else 1428 | { 1429 | ret = -EEXIST; 1430 | } 1431 | return ret; 1432 | } 1433 | 1434 | static int 1435 | mtpfs_mkdir (const char *path, mode_t mode) 1436 | { 1437 | enter_lock ("mkdir: %s", path); 1438 | int ret = mtpfs_mkdir_real (path, mode); 1439 | 1440 | return_unlock (ret); 1441 | } 1442 | 1443 | static int 1444 | mtpfs_rmdir (const char *path) 1445 | { 1446 | enter_lock ("rmdir %s", path); 1447 | int ret = 0; 1448 | int folder_id = -1; 1449 | if (strcmp (path, "/") == 0) 1450 | { 1451 | return_unlock (0); 1452 | } 1453 | int storageid = find_storage (path); 1454 | if (storageid < 0) 1455 | { 1456 | return_unlock (-ENOENT); 1457 | } 1458 | folder_id = 1459 | lookup_folder_id (storageArea[storageid].folders, (gchar *) path, NULL); 1460 | if (folder_id < 0) 1461 | return_unlock (-ENOENT); 1462 | 1463 | LIBMTP_Delete_Object (device, folder_id); 1464 | 1465 | storageArea[storageid].folders_changed = TRUE; 1466 | return_unlock (ret); 1467 | } 1468 | 1469 | /* Not working. need some way in libmtp to rename objects 1470 | int 1471 | mtpfs_rename (const char *oldname, const char *newname) 1472 | { 1473 | uint32_t old_id = parse_path(oldname); 1474 | LIBMTP_track_t *track; 1475 | track = LIBMTP_Get_Trackmetadata(device,old_id); 1476 | gchar *filename; 1477 | gchar **fields; 1478 | gchar *directory; 1479 | directory = (gchar *) g_malloc (strlen (newname) + 1); 1480 | directory = strcpy (directory, "/"); 1481 | fields = g_strsplit (newname, "/", -1); 1482 | int i; 1483 | uint32_t parent_id = 0; 1484 | for (i = 0; fields[i] != NULL; i++) { 1485 | if (strlen (fields[i]) > 0) { 1486 | if (fields[i + 1] == NULL) { 1487 | directory = g_strndup (directory, strlen (directory) - 1); 1488 | parent_id = lookup_folder_id (folders, directory, NULL); 1489 | if (parent_id < 0) 1490 | parent_id = 0; 1491 | filename = g_strdup (fields[i]); 1492 | } else { 1493 | directory = strcat (directory, fields[i]); 1494 | directory = strcat (directory, "/"); 1495 | 1496 | } 1497 | } 1498 | } 1499 | DBG("%s:%s:%d", filename, directory, parent_id); 1500 | 1501 | track->parent_id = parent_id; 1502 | track->title = g_strdup(filename); 1503 | int ret = LIBMTP_Update_Track_Metadata(device, track); 1504 | return ret; 1505 | } 1506 | */ 1507 | 1508 | /* Allow renaming of empty folders only */ 1509 | int 1510 | mtpfs_rename (const char *oldname, const char *newname) 1511 | { 1512 | enter_lock ("rename '%s' to '%s'", oldname, newname); 1513 | 1514 | int folder_id = -1, parent_id; 1515 | int folder_empty = 1; 1516 | int ret = -ENOTEMPTY; 1517 | LIBMTP_folder_t *folder; 1518 | LIBMTP_file_t *file; 1519 | 1520 | int storageid_old = find_storage (oldname); 1521 | if (storageid_old < 0) 1522 | { 1523 | return_unlock (-ENOENT); 1524 | } 1525 | int storageid_new = find_storage (newname); 1526 | if (storageid_new < 0) 1527 | { 1528 | return_unlock (-ENOENT); 1529 | } 1530 | if (strcmp (oldname, "/") != 0) 1531 | { 1532 | folder_id = 1533 | lookup_folder_id (storageArea[storageid_old].folders, 1534 | (gchar *) oldname, NULL); 1535 | } 1536 | if (folder_id < 0) 1537 | return_unlock (-ENOENT); 1538 | 1539 | check_folders (); 1540 | folder = LIBMTP_Find_Folder (storageArea[storageid_old].folders, folder_id); 1541 | 1542 | /* MTP Folder object not found? */ 1543 | if (folder == NULL) 1544 | return_unlock (-ENOENT); 1545 | 1546 | parent_id = folder->parent_id; 1547 | folder = folder->child; 1548 | 1549 | /* Check if empty folder */ 1550 | DBG ("Checking empty folder start for: subfolders"); 1551 | 1552 | while (folder != NULL) 1553 | { 1554 | if (folder->parent_id == folder_id) 1555 | { 1556 | folder_empty = 0; 1557 | break; 1558 | } 1559 | folder = folder->sibling; 1560 | } 1561 | 1562 | DBG ("Checking empty folder end for: subfolders. Result: %s", 1563 | (folder_empty == 1 ? "empty" : "not empty")); 1564 | 1565 | if (folder_empty == 1) 1566 | { 1567 | /* Find files */ 1568 | check_files (); 1569 | DBG ("Checking empty folder start for: files"); 1570 | file = files; 1571 | while (file != NULL) 1572 | { 1573 | if (file->parent_id == folder_id) 1574 | { 1575 | folder_empty = 0; 1576 | break; 1577 | } 1578 | file = file->next; 1579 | } 1580 | DBG ("Checking empty folder end for: files. Result: %s", 1581 | (folder_empty == 1 ? "empty" : "not empty")); 1582 | 1583 | /* Rename folder. First remove old folder, then create the new one */ 1584 | if (folder_empty == 1) 1585 | { 1586 | struct stat stbuf; 1587 | if ((ret = mtpfs_getattr_real (oldname, &stbuf)) == 0) 1588 | { 1589 | DBG ("removing folder %s, id %d", oldname, folder_id); 1590 | 1591 | ret = mtpfs_mkdir_real (newname, stbuf.st_mode); 1592 | LIBMTP_Delete_Object (device, folder_id); 1593 | storageArea[storageid_old].folders_changed = TRUE; 1594 | storageArea[storageid_new].folders_changed = TRUE; 1595 | } 1596 | } 1597 | } 1598 | return_unlock (ret); 1599 | } 1600 | 1601 | static int 1602 | mtpfs_statfs (const char *path, struct statfs *stbuf) 1603 | { 1604 | DBG ("mtpfs_statfs"); 1605 | stbuf->f_bsize = 1024; 1606 | stbuf->f_blocks = device->storage->MaxCapacity / 1024; 1607 | stbuf->f_bfree = device->storage->FreeSpaceInBytes / 1024; 1608 | stbuf->f_ffree = device->storage->FreeSpaceInObjects / 1024; 1609 | stbuf->f_bavail = stbuf->f_bfree; 1610 | return 0; 1611 | } 1612 | 1613 | void * 1614 | mtpfs_init () 1615 | { 1616 | LIBMTP_devicestorage_t *storage; 1617 | DBG ("mtpfs_init"); 1618 | files_changed = TRUE; 1619 | playlists_changed = TRUE; 1620 | DBG ("Ready"); 1621 | return 0; 1622 | } 1623 | 1624 | int 1625 | mtpfs_blank (const char *path, mode_t mode) 1626 | { 1627 | // Do nothing 1628 | } 1629 | 1630 | static struct fuse_operations mtpfs_oper = { 1631 | .chmod = mtpfs_blank, 1632 | .release = mtpfs_release, 1633 | .readdir = mtpfs_readdir, 1634 | .getattr = mtpfs_getattr, 1635 | .open = mtpfs_open, 1636 | .mknod = mtpfs_mknod, 1637 | .read = mtpfs_read, 1638 | .write = mtpfs_write, 1639 | .unlink = mtpfs_unlink, 1640 | .destroy = mtpfs_destroy, 1641 | .mkdir = mtpfs_mkdir, 1642 | .rmdir = mtpfs_rmdir, 1643 | .rename = mtpfs_rename, 1644 | .statfs = mtpfs_statfs, 1645 | .init = mtpfs_init, 1646 | }; 1647 | 1648 | int 1649 | main (int argc, char *argv[]) 1650 | { 1651 | int fuse_stat; 1652 | umask (0); 1653 | LIBMTP_raw_device_t *rawdevices; 1654 | int numrawdevices; 1655 | LIBMTP_error_number_t err; 1656 | int device_number = 0; 1657 | 1658 | int opt; 1659 | extern int optind; 1660 | extern char *optarg; 1661 | 1662 | g_mutex_init(&device_lock); 1663 | 1664 | //while ((opt = getopt(argc, argv, "d")) != -1 ) { 1665 | //switch (opt) { 1666 | //case 'd': 1667 | ////LIBMTP_Set_Debug(9); 1668 | //break; 1669 | //} 1670 | //} 1671 | 1672 | //argc -= optind; 1673 | //argv += optind; 1674 | 1675 | LIBMTP_Init (); 1676 | 1677 | fprintf (stdout, "Listing raw device(s)\n"); 1678 | err = LIBMTP_Detect_Raw_Devices (&rawdevices, &numrawdevices); 1679 | switch (err) 1680 | { 1681 | case LIBMTP_ERROR_NO_DEVICE_ATTACHED: 1682 | fprintf (stdout, " No raw devices found.\n"); 1683 | return 0; 1684 | case LIBMTP_ERROR_CONNECTING: 1685 | fprintf (stderr, 1686 | "Detect: There has been an error connecting. Exiting\n"); 1687 | return 1; 1688 | case LIBMTP_ERROR_MEMORY_ALLOCATION: 1689 | fprintf (stderr, 1690 | "Detect: Encountered a Memory Allocation Error. Exiting\n"); 1691 | return 1; 1692 | case LIBMTP_ERROR_NONE: 1693 | { 1694 | int i; 1695 | 1696 | fprintf (stdout, " Found %d device(s):\n", numrawdevices); 1697 | for (i = 0; i < numrawdevices; i++) 1698 | { 1699 | if (rawdevices[i].device_entry.vendor != NULL || 1700 | rawdevices[i].device_entry.product != NULL) 1701 | { 1702 | fprintf (stdout, 1703 | " %s: %s (%04x:%04x) @ bus %d, dev %d\n", 1704 | rawdevices[i].device_entry.vendor, 1705 | rawdevices[i].device_entry.product, 1706 | rawdevices[i].device_entry.vendor_id, 1707 | rawdevices[i].device_entry.product_id, 1708 | rawdevices[i].bus_location, rawdevices[i].devnum); 1709 | } 1710 | else 1711 | { 1712 | fprintf (stdout, 1713 | " %04x:%04x @ bus %d, dev %d\n", 1714 | rawdevices[i].device_entry.vendor_id, 1715 | rawdevices[i].device_entry.product_id, 1716 | rawdevices[i].bus_location, rawdevices[i].devnum); 1717 | } 1718 | } 1719 | } 1720 | break; 1721 | case LIBMTP_ERROR_GENERAL: 1722 | default: 1723 | fprintf (stderr, "Unknown connection error.\n"); 1724 | return 1; 1725 | } 1726 | 1727 | fprintf (stdout, "Attempting to connect device\n"); 1728 | device = LIBMTP_Open_Raw_Device (&rawdevices[device_number]); 1729 | if (device == NULL) 1730 | { 1731 | fprintf (stderr, "Unable to open raw device %d\n", device_number); 1732 | return 1; 1733 | } 1734 | 1735 | LIBMTP_Dump_Errorstack (device); 1736 | LIBMTP_Clear_Errorstack (device); 1737 | 1738 | char *friendlyname; 1739 | /* Echo the friendly name so we know which device we are working with */ 1740 | friendlyname = LIBMTP_Get_Friendlyname (device); 1741 | if (friendlyname == NULL) 1742 | { 1743 | printf ("Listing File Information on Device with name: (NULL)\n"); 1744 | } 1745 | else 1746 | { 1747 | printf ("Listing File Information on Device with name: %s\n", 1748 | friendlyname); 1749 | g_free (friendlyname); 1750 | } 1751 | 1752 | /* Get all storages for this device */ 1753 | int ret = LIBMTP_Get_Storage (device, LIBMTP_STORAGE_SORTBY_NOTSORTED); 1754 | if (ret != 0) 1755 | { 1756 | fprintf (stdout, "LIBMTP_Get_Storage() failed:%d\n", ret); 1757 | LIBMTP_Dump_Errorstack (device); 1758 | LIBMTP_Clear_Errorstack (device); 1759 | return 1; 1760 | } 1761 | 1762 | /* Check if multiple storage areas */ 1763 | LIBMTP_devicestorage_t *storage; 1764 | int i; 1765 | for (storage = device->storage, i = 0; storage != 0; 1766 | storage = storage->next, i++) 1767 | { 1768 | storageArea[i].storage = storage; 1769 | storageArea[i].folders = NULL; 1770 | storageArea[i].folders_changed = TRUE; 1771 | DBG ("Storage%d: %d - %s\n", i, storage->id, 1772 | storage->StorageDescription); 1773 | } 1774 | 1775 | DBG ("Start fuse"); 1776 | 1777 | fuse_stat = fuse_main (argc, argv, &mtpfs_oper); 1778 | DBG ("fuse_main returned %d\n", fuse_stat); 1779 | return fuse_stat; 1780 | } 1781 | 1782 | #ifdef USEMAD 1783 | /* Private buffer for passing around with libmad */ 1784 | typedef struct 1785 | { 1786 | /* The buffer of raw mpeg data for libmad to decode */ 1787 | void *buf; 1788 | 1789 | /* Cached data: pointers to the dividing points of frames 1790 | in buf, and the playing time at each of those frames */ 1791 | void **frames; 1792 | mad_timer_t *times; 1793 | 1794 | /* fd is the file descriptor if over the network, or -1 if 1795 | using mmap()ed files */ 1796 | int fd; 1797 | 1798 | /* length of the current stream, corrected for id3 tags */ 1799 | ssize_t length; 1800 | 1801 | /* have we finished fetching this file? (only in non-mmap()'ed case */ 1802 | int done; 1803 | 1804 | /* total number of frames */ 1805 | unsigned long num_frames; 1806 | 1807 | /* number of frames to play */ 1808 | unsigned long max_frames; 1809 | 1810 | /* total duration of the file */ 1811 | mad_timer_t duration; 1812 | 1813 | /* filename as mpg321 has opened it */ 1814 | char filename[PATH_MAX]; 1815 | } buffer; 1816 | 1817 | /* XING parsing is from the MAD winamp input plugin */ 1818 | 1819 | struct xing 1820 | { 1821 | int flags; 1822 | unsigned long frames; 1823 | unsigned long bytes; 1824 | unsigned char toc[100]; 1825 | long scale; 1826 | }; 1827 | 1828 | enum 1829 | { 1830 | XING_FRAMES = 0x0001, 1831 | XING_BYTES = 0x0002, 1832 | XING_TOC = 0x0004, 1833 | XING_SCALE = 0x0008 1834 | }; 1835 | 1836 | #define XING_MAGIC (('X' << 24) | ('i' << 16) | ('n' << 8) | 'g') 1837 | 1838 | /* Following two function are adapted from mad_timer, from the 1839 | libmad distribution */ 1840 | static int 1841 | parse_xing (struct xing *xing, struct mad_bitptr ptr, unsigned int bitlen) 1842 | { 1843 | if (bitlen < 64 || mad_bit_read (&ptr, 32) != XING_MAGIC) 1844 | goto fail; 1845 | 1846 | xing->flags = mad_bit_read (&ptr, 32); 1847 | bitlen -= 64; 1848 | 1849 | if (xing->flags & XING_FRAMES) 1850 | { 1851 | if (bitlen < 32) 1852 | goto fail; 1853 | 1854 | xing->frames = mad_bit_read (&ptr, 32); 1855 | bitlen -= 32; 1856 | } 1857 | 1858 | if (xing->flags & XING_BYTES) 1859 | { 1860 | if (bitlen < 32) 1861 | goto fail; 1862 | 1863 | xing->bytes = mad_bit_read (&ptr, 32); 1864 | bitlen -= 32; 1865 | } 1866 | 1867 | if (xing->flags & XING_TOC) 1868 | { 1869 | int i; 1870 | 1871 | if (bitlen < 800) 1872 | goto fail; 1873 | 1874 | for (i = 0; i < 100; ++i) 1875 | xing->toc[i] = mad_bit_read (&ptr, 8); 1876 | 1877 | bitlen -= 800; 1878 | } 1879 | 1880 | if (xing->flags & XING_SCALE) 1881 | { 1882 | if (bitlen < 32) 1883 | goto fail; 1884 | 1885 | xing->scale = mad_bit_read (&ptr, 32); 1886 | bitlen -= 32; 1887 | } 1888 | 1889 | return 1; 1890 | fail: 1891 | xing->flags = 0; 1892 | return 0; 1893 | } 1894 | 1895 | int 1896 | scan (void const *ptr, ssize_t len) 1897 | { 1898 | int duration = 0; 1899 | struct mad_stream stream; 1900 | struct mad_header header; 1901 | struct xing xing; 1902 | xing.frames = 0; 1903 | 1904 | unsigned long bitrate = 0; 1905 | int has_xing = 0; 1906 | int is_vbr = 0; 1907 | mad_stream_init (&stream); 1908 | mad_header_init (&header); 1909 | 1910 | mad_stream_buffer (&stream, ptr, len); 1911 | 1912 | int num_frames = 0; 1913 | 1914 | /* There are three ways of calculating the length of an mp3: 1915 | 1) Constant bitrate: One frame can provide the information 1916 | needed: # of frames and duration. Just see how long it 1917 | is and do the division. 1918 | 2) Variable bitrate: Xing tag. It provides the number of 1919 | frames. Each frame has the same number of samples, so 1920 | just use that. 1921 | 3) All: Count up the frames and duration of each frames 1922 | by decoding each one. We do this if we've no other 1923 | choice, i.e. if it's a VBR file with no Xing tag. 1924 | */ 1925 | 1926 | while (1) 1927 | { 1928 | if (mad_header_decode (&header, &stream) == -1) 1929 | { 1930 | if (MAD_RECOVERABLE (stream.error)) 1931 | continue; 1932 | else 1933 | break; 1934 | } 1935 | 1936 | /* Limit xing testing to the first frame header */ 1937 | if (!num_frames++) 1938 | { 1939 | if (parse_xing (&xing, stream.anc_ptr, stream.anc_bitlen)) 1940 | { 1941 | is_vbr = 1; 1942 | 1943 | if (xing.flags & XING_FRAMES) 1944 | { 1945 | /* We use the Xing tag only for frames. If it doesn't have that 1946 | information, it's useless to us and we have to treat it as a 1947 | normal VBR file */ 1948 | has_xing = 1; 1949 | num_frames = xing.frames; 1950 | break; 1951 | } 1952 | } 1953 | } 1954 | 1955 | /* Test the first n frames to see if this is a VBR file */ 1956 | if (!is_vbr && !(num_frames > 20)) 1957 | { 1958 | if (bitrate && header.bitrate != bitrate) 1959 | { 1960 | is_vbr = 1; 1961 | } 1962 | 1963 | else 1964 | { 1965 | bitrate = header.bitrate; 1966 | } 1967 | } 1968 | 1969 | /* We have to assume it's not a VBR file if it hasn't already been 1970 | marked as one and we've checked n frames for different bitrates */ 1971 | else if (!is_vbr) 1972 | { 1973 | break; 1974 | } 1975 | 1976 | duration = header.duration.seconds; 1977 | } 1978 | 1979 | if (!is_vbr) 1980 | { 1981 | double time = (len * 8.0) / (header.bitrate); /* time in seconds */ 1982 | //double timefrac = (double)time - ((long)(time)); 1983 | long nsamples = 32 * MAD_NSBSAMPLES (&header); /* samples per frame */ 1984 | 1985 | /* samplerate is a constant */ 1986 | num_frames = (long) (time * header.samplerate / nsamples); 1987 | 1988 | duration = (int) time; 1989 | DBG ("d:%d", duration); 1990 | } 1991 | 1992 | else if (has_xing) 1993 | { 1994 | /* modify header.duration since we don't need it anymore */ 1995 | mad_timer_multiply (&header.duration, num_frames); 1996 | duration = header.duration.seconds; 1997 | } 1998 | 1999 | else 2000 | { 2001 | /* the durations have been added up, and the number of frames 2002 | counted. We do nothing here. */ 2003 | } 2004 | 2005 | mad_header_finish (&header); 2006 | mad_stream_finish (&stream); 2007 | return duration; 2008 | } 2009 | 2010 | int 2011 | calc_length (int f) 2012 | { 2013 | struct stat filestat; 2014 | void *fdm; 2015 | char buffer[3]; 2016 | 2017 | fstat (f, &filestat); 2018 | 2019 | /* TAG checking is adapted from XMMS */ 2020 | int length = filestat.st_size; 2021 | 2022 | if (lseek (f, -128, SEEK_END) < 0) 2023 | { 2024 | /* File must be very short or empty. Forget it. */ 2025 | return -1; 2026 | } 2027 | 2028 | if (read (f, buffer, 3) != 3) 2029 | { 2030 | return -1; 2031 | } 2032 | 2033 | if (!strncmp (buffer, "TAG", 3)) 2034 | { 2035 | length -= 128; /* Correct for id3 tags */ 2036 | } 2037 | 2038 | fdm = mmap (0, length, PROT_READ, MAP_SHARED, f, 0); 2039 | if (fdm == MAP_FAILED) 2040 | { 2041 | g_error ("Map failed"); 2042 | return -1; 2043 | } 2044 | 2045 | /* Scan the file for a XING header, or calculate the length, 2046 | or just scan the whole file and add everything up. */ 2047 | int duration = scan (fdm, length); 2048 | 2049 | if (munmap (fdm, length) == -1) 2050 | { 2051 | g_error ("Unmap failed"); 2052 | return -1; 2053 | } 2054 | 2055 | lseek (f, 0, SEEK_SET); 2056 | return duration; 2057 | } 2058 | 2059 | #endif 2060 | -------------------------------------------------------------------------------- /mtpfs.h: -------------------------------------------------------------------------------- 1 | #ifndef _MTPFS_H_ 2 | #define _MTPFS_H_ 3 | 4 | #ifdef HAVE_CONFIG_H 5 | #include "config.h" 6 | #endif 7 | 8 | #ifdef linux 9 | /* For pread()/pwrite() */ 10 | #define _XOPEN_SOURCE 500 11 | #endif 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #ifdef USEMAD 27 | #include 28 | #include 29 | #include "id3read.h" 30 | #endif 31 | 32 | typedef struct 33 | { 34 | LIBMTP_devicestorage_t *storage; 35 | LIBMTP_folder_t *folders; 36 | gboolean folders_changed; 37 | } StorageArea; 38 | 39 | /* Function declarations */ 40 | 41 | /* local functions */ 42 | static LIBMTP_filetype_t find_filetype (const gchar * filename); 43 | static int lookup_folder_id (LIBMTP_folder_t * folderlist, gchar * path, 44 | gchar * parent); 45 | static int parse_path (const gchar * path); 46 | static void check_lost_files (); 47 | void check_folders (); 48 | static int find_storage (const gchar * path); 49 | 50 | /* fuse functions */ 51 | static void *mtpfs_init (void); 52 | static int mtpfs_blank (const char *path, mode_t mode); 53 | static int mtpfs_release (const char *path, struct fuse_file_info *fi); 54 | void mtpfs_destroy (void *buf); 55 | static int mtpfs_readdir (const gchar * path, void *buf, 56 | fuse_fill_dir_t filler, off_t offset, 57 | struct fuse_file_info *fi); 58 | static int mtpfs_getattr (const gchar * path, struct stat *stbuf); 59 | static int mtpfs_mknod (const gchar * path, mode_t mode, dev_t dev); 60 | static int mtpfs_open (const gchar * path, struct fuse_file_info *fi); 61 | static int mtpfs_read (const gchar * path, gchar * buf, size_t size, 62 | off_t offset, struct fuse_file_info *fi); 63 | static int mtpfs_write (const gchar * path, const gchar * buf, size_t size, 64 | off_t offset, struct fuse_file_info *fi); 65 | static int mtpfs_unlink (const gchar * path); 66 | static int mtpfs_mkdir (const char *path, mode_t mode); 67 | static int mtpfs_rmdir (const char *path); 68 | static int mtpfs_statfs (const char *path, struct statfs *stbuf); 69 | int calc_length (int f); 70 | 71 | static LIBMTP_mtpdevice_t *device; 72 | static StorageArea storageArea[4]; 73 | static LIBMTP_file_t *files = NULL; 74 | static gboolean files_changed = TRUE; 75 | static GSList *lostfiles = NULL; 76 | static GSList *myfiles = NULL; 77 | static LIBMTP_playlist_t *playlists = NULL; 78 | static gboolean playlists_changed = FALSE; 79 | static GMutex device_lock; 80 | 81 | #endif /* _MTPFS_H_ */ 82 | --------------------------------------------------------------------------------