From 3c841de8eb8a0d1bdb8bb1b19fff34ea96e72761 Mon Sep 17 00:00:00 2001 From: Joe Marcus Clarke Date: Fri, 16 Jan 2009 04:48:31 +0000 Subject: [PATCH] Add two additional properties to disc media so that applications can determine when media is available and that media's capacity. Reported by: Alexander Logvinov --- sysutils/hal/Makefile | 2 +- ...patch-hald_freebsd_probing_probe-storage.c | 39 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 sysutils/hal/files/patch-hald_freebsd_probing_probe-storage.c diff --git a/sysutils/hal/Makefile b/sysutils/hal/Makefile index 07168189bcca..1acc47eee67a 100644 --- a/sysutils/hal/Makefile +++ b/sysutils/hal/Makefile @@ -8,7 +8,7 @@ PORTNAME= hal DISTVERSION= 0.5.11 -PORTREVISION= 10 +PORTREVISION= 11 CATEGORIES= sysutils MASTER_SITES= http://hal.freedesktop.org/releases/ diff --git a/sysutils/hal/files/patch-hald_freebsd_probing_probe-storage.c b/sysutils/hal/files/patch-hald_freebsd_probing_probe-storage.c new file mode 100644 index 000000000000..d67ce03bff30 --- /dev/null +++ b/sysutils/hal/files/patch-hald_freebsd_probing_probe-storage.c @@ -0,0 +1,39 @@ +--- hald/freebsd/probing/probe-storage.c.orig 2009-01-12 16:07:59.000000000 -0500 ++++ hald/freebsd/probing/probe-storage.c 2009-01-12 16:20:20.000000000 -0500 +@@ -31,6 +31,8 @@ + #include + #include + #include ++#include ++#include + #include + #include + #include +@@ -211,7 +213,26 @@ main (int argc, char **argv) + goto end; + + if (hfp_cdrom_test_unit_ready(cdrom)) +- ret = 2; /* has media */ ++ { ++ int fd; ++ off_t size; ++ ++ libhal_device_set_property_bool(hfp_ctx, hfp_udi, "storage.removable.media_available", TRUE, &hfp_error); ++ fd = open(device_file, O_RDONLY | O_NONBLOCK); ++ if (fd > -1) ++ { ++ if (ioctl (fd, DIOCGMEDIASIZE, &size) == 0) ++ { ++ libhal_device_set_property_uint64(hfp_ctx, hfp_udi, "storage.removable.media_size", size, &hfp_error); ++ } ++ close(fd); ++ } ++ ret = 2; /* has media */ ++ } ++ else ++ { ++ libhal_device_set_property_bool(hfp_ctx, hfp_udi, "storage.removable.media_available", FALSE, &hfp_error); ++ } + + hfp_cdrom_free(cdrom); + }