summaryrefslogtreecommitdiff
path: root/doc/bugs/Utility__47__libdiskfree.c_more_BSD_friendly.mdwn
blob: 51894cac60f89aa2eb2b63d10d5a6512e1707b5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
### Please describe the problem.

There exist more BSD systems than FreeBSD. Thus I propose diff for Utility/libdiskfree.c.

Based on pkgsrc patching guidelines https://www.netbsd.org/docs/pkgsrc/components.html#components.patches.guidelines
I tried to cook a diff even I'm not C developer.


### What steps will reproduce the problem?

Add support for more OS for disk free check.

### What version of git-annex are you using? On what operating system?
git-annex-5.20150930


### Please provide any additional information below.

The diff probably needs check, improvement...

[[!format sh """
--- libdiskfree.c.orig	Sun Oct  4 15:18:07 2015
+++ libdiskfree.c	Sun Oct  4 15:23:23 2015
@@ -7,35 +7,30 @@
 
 /* Include appropriate headers for the OS, and define what will be used to
  * check the free space. */
-#if defined(__APPLE__)
-# define _DARWIN_FEATURE_64_BIT_INODE 1
-# include <sys/param.h>
-# include <sys/mount.h>
-# define STATCALL statfs
-# define STATSTRUCT statfs64
-#else
-#if defined (__FreeBSD__)
-# include <sys/param.h>
-# include <sys/mount.h>
-# define STATCALL statfs /* statfs64 not yet tested on a real FreeBSD machine */
-# define STATSTRUCT statfs
-#else
-#if defined __ANDROID__
-# warning free space checking code not available for Android
-# define UNKNOWN
-#else
 #if defined (__linux__) || defined (__FreeBSD_kernel__)
 /* Linux or Debian kFreeBSD */
 /* This is a POSIX standard, so might also work elsewhere too. */
 # include <sys/statvfs.h>
 # define STATCALL statvfs
 # define STATSTRUCT statvfs
-#else
-# warning free space checking code not available for this OS
+#endif
+
+#if defined __ANDROID__
+# warning free space checking code not available for Android
 # define UNKNOWN
 #endif
+
+#if defined (HAVE_SYS_PARAM_H) && defined (HAVE_SYS_MOUNT_H)
+#if defined(__APPLE__)
+# define _DARWIN_FEATURE_64_BIT_INODE 1
 #endif
-#endif
+# include <sys/param.h>
+# include <sys/mount.h>
+# define STATCALL statfs /* statfs64 not yet tested on a real FreeBSD machine */
+# define STATSTRUCT statfs64
+#else
+# warning free space checking code not available for this OS
+# define UNKNOWN
 #endif
 
 #include <errno.h>

"""]]

### Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders)

Not tested this "feature" yet, I got another issue which blocks me for now.

> Well, this code has been removing from git-annex, and it's now using
> <http://hackage.haskell.org/package/disk-free-space>. I think that
> library is somewhat more portable. [[done]]