Merge lp:~amdmi3/wargus/rip-music-freebsd into lp:wargus

Proposed by Dmitry Marakasov
Status: Merged
Approved by: Pali
Approved revision: 1890
Merged at revision: 1905
Proposed branch: lp:~amdmi3/wargus/rip-music-freebsd
Merge into: lp:wargus
Diff against target: 45 lines (+21/-1)
1 file modified
rip_music_unix.cpp (+21/-1)
To merge this branch: bzr merge lp:~amdmi3/wargus/rip-music-freebsd
Reviewer Review Type Date Requested Status
Stratagus Pending
Review via email: mp+258958@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'rip_music_unix.cpp'
2--- rip_music_unix.cpp 2012-05-20 13:27:53 +0000
3+++ rip_music_unix.cpp 2015-05-13 04:40:47 +0000
4@@ -39,7 +39,12 @@
5 #include <unistd.h>
6 #include <libgen.h>
7
8-#include <mntent.h>
9+#if defined(__linux__)
10+# include <mntent.h>
11+#elif defined(__FreeBSD__)
12+# include <sys/param.h>
13+# include <sys/mount.h>
14+#endif
15
16 #include "rip_music.h"
17
18@@ -140,6 +145,7 @@
19
20 static char * find_dev(const char * mnt_dir) {
21
22+#if defined(__linux__)
23 struct mntent * mnt;
24 char * dev = NULL;
25 FILE * file;
26@@ -167,6 +173,20 @@
27 endmntent(file);
28
29 return dev;
30+#elif defined(__FreeBSD__)
31+ struct statfs sfs;
32+
33+ if ( statfs(mnt_dir, &sfs) != 0 ) {
34+
35+ fprintf(stderr, "Error: Cannot get mounted device: %s\n", strerror(errno));
36+ return NULL;
37+
38+ }
39+
40+ return strdup(sfs.f_mntfromname);
41+#else
42+ return NULL;
43+#endif
44
45 }
46

Subscribers

People subscribed via source and target branches