Gentoo Archives: gentoo-commits

From: Sergei Trofimovich <slyfox@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-fs/mtpfs/files/, sys-fs/mtpfs/, sys-fs/mtpfs/files/mtpfs-1.1-wking-patches/
Date: Mon, 28 Sep 2015 21:31:31
Message-Id: 1443475870.c023f7466af628e1c9f6899cb6ae7d2323c3e865.slyfox@gentoo
1 commit: c023f7466af628e1c9f6899cb6ae7d2323c3e865
2 Author: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
3 AuthorDate: Mon Sep 28 21:30:23 2015 +0000
4 Commit: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
5 CommitDate: Mon Sep 28 21:31:10 2015 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c023f746
7
8 sys-fs/mtpfs: a huge robustification patchset by W. Trevor King!
9
10 Package-Manager: portage-2.2.22
11
12 sys-fs/mtpfs/files/mtpfs-1.1-g_printf.patch | 10 ++
13 .../0001-Use-GMutex-instead-of-GStaticMutex.patch | 49 +++++++++
14 ...evices-after-opening-the-connected-device.patch | 28 ++++++
15 ...llocate-additional-byte-for-trailing-null.patch | 55 +++++++++++
16 .../0004-Use-storageid-to-access-storageArea.patch | 42 ++++++++
17 ...DE-to-pull-out-the-access-portion-of-the-.patch | 46 +++++++++
18 .../0006-Check-for-find_storage-failures.patch | 109 +++++++++++++++++++++
19 ...path-instead-of-fields-0-for-find_storage.patch | 29 ++++++
20 sys-fs/mtpfs/mtpfs-1.1-r3.ebuild | 57 +++++++++++
21 9 files changed, 425 insertions(+)
22
23 diff --git a/sys-fs/mtpfs/files/mtpfs-1.1-g_printf.patch b/sys-fs/mtpfs/files/mtpfs-1.1-g_printf.patch
24 new file mode 100644
25 index 0000000..21e08c8
26 --- /dev/null
27 +++ b/sys-fs/mtpfs/files/mtpfs-1.1-g_printf.patch
28 @@ -0,0 +1,10 @@
29 +diff --git a/mtpfs.h b/mtpfs.h
30 +index f9532fa..1042a3d 100644
31 +--- a/mtpfs.h
32 ++++ b/mtpfs.h
33 +@@ -32,2 +32,5 @@
34 + #endif
35 ++#ifdef DEBUG
36 ++#include <glib/gprintf.h>
37 ++#endif
38 +
39
40 diff --git a/sys-fs/mtpfs/files/mtpfs-1.1-wking-patches/0001-Use-GMutex-instead-of-GStaticMutex.patch b/sys-fs/mtpfs/files/mtpfs-1.1-wking-patches/0001-Use-GMutex-instead-of-GStaticMutex.patch
41 new file mode 100644
42 index 0000000..9c1970b
43 --- /dev/null
44 +++ b/sys-fs/mtpfs/files/mtpfs-1.1-wking-patches/0001-Use-GMutex-instead-of-GStaticMutex.patch
45 @@ -0,0 +1,49 @@
46 +From 39872d8ff354c40d881f416e3b8b6df911379d37 Mon Sep 17 00:00:00 2001
47 +From: "W. Trevor King" <wking@×××××××.us>
48 +Date: Sun, 23 Aug 2015 12:05:35 -0700
49 +Subject: [PATCH 1/7] Use GMutex instead of GStaticMutex
50 +
51 +The static version was deprecated in GLib 2.32 [1], which was released
52 +on 2012-03-24 [2]. The difference between the two was that before
53 +2.32, GMutex could not be statically allocated. Since 2.32, GMutex
54 +can be statically allocated, so there's no reason to use GStaticMutex
55 +anymore.
56 +
57 +[1]: https://developer.gnome.org/glib/unstable/glib-Deprecated-Thread-APIs.html#GStaticMutex
58 +[2]: https://git.gnome.org/browse/glib/tag/?h=glib-2-32&id=2.32.0
59 +---
60 + mtpfs.c | 4 ++--
61 + mtpfs.h | 2 +-
62 + 2 files changed, 3 insertions(+), 3 deletions(-)
63 +
64 +diff --git a/mtpfs.c b/mtpfs.c
65 +index 553d282..286cd24 100644
66 +--- a/mtpfs.c
67 ++++ b/mtpfs.c
68 +@@ -28,8 +28,8 @@ static void dump_mtp_error()
69 + #define dump_mtp_error()
70 + #endif
71 +
72 +-#define enter_lock(a...) do { DBG("lock"); DBG(a); g_static_mutex_lock(&device_lock); } while(0)
73 +-#define return_unlock(a) do { DBG("return unlock"); g_static_mutex_unlock(&device_lock); return a; } while(0)
74 ++#define enter_lock(a...) do { DBG("lock"); DBG(a); g_mutex_lock(&device_lock); } while(0)
75 ++#define return_unlock(a) do { DBG("return unlock"); g_mutex_unlock(&device_lock); return a; } while(0)
76 +
77 + void
78 + free_files(LIBMTP_file_t *filelist)
79 +diff --git a/mtpfs.h b/mtpfs.h
80 +index 789eccb..f812ea6 100644
81 +--- a/mtpfs.h
82 ++++ b/mtpfs.h
83 +@@ -73,7 +73,7 @@ static GSList *lostfiles = NULL;
84 + static GSList *myfiles = NULL;
85 + static LIBMTP_playlist_t *playlists = NULL;
86 + static gboolean playlists_changed = FALSE;
87 +-static GStaticMutex device_lock = G_STATIC_MUTEX_INIT;
88 ++static GMutex device_lock = G_STATIC_MUTEX_INIT;
89 +
90 +
91 + #endif /* _MTPFS_H_ */
92 +--
93 +2.5.3
94 +
95
96 diff --git a/sys-fs/mtpfs/files/mtpfs-1.1-wking-patches/0002-Free-rawdevices-after-opening-the-connected-device.patch b/sys-fs/mtpfs/files/mtpfs-1.1-wking-patches/0002-Free-rawdevices-after-opening-the-connected-device.patch
97 new file mode 100644
98 index 0000000..42089d5
99 --- /dev/null
100 +++ b/sys-fs/mtpfs/files/mtpfs-1.1-wking-patches/0002-Free-rawdevices-after-opening-the-connected-device.patch
101 @@ -0,0 +1,28 @@
102 +From 2fb900e9e915f9ec6ac2f233255a0a527da164c2 Mon Sep 17 00:00:00 2001
103 +From: "W. Trevor King" <wking@×××××××.us>
104 +Date: Sun, 23 Aug 2015 21:59:45 -0700
105 +Subject: [PATCH 2/7] Free rawdevices after opening the connected device
106 +
107 +Avoid leaking the raw-device memory. For a similar example in the
108 +libmtp source, see LIBMTP_Get_First_Device [1].
109 +
110 +[1]: http://sourceforge.net/p/libmtp/code/ci/libmtp-1-1-9/tree/src/libmtp.c#l1690
111 +---
112 + mtpfs.c | 1 +
113 + 1 file changed, 1 insertion(+)
114 +
115 +diff --git a/mtpfs.c b/mtpfs.c
116 +index 286cd24..bdd5f46 100644
117 +--- a/mtpfs.c
118 ++++ b/mtpfs.c
119 +@@ -1390,6 +1390,7 @@ main (int argc, char *argv[])
120 +
121 + fprintf(stdout, "Attempting to connect device\n");
122 + device = LIBMTP_Open_Raw_Device(&rawdevices[i]);
123 ++ free (rawdevices);
124 + if (device == NULL) {
125 + fprintf(stderr, "Unable to open raw device %d\n", i);
126 + return 1;
127 +--
128 +2.5.3
129 +
130
131 diff --git a/sys-fs/mtpfs/files/mtpfs-1.1-wking-patches/0003-Allocate-additional-byte-for-trailing-null.patch b/sys-fs/mtpfs/files/mtpfs-1.1-wking-patches/0003-Allocate-additional-byte-for-trailing-null.patch
132 new file mode 100644
133 index 0000000..20cff00
134 --- /dev/null
135 +++ b/sys-fs/mtpfs/files/mtpfs-1.1-wking-patches/0003-Allocate-additional-byte-for-trailing-null.patch
136 @@ -0,0 +1,55 @@
137 +From 3929648c83910a45a37e84b4d3e5316631ce7c6b Mon Sep 17 00:00:00 2001
138 +From: "W. Trevor King" <wking@×××××××.us>
139 +Date: Mon, 24 Aug 2015 00:08:24 -0700
140 +Subject: [PATCH 3/7] Allocate additional byte for trailing null
141 +
142 +These variables needs a byte for every character in the path and an
143 +additional trailing null, but the length returned by strlen excludes
144 +the trailing null.
145 +---
146 + mtpfs.c | 8 ++++----
147 + 1 file changed, 4 insertions(+), 4 deletions(-)
148 +
149 +diff --git a/mtpfs.c b/mtpfs.c
150 +index bdd5f46..e31acd9 100644
151 +--- a/mtpfs.c
152 ++++ b/mtpfs.c
153 +@@ -416,7 +416,7 @@ parse_path (const gchar * path)
154 + LIBMTP_folder_t *folder;
155 + gchar **fields;
156 + gchar *directory;
157 +- directory = (gchar *) g_malloc (strlen (path));
158 ++ directory = (gchar *) g_malloc (strlen (path) + 1);
159 + directory = strcpy (directory, "");
160 + fields = g_strsplit (path, "/", -1);
161 + res = -ENOENT;
162 +@@ -488,7 +488,7 @@ mtpfs_release (const char *path, struct fuse_file_info *fi)
163 + gchar *filename = g_strdup("");
164 + gchar **fields;
165 + gchar *directory;
166 +- directory = (gchar *) g_malloc (strlen (path));
167 ++ directory = (gchar *) g_malloc (strlen (path) + 1);
168 + directory = strcpy (directory, "/");
169 + fields = g_strsplit (path, "/", -1);
170 + int i;
171 +@@ -1089,7 +1089,7 @@ mtpfs_mkdir_real (const char *path, mode_t mode)
172 + gchar **fields;
173 + gchar *directory;
174 +
175 +- directory = (gchar *) g_malloc (strlen (path));
176 ++ directory = (gchar *) g_malloc (strlen (path) + 1);
177 + directory = strcpy (directory, "/");
178 + fields = g_strsplit (path, "/", -1);
179 + int i;
180 +@@ -1168,7 +1168,7 @@ mtpfs_rename (const char *oldname, const char *newname)
181 + gchar *filename;
182 + gchar **fields;
183 + gchar *directory;
184 +- directory = (gchar *) g_malloc (strlen (newname));
185 ++ directory = (gchar *) g_malloc (strlen (newname) + 1);
186 + directory = strcpy (directory, "/");
187 + fields = g_strsplit (newname, "/", -1);
188 + int i;
189 +--
190 +2.5.3
191 +
192
193 diff --git a/sys-fs/mtpfs/files/mtpfs-1.1-wking-patches/0004-Use-storageid-to-access-storageArea.patch b/sys-fs/mtpfs/files/mtpfs-1.1-wking-patches/0004-Use-storageid-to-access-storageArea.patch
194 new file mode 100644
195 index 0000000..755e290
196 --- /dev/null
197 +++ b/sys-fs/mtpfs/files/mtpfs-1.1-wking-patches/0004-Use-storageid-to-access-storageArea.patch
198 @@ -0,0 +1,42 @@
199 +From 89ec461a73a2479fb5766b6b65a44e6e5b699b94 Mon Sep 17 00:00:00 2001
200 +From: "W. Trevor King" <wking@×××××××.us>
201 +Date: Mon, 24 Aug 2015 00:34:41 -0700
202 +Subject: [PATCH 4/7] Use storageid to access storageArea
203 +
204 +'i' is indexing playlist->tracks here, and we don't want to look in a
205 +sequential storage areas for each track.
206 +
207 +I've also added a null-folder check. I'm not sure if -ENOENT is the
208 +right code for "we can't find the parent directory in the storage area
209 +that contains the child", but it's the only non-success code that
210 +mtpfs_getattr_real returned before this commit. And returning
211 +anything is probably better than segfaulting when we try and
212 +dereference folder with 'folder->parent_id'. I've added a logging
213 +message to help debug things when we do get a null folder.
214 +---
215 + mtpfs.c | 9 ++++++++-
216 + 1 file changed, 8 insertions(+), 1 deletion(-)
217 +
218 +diff --git a/mtpfs.c b/mtpfs.c
219 +index e31acd9..9f924a9 100644
220 +--- a/mtpfs.c
221 ++++ b/mtpfs.c
222 +@@ -832,7 +832,14 @@ mtpfs_getattr_real (const gchar * path, struct stat *stbuf)
223 + filesize = filesize + strlen(file->filename) + 2;
224 + while (parent_id != 0) {
225 + check_folders();
226 +- folder = LIBMTP_Find_Folder(storageArea[i].folders,parent_id);
227 ++ folder =
228 ++ LIBMTP_Find_Folder
229 ++ (storageArea[storageid].folders, parent_id);
230 ++ if (folder == NULL) {
231 ++ DBG ("could not find %d in storage-area %d",
232 ++ parent_id, storageid);
233 ++ return -ENOENT;
234 ++ }
235 + parent_id = folder->parent_id;
236 + filesize = filesize + strlen(folder->name) + 1;
237 + }
238 +--
239 +2.5.3
240 +
241
242 diff --git a/sys-fs/mtpfs/files/mtpfs-1.1-wking-patches/0005-Use-O_ACCMODE-to-pull-out-the-access-portion-of-the-.patch b/sys-fs/mtpfs/files/mtpfs-1.1-wking-patches/0005-Use-O_ACCMODE-to-pull-out-the-access-portion-of-the-.patch
243 new file mode 100644
244 index 0000000..03bfb4c
245 --- /dev/null
246 +++ b/sys-fs/mtpfs/files/mtpfs-1.1-wking-patches/0005-Use-O_ACCMODE-to-pull-out-the-access-portion-of-the-.patch
247 @@ -0,0 +1,46 @@
248 +From 00bd3be1310fb36a3b2eddc931eb48c89744b2b4 Mon Sep 17 00:00:00 2001
249 +From: "W. Trevor King" <wking@×××××××.us>
250 +Date: Mon, 24 Aug 2015 01:31:17 -0700
251 +Subject: [PATCH 5/7] Use O_ACCMODE to pull out the access portion of the open
252 + flags
253 +
254 +Following [1]. I'm using cp from GNU Coreutils 8.23, and it's setting
255 +my flags to 32769 (O_WRONLY + 0x8000).
256 +
257 +[1]: http://www.gnu.org/software/libc/manual/html_node/Access-Modes.html#index-0_005fACCMODE
258 +---
259 + mtpfs.c | 18 ++++++++++++------
260 + 1 file changed, 12 insertions(+), 6 deletions(-)
261 +
262 +diff --git a/mtpfs.c b/mtpfs.c
263 +index 9f924a9..a82d479 100644
264 +--- a/mtpfs.c
265 ++++ b/mtpfs.c
266 +@@ -949,12 +949,18 @@ mtpfs_open (const gchar * path, struct fuse_file_info *fi)
267 + if (item_id < 0)
268 + return_unlock(-ENOENT);
269 +
270 +- if (fi->flags == O_RDONLY) {
271 +- DBG("read");
272 +- } else if (fi->flags == O_WRONLY) {
273 +- DBG("write");
274 +- } else if (fi->flags == O_RDWR) {
275 +- DBG("rdwrite");
276 ++ switch (fi->flags & O_ACCMODE) {
277 ++ case O_RDONLY:
278 ++ DBG ("read");
279 ++ break;
280 ++ case O_WRONLY:
281 ++ DBG ("write");
282 ++ break;
283 ++ case O_RDWR:
284 ++ DBG("rdwrite");
285 ++ break;
286 ++ default:
287 ++ DBG ("unexpected access mode: %d", fi->flags & O_ACCMODE);
288 + }
289 +
290 + int storageid;
291 +--
292 +2.5.3
293 +
294
295 diff --git a/sys-fs/mtpfs/files/mtpfs-1.1-wking-patches/0006-Check-for-find_storage-failures.patch b/sys-fs/mtpfs/files/mtpfs-1.1-wking-patches/0006-Check-for-find_storage-failures.patch
296 new file mode 100644
297 index 0000000..84fb346
298 --- /dev/null
299 +++ b/sys-fs/mtpfs/files/mtpfs-1.1-wking-patches/0006-Check-for-find_storage-failures.patch
300 @@ -0,0 +1,109 @@
301 +From 8860e176c8fb38006dc58516a5e5d9a1aab7be49 Mon Sep 17 00:00:00 2001
302 +From: "W. Trevor King" <wking@×××××××.us>
303 +Date: Mon, 24 Aug 2015 01:07:49 -0700
304 +Subject: [PATCH 6/7] Check for find_storage failures
305 +
306 +Instead of just blindly using storageArea[-1].
307 +---
308 + mtpfs.c | 28 ++++++++++++++++++++++++++++
309 + 1 file changed, 28 insertions(+)
310 +
311 +diff --git a/mtpfs.c b/mtpfs.c
312 +index a82d479..3fe17b8 100644
313 +--- a/mtpfs.c
314 ++++ b/mtpfs.c
315 +@@ -317,6 +317,7 @@ find_storage(const gchar * path)
316 + }
317 + }
318 + }
319 ++ DBG ("could not find storage for %s", path);
320 + return -1;
321 + }
322 +
323 +@@ -422,6 +423,9 @@ parse_path (const gchar * path)
324 + res = -ENOENT;
325 + int storageid;
326 + storageid = find_storage(path);
327 ++ if (storageid < 0) {
328 ++ return res;
329 ++ }
330 + for (i = 0; fields[i] != NULL; i++) {
331 + if (strlen (fields[i]) > 0) {
332 + if (fields[i + 1] != NULL) {
333 +@@ -495,6 +499,9 @@ mtpfs_release (const char *path, struct fuse_file_info *fi)
334 + int parent_id = 0;
335 + int storageid;
336 + storageid = find_storage(fields[0]);
337 ++ if (storageid < 0) {
338 ++ return_unlock (-ENOENT);
339 ++ }
340 + for (i = 0; fields[i] != NULL; i++) {
341 + if (strlen (fields[i]) > 0) {
342 + if (fields[i + 1] == NULL) {
343 +@@ -715,6 +722,9 @@ mtpfs_readdir (const gchar * path, void *buf, fuse_fill_dir_t filler,
344 + int i;
345 + int storageid = -1;
346 + storageid=find_storage(path);
347 ++ if (storageid < 0) {
348 ++ return_unlock (-ENOENT);
349 ++ }
350 + // Get folder listing.
351 + int folder_id = 0;
352 + if (strcmp (path, "/") != 0) {
353 +@@ -812,6 +822,9 @@ mtpfs_getattr_real (const gchar * path, struct stat *stbuf)
354 +
355 + int storageid;
356 + storageid=find_storage(path);
357 ++ if (storageid < 0) {
358 ++ return -ENOENT;
359 ++ }
360 +
361 + if (g_ascii_strncasecmp (path, "/Playlists",10) == 0) {
362 + LIBMTP_playlist_t *playlist;
363 +@@ -965,6 +978,9 @@ mtpfs_open (const gchar * path, struct fuse_file_info *fi)
364 +
365 + int storageid;
366 + storageid=find_storage(path);
367 ++ if (storageid < 0) {
368 ++ return_unlock (-ENOENT);
369 ++ }
370 + FILE *filetmp = tmpfile ();
371 + int tmpfile = fileno (filetmp);
372 + if (tmpfile != -1) {
373 +@@ -1096,6 +1112,9 @@ mtpfs_mkdir_real (const char *path, mode_t mode)
374 + item = g_slist_find_custom (myfiles, path, (GCompareFunc) strcmp);
375 + int item_id = parse_path (path);
376 + int storageid = find_storage(path);
377 ++ if (storageid < 0) {
378 ++ return_unlock (-ENOENT);
379 ++ }
380 + if ((item == NULL) && (item_id < 0)) {
381 + // Split path and find parent_id
382 + gchar *filename = g_strdup("");
383 +@@ -1161,6 +1180,9 @@ mtpfs_rmdir (const char *path)
384 + return_unlock(0);
385 + }
386 + int storageid=find_storage(path);
387 ++ if (storageid < 0) {
388 ++ return_unlock (-ENOENT);
389 ++ }
390 + folder_id = lookup_folder_id (storageArea[storageid].folders, (gchar *) path, NULL);
391 + if (folder_id < 0)
392 + return_unlock(-ENOENT);
393 +@@ -1223,7 +1245,13 @@ mtpfs_rename (const char *oldname, const char *newname)
394 + LIBMTP_file_t *file;
395 +
396 + int storageid_old=find_storage(oldname);
397 ++ if (storageid_old < 0) {
398 ++ return_unlock (-ENOENT);
399 ++ }
400 + int storageid_new=find_storage(newname);
401 ++ if (storageid_new < 0) {
402 ++ return_unlock (-ENOENT);
403 ++ }
404 + if (strcmp (oldname, "/") != 0) {
405 + folder_id = lookup_folder_id (storageArea[storageid_old].folders, (gchar *) oldname, NULL);
406 + }
407 +--
408 +2.5.3
409 +
410
411 diff --git a/sys-fs/mtpfs/files/mtpfs-1.1-wking-patches/0007-Use-path-instead-of-fields-0-for-find_storage.patch b/sys-fs/mtpfs/files/mtpfs-1.1-wking-patches/0007-Use-path-instead-of-fields-0-for-find_storage.patch
412 new file mode 100644
413 index 0000000..b524391
414 --- /dev/null
415 +++ b/sys-fs/mtpfs/files/mtpfs-1.1-wking-patches/0007-Use-path-instead-of-fields-0-for-find_storage.patch
416 @@ -0,0 +1,29 @@
417 +From 76ff042e1334fdbef9803ea71b5d8b1d380efd7e Mon Sep 17 00:00:00 2001
418 +From: "W. Trevor King" <wking@×××××××.us>
419 +Date: Mon, 24 Aug 2015 20:58:26 -0700
420 +Subject: [PATCH 7/7] Use 'path' instead of 'fields[0]' for find_storage
421 +
422 +When my path is '/Internal storage/Music/...', fields[0] will be an
423 +empty string, and find_storage will fail to find a storage area that
424 +matches that empty string. All of our other find_storage calls use
425 +the full path, so follow that example here.
426 +---
427 + mtpfs.c | 2 +-
428 + 1 file changed, 1 insertion(+), 1 deletion(-)
429 +
430 +diff --git a/mtpfs.c b/mtpfs.c
431 +index 3fe17b8..291f49d 100644
432 +--- a/mtpfs.c
433 ++++ b/mtpfs.c
434 +@@ -498,7 +498,7 @@ mtpfs_release (const char *path, struct fuse_file_info *fi)
435 + int i;
436 + int parent_id = 0;
437 + int storageid;
438 +- storageid = find_storage(fields[0]);
439 ++ storageid = find_storage(path);
440 + if (storageid < 0) {
441 + return_unlock (-ENOENT);
442 + }
443 +--
444 +2.5.3
445 +
446
447 diff --git a/sys-fs/mtpfs/mtpfs-1.1-r3.ebuild b/sys-fs/mtpfs/mtpfs-1.1-r3.ebuild
448 new file mode 100644
449 index 0000000..d16925f
450 --- /dev/null
451 +++ b/sys-fs/mtpfs/mtpfs-1.1-r3.ebuild
452 @@ -0,0 +1,57 @@
453 +# Copyright 1999-2015 Gentoo Foundation
454 +# Distributed under the terms of the GNU General Public License v2
455 +# $Id$
456 +
457 +EAPI=5
458 +
459 +inherit eutils
460 +
461 +DESCRIPTION="A FUSE filesystem providing access to MTP devices"
462 +HOMEPAGE="http://www.adebenham.com/mtpfs/"
463 +SRC_URI="http://www.adebenham.com/files/mtp/${P}.tar.gz"
464 +
465 +LICENSE="GPL-3"
466 +SLOT="0"
467 +KEYWORDS="~amd64 ~x86"
468 +IUSE="debug mad"
469 +
470 +RDEPEND="dev-libs/glib:2
471 + >=media-libs/libmtp-1.1.2
472 + sys-fs/fuse
473 + mad? (
474 + media-libs/libid3tag
475 + media-libs/libmad
476 + )"
477 +DEPEND="${RDEPEND}
478 + virtual/pkgconfig"
479 +
480 +DOCS=(AUTHORS NEWS README)
481 +
482 +src_prepare() {
483 + sed -e "/#include <string.h>/ a\
484 + #include <stdlib.h>" -i mtpfs.h id3read.c || die #implicit
485 +
486 + epatch "${FILESDIR}"/${P}-fix-mutex-crash.patch
487 + epatch "${FILESDIR}"/${P}-unitialized-variable.patch
488 + epatch "${FILESDIR}"/${P}-wking-patches/*.patch
489 + epatch "${FILESDIR}"/${P}-g_printf.patch
490 +}
491 +
492 +src_configure() {
493 + econf $(use_enable debug) \
494 + $(use_enable mad)
495 +}
496 +
497 +pkg_postinst() {
498 + einfo "To mount your MTP device, issue:"
499 + einfo " /usr/bin/mtpfs <mountpoint>"
500 + echo
501 + einfo "To unmount your MTP device, issue:"
502 + einfo " /usr/bin/fusermount -u <mountpoint>"
503 +
504 + if use debug; then
505 + echo
506 + einfo "You have enabled debugging output."
507 + einfo "Please make sure you run mtpfs with the -d flag."
508 + fi
509 +}