summaryrefslogtreecommitdiff
path: root/sysutils/hal/patches/patch-ab
blob: 03a9f12cb547f715284cb443bd80ca796f76d86e (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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
$NetBSD: patch-ab,v 1.3 2008/12/20 21:11:05 jmcneill Exp $

--- tools/hal-storage-shared.c.orig	2008-05-08 02:24:24 +0300
+++ tools/hal-storage-shared.c	2008-11-23 13:38:53 +0200
@@ -31,7 +31,7 @@
 #include <string.h>
 #include <glib.h>
 #include <glib/gstdio.h>
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__APPLE__)
 #include <fstab.h>
 #include <sys/param.h>
 #include <sys/ucred.h>
@@ -42,6 +42,10 @@
 #include <fcntl.h>
 #include <sys/mnttab.h>
 #include <sys/vfstab.h>
+#elif __NetBSD__
+#include <fstab.h>
+#include <sys/param.h>
+#include <sys/mount.h>
 #else
 #include <mntent.h>
 #endif
@@ -53,20 +57,27 @@
 
 #include "hal-storage-shared.h"
 
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__APPLE__)
 struct mtab_handle
 {
   struct statfs	*mounts;
   int		n_mounts;
   int		iter;
 };
+#elif __NetBSD__
+struct mtab_handle
+{
+  struct statvfs *mounts;
+  int		n_mounts;
+  int		iter;
+};
 #endif
 
 
 gboolean
 mtab_open (gpointer *handle)
 {
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__APPLE__)
 	struct mtab_handle *mtab;
 
 	mtab = g_new0 (struct mtab_handle, 1);
@@ -90,7 +101,7 @@ mtab_open (gpointer *handle)
 char *
 mtab_next (gpointer handle, char **mount_point)
 {
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__APPLE__)
 	struct mtab_handle *mtab = handle;
 
 	if (mtab->iter < mtab->n_mounts) {
@@ -131,7 +142,7 @@ mtab_next (gpointer handle, char **mount
 void
 mtab_close (gpointer handle)
 {
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__APPLE__)
 	g_free (handle);
 #else
 	fclose (handle);
@@ -143,7 +154,7 @@ mtab_close (gpointer handle)
 gboolean
 fstab_open (gpointer *handle)
 {
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__APPLE__)
 	return setfsent () == 1;
 #elif sun
 	*handle = fopen (VFSTAB, "r");
@@ -157,7 +168,7 @@ fstab_open (gpointer *handle)
 char *
 fstab_next (gpointer handle, char **mount_point)
 {
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__APPLE__)
 	struct fstab *fstab;
 
 	fstab = getfsent ();
@@ -188,14 +199,16 @@ fstab_next (gpointer handle, char **moun
 void
 fstab_close (gpointer handle)
 {
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__APPLE__)
 	endfsent ();
 #else
 	fclose (handle);
 #endif
 }
 
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__DragonFly__)
+#define UMOUNT		"/sbin/umount"
+#elif __NetBSD__
 #define UMOUNT		"/sbin/umount"
 #elif sun
 #define UMOUNT		"/sbin/umount"
@@ -467,7 +480,7 @@ line_found:
 	/* construct arguments to /bin/umount */
 	na = 0;
 	args[na++] = UMOUNT;
-#ifndef __FreeBSD__
+#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__)
 	if (option_lazy)
 		args[na++] = "-l";
 #endif
@@ -625,13 +638,18 @@ try_open_excl_again:
 	/* construct arguments to EJECT_PROGRAM (e.g. /usr/bin/eject) */
 	na = 0;
 	args[na++] = EJECT_PROGRAM;
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__DragonFly__)
 	args[na++] = "-f";
 	args[na++] = (char *) device;
 	if (closetray)
 		args[na++] = "close";
 	else
 		args[na++] = "eject";
+#elif __NetBSD__
+	args[na++] = "-f";
+	if (closetray)
+		args[na++] = "-l";
+	args[na++] = (char *) device;
 #else
 	if (closetray) {
 		args[na++] = "-t";