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
|
$NetBSD: patch-ak,v 1.3 2011/01/08 13:00:13 obache Exp $
--- hald/freebsd/probing/probe-volume.c.orig 2009-09-17 13:45:09.000000000 +0000
+++ hald/freebsd/probing/probe-volume.c
@@ -33,7 +33,11 @@
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
+#ifdef __DragonFly__
+#include <sys/diskslice.h>
+#else
#include <sys/disk.h>
+#endif
#include <sys/cdio.h>
#include <sys/param.h>
#include <sys/mount.h>
@@ -41,7 +45,11 @@
#include <ufs/ufs/ufsmount.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>
+#ifdef __DragonFly__
+#include <ufs/ufs/ufs_types.h>
+#else
#include <libufs.h>
+#endif
#include <isofs/cd9660/iso.h>
#include <glib.h>
#include <libvolume_id.h>
@@ -332,6 +340,9 @@ main (int argc, char **argv)
gboolean is_blank = FALSE;
const char *usage;
char *label;
+#ifdef __DragonFly__
+ struct partinfo device_info;
+#endif
unsigned int sector_size = 0;
off_t media_size = 0;
@@ -371,7 +382,12 @@ main (int argc, char **argv)
is_blank = (! has_audio && ! has_data);
}
+#ifdef __DragonFly__
+ ioctl(fd, DIOCGPART, &device_info);
+ media_size = device_info.media_size;
+#else
ioctl(fd, DIOCGMEDIASIZE, &media_size);
+#endif
/*
* We only check for filesystems if the volume has no children,
@@ -563,16 +579,35 @@ main (int argc, char **argv)
if (vid && ! strcmp (vid->type, "ufs"))
{
+#ifdef __DragonFly__
+ struct fs fs;
+ int rfd;
+ ssize_t nr;
+
+ if ((rfd = open(device_file, O_RDONLY)) >= 0) {
+ lseek(rfd, (off_t) SBOFF, SEEK_SET);
+
+ nr = read(rfd, &fs, (size_t) SBSIZE);
+ close(rfd);
+ }
+
+ if (nr == (ssize_t) SBSIZE)
+#else
struct uufsd ufsdisk;
if (ufs_disk_fillout(&ufsdisk, device_file) == 0)
+#endif
{
char ufsid[64];
char **ufs_devs = NULL;
int num_udis;
int i;
+#ifdef __DragonFly__
+ snprintf(ufsid, sizeof(ufsid), "%08x%08x", fs.fs_id[0], fs.fs_id[1]);
+#else
snprintf(ufsid, sizeof(ufsid), "%08x%08x", ufsdisk.d_fs.fs_id[0], ufsdisk.d_fs.fs_id[1]);
+#endif
libhal_device_set_property_string(hfp_ctx, hfp_udi, "volume.freebsd.ufsid", ufsid, &hfp_error);
ufs_devs = libhal_manager_find_device_string_match(hfp_ctx,
"volume.freebsd.ufsid",
@@ -597,7 +632,9 @@ main (int argc, char **argv)
}
if (ufs_devs)
libhal_free_string_array(ufs_devs);
+#ifndef __DragonFly__
ufs_disk_close(&ufsdisk);
+#endif
}
}
@@ -628,7 +665,11 @@ main (int argc, char **argv)
libhal_device_set_property_string(hfp_ctx, hfp_udi, "volume.uuid", vid ? vid->uuid : "", &hfp_error);
+#ifdef __DragonFly__
+ sector_size = device_info.media_blksize;
+#else
ioctl(fd, DIOCGSECTORSIZE, §or_size);
+#endif
if (sector_size != 0)
libhal_device_set_property_uint64(hfp_ctx, hfp_udi, "volume.block_size", sector_size, &hfp_error);
|